Steve Naroff [Sat, 9 Aug 2008 16:04:40 +0000 (16:04 +0000)]
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.
Steve Naroff [Fri, 8 Aug 2008 17:50:35 +0000 (17:50 +0000)]
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.
Ted Kremenek [Thu, 7 Aug 2008 22:30:22 +0000 (22:30 +0000)]
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).
Ted Kremenek [Wed, 6 Aug 2008 15:50:59 +0000 (15:50 +0000)]
Reorder serialization methods.
When serializing DeclStmt, encode a bit indicating whether or not the DeclStmt owns the Decl. This is an interim solution.
Daniel Dunbar [Wed, 6 Aug 2008 05:08:45 +0000 (05:08 +0000)]
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.
Daniel Dunbar [Wed, 6 Aug 2008 00:03:29 +0000 (00:03 +0000)]
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.
Daniel Dunbar [Tue, 5 Aug 2008 23:31:02 +0000 (23:31 +0000)]
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.
Ted Kremenek [Tue, 5 Aug 2008 20:46:55 +0000 (20:46 +0000)]
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.
Ted Kremenek [Tue, 5 Aug 2008 18:50:11 +0000 (18:50 +0000)]
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.
Daniel Dunbar [Tue, 5 Aug 2008 01:35:17 +0000 (01:35 +0000)]
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...
Daniel Dunbar [Tue, 5 Aug 2008 00:07:51 +0000 (00:07 +0000)]
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.
Daniel Dunbar [Mon, 4 Aug 2008 20:02:37 +0000 (20:02 +0000)]
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>
Ted Kremenek [Mon, 4 Aug 2008 18:15:26 +0000 (18:15 +0000)]
Misc cleanups.
When results go to a auto-generated dir in /tmp, don't use randomized file names. Just output /tmp/scan-build-DATE-counter, where counter is an auto-incremented counter for runs produced that day.
Daniel Dunbar [Mon, 4 Aug 2008 16:51:22 +0000 (16:51 +0000)]
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.
Chris Lattner [Mon, 4 Aug 2008 07:31:14 +0000 (07:31 +0000)]
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.
Daniel Dunbar [Fri, 1 Aug 2008 00:01:51 +0000 (00:01 +0000)]
Support constructor and destructor attributes in CodeGen
- There is an miscompilation issue remaining due to a poor
interaction between the delayed emission of static functions and
the emission of constructors, but that already existed prior to
this change.
Daniel Dunbar [Thu, 31 Jul 2008 22:40:48 +0000 (22:40 +0000)]
Support __attribute__(({con,de}structor)) in Parse & Sema
- Including possible priority argument
- In other news, the attribute parsing code really needs a cleanup
Daniel Dunbar [Wed, 30 Jul 2008 16:32:24 +0000 (16:32 +0000)]
Change CodeGenModule GlobalDeclMap to directly reference globals
instead of mapping the decl to a bitcast of the global to the correct
type.
- GetAddrOf{Function,GlobalVar} introduce the bitcast on every use now.
- This solves a problem where a dangling pointer could be introduced
by the RAUW done when replacing a forward or tentative
definition. See testcase for more details.
Daniel Dunbar [Tue, 29 Jul 2008 23:18:29 +0000 (23:18 +0000)]
Rework codegen emission of globals
- No (intended) functionality change.
- Primary purpose is to clearly separate (lazy) construction of
globals that are a forward declaration or tentative definition from
those that are the final definition.
- Lazy construction is now encapsulated in
GetAddrOf{Function,GlobalVar} while final definitions are
constructed in EmitGlobal{Function,Var}Definition.
- External interface for dealing with globals is now limited to
EmitGlobal and GetAddrOf{Function,GlobalVar}.
- Also updated helper functions dealing with statics, annotations,
and ctors to be private.