Douglas Gregor [Wed, 16 Dec 2009 18:50:27 +0000 (18:50 +0000)]
When value-initializing a class with no user-defined constructors but
with a non-trivial default constructor, zero-initialize the storage
and then call the default constructor. Fixes PR5800.
Nuno Lopes [Wed, 16 Dec 2009 16:59:22 +0000 (16:59 +0000)]
implement PR5654: add -fassume-sane-operator-new, which is enabled by default, and adds the malloc attribute to the global function new() and to the overloaded new operators.
feel free to chage the name to this lengthy argument
John McCall [Wed, 16 Dec 2009 12:17:52 +0000 (12:17 +0000)]
Shift things around so that it's easier to recover from a missing
function in a C++ call using an arbitrary call-expression type.
Actually exploit this to fix the recovery implemented earlier.
Zhongxing Xu [Wed, 16 Dec 2009 11:27:52 +0000 (11:27 +0000)]
Add a new kind of region: CXXObjectRegion. Currently it has only one
attribute: the object type.
Add initial support for visiting CXXThisExpr.
Fix a bunch of 80-col violations.
John McCall [Wed, 16 Dec 2009 08:11:27 +0000 (08:11 +0000)]
Introduce a centralized routine in Sema for diagnosing failed lookups (when
used as expressions). In dependent contexts, try to recover by doing a lookup
in previously-dependent base classes. We get better diagnostics out, but
unfortunately the recovery fails: we need to turn it into a method call
expression, not a bare call expression. Thus this is still a WIP.
Douglas Gregor [Wed, 16 Dec 2009 06:35:08 +0000 (06:35 +0000)]
Eliminate Sema::CheckValueInitialization; its callers now use
InitializationSequence to perform the actual initialization.
Also, introduced the notion of a tree of initialized entities, so that
we can know where an initialization began when dealing with nested
initializations (as occur when performing list initialization). This
will, eventually, be useful for producing better diagnostics when list
initialization fails, because we can show the path from the top-level
object being initialized down to the actual subobject where
initialization failed.
Eli Friedman [Wed, 16 Dec 2009 06:28:21 +0000 (06:28 +0000)]
Add abort() as a builtin. This has two effects: one, we warn for incorrect
declarations of abort(), and two, we mark it noreturn. Missing the latter
shows up in one of the "embarassing" tests (from the thread on llvmdev
"detailed comparison of generated code size for LLVM and other compilers").
Ted Kremenek [Wed, 16 Dec 2009 03:18:58 +0000 (03:18 +0000)]
Add (initial?) static analyzer support for handling C++ references.
This change was a lot bigger than I originally anticipated; among
other things it requires us storing more information in the CFG to
record what block-level expressions need to be evaluated as lvalues.
The big change is that CFGBlocks no longer contain Stmt*'s by
CFGElements. Currently CFGElements just wrap Stmt*, but they also
store a bit indicating whether the block-level expression should be
evalauted as an lvalue. DeclStmts involving the initialization of a
reference require us treating the initialization expression as an
lvalue, even though that information isn't recorded in the AST.
Conceptually this change isn't that complicated, but it required
bubbling up the data through the CFGBuilder, to GRCoreEngine, and
eventually to GRExprEngine.
The addition of CFGElement is also useful for when we want to handle
more control-flow constructs or other data we want to keep in the CFG
that isn't represented well with just a block of statements.
In GRExprEngine, this patch introduces logic for evaluating the
lvalues of references, which currently retrieves the internal "pointer
value" that the reference represents. EvalLoad does a two stage load
to catch null dereferences involving an invalid reference (although
this could possibly be caught earlier during the initialization of a
reference).
Symbols are currently symbolicated using the reference type, instead
of a pointer type, and special handling is required creating
ElementRegions that layer on SymbolicRegions (see the changes to
RegionStoreManager).
Along the way, the DeadStoresChecker also silences warnings involving
dead stores to references. This was the original change I introduced
(which I wrote test cases for) that I realized caused GRExprEngine to
crash.
Daniel Dunbar [Tue, 15 Dec 2009 22:01:24 +0000 (22:01 +0000)]
Update tests to use %clang instead of 'clang', and forcibly disable use of '
clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to
garbage).
Fixes a code gen bug related to accessing a now
non-existing 'isa' field of a non-existing struct type
all related to legacy type definition for 'id' which we have
dropped in clang in favor of a built-in type.
(fixes radar 7470820).
Chris Lattner [Tue, 15 Dec 2009 20:48:12 +0000 (20:48 +0000)]
enable reuse of MacroArgs objects. This is a small (2.5%) win
on PR5610 (2.185 -> 2.130s). The big issue is that this is making
insanely huge macro argument lists with over a million tokens in it.
The reason that mallco and free are so expensive is that we are
actually going to the kernel to get it, and switching to a bump
pointer allocator won't change this in an interesting way.
Daniel Dunbar [Tue, 15 Dec 2009 20:14:24 +0000 (20:14 +0000)]
Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
can be useful to redefine what gets run as 'clang -cc1' (for example, to set
a default target).
Anders Carlsson [Tue, 15 Dec 2009 19:16:31 +0000 (19:16 +0000)]
If a ParmVarDecl's default argument is a CXXExprWithTemporaries, return the underlying expr instead. Add getNumDefaultArgTemporaries and getDefaultArgTemporary which returns the temporaries a default arg creates.
Nate Begeman [Tue, 15 Dec 2009 18:13:04 +0000 (18:13 +0000)]
Support OpenCL 1.1 odd-length vector component accessors.
For hi/odd of an odd-length vector, the last component is undefined. Since
we shuffle with an undef vector, no CodeGen needs to change to support this.
Chris Lattner [Tue, 15 Dec 2009 07:26:51 +0000 (07:26 +0000)]
update to match LLVM API change:
Remove isPod() from DenseMapInfo, splitting it out to its own
isPodLike type trait. This is a generally useful type trait for
more than just DenseMap, and we really care about whether something
acts like a pod, not whether it really is a pod.
Daniel Dunbar [Tue, 15 Dec 2009 04:24:24 +0000 (04:24 +0000)]
Fix a COVTCTII (crash-on-valid-that-clang-thinks-is-invalid, duh),
note_previous_decl was used where note_previous_declaration was intended. Better
names or PR5785 might be nice.
Ted Kremenek [Tue, 15 Dec 2009 04:12:12 +0000 (04:12 +0000)]
Until we can make the dead stores checker smarter, dont' emit dead store warnings for C++ objects (whose constructors/destructors have possible side-effects).
Mike Stump [Tue, 15 Dec 2009 03:11:10 +0000 (03:11 +0000)]
This patch should fix PR2461. It allows clang to apply the noreturn
attribute to function pointers. It also fixes Sema to check function
pointers for the noreturn attribute when checking for fallthrough.
Patch by Chip Davis, with a slight fix to pass the testsuite.
John McCall [Tue, 15 Dec 2009 02:19:47 +0000 (02:19 +0000)]
Diagnose the use of typedefs for template specialization types in the scope
specifiers for out-of-line declarations, e.g.
typedef Temp<int> MyTemp;
template <> MyTemp::foo;
Chris Lattner [Tue, 15 Dec 2009 01:51:03 +0000 (01:51 +0000)]
set up the machinery for a MacroArgs cache hanging off Preprocessor.
We creating and free thousands of MacroArgs objects (and the related
std::vectors hanging off them) for the testcase in PR5610 even though
there are only ~20 live at a time. This doesn't actually use the
cache yet.
Ted Kremenek [Tue, 15 Dec 2009 01:38:04 +0000 (01:38 +0000)]
Start the ball rolling on C++ support in the static analyzer. For
now, don't construct CFGs that contain C++ try/catch statements, and
have GRExprEngine abort a path if it encounters a C++ construct it
doesn't understand (which is mostly everything at this point).
Daniel Dunbar [Tue, 15 Dec 2009 00:06:45 +0000 (00:06 +0000)]
Add -resource-dir to clang -cc1, this allows the base directory for compiler
resources (e.g., /usr/lib/clang/1.1) to be passed on the command line instead of
computed.
Chris Lattner [Mon, 14 Dec 2009 22:12:52 +0000 (22:12 +0000)]
move the VarargsElided member of MacrosArgs to shrink the MacroArgs struct
on 64-bit targets. Pass Preprocessor into create/destroy methods of MacroArgs
even though it isn't used yet.
Patch to fix 32-bit @try failure with internal assertion when compiling
an Objective-C rethrow nested inside another try/catch block. (fixes radar 7466728).