Commit Graph

39515 Commits

Author SHA1 Message Date
Jordan Rose ce6c99a559 [analyzer] Reduce code duplication: make CXXDestructorCall a CXXInstanceCall.
While there is now some duplication between SimpleCall and the CXXInstanceCall
sub-hierarchy, this is much better than copy-and-pasting the devirtualization
logic shared by both instance methods and destructors.

An unfortunate side effect is that there is no longer a single CallEvent type
that corresponds to "calls written as CallExprs". For the most part this is a
good thing, but the checker callback eval::Call still takes a CallExpr rather
than a CallEvent (since we're not sure if we want to allow checkers to
evaluate other kinds of calls). A mistake here will be caught by a cast<> in
CheckerManager::runCheckersForEvalCall.

No functionality change.

llvm-svn: 161809
2012-08-13 23:46:05 +00:00
Jordan Rose 710f6b1259 [analyzer] Be more careful when downcasting for devirtualization.
Virtual base regions are never layered, so simply stripping them off won't
necessarily get you to the correct casted class. Instead, what we want is
the same logic for evaluating dynamic_cast: strip off base regions if possible,
but add new base regions if necessary.

llvm-svn: 161808
2012-08-13 23:46:01 +00:00
Jordan Rose 574ef152fc [analyzer] Handle dynamic_casts that turn out to be upcasts.
This can occur with multiple inheritance, which jumps from one parent to
the other, and with virtual inheritance, since virtual base regions always
wrap the actual object and can't be nested within other base regions.

This also exposed some incorrect logic for multiple inheritance: even if B
is known not to derive from C, D might still derive from both of them.

llvm-svn: 161798
2012-08-13 22:11:42 +00:00
Jordan Rose 07a7ed80cb [analyzer] Don't strip CXXBaseObjectRegions when checking dynamic_casts.
...and /do/ strip CXXBaseObjectRegions when casting to a virtual base class.

This allows us to enforce the invariant that a CXXBaseObjectRegion can always
provide an offset for its base region if its base region has a known class
type, by only allowing virtual bases and direct non-virtual bases to form
CXXBaseObjectRegions.

This does mean some slight problems for our modeling of dynamic_cast, which
needs to be resolved by finding a path from the current region to the class
we're trying to cast to.

llvm-svn: 161797
2012-08-13 22:11:34 +00:00
Chad Rosier 7459543795 [ms-inline asm] Add a helpful assert.
llvm-svn: 161796
2012-08-13 22:04:09 +00:00
Chad Rosier 162b14f326 [ms-inline asm] Address a potential buffer overflow.
llvm-svn: 161793
2012-08-13 21:35:47 +00:00
Richard Smith 47726b2f02 PR13570: When an unresolved overloaded call appeared in a dependent context, we
forgot to set it as being instantiation-dependent as well as being type- and
value-dependent.

llvm-svn: 161791
2012-08-13 21:29:18 +00:00
Manman Ren 6c30e137d0 ARM: enable struct byval for AAPCS-VFP.
rdar://9877866

llvm-svn: 161790
2012-08-13 21:23:55 +00:00
Fariborz Jahanian 7513fa346c c: small refactoring of checking for __attribute__(const))
per Richard's comment.

llvm-svn: 161786
2012-08-13 21:15:02 +00:00
Chad Rosier 65a8e0b69f [ms-inline asm] Have patchMSAsmStrings() return a vector or AsmStrings.
The AsmParser expects a single asm instruction, but valid ms-style inline asm
statements may contain  multiple instructions.

This happens with asm blocks

__asm {
  mov ebx, eax
  mov ecx, ebx
}

or when multiple asm statements are adjacent to one another

__asm mov ebx, eax
__asm mov ecx, ebx

and

__asm mov ebx, eax __asm mov ecx, ebx

Currently, asm blocks are not properly handled.

llvm-svn: 161780
2012-08-13 20:32:07 +00:00
Richard Smith ef8bf4368e Factor out computation of whether a typeid's expression is potentially
evaluated into a CXXTypeid member function. No functionality change.

llvm-svn: 161779
2012-08-13 20:08:14 +00:00
Marshall Clow 35a5f3e539 Minor rework of code example for clarity. No functionality change
llvm-svn: 161776
2012-08-13 18:56:38 +00:00
Fariborz Jahanian 794ae1ea77 c: make __has_attribute(const) work for const
function attribute. // rdar://10253857

llvm-svn: 161767
2012-08-13 18:04:58 +00:00
David Blaikie fb7cb3fdd0 Teach Git to ignore the tools/extra directory.
llvm-svn: 161764
2012-08-13 17:45:30 +00:00
Douglas Gregor 35ceb27fa4 When looking for the comment associated with a declaration, adjust the
'templated' declaration for a function or class template to refer to
the function or class template itself, to which the documentation will
be attached. Fixes PR13593.

llvm-svn: 161762
2012-08-13 16:37:30 +00:00
Douglas Gregor 03b5ebe4cb When the header file search resolves a quoted include to a file in the
current directory, propagate the framework and in-index-header-map
from the including header's information down to the included header's
information. Fixes <rdar://problem/11261291>.

As with everything header-map related, we can't really test this in
isolation within Clang, so it's tested elsewhere.

llvm-svn: 161759
2012-08-13 15:47:39 +00:00
Alexander Kornienko bf4871d363 Implemented -ast-dump, -ast-print, -ast-dump-filter options in clang-check
llvm-svn: 161753
2012-08-13 10:50:08 +00:00
Alexander Kornienko 199cd94f50 Added some preprocessor memory usage stats to -cc1 -print-stats
llvm-svn: 161752
2012-08-13 10:46:42 +00:00
Eric Christopher 921cf137b3 This is always going to be true so the cast isn't necessary.
llvm-svn: 161744
2012-08-13 02:07:42 +00:00
Dmitri Gribenko a43ec186a4 Attaching comments to declarations: find comment attached to any redeclaration
Not only look for the comment near the declaration itself, but also walk the
redeclaration chain: the previous declaration might have had a documentation
comment.

llvm-svn: 161722
2012-08-11 00:51:43 +00:00
Jordan Rose a423e4c022 [analyzer] Remove unused StoreManager::CastResult class.
No functionality change.

llvm-svn: 161715
2012-08-10 22:43:32 +00:00
Fariborz Jahanian 5e74a1af6f Removed an unused function I added a while back.
llvm-svn: 161714
2012-08-10 22:28:13 +00:00
Jordan Rose 02e5309b35 [analyzer] Strip CXXBaseObjectRegions when devirtualizing method calls.
This was causing a crash when we tried to re-apply a base object region to
itself. It probably also caused incorrect offset calculations in RegionStore.

PR13569 / <rdar://problem/12076683>

llvm-svn: 161710
2012-08-10 22:26:46 +00:00
Jordan Rose 51bcb226a2 [analyzer] Try to devirtualize even if the static callee has no definition.
This mostly affects pure virtual methods, but would also affect parent
methods defined inline in the header when analyzing the child's source file.

llvm-svn: 161709
2012-08-10 22:26:43 +00:00
Jordan Rose 13937b1d7a [analyzer] Add clang_analyzer_checkInlined for debugging purposes.
This check is also accessible through the debug.ExprInspection checker.
Like clang_analyzer_eval, you can use it to test the analyzer engine's
current state; the argument should be true or false to indicate whether or
not you expect the function to be inlined.

When used in the positive case (clang_analyzer_checkInlined(true)), the
analyzer prints the message "TRUE" if the function is ever inlined. However,
clang_analyzer_checkInlined(false) should never print a message; this asserts
that there should be no paths on which the current function is inlined, but
then there are no paths on which to print a message! (If the assertion is
violated, the message "FALSE" will be printed.)

This asymmetry comes from the fact that the only other chance to print a
message is when the function is analyzed as a top-level function. However,
when we do that, we can't be sure it isn't also inlined elsewhere (such as
in a recursive function, or if we want to analyze in both general or
specialized cases). Rather than have all checkInlined calls have an appended,
meaningless "FALSE" or "TOP-LEVEL" case, there is just no message printed.

void clang_analyzer_checkInlined(int);

For debugging purposes only!

llvm-svn: 161708
2012-08-10 22:26:29 +00:00
Fariborz Jahanian 29622c1f0b objective-C: test for delayed parsing of K&R funcitons
inside objc class implementation. // rdar://10387088

llvm-svn: 161705
2012-08-10 22:01:36 +00:00
Chad Rosier baf53f9ff8 [ms-inline asm] Avoid extra allocations by making this an array of StringRefs.
llvm-svn: 161703
2012-08-10 21:36:25 +00:00
Manman Ren 804137fd75 Add comments for turning on byval
llvm-svn: 161702
2012-08-10 21:32:09 +00:00
Chad Rosier f32302a7d9 [ms-inline asm] PatchMSAsmString() doesn't correctly patch non-simple asm
statements.  Therefore, we can't pass the PatchedAsmString to the AsmParser
and expect things to work.

llvm-svn: 161701
2012-08-10 21:27:11 +00:00
Eli Friedman dc009da2a8 Don't emit an invoke whose normal destination is a landingpad. Fixes test
regression on test/CodeGenObjC/2008-10-3-EhValue.m on non-Darwin targets.

llvm-svn: 161700
2012-08-10 21:26:17 +00:00
Fariborz Jahanian f64b4722eb objective-C++: dalyed parsing of ctors with member
initializer list defined inside an objc class
implementation. wip

llvm-svn: 161699
2012-08-10 21:15:06 +00:00
Chad Rosier d6ef704fe4 [ms-inline asm] Fix a memory leak introduced in r161686.
llvm-svn: 161698
2012-08-10 21:06:19 +00:00
Ted Kremenek 5d858cb916 Fix horrible regression in control of warnings caused by introduction of -Wpedantic.
While -Wpedantic was reasonable, -Wno-pedantic would turn off a bunch of warnings that
are on by default.  This counters the intention of this warning flag.

To fix this, -Wpedantic now includes extentions that are not on by default.  The
remaining warnings will manifest anyway, and won't accidentally get turned off
by -Wno-pedantic.

Fixes <rdar://problem/12076105>

llvm-svn: 161695
2012-08-10 20:50:00 +00:00
Manman Ren d4badd7420 ARM: enable struct byval for AAPCS.
rdar://9877866
PR://13350

llvm-svn: 161694
2012-08-10 20:42:31 +00:00
Fariborz Jahanian 053227f808 objective-C++: delay parsing of ctor with try block
with member initializer list defined inside
an objc implementation block. wip.

llvm-svn: 161692
2012-08-10 20:34:17 +00:00
DeLesley Hutchins 0c90c2bc4b Thread-safety-analysis: adds existential quantification over lock
expressions.  The syntax &MyClass::mutex is interpreted as a
pattern that matches m->mutex for any object m of type MyClass.

llvm-svn: 161691
2012-08-10 20:29:46 +00:00
DeLesley Hutchins 9b1d72f3e3 Thread safety analysis: refactor to support more sophisticated handling
of expressions, and better error messages.

llvm-svn: 161690
2012-08-10 20:19:55 +00:00
Chad Rosier a7020aee00 [ms-inline asm] Add clobbers to AST representation.
llvm-svn: 161686
2012-08-10 19:13:14 +00:00
Dylan Noblesmith 8d48c8c675 Frontend: define _LP64 in a target-independent way
Instead of adding it to each individual subclass in
Targets.cpp, simply check the appropriate target
values.

Where before it was only on x86_64 and ppc64, it's now
also defined on mips64 and nvptx64.

Also add a bunch of negative tests to ensure it is *not*
defined on any other architectures while we're here.

llvm-svn: 161685
2012-08-10 19:12:37 +00:00
Anna Zaks d4e65373f3 [analyzer] ObjC Inlining: add tests for ivars and properties.
TODO:
 - Handle @syncronized properties.
 - Always inline properties declared publicly (do not split the path).
This is tricky since there is no mapping from a Decl to the property in
the AST as far as I can tell.

llvm-svn: 161683
2012-08-10 18:56:01 +00:00
Anna Zaks 75f49a9c07 [analyzer] Track if a region can be a subclass in the dynamic type info.
When object is allocated with alloc or init, we assume it cannot be a
subclass (currently used only for bifurcation purposes).

llvm-svn: 161682
2012-08-10 18:55:58 +00:00
Anna Zaks 920af014c1 [analyzer] Optimize dynamic dispatch bifurcation by detecting the cases
when we don't need to split.

In some cases we know that a method cannot have a different
implementation in a subclass:
 - the class is declared in the main file (private)
 - all the method declarations (including the ones coming from super
classes) are in the main file.

This can be improved further, but might be enough for the heuristic.
(When we are too aggressive splitting the state, efficiency suffers.
When we fail to split the state coverage might suffer.)

llvm-svn: 161681
2012-08-10 18:55:53 +00:00
DeLesley Hutchins c9776faa4f Refactor thread safety analysis to use a different data structure
to track locksets.  This is in preparation for further changes.

llvm-svn: 161680
2012-08-10 18:39:05 +00:00
Chad Rosier 3674ebaa6b [ms-inline asm] Use asserts as these calls are now guarded by identical checks.
llvm-svn: 161676
2012-08-10 18:20:12 +00:00
Fariborz Jahanian 8cecfe9fc9 objective-C++: delayed parsing of member function with
function-try-block occuring in objc's implementation
block. wip.

llvm-svn: 161675
2012-08-10 18:10:56 +00:00
Chad Rosier 02a8439730 Whitespace.
llvm-svn: 161673
2012-08-10 17:56:09 +00:00
Fariborz Jahanian 712bb81a6d objective-C++: Delayed parsing of most common
member functions defined inside an objc class
implementation. wip.

llvm-svn: 161667
2012-08-10 15:54:40 +00:00
Joerg Sonnenberger 42cf26883e Add missing cctype includes.
llvm-svn: 161660
2012-08-10 10:58:18 +00:00
Joerg Sonnenberger 8c02a241f4 Decrementing std::string::end is not portable, use array access instead.
llvm-svn: 161659
2012-08-10 10:57:52 +00:00
Benjamin Kramer 3a913ed805 Fix a couple of pedantic gcc warnings.
llvm-svn: 161656
2012-08-10 10:06:13 +00:00