Commit Graph

1131 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis dfaf82ac2d Handle BuiltinType::WChar inside CodeGenTypes::ConvertNewType().
llvm-svn: 54593
2008-08-09 22:01:55 +00:00
Chris Lattner 572100b648 Fix PR2400 by more graceful handling of invalid decls. Don't try to layout
an invalid struct decl.  Thanks to Martin Doucha for the 
isIncompleteArrayType part of this patch.

llvm-svn: 54592
2008-08-09 21:35:13 +00:00
Gordon Henriksen 04c50bd7e0 Expressive diagnostics-- worth their weight in gold?
(Fixing a spelling error.)

llvm-svn: 54591
2008-08-09 19:58:22 +00:00
Argyrios Kyrtzidis cbad725bf4 Change 'Wchar' to 'WChar' casing, for consistency.
No functionality change.

llvm-svn: 54588
2008-08-09 17:20:01 +00:00
Argyrios Kyrtzidis d8f2f5f1b7 Handle WChar inside BuiltinType::getName().
llvm-svn: 54587
2008-08-09 17:11:33 +00:00
Argyrios Kyrtzidis 40e9e4828f Implement support for the 'wchar_t' C++ type.
llvm-svn: 54585
2008-08-09 16:51:54 +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
Ted Kremenek 4455a9d378 Added FIXME.
llvm-svn: 54568
2008-08-09 00:41:45 +00:00
Argyrios Kyrtzidis 5c45c9b063 Passing right brace location to ActOnFinishCXXClassDef is redundant, since it gets passed to ActOnFinishCXXMemberSpecification too.
llvm-svn: 54567
2008-08-09 00:39:29 +00:00
Ted Kremenek 0216b83d94 Don't use Expr::isIntegerConstantExpr just to check if a pointer value is initialize to NULL.
llvm-svn: 54563
2008-08-09 00:05:14 +00:00
Chris Lattner c893a67fe3 update to make IRBuilder API change.
llvm-svn: 54548
2008-08-08 19:57:58 +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
Argyrios Kyrtzidis 6bd44afc2f Destroy and delete the FieldDecl members of a RecordDecl.
llvm-svn: 54527
2008-08-08 14:08:55 +00:00
Ted Kremenek dcb5e38927 ParseAST now never releases the passed ASTConsumer. This is the responsibility of the client.
The motivation is that clients may either:

(a) query the ASTConsumer object after AST parsing to collect data/etc.
(b) reuse the ASTConsumer.

llvm-svn: 54502
2008-08-08 02:46:37 +00:00
Ted Kremenek 4a35180f6d Use DeclStmt::decl_iterator instead of walking the getNextDeclarator() chain.
llvm-svn: 54501
2008-08-08 02:45:18 +00:00
Ted Kremenek 4b1327960d Added AssumeSymGT, AssumeSymGE, AssumeSymLT, AssumeSymLE to add some minor improvements to path-sensitivity. Right now we basically treat 'x > y' and 'x < y' as implying 'x != y', but this restriction will only inevitably apply to our must rudimentary value tracking component (we'll implement more advanced value reasoning later).
llvm-svn: 54493
2008-08-07 22:30:22 +00:00
Ted Kremenek 18391f432b Don't flag any dead stores for variables marked unused.
llvm-svn: 54492
2008-08-07 22:28:30 +00:00
Argyrios Kyrtzidis faf0876cab Add CXXRecordType class.
llvm-svn: 54488
2008-08-07 20:55:28 +00:00
Ted Kremenek 7db4f60b26 ParseAST now conditionally deletes the passed ASTConsumer.
ModuleBuilder now performs llvmgen in HandleTranslationUnit.

This patch follows from the discussion on the following thread on cfe-commits:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080804/006849.html

llvm-svn: 54486
2008-08-07 19:47:41 +00:00
Ted Kremenek 31691ae862 Fix --html-diags in driver by delaying the construction of an HTMLDiagnosticClient until after we have created the Preprocessor object.
llvm-svn: 54472
2008-08-07 17:49:57 +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
Ted Kremenek 955516e6c7 attribute "unused" also applies to functions.
llvm-svn: 54440
2008-08-07 01:02:05 +00:00
Ted Kremenek c3b4c52a4d Fix <rdar://problem/6125909>.
Unify logic in return-of-stack-check (Sema) for casts and implicit casts.

llvm-svn: 54439
2008-08-07 00:49:01 +00:00
Ted Kremenek 8889bb3ff4 Cleanup some processing with DeclStmt, and gradually start using the internal BumpPtrAllocator to allocator more of CFG's data structures.
llvm-svn: 54433
2008-08-06 23:20:50 +00:00
Ted Kremenek e26ccf3553 Always construct the BumpPtrAllocator used by CFG as an instance variable.
llvm-svn: 54429
2008-08-06 22:22:32 +00:00
Ted Kremenek 66db7d66de Fix serialization of DeclStmt.
llvm-svn: 54428
2008-08-06 22:17:30 +00:00
Ted Kremenek 8d78a09a56 Reorder serialization methods.
When serializing DeclStmt, encode a bit indicating whether or not the DeclStmt owns the Decl.  This is an interim solution.

llvm-svn: 54410
2008-08-06 15:50:59 +00:00
Daniel Dunbar e8bdce441b Fix EmitNullInitializationToLValue for bitfield lvalues.
- PR2643

llvm-svn: 54397
2008-08-06 05:32:55 +00:00
Daniel Dunbar ead7c91240 Fix bitfield accesses which straddle the boundary of the underlying
type.

 - This generates somewhat less optimal code than before but this is
   not hard to rectify once stable (at the cost of slightly more
   complex code).

 - This currently always uses little-endian ordering of the bitfield. 

 - This breaks the CodeGen/bitfield.c test because it was grepping for
   hard-coded assembly instructions. Will fix once a better test case
   is constructed (hard to do without execution).

 - This fixes SingleSource/UnitTests/2006-01-23-InitializedBitField.c
   and Regression/C/PR1386.c from the test suite.

 - <rdar://problem/6085090>, <rdar://problem/6094169>

llvm-svn: 54395
2008-08-06 05:08:45 +00:00
Daniel Dunbar bfb1cd7454 Fix CodeGen of pointer arithmetic in compound assignment statements.
- Changed EmitSub to work on all cases (arithmetic, ptr - int, ptr -
   ptr) so that implementation matches that of other operators.

 - Modify EmitCompoundAssign to compute and perform the appropriate
   casts of left, right, and result types for the assorted pointer
   arithmetic cases.

 - Fix EmitSub (ptr - int) case to negate the rhs *after*
   extension. This is critical when the rhs is unsigned (and needs
   extension).

 - This fixes cfrac.

 - <rdr://6115726>

llvm-svn: 54392
2008-08-06 02:00:38 +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
Nico Weber b5fc3c300a add a libDriver, for now only move the text diangostics stuff from Driver to there
llvm-svn: 54383
2008-08-05 23:33:20 +00:00
Daniel Dunbar 829e988899 Change CodeGen of global decls to key off of the name (instead of
having multiple bindings from all the possible decls which
  conceptually map to the same global).

 - This eliminates CodeGen depending on the LLVM module for name
   lookup.

 - This also eliminates the need for ReplaceMapValuesWith (hurrah).

 - This handles lookups for FunctionDecls correctly in the presence of
   aliases, this was previously broken.

 - WIP: Can still clean up & unify variable and function emission.

llvm-svn: 54382
2008-08-05 23:31:02 +00:00
Nico Weber de565e3bc9 remove spaces at eol to test commit access
llvm-svn: 54381
2008-08-05 23:15:29 +00:00
Ted Kremenek 4f8792b616 Added decl_iterator to DeclStmt to provide an abstract interface to iterate over the ScopedDecls of a DeclStmt.
Updated a few clients of DeclStmt::getNextDeclarator() to use decl_iterator instead.  Will update other clients after additional testing.

llvm-svn: 54368
2008-08-05 20:46:55 +00:00
Ted Kremenek 9f6112c4e6 Remove excess #include.
llvm-svn: 54366
2008-08-05 19:56:24 +00:00
Ted Kremenek 2c674f6dbb Refactored driver logic for CodeGen into LLVMCodeGenWriter. This ASTConsumer layers on top of LLVMCodeGen (another existing ASTConsumer) to emit bitcode files to disk. This layering takes this logic out of clang.cpp and puts it directly into the ASTConsumer interface. The benefit is that now --emit-llvm works with both serialized ASTs and regular source files.
llvm-svn: 54364
2008-08-05 18:50:11 +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
Chris Lattner 197a301669 Fix rdar://6124613 a crash on invalid code.
llvm-svn: 54340
2008-08-05 06:19:09 +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
Daniel Dunbar 5aa55d51ca Bug fix, CodeGen of (void*) - (void*) was broken.
- <rdar://problem/6122967>

llvm-svn: 54338
2008-08-05 00:47:03 +00:00
Daniel Dunbar 81f7f2904c Add EXTWARN Diagnostic class.
- Like EXTENSION but always generates a warning (even without
   -pedantic).
 - Updated ptr -> int, int -> ptr, and incompatible cast warnings to
   be EXTWARN.
 - Other EXTENSION level diagnostics should be audited for upgrade.
 - Updated several test cases to fix code which produced unanticipated
   warnings.

llvm-svn: 54335
2008-08-05 00:07:51 +00:00
Ted Kremenek be9b33bf0f Nico Weber:
"the attached patch fixes some typos, 80 cols violations, etc. in comments."

llvm-svn: 54328
2008-08-04 22:51:42 +00:00
Daniel Dunbar b692ef405b Fix several issues in checking of address-of expressions.
- clang was erroneously accepting address-of applied to lvalue
   expressions involving pointer arithmetic.
 - clang was erroneously rejecting address-of applied to deref
   expressions of pointer-typed variables.
 - Improved existing test case.
 - Fixes: <rdar://problem/6113867>, <rdar://problem/6080158>

llvm-svn: 54326
2008-08-04 20:02:37 +00:00
Daniel Dunbar d27262f369 Avoid creating dummy block when no indirect gotos are present.
llvm-svn: 54322
2008-08-04 17:24:44 +00:00
Daniel Dunbar 88402ce8d0 Add CodeGen support for indirect goto.
- Follows emission scheme used by llvm-gcc, i.e. invent an id for
   each label whose address is taken and replace each indirect goto by
   a switch to each possible target.
 - Currently we emit a switch for each indirect goto instead of
   merging them as llvm-gcc does.

llvm-svn: 54318
2008-08-04 16:51:22 +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
Ted Kremenek 9512c122fa Change 'dead store (++/--)' to 'dead increment'
llvm-svn: 54268
2008-08-02 18:19:48 +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