Commit Graph

282 Commits

Author SHA1 Message Date
Chandler Carruth e71d0628f7 Implement most of the remaining logic in __is_literal type trait. This
should now support all of the C++98 types, and all of the C++0x types
Clang supports.

llvm-svn: 130079
2011-04-24 02:49:34 +00:00
Chandler Carruth ad7d404732 Begin tracking trivialness of move constructors and move assignment
operators in C++ record declarations.

This patch starts off by updating a bunch of the standard citations to
refer to the draft 0x standard so that the semantics intended for move
varianst is clear. Where necessary these are duplicated so they'll be
available in doxygen.

It adds bit fields to keep track of the state for the move constructs,
and updates all the code necessary to track this state (I think) as
members are declared for a class. It also wires the state into the
various trait-like accessors in the AST's API, and tests that the type
trait expressions now behave correctly in the presence of move
constructors and move assignment operators.

This isn't complete yet due to these glaring FIXMEs:
1) No synthesis of implicit move constructors or assignment operators.
2) I don't think we correctly enforce the new logic for both copy and
   move trivial checks: that the *selected* copy/move
   constructor/operator is trivial. Currently this requires *all* of them
   to be trivial.
3) Some of the trait logic needs to be folded into the fine-grained
   trivial bits to more closely match the wording of the standard. For
   example, many of the places we currently set a bit to track POD-ness
   could be removed by querying other more fine grained traits on
   demand.

llvm-svn: 130076
2011-04-23 23:10:33 +00:00
Chandler Carruth a3e1f9a02c Implement basic __is_trivial type-trait support, enough to close PR9472.
This introduces a few APIs on the AST to bundle up the standard-based
logic so that programmatic clients have access to exactly the same
behavior.

There is only one serious FIXME here: checking for non-trivial move
constructors and move assignment operators. Those bits need to be added
to the declaration and accessors provided.

This implementation should be enough for the uses of __is_trivial in
libstdc++ 4.6's C++98 library implementation.

Ideas for more thorough test cases or any edge cases missing would be
appreciated. =D

llvm-svn: 130057
2011-04-23 10:47:28 +00:00
Douglas Gregor 57477675ef Eliminate an uninteresting assertion; invalid code involving
out-of-line destructors can result in the addition of redundant
destructors to a class. It's not harmful to the AST. Fixes
<rdar://problem/9158632>.

llvm-svn: 129860
2011-04-20 17:22:00 +00:00
Abramo Bagnara 29c2d46786 Fixed InnerLocStart.
llvm-svn: 127330
2011-03-09 14:09:51 +00:00
Douglas Gregor f2f0806f71 Teach libclang's token-annotation logic about context-sensitive
keywords for Objective-C+ and C++0x. 

llvm-svn: 127253
2011-03-08 17:10:18 +00:00
Abramo Bagnara ea94788cf4 Fixed source range for StaticAssertDecl and LinkageSpecDecl. Fixed source range for declarations using postfix types.
llvm-svn: 127251
2011-03-08 16:41:52 +00:00
Abramo Bagnara dff1930bf7 Fixed source range for all DeclaratorDecl's.
llvm-svn: 127225
2011-03-08 08:55:46 +00:00
Abramo Bagnara 66a35d765f Removed left brace location from LinkageSpecDecl.
llvm-svn: 126945
2011-03-03 16:52:29 +00:00
Abramo Bagnara 4a8cda8556 Fixed end source location for LinkageSpecDecl.
llvm-svn: 126943
2011-03-03 14:52:38 +00:00
Alexis Hunt c5575cced8 Implement delegating constructors partially.
This successfully performs constructor lookup and verifies that a
delegating initializer is the only initializer present.

This does not perform loop detection in the initialization, but it also
doesn't codegen delegating constructors at all, so this won't cause
runtime infinite loops yet.

llvm-svn: 126552
2011-02-26 19:13:13 +00:00
Douglas Gregor c05ba2ef12 Push nested-name-specifier source location information into namespace
aliases.

llvm-svn: 126496
2011-02-25 17:08:07 +00:00
Douglas Gregor 12441b3bc5 Push nested-name-specifier source location information into using directives.
llvm-svn: 126489
2011-02-25 16:33:46 +00:00
Douglas Gregor a9d87bc6ac Update UsingDecl, UnresolvedUsingTypenameDecl, and
UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the
extremely-lossy NestedNameSpecifier/SourceRange pair it used to use,
improving source-location information.

Various infrastructure updates to support NestedNameSpecifierLoc:
  - AST/PCH (de-)serialization
  - Recursive AST visitor
  - libclang traversal (including the first tests of this
    functionality)

llvm-svn: 126459
2011-02-25 00:36:19 +00:00
Douglas Gregor b11aad8cba Revert all of my commits that devirtualized the Decl hierarchy, which
lead to a serious slowdown (4%) on parsing of Cocoa.h. This memory
optimization should be revisited later, when we have time to look at
the generated code.

llvm-svn: 126033
2011-02-19 18:51:44 +00:00
Douglas Gregor b494173c93 Devirtualize TagDecl::completeDefinition().
llvm-svn: 125755
2011-02-17 18:06:05 +00:00
Sebastian Redl 0890502f44 Basic implementation of inherited constructors. Only generates declarations, and probably only works for very basic use cases.
llvm-svn: 124970
2011-02-05 19:23:19 +00:00
Anders Carlsson 1eb95961d3 Use attributes for all the override control specifiers.
llvm-svn: 124122
2011-01-24 16:26:15 +00:00
Anders Carlsson 67f9e61127 Add final/explicit getters and setters to CXXRecordDecl.
llvm-svn: 124037
2011-01-22 17:22:48 +00:00
Douglas Gregor f282a76fab Implement the preference for move-construction over copy-construction
when returning an NRVO candidate expression. For example, this
properly picks the move constructor when dealing with code such as

  MoveOnlyType f() { MoveOnlyType mot; return mot; }

The previously-XFAIL'd rvalue-references test case now works, and has
been moved into the appropriate paragraph-specific test case.

llvm-svn: 123992
2011-01-21 19:38:21 +00:00
John McCall 424cec97bd Change QualType::getTypePtr() to return a const pointer, then change a
thousand other things which were (generally inadvertantly) relying on that.

llvm-svn: 123814
2011-01-19 06:33:43 +00:00
Jay Foad 39c7980772 PR3558: mark "logically const" accessor methods in ASTContext as const,
and mark the fields they use as mutable. This allows us to remove a few
const_casts.

llvm-svn: 123314
2011-01-12 09:06:06 +00:00
Alexis Hunt a50dd46ee8 Rename CXXCtorInitializer::BaseOrMember to Initializee, since it will also be
used to store the CXXConstructorDecl in a delegating constructor.

llvm-svn: 123095
2011-01-08 23:01:16 +00:00
Alexis Hunt 1d7926502f Renamed CXXBaseOrMemberInitializer to CXXCtorInitializer. This is both shorter,
more accurate, and makes it make sense for it to hold a delegating constructor
call.

llvm-svn: 123084
2011-01-08 20:30:50 +00:00
Douglas Gregor 44e7df67d9 Implement pack expansion of base initializers, so that we can
initialize those lovely mixins that come from pack expansions of base
specifiers.

llvm-svn: 122793
2011-01-04 00:32:56 +00:00
Douglas Gregor 752a595655 Implement pack expansions whose pattern is a base-specifier.
llvm-svn: 122782
2011-01-03 22:36:02 +00:00
Douglas Gregor 027ba500ab Revert r120808, my previous implementation of caching for the linkage
and visibility of declarations, because it was extremely messy and it
increased the size of NamedDecl.

An improved implementation is forthcoming.

llvm-svn: 121012
2010-12-06 17:49:01 +00:00
Francois Pichet d583da04d0 More anonymous struct/union redesign. This one deals with anonymous field used in a constructor initializer list:
struct X {
  X() : au_i1(123) {}
  union {
    int au_i1;
    float au_f1;
  };
};

clang will now deal with au_i1 explicitly as an IndirectFieldDecl.

llvm-svn: 120900
2010-12-04 09:14:42 +00:00
Douglas Gregor 17fed4c754 Implement caching for the linkage and visibility calculations of
declarations.

The motivation for this patch is that linkage/visibility computations
are linear in the number of redeclarations of an entity, and we've run
into a case where a single translation unit has > 6500 redeclarations
of the same (unused!) external variable. Since each redeclaration
involves a linkage check, the resulting quadratic behavior makes Clang
slow to a crawl. With this change, a simple test with 512
redeclarations of a variable syntax-checks ~20x faster than
before.

That said, I hate this change, and will probably end up reverting it
in a few hours. Reasons to hate it:
  - It makes NamedDecl larger, since we don't have enough free bits in
  Decl to squeeze in the extra information about caching.
  - There are way too many places where we need to invalidate this
  cache, because the visibility of a declaration can change due to
  redeclarations (!). Despite self-hosting and passing the testsuite,
  I have no confidence that I've found all of places where this cache
  needs to be invalidated.

llvm-svn: 120808
2010-12-03 17:11:42 +00:00
Douglas Gregor 4b00d3b55a Eliminate two uses of NDEBUG in headers that cause different symbols
to be available in debug vs. release builds.

llvm-svn: 120629
2010-12-02 00:22:25 +00:00
Argyrios Kyrtzidis 2703bebc58 Replace UsingDecl's SmallPtrSet of UsingShadowDecls with a linked list to avoid leaking memory.
Fixes rdar://8649963.

llvm-svn: 118674
2010-11-10 05:40:41 +00:00
Douglas Gregor bd6b17f4ef Improve our handling of C++ [class.copy]p3, which specifies that a
constructor template will not be used to copy a class object to a
value of its own type. We were eliminating all constructor templates
whose specializations look like a copy constructor, which eliminated
important candidates. Fixes PR8182.

llvm-svn: 118418
2010-11-08 17:16:59 +00:00
Chris Lattner 5c0b40528d Rename alignof -> alignOf to avoid irritating C++'0x compilers,
PR8423

llvm-svn: 117775
2010-10-30 05:14:06 +00:00
Douglas Gregor d4c5ed038c Make the deserialization of C++ base class specifiers lazy, improving
the performance of C++ PCH and reducing stack depth in the reader.

llvm-svn: 117732
2010-10-29 22:39:52 +00:00
Argyrios Kyrtzidis e16a5300ba Keep track in chained PCH of implicit members that were added after the definition was completed.
llvm-svn: 117240
2010-10-24 17:26:54 +00:00
Argyrios Kyrtzidis 65ad5691fd Put the mechanism in place to track modifications in an AST entity that were committed after
its initial creation/deserialization and store the changes in a chained PCH.

The idea is that the AST entities call methods on the ASTMutationListener to give notifications
of changes; the PCHWriter implements the ASTMutationListener interface and stores the incremental changes
of the updated entity. WIP

llvm-svn: 117235
2010-10-24 17:26:36 +00:00
Craig Silverstein af8808dd28 Pass TInfo to CXXDestructorDecl::Create(), just like we do for other
function decls.

Reviewed by rjmccall and nlewycky.

llvm-svn: 116979
2010-10-21 00:44:50 +00:00
Argyrios Kyrtzidis 00f5266dbf When implicit members are added to a C++ record, notify the serializer so that a chained PCH writes the definition again.
Thanks to Doug for the hint!

llvm-svn: 116975
2010-10-20 23:48:42 +00:00
Douglas Gregor 457104e98b Move the management of the set of conversion functions in a C++ class
into CXXRecordDecl. The only part that we do not handle this way are
using declarations, since that would require extra name lookup that we
don't currently want to pay for. This fixes <rdar://problem/8459981>,
so that LLDB can build a CXXRecordDecl and magically get all of the
right bits set.

llvm-svn: 115026
2010-09-29 04:25:11 +00:00
Douglas Gregor 8fb9512966 Move the maintenance of CXXRecordDecl::DefinitionData's Abstract bit
completely into CXXRecordDecl, by adding a new completeDefinition()
function. This required a little reshuffling of the final-overrider
checking code, since the "abstract" calculation in the presence of
abstract base classes needs to occur in
CXXRecordDecl::completeDefinition() but we don't want to compute final
overriders more than one in the common case.

llvm-svn: 115007
2010-09-29 00:15:42 +00:00
Douglas Gregor 7d9120c3ed Teach FunctionDecl::setPure() to (indirectly) mark the Abstract bit in
CXXRecordDecl::DefinitionData, rather than having Sema mark the bit.

llvm-svn: 114993
2010-09-28 21:55:22 +00:00
Douglas Gregor 11c024bbeb Reinstate r114925 and r114929, both steps toward
<rdar://problem/8459981>.

llvm-svn: 114984
2010-09-28 20:50:54 +00:00
Douglas Gregor 9d5938ae8a Centralize the management of CXXRecordDecl::DefinitionData's Empty bit
in CXXRecordDecl itself. Yes, this is also part of <rdar://problem/8459981>.

This reinstates r114924, with one crucial bug fix: we were ignoring
the implicit fields created by anonymous structs/unions when updating
the bits in CXXRecordDecl, which means that a class/struct containing
only an anonymous class/struct would be considered "empty". Hilarity
follows. 

llvm-svn: 114980
2010-09-28 20:38:10 +00:00
Douglas Gregor a832d3e2cc Reinstate r114921, which I've exonerated via a self-host build.
Centralize the management of CXXRecordDecl::DefinitionData's Aggregate
and PlainOldData bits in CXXRecordDecl itself. Another milepost on the
road toward <rdar://problem/8459981>.

llvm-svn: 114977
2010-09-28 19:45:33 +00:00
Bill Wendling 6d8c442e08 Temporarily revert 114929 114925 114924 114921. It looked like they (or at least
one of them) was causing a series of failures:

http://google1.osuosl.org:8011/builders/clang-x86_64-darwin10-selfhost/builds/4518

svn merge -c -114929 https://llvm.org/svn/llvm-project/cfe/trunk
--- Reverse-merging r114929 into '.':
U    include/clang/Sema/Sema.h
U    include/clang/AST/DeclCXX.h
U    lib/Sema/SemaDeclCXX.cpp
U    lib/Sema/SemaTemplateInstantiateDecl.cpp
U    lib/Sema/SemaDecl.cpp
U    lib/Sema/SemaTemplateInstantiate.cpp
U    lib/AST/DeclCXX.cpp
svn merge -c -114925 https://llvm.org/svn/llvm-project/cfe/trunk
--- Reverse-merging r114925 into '.':
G    include/clang/AST/DeclCXX.h
G    lib/Sema/SemaDeclCXX.cpp
G    lib/AST/DeclCXX.cpp
svn merge -c -114924 https://llvm.org/svn/llvm-project/cfe/trunk
--- Reverse-merging r114924 into '.':
G    include/clang/AST/DeclCXX.h
G    lib/Sema/SemaDeclCXX.cpp
G    lib/Sema/SemaDecl.cpp
G    lib/AST/DeclCXX.cpp
U    lib/AST/ASTContext.cpp
svn merge -c -114921 https://llvm.org/svn/llvm-project/cfe/trunk
--- Reverse-merging r114921 into '.':
G    include/clang/AST/DeclCXX.h
G    lib/Sema/SemaDeclCXX.cpp
G    lib/Sema/SemaDecl.cpp
G    lib/AST/DeclCXX.cpp

llvm-svn: 114933
2010-09-28 01:09:49 +00:00
Douglas Gregor 1f93ffb3e6 Centralize the management of CXXRecordDecl::DefinitionData's
HasTrivialConstructor, HasTrivialCopyConstructor,
HasTrivialCopyAssignment, and HasTrivialDestructor bits in
CXXRecordDecl's methods. This completes all but the Abstract bit and
the set of conversion functions, both of which will require a bit of
extra work. The majority of <rdar://problem/8459981> is now
implemented (but not all of it).

llvm-svn: 114929
2010-09-28 00:00:00 +00:00
Douglas Gregor d22553cf21 Centralize the management of CXXRecordDecl::DefinitionData's
Polymorphic bit in CXXRecordDecl itself. Yes, this is also part of
<rdar://problem/8459981>.

llvm-svn: 114925
2010-09-27 23:39:06 +00:00
Douglas Gregor 01daafc58a Centralize the management of CXXRecordDecl::DefinitionData's Empty bit
in CXXRecordDecl itself. Yes, this is also part of <rdar://problem/8459981>.

llvm-svn: 114924
2010-09-27 23:31:14 +00:00
Douglas Gregor 1be93f5143 Centralize the management of CXXRecordDecl::DefinitionData's Aggregate
and PlainOldData bits in CXXRecordDecl itself. Another milepost on the
road toward <rdar://problem/8459981>.

llvm-svn: 114921
2010-09-27 23:16:44 +00:00
Douglas Gregor 8f9ebe54b3 Centralize the handling of CXXRecordDecl::DefinitionData's
DeclaredDestructor and UserDeclaredDestructor bits in CXXRecordDecl
itself. Another step on the road to <rdar://problem/8459981>.

llvm-svn: 114918
2010-09-27 22:48:58 +00:00