Commit Graph

957 Commits

Author SHA1 Message Date
Chris Lattner 5bbb3c8ad9 Push DeclGroup much farther throughout the compiler. Now the various
productions (except the already broken ObjC cases like @class X,Y;) in 
the parser that can produce more than one Decl return a DeclGroup instead
of a Decl, etc.

This allows elimination of the Decl::NextDeclarator field, and exposes
various clients that should look at all decls in a group, but which were
only looking at one (such as the dumper, printer, etc).  These have been
fixed.

Still TODO:

1) there are some FIXME's in the code about potentially using
DeclGroup for better location info.
2) ParseObjCAtDirectives should return a DeclGroup due to @class etc.
3) I'm not sure what is going on with StmtIterator.cpp, or if it can
   be radically simplified now.
4) I put a truly horrible hack in ParseTemplate.cpp.

I plan to bring up #3/4 on the mailing list, but don't plan to tackle
#1/2 in the short term.

llvm-svn: 68002
2009-03-29 16:50:03 +00:00
Chris Lattner 3d954d5d0e simplify
llvm-svn: 68000
2009-03-29 16:04:50 +00:00
Chris Lattner 63595ddcb5 switch TemplateOrInstantiation to be a PointerUnion, which
simplifies some code.

llvm-svn: 67993
2009-03-29 07:03:59 +00:00
Chris Lattner 51ce02d264 change another PointerIntPair into a PointerUnion.
llvm-svn: 67991
2009-03-29 06:43:22 +00:00
Chris Lattner b81eb052f2 switch DeclBase::DeclCtx to the new happy and type-safe
llvm::PointerUnion class.

llvm-svn: 67988
2009-03-29 06:06:59 +00:00
Chris Lattner 20d79aa1c2 adjust to llvm mainline changes.
llvm-svn: 67980
2009-03-29 04:32:54 +00:00
Anders Carlsson f03bb51a00 Let getIdentifierNamespaceForKind know about aliases and have it treat them just like namespace decls.
llvm-svn: 67963
2009-03-28 23:02:53 +00:00
Anders Carlsson ff25fdf2fb Create AST nodes for namespace aliases.
llvm-svn: 67962
2009-03-28 22:58:02 +00:00
Cedric Venet 351c71a85f CMake: remove TranslationUnit.cpp from build (file has been removed).
llvm-svn: 67944
2009-03-28 12:41:49 +00:00
Chris Lattner 6b6185b18f some random cleanups
llvm-svn: 67928
2009-03-28 06:53:40 +00:00
Chris Lattner 529efc74ad rename some methods.
llvm-svn: 67923
2009-03-28 06:33:19 +00:00
Chris Lattner 23b88b73e1 Cleanups for DeclGroup.
llvm-svn: 67922
2009-03-28 06:26:18 +00:00
Chris Lattner fcd33a68e4 rename NextDeclInScope to NextDeclInContext, since the pointer
points within contexts not scopes.

llvm-svn: 67919
2009-03-28 06:04:26 +00:00
Chris Lattner 1ad4eeb9c7 remove TranslationUnit.
llvm-svn: 67914
2009-03-28 04:31:31 +00:00
Chris Lattner a5adead17b push more ASTContext goodness out through interfaces that use
TranslationUnit

llvm-svn: 67913
2009-03-28 04:27:18 +00:00
Chris Lattner d070278ec9 simplify away some dead ownership stuff, TranslationUnit is now
just a wrapper around ASTContext.

llvm-svn: 67906
2009-03-28 04:00:23 +00:00
Chris Lattner edf7eb77cf hoist TranslationUnit some more.
llvm-svn: 67905
2009-03-28 03:56:54 +00:00
Chris Lattner 96c339a661 eliminate some wrappers.
llvm-svn: 67904
2009-03-28 03:53:02 +00:00
Chris Lattner f7d9e2ba1c eliminate ReadASTBitcodeFile
llvm-svn: 67903
2009-03-28 03:49:26 +00:00
Chris Lattner d286851b57 move serialization logic from TranslationUnit to ASTContext.
llvm-svn: 67902
2009-03-28 03:45:20 +00:00
Chris Lattner 5cf49fe587 eliminate ASTConsumer::InitializeTU, all clients are
happy with just ASTContext, they don't need a TU.

llvm-svn: 67894
2009-03-28 02:18:25 +00:00
Chris Lattner a6f4ca2b6f remove TranslationUnit::OwnsDecls, which is only set, never read.
llvm-svn: 67891
2009-03-28 01:44:40 +00:00
Eli Friedman 8b7b1b1aee Change compound assignment operators to keep track of both the promoted
LHS type and the computation result type; this encodes information into 
the AST which is otherwise non-obvious.  Fix Sema to always come up with the 
right answer for both of these types.  Fix IRGen and the analyzer to 
account for these changes.  This fixes PR2601.  The approach is inspired 
by PR2601 comment 2.

Note that this changes real *= complex in CodeGen from a silent 
miscompilation to an explicit error.

I'm not really sure that the analyzer changes are correct, or how to 
test them... someone more familiar with the analyzer should check those 
changes.

llvm-svn: 67889
2009-03-28 01:22:36 +00:00
Douglas Gregor 5c7c9cb678 Make our diagnostics about the obsolete GNU designated-initializer
syntax into extension warnings, and provide code-modification hints
showing how to fix the problem.

llvm-svn: 67885
2009-03-28 00:41:23 +00:00
Douglas Gregor c741fb15a5 Better way to free NestedNameSpecifiers. Thanks, Chris
llvm-svn: 67880
2009-03-27 23:54:10 +00:00
Douglas Gregor 6fcec66525 Perform a very, very ugly song-and-dance number to free the
NestedNameSpecifiers without causing problems for the FoldingSet that
contains them.

llvm-svn: 67877
2009-03-27 23:25:45 +00:00
Douglas Gregor 333489bba3 Initial implementation of parsing, semantic analysis, and template
instantiation for C++ typename-specifiers such as

  typename T::type

The parsing of typename-specifiers is relatively easy thanks to
annotation tokens. When we see the "typename", we parse the
typename-specifier and produce a typename annotation token. There are
only a few places where we need to handle this. We currently parse the
typename-specifier form that terminates in an identifier, but not the
simple-template-id form, e.g.,

  typename T::template apply<U, V>

Parsing of nested-name-specifiers has a similar problem, since at this
point we don't have any representation of a class template
specialization whose template-name is unknown.

Semantic analysis is only partially complete, with some support for
template instantiation that works for simple examples. 

llvm-svn: 67875
2009-03-27 23:10:48 +00:00
Eli Friedman 6ecb5afcd6 Fix test failures caused by reading memory after freeing it. My fix is
rather nasty, but I can't think of a better fix off the top of my head.

llvm-svn: 67867
2009-03-27 20:56:17 +00:00
Chris Lattner 8e097198fc minor cleanups: make getIdentifierNamespace() be a single load
instead of a load + large inlined switch.

llvm-svn: 67864
2009-03-27 20:18:19 +00:00
Chris Lattner 17a1bfa9d8 reduce # const_casts, no functionality change.
llvm-svn: 67861
2009-03-27 19:19:59 +00:00
Chris Lattner 586c66d5ba change Decl::DeclCtx to use a PointerIntPair instead of hand bitmangling.
llvm-svn: 67858
2009-03-27 18:46:15 +00:00
Douglas Gregor f21eb49a04 Revamp our representation of C++ nested-name-specifiers. We now have a
uniqued representation that should both save some memory and make it
far easier to properly build canonical types for types involving
dependent nested-name-specifiers, e.g., "typename T::Nested::type".

This approach will greatly simplify the representation of
CXXScopeSpec. That'll be next.

llvm-svn: 67799
2009-03-26 23:50:42 +00:00
Anders Carlsson 6750d16002 Add
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
                                    AccessSpecifier AS);
   
so we can easily add access specifiers to diagnostics.

llvm-svn: 67795
2009-03-26 23:46:50 +00:00
Anders Carlsson a28908d575 Tighten the setAccess assert. We now allow AS_none if the decl contex is not a C++ record decl.
Also, fix fallout from the change.

llvm-svn: 67717
2009-03-25 23:38:06 +00:00
Douglas Gregor 8ea8fd48f2 Instantiation for member classes of class templates. Note that only
the declarations of member classes are instantiated when the owning
class template is instantiated. The definitions of such member classes
are instantiated when a complete type is required.

This change also introduces the injected-class-name into a class
template specialization.

llvm-svn: 67707
2009-03-25 21:17:03 +00:00
Douglas Gregor dfcad11842 Predicate to detect when a RecordDecl is really the injected-class-name
llvm-svn: 67687
2009-03-25 15:59:44 +00:00
Douglas Gregor 64259f5143 Type::isObjectType now implements the (more sensible) C++ definition
of "object type" rather than the C definition of "object type". The
difference is that C's "object type" excludes incomplete types such as

  struct X;

However, C's definition also makes it far too easy to use isObjectType
as a means to detect incomplete types when in fact we should use other
means (e.g., Sema::RequireCompleteType) that cope with C++ semantics,
including template instantiation.

I've already audited every use of isObjectType and isIncompleteType to
ensure that they are doing the right thing for both C and C++, so this
is patch does not change any functionality.

llvm-svn: 67648
2009-03-24 20:32:41 +00:00
Eli Friedman 94c25c66b5 Fix PR3868 by making Evaluate handle cases like "(long)&a + 4".
llvm-svn: 67593
2009-03-24 01:14:50 +00:00
Chris Lattner 656711a36b use isa<>
llvm-svn: 67543
2009-03-23 17:57:53 +00:00
Eli Friedman 449fe54cff Minor Evaluate cleanup; add some boilerplate implementations to
Evaluate for __extension__ and __builtin_choose_expr.

llvm-svn: 67506
2009-03-23 04:56:01 +00:00
Eli Friedman 6400433980 Minor enhancements to Evaluate.
llvm-svn: 67503
2009-03-23 04:38:34 +00:00
Eli Friedman e8dd7b3228 Adjust isModifiableLvalue to give a slightly more useful diagnostic for
attempting to illegally modify a BlockDeclRefExpr.

llvm-svn: 67491
2009-03-22 23:26:56 +00:00
Eli Friedman 7fa3faa417 Fix code to mark block variables as const to actually work. Fix
isObjCObjectPointerType to work with qualified types.  Adjust test for 
changes.

If the SemaExpr changes are wrong or break existing code, feel free to 
delete the "ExprTy.addConst();" line and revert my changes to 
test/Sema/block-literal.c.

llvm-svn: 67489
2009-03-22 23:00:19 +00:00
Anders Carlsson 7cbd8fb6b0 Keep track of whether a class is abstract or not. This is currently only used for the __is_abstract type trait.
llvm-svn: 67461
2009-03-22 01:52:17 +00:00
Chris Lattner 17556b2d95 fix some warnings in release-assert mode.
llvm-svn: 67456
2009-03-22 00:10:22 +00:00
Chris Lattner 7d5608dd72 add an assertion for unreachable code.
llvm-svn: 67432
2009-03-21 06:40:50 +00:00
Chris Lattner c2d987425d partially inline getAttrs() to speed up PR3810 (and lots of
other code presumably) by 4.3%

llvm-svn: 67430
2009-03-21 06:27:31 +00:00
Douglas Gregor 6d00c993f5 When building the structured initializer list, pre-allocate storage in
its vectors based on the subobject type we're initializing and the
(unstructured) initializer list. This eliminates some malloc thrashing
when parsing initializers (from 117 vector reallocations down to 0
when parsing Cocoa.h). We can't always pre-allocate the right amount
of storage, since designated initializers can cause us to initialize
in non-predictable patterns.

llvm-svn: 67421
2009-03-20 23:58:33 +00:00
Douglas Gregor 52a47e9c7b Destroy expressions properly when resizing an initializer list
llvm-svn: 67417
2009-03-20 23:38:03 +00:00
Ted Kremenek dfd72c2b44 Fix <rdar://problem/6704086> by allowing the format string checking in Sema to
allow non-literal format strings that are variables that (a) permanently bind to
a string constant and (b) whose string constants are resolvable within the same
translation unit.

llvm-svn: 67404
2009-03-20 21:35:28 +00:00