Commit Graph

74246 Commits

Author SHA1 Message Date
Ted Kremenek 4cad5fc035 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.

llvm-svn: 91501
2009-12-16 03:18:58 +00:00
Mike Stump 11ba8d989c Add some documentation for recent checkins. WIP.
llvm-svn: 91500
2009-12-16 03:18:14 +00:00
Mike Stump b85ffb689e Add an addition check for undefined behavior for when we hit a
__builtin_unreachable.  WIP.

llvm-svn: 91499
2009-12-16 03:07:12 +00:00
Mike Stump 3f6f9febad Implement additional undefined checks for additional loads and stores. WIP.
llvm-svn: 91498
2009-12-16 02:57:00 +00:00
Victor Hernandez dd7418ae3f MDNodes that refer to an instruction are local to a function; in that case, explicitly keep track of the function they are local to
llvm-svn: 91497
2009-12-16 02:52:09 +00:00
Johnny Chen 466231ab92 Add encoding bits for some Thumb instructions. Plus explicitly set the top two
bytes of Inst to 0x0000 for the benefit of the Thumb decoder.

llvm-svn: 91496
2009-12-16 02:32:54 +00:00
Devang Patel c69d9607f8 XFAIL on ppc-darwin.
llvm-svn: 91495
2009-12-16 02:11:38 +00:00
Anders Carlsson afb2dade0c Check in a rudimentary FullExpr class that isn't used anywhere yet. Rename Action::FullExpr to Action::MakeFullExpr to avoid name clashes.
llvm-svn: 91494
2009-12-16 02:09:40 +00:00
John McCall 0db42252f7 Successive anonymous namespaces name the same scope. I misinterpreted the
standard the last time.  Fixes PR5766.

llvm-svn: 91493
2009-12-16 02:06:49 +00:00
Douglas Gregor 85dabae6ad Switch the C++ new expression over to InitializationSequence, rather
than using its own partial implementation of initialization. 

Switched CheckInitializerTypes over to
InitializedEntity/InitializationKind, to help move us closer to
InitializationSequence.

Added InitializedEntity::getName() to retrieve the name of the entity,
for diagnostics that care about such things.

Implemented support for default initialization in
InitializationSequence.

Clean up the determination of the "source expressions" for an
initialization sequence in InitializationSequence::Perform.

Taught CXXConstructExpr to store more location information.

llvm-svn: 91492
2009-12-16 01:38:02 +00:00
Evan Cheng 1be6286028 Re-enable 91381 with fixes.
llvm-svn: 91489
2009-12-16 00:53:11 +00:00
Chris Lattner 177be32334 revert my strstr optimization, I'm told it breaks x86-64 bootstrap.
Will reapply with a fix when I get a chance.

llvm-svn: 91486
2009-12-16 00:46:02 +00:00
Dale Johannesen 56f041406d Do better with physical reg operands (typically, from inline asm)
in local register allocator.  If a reg-reg copy has a phys reg
input and a virt reg output, and this is the last use of the phys
reg, assign the phys reg to the virt reg.  If a reg-reg copy has
a phys reg output and we need to reload its spilled input, reload
it directly into the phys reg than passing it through another reg.

Following 76208, there is sometimes no dependency between the def of
a phys reg and its use; this creates a window where that phys reg
can be used for spilling (this is true in linear scan also).  This
is bad and needs to be fixed a better way, although 76208 works too
well in practice to be reverted.  However, there should normally be
no spilling within inline asm blocks.  The patch here goes a long way
towards making this actually be true.

llvm-svn: 91485
2009-12-16 00:29:41 +00:00
John McCall 826ca5630e Every anonymous namespace is different. Caught by clang++.
llvm-svn: 91481
2009-12-16 00:15:28 +00:00
John McCall 323c30c5f4 Explicit template instantiations must happen in the template's immediately
enclosing namespace.  Caught by clang++.

llvm-svn: 91480
2009-12-16 00:13:24 +00:00
Bill Wendling 2d5967d005 Helpful comment added. Some code cleanup. No functional change.
llvm-svn: 91479
2009-12-16 00:08:36 +00:00
Bill Wendling 3766491eee Initialize uninitialized variables.
llvm-svn: 91477
2009-12-16 00:01:27 +00:00
Bill Wendling 776ef4dd32 Initialize uninitialized variables.
llvm-svn: 91475
2009-12-16 00:00:18 +00:00
Fariborz Jahanian e8d28904b0 Diagnose attempting to assign to a sub-structure of an ivar
using objective-c property. (fixes radar 7449707)

llvm-svn: 91474
2009-12-15 23:59:41 +00:00
Ted Kremenek 9158fb748c Remove ValueManager::getRegionValueSymbolValOrUnknown(). It was just extra veneer on top of getRegionValueSymbolVal().
llvm-svn: 91471
2009-12-15 23:23:27 +00:00
Jeffrey Yasskin e0d8e14e11 Change indirect-globals to use a dedicated allocIndirectGV. This lets us
remove start/finishGVStub and the BufferState helper class from the
MachineCodeEmitter interface.  It has the side-effect of not setting the
indirect global writable and then executable on ARM, but that shouldn't be
necessary.

llvm-svn: 91464
2009-12-15 22:42:46 +00:00
Bill Wendling 098a38b5ce Some command lines don't like numbers with leading zeros. Remove them.
llvm-svn: 91463
2009-12-15 22:42:19 +00:00
John McCall e9f92a017c Link up member-class redeclarations during template instantiation.
This test courtesy of LLVM.

llvm-svn: 91462
2009-12-15 22:29:06 +00:00
Daniel Dunbar 5618e98f33 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).

llvm-svn: 91460
2009-12-15 22:01:24 +00:00
Bob Wilson e44756d7c2 Reapply 91184 with fixes and an addition to the testcase to cover the problem
found last time.  Instead of trying to modify the IR while iterating over it,
I've change it to keep a list of WeakVH references to dead instructions, and
then delete those instructions later.  I also added some special case code to
detect and handle the situation when both operands of a memcpy intrinsic are
referencing the same alloca.

llvm-svn: 91459
2009-12-15 22:00:51 +00:00
Daniel Dunbar c6d3c5ef76 lit: Improve error when gtest discovery fails.
llvm-svn: 91458
2009-12-15 22:00:37 +00:00
Fariborz Jahanian 2b9fc83db5 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).

llvm-svn: 91455
2009-12-15 21:34:52 +00:00
Anders Carlsson 6e997b2993 ShouldDestroyTemporaries? I don't think so.
llvm-svn: 91450
2009-12-15 20:51:39 +00:00
Chris Lattner 1316249ad2 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.

llvm-svn: 91449
2009-12-15 20:48:12 +00:00
Dan Gohman c87c16b030 Revert 90628, which was incorrect.
llvm-svn: 91448
2009-12-15 20:21:44 +00:00
Daniel Dunbar 8fbe78f6fc 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).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Chris Lattner a3aef788ec Fix GetConstantStringInfo to not look into MDString (it works on
real data, not metadata) and fix DbgInfoPrinter to not abuse
GetConstantStringInfo.

llvm-svn: 91444
2009-12-15 19:34:20 +00:00
Jim Grosbach 38c4f4b5d1 whitespace
llvm-svn: 91442
2009-12-15 19:28:13 +00:00
Devang Patel 1f4690c624 Add support to emit debug info for C++ namespaces.
llvm-svn: 91440
2009-12-15 19:16:48 +00:00
Anders Carlsson 714d0969b3 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.
llvm-svn: 91439
2009-12-15 19:16:31 +00:00
Chris Lattner 26ab363361 optimize strstr, PR5783
llvm-svn: 91438
2009-12-15 19:14:40 +00:00
Nate Begeman ac8183a830 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.

llvm-svn: 91437
2009-12-15 18:13:04 +00:00
Mike Stump 4ec1237106 Add testcase for recent checkin.
Patch by Chip Davis.

llvm-svn: 91436
2009-12-15 18:02:45 +00:00
Fariborz Jahanian d1a2d5719a Implement conditional block invocation rewrite
and some clean up and a block rewriter test.

llvm-svn: 91435
2009-12-15 17:30:20 +00:00
Johnny Chen c28e629c2d Added encoding bits for the Thumb ISA. Initial checkin.
llvm-svn: 91434
2009-12-15 17:24:14 +00:00
Douglas Gregor 906db8a546 Fix some diagnostic-related FIXMEs, from Nicola Gigante
llvm-svn: 91433
2009-12-15 16:44:32 +00:00
Dan Gohman 265ce318b8 Delete an unused function.
llvm-svn: 91432
2009-12-15 16:30:09 +00:00
Douglas Gregor dce7d0e8d9 Elaborated types are specifier types, based on a patch from Cornelius
llvm-svn: 91431
2009-12-15 16:28:32 +00:00
Zhongxing Xu 765f3e4f35 Add comments.
llvm-svn: 91430
2009-12-15 09:32:42 +00:00
Zhongxing Xu 950978a44b Remove displayProgress parameter.
llvm-svn: 91429
2009-12-15 09:09:49 +00:00
Chris Lattner 24aba42d04 add some other xforms that should be done as part of PR5783
llvm-svn: 91428
2009-12-15 09:05:13 +00:00
Chris Lattner 4179fa0357 a few improvements:
1. Use std::equal instead of reinventing it.
2. don't run dtors in destroy_range if element is pod-like.
3. Use isPodLike to decide between memcpy/uninitialized_copy 
   instead of is_class.  isPodLike is more generous in some cases.

llvm-svn: 91427
2009-12-15 08:34:01 +00:00
Chris Lattner 6087a3e76b hoist the begin/end/capacity members and a few trivial methods
up into the non-templated SmallVectorBase class.

llvm-svn: 91426
2009-12-15 08:29:22 +00:00
Chris Lattner 62e04783c0 improve isPodLike to know that all non-class types are pod.
llvm-svn: 91425
2009-12-15 07:40:44 +00:00
Chris Lattner 13b3928d62 move isPodLike<clang::QualType> out to Type.h. We don't
want some clients of QualType to think it's a pod and some to 
not know it is.

llvm-svn: 91424
2009-12-15 07:30:12 +00:00