Commit Graph

206 Commits

Author SHA1 Message Date
Douglas Gregor 9774aa13c7 Temporary disable the const-object-declaration-without-initializer check, because it depends on linkage-specifier semantics we don't yet have
llvm-svn: 58377
2008-10-29 13:50:18 +00:00
Douglas Gregor 8e1cf608dc Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:

  - Try/Perform-ImplicitConversion now handles implicit conversions
    that don't involve references.
  - Try/Perform-CopyInitialization uses
    CheckSingleAssignmentConstraints for C. PerformCopyInitialization
    is now used for all argument passing and returning values from a
    function.
  - Diagnose errors with declaring references and const values without
    an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
  
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.

llvm-svn: 58353
2008-10-29 00:13:59 +00:00
Douglas Gregor f19b2319c9 Rename ExplicitCCastExpr to CStyleCastExpr
llvm-svn: 58331
2008-10-28 15:36:24 +00:00
Douglas Gregor 6b75484ba6 Improve our handling of (C++) references within Clang. Specifically:
- Do not allow expressions to ever have reference type
  - Extend Expr::isLvalue to handle more cases where having written a
    reference into the source implies that the expression is an lvalue
    (e.g., function calls, C++ casts).
  - Make GRExprEngine::VisitCall treat the call arguments as lvalues when
    they are being bound to a reference parameter.

llvm-svn: 58306
2008-10-28 00:22:11 +00:00
Douglas Gregor e200adc503 Refactor the expression class hierarchy for casts. Most importantly:
- CastExpr is the root of all casts
  - ImplicitCastExpr is (still) used for all explicit casts
  - ExplicitCastExpr is now the root of all *explicit* casts
  - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++
  - CXXFunctionalCastExpr inherits from ExplicitCastExpr
  - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all
    of the C++ named cast expression types (static_cast, dynamic_cast, etc.)
  - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, 
    CXXReinterpretCastExpr, and CXXConstCastExpr to 

Also, fixed returned-stack-addr.cpp, which broke once when we fixed
reinterpret_cast to diagnose double->int* conversions and again when
we eliminated implicit conversions to reference types. The fix is in
both testcase and SemaChecking.cpp.

Most of this patch is simply support for the renaming. There's very
little actual change in semantics.

llvm-svn: 58264
2008-10-27 19:41:14 +00:00
Steve Naroff c6db58a6bd Replace common diagnostic with a convenience function.
This simplifies debug of this particular diagnostic (and removes some code clutter).

llvm-svn: 58242
2008-10-27 11:34:16 +00:00
Argyrios Kyrtzidis 22c40fa285 -Add support for cv-qualifiers after function declarators.
-Add withConst/withVolatile/withRestrict methods to QualType class, that return the QualType plus the respective qualifier.

llvm-svn: 58120
2008-10-24 21:46:40 +00:00
Douglas Gregor a8aa7a08b8 PR2942: FunctionDecls by typedef crash the C++ front-end
llvm-svn: 58100
2008-10-24 18:09:54 +00:00
Argyrios Kyrtzidis 1a527ea1e5 Restrict creation of OverloadedFunctionDecl only to C++ (it was getting used for invalid redeclarations on C).
llvm-svn: 58008
2008-10-22 23:08:24 +00:00
Douglas Gregor 5251f1b283 Preliminary support for function overloading
llvm-svn: 57909
2008-10-21 16:13:35 +00:00
Daniel Dunbar 4290d46bd4 Implement #pragma pack use in structure packing. The general approach
is to encode the state of the #pragma pack stack as an attribute when
the structure is declared. 

 - Extend PackedAttr to take an alignment (in bits), and reuse for
   both __attribute__((packed)) (which takes no argument, instead
   packing tightly (to "minimize the memory required") and for #pragma
   pack (which allows specification of the maximum alignment in
   bytes). __attribute__((packed)) is just encoded as Alignment=1.

   This conflates two related but different mechanisms, but it didn't
   seem worth another attribute.

 - I have attempted to follow the MSVC semantics as opposed to the gcc
   ones, since if I understand correctly #pragma pack originated with
   MSVC. The semantics are generally equivalent except when the stack
   is altered during the definition of a structure; its not clear if
   anyone does this in practice. See testcase if curious.

llvm-svn: 57623
2008-10-16 02:34:03 +00:00
Daniel Dunbar 5460374cd9 Add Sema implementation of #pragma pack stack.
- Follows the MSVC (original) implementation, including support of
   pack(show) (useful for testing).
 - Implements support for named pack records which gcc seems to
   ignore (or implements incorrectly).
 - Not currently wired to anything, only functionality change is the
   type checking of the pragma.

llvm-svn: 57476
2008-10-14 05:35:18 +00:00
Chris Lattner 79ef843533 silence some release-assert warnings.
llvm-svn: 57391
2008-10-12 00:28:42 +00:00
Chris Lattner a97132a9c4 Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue.  Implement this in codegen by moving the code out of CGBuiltin
into EmitConstantExpr.

llvm-svn: 57163
2008-10-06 07:26:43 +00:00
Chris Lattner cb13691a62 Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExpr
which is checking for something that can be inconsistent with
what we can constant fold.

llvm-svn: 57159
2008-10-06 06:49:02 +00:00
Chris Lattner c43467526d "Enhance" CheckArithmeticConstantExpression to accept ?: with a constant
condition as a constant even if the unevaluated side is a not a constant.
We don't do this when extensions are off, and we emit a warning when this 
happens:

t.c:22:11: warning: expression is not a constant, but is accepted as one by GNU extensions
short t = __builtin_constant_p(5353) ? 42 : somefunc();
          ^                                 ~~~~~~~~~~

suggestions for improvement are welcome.  This is obviously horrible, but
is required for real-world code.

llvm-svn: 57153
2008-10-06 05:42:39 +00:00
Daniel Dunbar 325601a9e5 Merge postfix attributes on record decls.
llvm-svn: 57019
2008-10-03 17:33:35 +00:00
Daniel Dunbar 15619c7e4b Pass postfix attributes to ActOnFields.
llvm-svn: 56992
2008-10-03 02:03:53 +00:00
Steve Naroff 2231569f01 Add getTypeSpecStartLoc() to VarDecls and FunctionDecls.
This is a temporary solution to help with the block rewriter (though it certainly has general utility).
Once DeclGroup's are implemented, this SourceLocation should be stored with it (since it applies to all the decls).

llvm-svn: 56985
2008-10-03 00:02:03 +00:00
Daniel Dunbar dc2ab1740a Add Builtins.def attribute for "can be a constant expression".
- Enabled for builtins which are always constant expressions
   (__builtin_huge_val*, __builtin_inf*, __builtin_constant_p,
   __builtin_classify_type, __builtin___CFStringMakeConstantString).

Added Builtin::Context::isConstantExpr.
 - Currently overly simply interface which only works for builtins
   whose constantexprness does not depend on their arguments.

CallExpr::isBuiltinConstantExpr now takes an ASTContext argument.

llvm-svn: 56983
2008-10-02 23:30:31 +00:00
Steve Naroff d40a39626c Changed Sema::CheckForConstantInitializer to allow global block literals.
This commit also includes some name changes in the blocks rewriter (no functionality change).

llvm-svn: 56955
2008-10-02 17:12:56 +00:00
Steve Naroff 38093af363 Add a random C99 comment/reference.
llvm-svn: 56800
2008-09-29 20:07:05 +00:00
Chris Lattner ff2c187e59 Replace a comparison with a static list of builtins that was wrong (it
wasn't covering checking builtins like __builtin___vsnprintf_chk) with
a check that won't get out of date. 

llvm-svn: 56767
2008-09-28 05:54:29 +00:00
Steve Naroff a5629376e8 Fix http://llvm.org/bugs/show_bug.cgi?id=2760.
llvm-svn: 56280
2008-09-17 14:05:40 +00:00
Daniel Dunbar 84b70f7f0f Add --suppress-system-warnings (on by default, use =0 to disable)
- For investigating warnings in system headers / builtins.
 - Currently also enables the behavior that allows silent redefinition
   of types in system headers. Conceptually these are separate but I
   didn't feel it was worth two options (or changing LangOptions).

llvm-svn: 56163
2008-09-12 18:10:20 +00:00
Argyrios Kyrtzidis 5b144d5cc4 Add Sema::isDeclInScope which wraps IdentifierResolver::isDeclInScope.
No functionality change.

llvm-svn: 56014
2008-09-09 21:18:04 +00:00
Steve Naroff 44cfcb6fb1 Tweak implementation for allowing ObjC builtin type redefinitions.
- Replace string comparisons with pre-defined idents.
- Avoid calling isBuiltinObjCType() to avoid two checks. 
- Remove isBuiltinObjCType(), since it was only used in Sema::MergeTypeDefDecl().
- Have Sema::MergeTypeDefDecl() set the new type.

This is a moidified version of an patch by David Chisnall.

llvm-svn: 55990
2008-09-09 14:32:20 +00:00
Daniel Dunbar 1e6ff5f37f Add ThreadSpecified bit to Decl.
- Patch from Kevin Tew.

llvm-svn: 55940
2008-09-08 20:05:47 +00:00
Ted Kremenek 6ddf53e4bd Add comment back that Argiris pointed out that I mistakenly removed (the comments below it were stale, so I accidently removed the whole thing).
llvm-svn: 55841
2008-09-05 17:39:33 +00:00
Ted Kremenek 2147570258 Change struct forward declarations and definitions to use unique RecordDecls, as opposed to creating a single RecordDecl and reusing it.
This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet).

The motivation of this patch is as follows:
- Capture more source information, necessary for refactoring/rewriting clients.

- Pave the way to resolve ownership issues with RecordDecls with the forthcoming
  addition of DeclGroups.

Current caveats:
- Until DeclGroups are in place, we will leak RecordDecls not explicitly
  referenced by the AST.  For example:

    typedef struct { ... } x;  

  The RecordDecl for the struct will be leaked because the TypedefDecl doesn't
  refer to it.  This will be solved with DeclGroups.
  
- This patch also (temporarily) breaks CodeGen.  More below.

High-level changes:
- As before, TagType still refers to a TagDecl, but it doesn't own it.  When
  a struct/union/class is first referenced, a RecordType and RecordDecl are
  created for it, and the RecordType refers to that RecordDecl.  Later, if
  a new RecordDecl is created, the pointer to a RecordDecl in RecordType is
  updated to point to the RecordDecl that defines the struct/union/class.

- TagDecl and RecordDecl now how a method 'getDefinition()' to return the
  TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular
  enum/struct/class/union. This is useful from going from a RecordDecl* that
  defines a forward declaration to the RecordDecl* that provides the actual
  definition. Note that this also works for EnumDecls, except that in this case
  there is no distinction between forward declarations and definitions (yet).

- Clients should no longer assume that 'isDefinition()' returns true from a
  RecordDecl if the corresponding struct/union/class has been defined.
  isDefinition() only returns true if a particular RecordDecl is the defining
  Decl. Use 'getDefinition()' instead to determine if a struct has been defined.

- The main changes to Sema happen in ActOnTag. To make the changes more
  incremental, I split off the processing of enums and structs et al into two
  code paths. Enums use the original code path (which is in ActOnTag) and
  structs use the ActOnTagStruct. Eventually the two code paths will be merged,
  but the idea was to preserve the original logic both for comparison and not to
  change the logic for both enums and structs all at once.

- There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls
  that correspond to the same type simply have a pointer to that type. If we
  need to figure out what are all the RecordDecls for a given type we can build
  a backmap.

- The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the
  changes to RecordDecl. For some reason 'svn' marks the entire file as changed.

Why is CodeGen broken:
- Codegen assumes that there is an equivalence between RecordDecl* and
  RecordType*. This was true before because we only created one RecordDecl* for
  a given RecordType*, but it is no longer true. I believe this shouldn't be too
  hard to change, but the patch was big enough as it is.
  
I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C).  

llvm-svn: 55839
2008-09-05 17:16:31 +00:00
Ted Kremenek cb36325316 Remove stale comments.
llvm-svn: 55822
2008-09-05 01:38:34 +00:00
Ted Kremenek 47923c7e59 Remove "NextDecl" from RecordDecl. This change touches many files that where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration.
The motivation behind this change is that chaining the RecordDecls is simply unnecessary.  Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType.

llvm-svn: 55821
2008-09-05 01:34:33 +00:00
Daniel Dunbar 0ff4192f3a Set register storage class correctly for function parameters.
- PR2730

llvm-svn: 55739
2008-09-03 21:54:21 +00:00
Ted Kremenek 3060d98ad0 Fix 80 col violations.
llvm-svn: 55707
2008-09-03 18:03:35 +00:00
Ted Kremenek ceb3ca94b7 When creating CXXRecordDecls and RecordDecls within ActOnTag, hook up the new [CXX]RecordDecl with the RecordDecl chain.
llvm-svn: 55652
2008-09-02 21:26:19 +00:00
Eli Friedman de09ce03c4 Fix for PR2747: allow pointer->int casts with a null base; these are
offset-of-like expressions.

llvm-svn: 55627
2008-09-02 09:37:00 +00:00
Eli Friedman 4c55e2c4ed 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.

llvm-svn: 55614
2008-09-01 22:08:17 +00:00
Nuno Lopes 2c5208c59f fix one more this-is-not-a-constant error. test included
llvm-svn: 55609
2008-09-01 18:42:41 +00:00
Nuno Lopes feac637074 make CheckArithmeticConstantExpression() aware of &foo and pointers
llvm-svn: 55607
2008-09-01 14:47:06 +00:00
Nico Weber fa5856a936 minor cleanup
llvm-svn: 55538
2008-08-29 17:02:23 +00:00
Daniel Dunbar 279d1ccc57 Move implicit Obj-C param creation into ObjCMethodDecl.
- Add ObjCMethodDecl::createImplicitParams.
 - Remove ObjCMethodDecl::set{Self,Cmd}Decl
 - Remove Sema::CreateImplicitParameter

No (intended) functionality change.

llvm-svn: 55356
2008-08-26 06:07:48 +00:00
Eli Friedman 3d421e190a 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.

llvm-svn: 55339
2008-08-25 21:31:01 +00:00
Eli Friedman 0a2ba3f10b 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.

llvm-svn: 55331
2008-08-25 20:46:57 +00:00
Anders Carlsson 41e0881b34 Initial sema support for C++ static initializers.
llvm-svn: 55166
2008-08-22 05:00:02 +00:00
Eli Friedman 47f7711e4b 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.

llvm-svn: 55158
2008-08-22 00:56:42 +00:00
Ted Kremenek 0e857200bb 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.

llvm-svn: 55037
2008-08-20 03:26:33 +00:00
Argyrios Kyrtzidis 3bab3d21f9 Add ExplicitCastExpr to replace the current CastExpr, and have ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr):
Expr
  -> CastExpr
     -> ExplicitCastExpr
     -> ImplicitCastExpr 

llvm-svn: 54955
2008-08-18 23:01:59 +00:00
Chris Lattner 5d1cfa1229 various updates to match r54873 on mainline.
llvm-svn: 54874
2008-08-17 07:19:51 +00:00
Daniel Dunbar 56fdb6ae69 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.

llvm-svn: 54632
2008-08-11 06:23:49 +00:00
Daniel Dunbar 6e8aa537f8 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).

llvm-svn: 54629
2008-08-11 05:35:13 +00:00
Daniel Dunbar c74b5cc2bc More #include cleaning
- Drop Diagnostic.h from DeclSpec.h, move utility Diag methods into
   implementation .cpp

llvm-svn: 54626
2008-08-11 03:45:03 +00:00
Steve Naroff 63ebb3cd3e Cleanup from yesterday...make isTentativeDefinition() a static helper function (no need for it to be part of the Sema API).
llvm-svn: 54613
2008-08-10 15:28:06 +00:00
Steve Naroff 84e37356d6 Sema::CheckForFileScopedRedefinitions(): Make sure tentative decls of incomplete array types are completed (and diagnosed properly).
llvm-svn: 54612
2008-08-10 15:20:13 +00:00
Chris Lattner 6307f19726 rename PreDefinedExpr -> PredefinedExpr
llvm-svn: 54605
2008-08-10 01:53:14 +00:00
Steve Naroff 239255d2a6 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.

llvm-svn: 54583
2008-08-09 16:04:40 +00:00
Argyrios Kyrtzidis 2f67f37daf When in C++, invoke ASTConsumer::HandleTagDeclDefinition in Sema::ActOnFinishCXXClassDef,
at which point the C++ struct/class/union is fully parsed.

llvm-svn: 54569
2008-08-09 00:58:37 +00:00
Steve Naroff 5bb8f2264b 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)...

llvm-svn: 54533
2008-08-08 17:50:35 +00:00
Steve Naroff f960c0bb9e Sema::ActOnEnumBody(): handle nested enum redefinitions.
Fixes <rdar://problem/6093889> Nested enum redefinition crashes sema.

llvm-svn: 54463
2008-08-07 14:08:16 +00:00
Daniel Dunbar ffc29be83f 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>

llvm-svn: 54388
2008-08-06 00:03:29 +00:00
Daniel Dunbar 1ff1d1fd51 Move AsmLabel into Declarator instead of just a parameter to
ActOnDeclarator.

llvm-svn: 54353
2008-08-05 16:28:08 +00:00
Daniel Dunbar 4983df37a7 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...

llvm-svn: 54339
2008-08-05 01:35:17 +00:00
Chris Lattner 7adf076088 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.

llvm-svn: 54317
2008-08-04 07:31:14 +00:00
Argyrios Kyrtzidis 25d05e88a5 Wherever a type is used/returned from the Action module, use TypeTy instead of DeclTy or void.
No functionality change.

llvm-svn: 54265
2008-08-01 10:35:27 +00:00
Chris Lattner 574dee6cac change more instances of QualType::getCanonicalType to call
ASTContext::getCanonicalType instead (PR2189)

llvm-svn: 54105
2008-07-26 22:17:49 +00:00
Chris Lattner f9c49e5d27 Reject typedef redefinitions when the underlying types are not identical,
even if in a system header etc.  rdar://6079937

llvm-svn: 54038
2008-07-25 18:44:27 +00:00
Steve Naroff 542cd5d3f9 Move fix in r54013 from the parser to sema.
llvm-svn: 54032
2008-07-25 17:57:26 +00:00
Ted Kremenek 73295fab89 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).

llvm-svn: 53955
2008-07-23 18:04:17 +00:00
Chris Lattner d7352d6801 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>

llvm-svn: 53883
2008-07-21 22:17:28 +00:00
Argyrios Kyrtzidis ef34aed1f9 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().
llvm-svn: 53724
2008-07-17 17:49:50 +00:00
Argyrios Kyrtzidis bd25998a45 When in C++, make EnumConstant names hide tag names in the same scope, instead of colliding with them.
llvm-svn: 53702
2008-07-16 21:01:53 +00:00
Steve Naroff de7d0f69ba 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.

llvm-svn: 53694
2008-07-16 18:22:22 +00:00
Argyrios Kyrtzidis 7da34d050b 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.

llvm-svn: 53667
2008-07-16 07:45:46 +00:00
Chris Lattner 2bd2e028ca rename "SInt" methods to "Int" in APValue.
llvm-svn: 53467
2008-07-11 19:19:21 +00:00
Chris Lattner b218272778 Add parser support for __builtin_stdarg_start, PR2531
llvm-svn: 53328
2008-07-09 17:26:36 +00:00
Nuno Lopes 7bfa180056 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)

llvm-svn: 53174
2008-07-07 16:46:50 +00:00
Anders Carlsson 7a241baf2f Shuffle things around in preparation for integrating Eli's constant evaluator.
llvm-svn: 53074
2008-07-03 04:20:39 +00:00
Chris Lattner 9ff58d7caf Fix PR2020 by recovering by defining an anonymous enum, instead of recovering
by filling in the body of a union with enum constants.

llvm-svn: 53069
2008-07-03 03:30:58 +00:00
Argyrios Kyrtzidis ed9834272f Add Sema support for C++ classes.
llvm-svn: 52956
2008-07-01 10:37:29 +00:00
Chris Lattner 2727d1b221 move some code from all callers of ProcessDeclAttributes into
the implementation of ProcessDeclAttributes.

llvm-svn: 52875
2008-06-29 00:02:00 +00:00
Chris Lattner a574154106 more attribute refactoring/renaming, no functionality change.
llvm-svn: 52874
2008-06-28 23:58:55 +00:00
Argyrios Kyrtzidis 853fbea313 Replace CurFunctionDecl and CurMethodDecl with methods getCurFunctionDecl() and getCurMethodDecl() that return the appropriate Decl through CurContext.
llvm-svn: 52852
2008-06-28 06:07:14 +00:00
Chris Lattner 2c6fcf5abb move decl attribute processing to a new SemaDeclAttr.cpp.
llvm-svn: 52792
2008-06-26 18:38:35 +00:00
Chris Lattner cf31de3760 Make Declarator::getDeclSpec() return a const reference to avoid
cases where mutation can introduce bugs.  Propagate around 'const'.

llvm-svn: 52772
2008-06-26 06:49:43 +00:00
Chris Lattner 3e39fa365d add a comment about something that was surprising, at least to me.
llvm-svn: 52771
2008-06-26 06:39:41 +00:00
Chris Lattner 4b413ea3bf 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.

llvm-svn: 52769
2008-06-26 06:27:57 +00:00
Chris Lattner c4f38851e6 Don't add isa with @defs only to work around it in the code generator, patch
by David Chisnall. 

llvm-svn: 52597
2008-06-21 21:37:25 +00:00
Chris Lattner 535b830449 add parser and sema support for the funny ObjC '@defs' thing.
Patch by David Chisnall!

llvm-svn: 52586
2008-06-21 19:39:06 +00:00
Chris Lattner 5696e7badf Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.
Patch by David Chisnall!

llvm-svn: 52422
2008-06-17 18:05:57 +00:00
Eli Friedman 61b529f466 Don't crash if we can't find FileEntry info for a typedef, since one
isn't guaranteed to exist. This fixes a crash with conflicting typedefs
coming from stdin.

This also fixes the crash in PR2406, but doesn't completely fix the 
issue; it appears there's something strange about the physical location 
for the definition of int64_t in stdlib.h.

llvm-svn: 52209
2008-06-11 06:20:39 +00:00
Argyrios Kyrtzidis 406fb231f8 -Add DeclChain member to DeclContext.
-ScopedDecls get chained to their DeclContext.
-DeclContext's DeclChain replaces FunctionDecl's DeclChain and EnumDecl's ElementList.

llvm-svn: 52164
2008-06-10 01:32:09 +00:00
Argyrios Kyrtzidis 554a07bab3 -Changes to TagDecl:
Added TagKind enum.
  Added getTagKind() method.
  Added convenience methods: isEnum(), isStruct(), isUnion(), isClass().
-RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one.

llvm-svn: 52160
2008-06-09 23:19:58 +00:00
Eli Friedman e6e0f23a29 Add code to make test/CodeGen/struct-init.c work correctly without the
pointer cast hack currently in isIntegerConstantExpr 
(in lib/AST/Expr.cpp).  Also removes an odd test that even gcc doesn't accept.

The reason the pointer cast hack is relevant here is that it makes Sema 
end up misinterpreting the relevant expression as a null pointer constant.

The reason for this patch is that I plan to remove the pointer cast hack 
sometime soon because it causes strange issues, especially in its 
current form; see my recent email to cfe-dev
"[PATCH] add constant expression evaluation to the AST and fix PR2413".

llvm-svn: 52120
2008-06-09 05:05:07 +00:00
Nuno Lopes b6f7953818 implement the alias attirbute (in both Sema and Codegen)
llvm-svn: 52092
2008-06-08 15:45:52 +00:00
Eli Friedman 01321c3b8c Clean up dead code from SemaInit landing.
llvm-svn: 52054
2008-06-06 19:40:52 +00:00
Eli Friedman 149614bfe7 Re-fix r51907 in a way which doesn't affect valid code. This essentially
moves the check for the invalid construct to a point where it doesn't 
affect other uses of isIntegerConstantExpr, and we can warn properly 
when the extension is used.  This makes it a bit more complicated, but 
it's a lot cleaner.

Steve, please tell me if this check is sufficient to handle the 
relevant system header.  I know it's enough to handle the testcase, but 
I don't know what exactly the original looks like.

llvm-svn: 51918
2008-06-03 21:01:11 +00:00
Nuno Lopes 3fe4651e2e fix decl attributes cleaning
this plugs the leak of attributes and also fixes a crash in the test

llvm-svn: 51862
2008-06-01 22:53:53 +00:00
Eli Friedman 66572afde4 Allow a pointer implicitly cast to a bool as a constant expression, as
required by the standard (the standard doesn't know anything about 
implicit casts).

Disallow pointers cast to non-integral arithmetic types as constant 
expressions.  This was previously allowed by accident. 

llvm-svn: 51779
2008-05-30 18:14:48 +00:00
Eli Friedman aee9e54dca Don't swap function decls, and add them to the scope as they are
encountered.  Mixing up the decls is unintuitive, and confuses the AST 
destruction code. Fixes PR2360.

Note that there is a need to look up the characteristics and 
declarations of a function associated with a particular name or decl, 
but the original swapping code doesn't solve it properly. 
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001644.html is one 
suggestion for how to fix that.

llvm-svn: 51584
2008-05-27 05:07:37 +00:00
Eli Friedman 3e113409cb Implementation of gcc mode attribute; this is significant because
it fixes PR2204.  Not too much to say about the implementation; it works 
in a similar way to the vector size attribute.

At some point, we need to modify the targets to provide information 
about the appropriate types.

llvm-svn: 51577
2008-05-27 03:33:27 +00:00
Ted Kremenek 20ccc4c3ed Revert r51498: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=51498&r1=51497&r2=51498&view=diff
Turns out that there are multiple places where a redefinition diagnostic can be emitted.  A cleaner solution (without touching Sema) is to have
the Driver turn off these diagnostics.  (will submit this patch soon)

llvm-svn: 51502
2008-05-23 21:28:18 +00:00