Ted Kremenek [Fri, 17 Oct 2008 00:51:01 +0000 (00:51 +0000)]
Remove lval::FieldOffset, lval::ArrayOffset. These will be replaced with regions.
Remove GRExprEngine::getLVal and RValues::MakeVal.
Enhance StoreManager "GetLValue" methods to dispatch for specific kinds of lvalue queries, as opposed to interogating the expression tree (GRExprEngine already does this).
Added FIXMEs. In particular, we no longer "assume" that a base pointer in a field/array access is null (this logic was removed). Perhaps we should do this when fetching the lvalue for fields and array elements?
Daniel Dunbar [Thu, 16 Oct 2008 16:54:18 +0000 (16:54 +0000)]
Add --disable-free flag to clang.
- Disables the freeing of the ASTContext and the TranslationUnit
after parsing & sema.
- Primarily for timing the impact on -fsyntax-only timings.
Zhongxing Xu [Thu, 16 Oct 2008 06:09:51 +0000 (06:09 +0000)]
This is the first step to build a better evaluation model for GRExprEngine. A
new VisitLValue method is added to replace the old VisitLVal. The semantics
model becomes more explicit to separate rvalue evaluation from lvalue
evaluation.
Daniel Dunbar [Thu, 16 Oct 2008 03:51:50 +0000 (03:51 +0000)]
Teach tryEvaluate that fabs, copysign, and unary +/- are constants for
floats.
- With testcase, which also has some other things GCC folds but we
don't commented out in it.
Daniel Dunbar [Thu, 16 Oct 2008 02:34:03 +0000 (02:34 +0000)]
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.
Issue a warning when there's an ambiguous function declarator (that could be a direct initializer for a variable defition).
Idea originated from here: http://thread.gmane.org/gmane.comp.gcc.devel/101524
Ted Kremenek [Wed, 15 Oct 2008 05:23:41 +0000 (05:23 +0000)]
Enhance dead store checker to not flag preincrements to dead variables where the preincrement is a subexpression, e.g. foo(++x); This can cause false negatives, but will remove a whole class of false positives.
Simplify handling of struct/union/class tags.
Instead of using two sets of Decl kinds (Struct/Union/Class and CXXStruct/CXXUnion/CXXClass), use one 'Record' and one 'CXXRecord' Decl kind and make tag kind a property of TagDecl.
Cleans up the code a bit and better reflects that Decl class structure.
Steve Naroff [Tue, 14 Oct 2008 22:18:38 +0000 (22:18 +0000)]
Downgrade incompatibilities with objc qualified types (e.g. id <P>) to warnings.
Note: One day, we should consider moving the actual diags to ObjCQualifiedIdTypesAreCompatible(), since it has more information on the actual problem. GCC currently emits slightly more instructive errors for some cases involving protocols. I added a FIXME to the code.
Daniel Dunbar [Tue, 14 Oct 2008 05:35:18 +0000 (05:35 +0000)]
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.
Ted Kremenek [Mon, 13 Oct 2008 21:46:42 +0000 (21:46 +0000)]
Use 'realpath' to resolve the absolute path to clang and ccc-analyzer.
Add "-analyze-headers" option to scan-build that passes the option -analyzer-opt-analyze-headers to clang.
Daniel Dunbar [Mon, 13 Oct 2008 17:02:26 +0000 (17:02 +0000)]
Lift out ABIInfo abstract base class.
- Currently still lives in CGCall.cpp but is intended to be the
target specific place for hooking ABI information.
- Select ABIInfo to use based on Target's prefix and pointer width.
Implement more efficient Decl <-> DeclContext conversions.
When the static type on the Decl side is a subclass of DeclContext the compiler will use a "inlinable" static_cast, instead of always using an out-of-line function call.
Note, though, that the isa<> check still uses an out-of-line function call.
Chris Lattner [Sun, 12 Oct 2008 05:29:20 +0000 (05:29 +0000)]
Add a new -rewrite-test option, which is basically a
playground to experiment with some new rewriter approaches. For now
it is probably the most complex version of 'cat' ever invented.
Chris Lattner [Sun, 12 Oct 2008 04:51:35 +0000 (04:51 +0000)]
Change FormTokenWithChars to take the token kind to form, since all clients
were setting a kind and then forming it. This is just a minor API cleanup,
no functionality change.
Chris Lattner [Sun, 12 Oct 2008 04:05:48 +0000 (04:05 +0000)]
Add a new mode to the lexer which enables it to return all characters,
even whitespace, as tokens from the file. This is enabled with
L->SetKeepWhitespaceMode(true) on a raw lexer. In this mode, you too
can use clang as a really complex version of 'cat' with code like this:
This will emit exactly the input file, with no canonicalization or other
translation. Realistic clients actually do something with the tokens of
course :)
Chris Lattner [Sun, 12 Oct 2008 01:31:51 +0000 (01:31 +0000)]
Simplify raw mode lexing by treating an unterminate /**/ comment the
same we we do an unterminated string or character literal. This makes
it so we can guarantee that the lexer never calls into the
preprocessor (which would be suicide for a raw lexer).
Chris Lattner [Sun, 12 Oct 2008 01:15:46 +0000 (01:15 +0000)]
Change how raw lexers are handled: instead of creating them and then
using LexRawToken, create one and use LexFromRawLexer. This avoids
twiddling the RawLexer flag around and simplifies some code (even
speeding raw lexing up a tiny bit).
This change also improves the token paster to use a Lexer on the stack
instead of new/deleting it.
Steve Naroff [Fri, 10 Oct 2008 01:28:17 +0000 (01:28 +0000)]
Final phase of converting BlockDecls over to DeclContext. This is unfortunately a largish/complex diff, however it was necessry to pass all the current block tests.
class C {
static const int number = 50;
static int arr[number];
};
Here's how it worked:
-GetTypeForDeclarator was called from both Sema::ActOnCXXMemberDeclarator and Sema::ActOnDeclarator.
-VariableArrayTypes are not uniqued so two VariableArrayTypes were created with the same DeclRefExpr.
-On exit they both tried to destroy that one DeclRefExpr.
The fix is not to use GetTypeForDeclarator from the Sema::ActOnCXXMemberDeclarator.
Steve Naroff [Wed, 8 Oct 2008 18:44:00 +0000 (18:44 +0000)]
Instantiate the BlockDecl in ActOnBlockStart() so we can use it as a DeclContext.
This required changes to attach the compound statement later on (like we do for functions).
Steve Naroff [Wed, 8 Oct 2008 17:01:13 +0000 (17:01 +0000)]
- Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.
This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?).
Still some follow-up work to finish this (forthcoming).
Zhongxing Xu [Wed, 8 Oct 2008 02:50:44 +0000 (02:50 +0000)]
This is the first step to implement a field-sensitive store model. Other things are simplified: no heap shape assumption, no parameter alias assumption, etc.
Ted Kremenek [Tue, 7 Oct 2008 23:09:49 +0000 (23:09 +0000)]
Migrate DeclStmt over to using a DeclGroup instead of a pointer to a ScopedDecl*.
This also removes the ugly hack needed in CFG.cpp for subclassing DeclStmt to create a DeclStmt with one Decl*.
In ParseParenDeclarator match "D.setGroupingParens(true);" with another setGroupingParens call after the ')' is parsed.
Fixes this bug:
int (x)(0); // error, expected function declarator where the '(0)' initializer is
Simplify handling of direct initializers by letting Sema::AddInitializerToDecl handle conversions, instead of using Sema::ActOnCXXTypeConstructExpr.
Additional benefit is that diagnostics are the same for both direct-initialization and copy-initialization.
In the case of "int x( expression );":
-The Init expression of VarDecl 'x' will be the expression inside the parentheses.
-VarDecl::hasCXXDirectInitializer for VarDecl 'x' will return true to let clients distinguish from "int x = expression ;".
Ted Kremenek [Mon, 6 Oct 2008 22:45:07 +0000 (22:45 +0000)]
Explicitly access the first Decl* referenced by a DeclStmt instead of using "getDecl()." Added a FIXME indicating that the call to RewriteObjCQualifiedInterfaceTypes() is meant to modifying the type-specifier; hopefully this will be a little more clean once DeclGroups contain type specifiers.
Ted Kremenek [Mon, 6 Oct 2008 22:17:16 +0000 (22:17 +0000)]
Modified DeclGroupRef to always load/store the internal pointer value as Decl*. This hopefully will obviate any concerns with violating strict type-aliasing issues.
Ted Kremenek [Mon, 6 Oct 2008 20:58:11 +0000 (20:58 +0000)]
When processing Objective-C foreach statements, first check to see if the statement has a DeclStmt with a single Decl. Afterwards, use DeclStmt::getSolitaryDecl() to access that Decl (thus avoiding an assertion being triggered). These changes remove an unneeded use of ScopedDecl::getNextDeclarator() and DeclStmt::getDecl().