Граф коммитов

120 Коммитов

Автор SHA1 Сообщение Дата
Eli Friedman 6d4abe1eee Backing out r55607 due to logic errors and test regression.
I'll try to come up with a correct fix for the testcase sometime soon.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55614 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-01 22:08:17 +00:00
Nuno Lopes 73419bf6cb fix one more this-is-not-a-constant error. test included
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55609 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-01 18:42:41 +00:00
Nuno Lopes f7e37ce840 make CheckArithmeticConstantExpression() aware of &foo and pointers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55607 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-01 14:47:06 +00:00
Nico Weber 491be73282 minor cleanup
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55538 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-29 17:02:23 +00:00
Daniel Dunbar 451318c08a Move implicit Obj-C param creation into ObjCMethodDecl.
- Add ObjCMethodDecl::createImplicitParams.
 - Remove ObjCMethodDecl::set{Self,Cmd}Decl
 - Remove Sema::CreateImplicitParameter

No (intended) functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55356 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 06:07:48 +00:00
Eli Friedman eb4b7051a5 Do typechecking and codegen for K&R-style function declarations
correctly.  Not a regression, but made more obvious by my recent fix 
which made function type compatibility checking a bit more strict.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55339 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-25 21:31:01 +00:00
Eli Friedman c3f07644a7 Fix for PR2720; be a little bit more permissive in initializers for
casting pointers to integers.

Eventually, we should check whether we can evaluate an expression 
using Expr::tryEvaluate, and this codepath should be tightened to only 
handle standard-compliant cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55331 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-25 20:46:57 +00:00
Anders Carlsson c5eb731144 Initial sema support for C++ static initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55166 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 05:00:02 +00:00
Eli Friedman 3d815e7eb5 Rewrite type compatibility testing to do type merging rather than just
testing compatibility.  This is necessary for some constructs, like merging
redeclarations.

Also, there are some ObjC changes to make sure that 
typesAreCompatible(a,b) == typesAreCompatible(b,a).  I don't have any 
ObjC code beyond the testsuite, so please tell me if there are any cases 
where this doesn't behave as expected.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55158 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 00:56:42 +00:00
Ted Kremenek 01e6779fac Added ObjCAtDefsFieldDecl to represent FieldDecls created by @defs.
This fixes an ownership issue where FieldDecls could be owned both by an ObjCInterfaceDecl and a RecordDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55037 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-20 03:26:33 +00:00
Argyrios Kyrtzidis 0835a3cdee Add ExplicitCastExpr to replace the current CastExpr, and have ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr):
Expr
  -> CastExpr
     -> ExplicitCastExpr
     -> ImplicitCastExpr 

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54955 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-18 23:01:59 +00:00
Chris Lattner 9aa77f137b various updates to match r54873 on mainline.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54874 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 07:19:51 +00:00
Daniel Dunbar acc5f3e423 More #include cleaning
- Kill unnecessary #includes in .cpp files. This is an automatic
   sweep so some things removed are actually used, but happen to be
   included by a previous header. I tried to get rid of the obvious
   examples and this was the easiest way to trim the #includes in one
   fell swoop.
 - We now return to regularly scheduled development.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 06:23:49 +00:00
Daniel Dunbar c4a1dea2dc More #include cleaning
- Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h
 - Moved Sema::getCurMethodDecl() out of line (dependent on
   ObjCMethodDecl via dyn_cast).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54629 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 05:35:13 +00:00
Daniel Dunbar e4858a65a9 More #include cleaning
- Drop Diagnostic.h from DeclSpec.h, move utility Diag methods into
   implementation .cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54626 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 03:45:03 +00:00
Steve Naroff d4d46cd616 Cleanup from yesterday...make isTentativeDefinition() a static helper function (no need for it to be part of the Sema API).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54613 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 15:28:06 +00:00
Steve Naroff f855e6fbeb Sema::CheckForFileScopedRedefinitions(): Make sure tentative decls of incomplete array types are completed (and diagnosed properly).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54612 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 15:20:13 +00:00
Chris Lattner d9f6910f4e rename PreDefinedExpr -> PredefinedExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54605 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 01:53:14 +00:00
Steve Naroff 907747b3a6 Fix Sema::MergeVarDecl() to better handle type compatibility. The previous code was trying to handle arrays specially (which didn't work for pointers to array). Removed local helper function areEquivalentArrayTypes(), replacing it's use with the more general ASTContext::typesAreCompatible() predicate.
Even though the test case this fixes is in "tentative-decls.c", this bug didn't have anything to do with our handling of tentative definitions (which is what I first expected). In any event, this is a tricky area of the spec.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54583 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-09 16:04:40 +00:00
Argyrios Kyrtzidis a4755c6ffa When in C++, invoke ASTConsumer::HandleTagDeclDefinition in Sema::ActOnFinishCXXClassDef,
at which point the C++ struct/class/union is fully parsed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54569 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-09 00:58:37 +00:00
Steve Naroff ff9eb1fe0a Fix issues with C "tentative" definitions.
- Move checking from MergeVarDecl->FinializeDeclaratorGroup. Since MergeVarDecl is called before the initializer is attacted, it can't be done there (this removes a long standing FIXME).
- Add Sema::isTentativeDefinition() and Sema::CheckForFileScopedRedefinitions().
- Remove FIXME's and touch-up test case.

Still some more work to do (forthcoming)...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54533 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-08 17:50:35 +00:00
Steve Naroff 02408c67c4 Sema::ActOnEnumBody(): handle nested enum redefinitions.
Fixes <rdar://problem/6093889> Nested enum redefinition crashes sema.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54463 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-07 14:08:16 +00:00
Daniel Dunbar a735ad8be5 Implement GNU asm-label extension support in CodeGen. This fixes
scimark2 on Darwin.

 - Added Sema support for asm-label on variables, which I forgot before.

 - Update CodeGen to use GlobalDeclMap to determine if static Decls
   require emission (instead of LLVM module name lookup). Important
   since the Decl name and the LLVM module name can differ.

 - <rdar://problem/6116729>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54388 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 00:03:29 +00:00
Daniel Dunbar 914701ed49 Move AsmLabel into Declarator instead of just a parameter to
ActOnDeclarator.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54353 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 16:28:08 +00:00
Daniel Dunbar a80f8749f2 Add more Parser/Sema support for GCC asm-label extension.
- ActOnDeclarator now takes an additional parameter which is the
   AsmLabel if used. Its unfortunate that this bubbles up this high,
   but we cannot just lump it in as an attribute without mistakenly
   *accepting* it as an attribute.
 - The actual asm-label itself is, however, encoded as an AsmLabelAttr
   on the FunctionDecl.
 - Slightly improved parser error recovery on malformed asm-labels.
 - CodeGen support still missing...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54339 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 01:35:17 +00:00
Chris Lattner c63a1f276f Finally fix PR2189. This makes a fairly invasive but important change to
move getAsArrayType into ASTContext instead of being a method on type.
This is required because getAsArrayType(const AT), where AT is a typedef
for "int[10]" needs to return ArrayType(const int, 10).

Fixing this greatly simplifies getArrayDecayedType, which is a good sign.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54317 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-04 07:31:14 +00:00
Argyrios Kyrtzidis 39caa08809 Wherever a type is used/returned from the Action module, use TypeTy instead of DeclTy or void.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54265 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-01 10:35:27 +00:00
Chris Lattner b77792eabf change more instances of QualType::getCanonicalType to call
ASTContext::getCanonicalType instead (PR2189)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54105 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 22:17:49 +00:00
Chris Lattner 99cb9976ef Reject typedef redefinitions when the underlying types are not identical,
even if in a system header etc.  rdar://6079937



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54038 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-25 18:44:27 +00:00
Steve Naroff 394f3f483f Move fix in r54013 from the parser to sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54032 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-25 17:57:26 +00:00
Ted Kremenek b8db21d4df When constructing an ObjCIvarDecl object in Sema, provide its visibility up front instead of setting it afterwards.
This change also fixes a subtle bug where the access control of an ivar would be initialized to garbage if we didn't have an explicit visibility specifier (e.g., @private).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53955 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-23 18:04:17 +00:00
Chris Lattner 7caeabd868 minor cleanup to the actions interface to pass around SmallVectorImpl instead
of a specific smallvector size.

Fix protocol lists to pass down proper location info, so we get diagnostics
like this:

t.m:3:35: error: cannot find protocol definition for 'NSCopying', referenced by 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
                                  ^

instead of this:

t.m:3:44: error: cannot find protocol definition for 'NSCopying', referenced by 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
                                           ^


Add a new IdentifierLocPair typedef which is just a pair<IdentifierInfo*, SourceLocation>



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53883 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-21 22:17:28 +00:00
Argyrios Kyrtzidis 90eb539bc3 Unify ctx_iterator/ctx_begin()/ctx_end() and iterator/begin()/end() so that a single iterator type is used for both traversing decls of the same declaration context *and* of the parent declaration contexts, depending on the value of the bool parameter 'LookInParentCtx' that is passed to IdentifierResolver::begin().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53724 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-17 17:49:50 +00:00
Argyrios Kyrtzidis 0ff12f078c When in C++, make EnumConstant names hide tag names in the same scope, instead of colliding with them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53702 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-16 21:01:53 +00:00
Steve Naroff 8f3b2654a9 Two fixes:
- Make sure ObjCIvarDecl propagates the bitfield width.
- RewriteObjC::SynthesizeIvarOffsetComputation(): Avoid using the __OFFSETOF__ mumbo jumbo for bitfields (since it isn't legal C). This fixes <rdar://problem/5986079> clang ObjC rewriter: bitfields and ivar access don't mix.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53694 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-16 18:22:22 +00:00
Argyrios Kyrtzidis b02ef242c7 When checking for name collision between a tag and a previously defined namespace, the collision occured even when the tag was in a different nested scope.
Fix it by taking into account the scope when checking for namespace-tag name collisions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53667 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-16 07:45:46 +00:00
Chris Lattner cf0f51d10f rename "SInt" methods to "Int" in APValue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53467 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 19:19:21 +00:00
Chris Lattner f8396b6b58 Add parser support for __builtin_stdarg_start, PR2531
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53328 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 17:26:36 +00:00
Nuno Lopes 9a979c327c fix CheckForConstantInitializer() for Compound Literals
also fix the correspondent test (it was expecting more errors than it should. please confirm my fix is correct (at least gcc agrees with me)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53174 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 16:46:50 +00:00
Anders Carlsson c44eec6dd2 Shuffle things around in preparation for integrating Eli's constant evaluator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53074 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 04:20:39 +00:00
Chris Lattner 14943b90d9 Fix PR2020 by recovering by defining an anonymous enum, instead of recovering
by filling in the body of a union with enum constants.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53069 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 03:30:58 +00:00
Argyrios Kyrtzidis 07952324dd Add Sema support for C++ classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52956 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-01 10:37:29 +00:00
Chris Lattner 3ff30c8e6e move some code from all callers of ProcessDeclAttributes into
the implementation of ProcessDeclAttributes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52875 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-29 00:02:00 +00:00
Chris Lattner f2e4bd51aa more attribute refactoring/renaming, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52874 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-28 23:58:55 +00:00
Argyrios Kyrtzidis 53d0ea5f5b Replace CurFunctionDecl and CurMethodDecl with methods getCurFunctionDecl() and getCurMethodDecl() that return the appropriate Decl through CurContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52852 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-28 06:07:14 +00:00
Chris Lattner 6b6b5372f4 move decl attribute processing to a new SemaDeclAttr.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52792 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 18:38:35 +00:00
Chris Lattner 985abd958d Make Declarator::getDeclSpec() return a const reference to avoid
cases where mutation can introduce bugs.  Propagate around 'const'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52772 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 06:49:43 +00:00
Chris Lattner d546fc5f20 add a comment about something that was surprising, at least to me.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52771 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 06:39:41 +00:00
Chris Lattner fca0ddd429 fix a bug handling type attributes in the declspec. declspec processing
used to mutate the attribute list for declspecs when the type was 
converted, breaking the case where one declspec was shared by multiple
declarators.

This fixes rdar://6032532.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52769 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 06:27:57 +00:00
Chris Lattner 18ae3cfe2a Don't add isa with @defs only to work around it in the code generator, patch
by David Chisnall. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52597 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 21:37:25 +00:00