Commit Graph

26814 Commits

Author SHA1 Message Date
Chad Rosier 93380f63c9 [ms-inline asm] Use the new GetMCInstOperandNum() interface in the front-end.
llvm-svn: 163126
2012-09-03 20:40:52 +00:00
Timur Iskhodzhanov 27b6edf839 Fix PR13444 - wrong mangling of "const char * const *" and friends with "-cxx-abi microsoft"
llvm-svn: 163110
2012-09-03 09:08:10 +00:00
Evgeniy Stepanov 763671edeb Android standalone toolchain support.
This change adds detection of C++ headers and libraries paths when
building with the standalone toolchain from Android NDK. They are in a
slightly unusual place.

llvm-svn: 163109
2012-09-03 09:05:50 +00:00
Chad Rosier fd648a0320 Removed unused argument.
llvm-svn: 163105
2012-09-03 03:16:15 +00:00
Chad Rosier 30c0cb2f30 [ms-inline asm] Update for the MatchInstruction API change in r163101.
llvm-svn: 163102
2012-09-03 02:30:13 +00:00
Logan Chien c6fd820937 Rename ANDROIDEABI to Android.
Most of the code guarded with ANDROIDEABI are not
ARM-specific, and having no relation with arm-eabi.
Thus, it will be more natural to call this
environment "Android" instead of "ANDROIDEABI".

Note: We are not using ANDROID because several projects
are using "-DANDROID" as the conditional compilation
flag.

llvm-svn: 163088
2012-09-02 09:30:11 +00:00
Joao Matos c32a7e4d8e Implemented parsing and AST support for the MS __leave exception statement. Also a minor fix to __except printing in StmtPrinter.cpp. Thanks to Aaron Ballman for review.
llvm-svn: 163083
2012-09-02 03:45:41 +00:00
Joao Matos 26b2095401 Added a diagnostic for mismatched MS inheritance attributes. Also fixed the incomplete type member pointer size calculation under the MS ABI.
llvm-svn: 163078
2012-09-02 00:13:48 +00:00
Joao Matos 2898134f15 Fixed typo causing tests to fail on non-MSVC machines.
llvm-svn: 163077
2012-09-01 23:24:10 +00:00
Joao Matos 344e9f61de Refactored the Windows headers location lookup code. Expose it so standalone tools can have access to it.
llvm-svn: 163076
2012-09-01 22:33:43 +00:00
Jordan Rose d229e39a9a [analyzer] Silence unused variable warnings in NDEBUG builds.
No functionality change.

llvm-svn: 163073
2012-09-01 19:15:13 +00:00
Jordan Rose 21580c2f92 [analyzer] Disallow creation of int vals with explicit bit width / signedness.
All clients of BasicValueFactory should be using QualTypes instead, and
indeed it seems they are. This caught the (fortunately harmless) bug
fixed in the previous commit.

No intended functionality change.

llvm-svn: 163069
2012-09-01 17:39:24 +00:00
Jordan Rose a44ad1b35c [analyzer] Don't attempt to create a floating-point value of "1" for ++/--.
The current logic would actually create a float- or double-sized signed
integer value of 1, which is not at all the same.

No test because the value would be swallowed by an Unknown as soon as it
gets added or subtracted to the original value, but it enables the cleanup
in the next patch.

llvm-svn: 163068
2012-09-01 17:39:17 +00:00
Jordan Rose ccf192e469 [analyzer] Future-proofing r163012 (nameless functions and RetainCountChecker)
Any future exceptions need to go INSIDE the test that checks if the
IdentifierInfo is non-null!

No functionality change. Thanks for the review, Ted.

llvm-svn: 163067
2012-09-01 17:39:13 +00:00
Jordan Rose 82ae9898ef [analyzer] Treat all struct values as regions (even rvalues).
This allows us to correctly symbolicate the fields of structs returned by
value, as well as get the proper 'this' value for when methods are called
on structs returned by value.

This does require a moderately ugly hack in the StoreManager: if we assign
a "struct value" to a struct region, that now appears as a Loc value being
bound to a region of struct type. We handle this by simply "dereferencing"
the struct value region, which should create a LazyCompoundVal.

This should fix recent crashes analyzing LLVM and on our internal buildbot.

<rdar://problem/12137950>

llvm-svn: 163066
2012-09-01 17:39:09 +00:00
Jordan Rose 2da564380a [analyzer] Always derive a CallEvent's return type from its origin expr.
Previously, we preferred to get a result type by looking at the callee's
declared result type. This allowed us to handlereferences, which are
represented in the AST as lvalues of their pointee type. (That is, a call
to a function returning 'int &' has type 'int' and value kind 'lvalue'.)

However, this results in us preferring the original type of a function
over a casted type. This is a problem when a function  pointer is casted
to another type, because the conjured result value will have the wrong
type. AdjustedReturnValueChecker is supposed to handle this, but still
doesn't handle the case where there is no "original function" at all,
i.e. where the callee is unknown.

Now, we instead look at the call expression's value kind (lvalue, xvalue,
or prvalue), and adjust the expr's type accordingly. This will have no
effect when the function is inlined, and will conjure the value that will
actually be used when it is not.

This makes AdjustedReturnValueChecker /nearly/ unnecessary; unfortunately,
the cases where it would still be useful are where we need to cast the
result of an inlined function or a checker-evaluated function, and in these
cases we don't know what we're casting /from/ by the time we can do post-
call checks. In light of that, remove AdjustedReturnValueChecker, which
was already not checking quite a few calls.

llvm-svn: 163065
2012-09-01 17:39:00 +00:00
Ted Kremenek cdf814900d Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.
This is similar to how we divide up the StaticAnalyzer libraries to separate
core functionality to what is clearly associated with Frontend actions.

llvm-svn: 163050
2012-09-01 05:09:24 +00:00
Joao Matos a5c42e9f2a Changed the remaining dead asserts to llvm_unreachable.
llvm-svn: 163039
2012-09-01 00:13:24 +00:00
Chris Lattner 6dc7e57d6a don't warn about unused values when the unused value is a statement expression expanded from a macro. This is of dubious utility in general, but is specifically a major issue for the linux kernel. This resolves PR13747.
llvm-svn: 163034
2012-08-31 22:39:21 +00:00
Joao Matos e9a3ed4d71 Normalize line endings of r163013 (part 2).
llvm-svn: 163032
2012-08-31 22:18:20 +00:00
Benjamin Kramer 648e68b809 Remove windows line endings.
While there fix a dead assert.

llvm-svn: 163031
2012-08-31 22:14:25 +00:00
DeLesley Hutchins f5cf7903d9 Thread-safety analysis: fix handling of LOCK_RETURNED attribute so that the
latest definition of a function is always used when computing lock expressions.

llvm-svn: 163028
2012-08-31 22:09:53 +00:00
DeLesley Hutchins 3c3d57bc16 Thread-safety analysis: fix handling of string constants in mutex
expressions, which should be ignored right now.

llvm-svn: 163026
2012-08-31 21:57:32 +00:00
Joao Matos c0d4c1bcde Normalize line endings of r163022.
llvm-svn: 163023
2012-08-31 21:34:27 +00:00
Joao Matos e85e3b64f8 Emulate MSVC's preprocessor macro argument separator behavior by not considering commas from nested macro expansions as argument separators. Fixes parsing of VS 2012 headers.
llvm-svn: 163022
2012-08-31 21:10:54 +00:00
Fariborz Jahanian 0e337543dc objective-C ARC; detect and warn on retain cycle when
property-dot syntax is used on an object whose
capture causes retain cycle. // rdar://11702054

llvm-svn: 163017
2012-08-31 20:04:47 +00:00
Joao Matos dc86f94f62 Improved MSVC __interface support by adding first class support for it, instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins.
llvm-svn: 163013
2012-08-31 18:45:21 +00:00
Jordan Rose d65f1c8d6e [analyzer] RetainCountChecker: don't assume all functions have names.
Fixes a hard-to-reach crash when calling a non-member overloaded operator
with arguments that may be callbacks.

Future-proofing: don't make the same assumption in MallocSizeofChecker.
Aside from possibly respecting attributes in the future, it might be
possible to call 'malloc' through a function pointer.

I audited all other uses of FunctionDecl::getIdentifier() in the analyzer;
they all now correctly test to see if the identifier is present before
using it.

llvm-svn: 163012
2012-08-31 18:19:18 +00:00
Joao Matos 0e167f7368 Fixed invalid iterators. Since the iterator is invalidated after the erase() call, we need to replace it with the new one returned. This was triggering an assert under MSVC 2012 and making all the ARCMT/ tests fail.
llvm-svn: 163007
2012-08-31 17:28:09 +00:00
Jordan Rose 219c9d0dd3 [analyzer] Though C++ inlining is enabled, don't inline ctors and dtors.
More generally, this adds a new configuration option 'c++-inlining', which
controls which C++ member functions can be considered for inlining. This
uses the new -analyzer-config table, so the cc1 arguments will look like this:

... -analyzer-config c++-inlining=[none|methods|constructors|destructors]

Note that each mode implies that all the previous member function kinds
will be inlined as well; it doesn't make sense to inline destructors
without inlining constructors, for example.

The default mode is 'methods'.

llvm-svn: 163004
2012-08-31 17:06:49 +00:00
Fariborz Jahanian 6ce25c09ed objective-C: underline name of the missing method
in the diagnbostic. // rdar://11303469

llvm-svn: 163003
2012-08-31 17:03:18 +00:00
Dmitri Gribenko 6bab9113b0 Remove the useless CommentOptions class.
llvm-svn: 162986
2012-08-31 10:35:30 +00:00
Ted Kremenek 40ea0eaaa1 Make AnalyzerOptions a shared object between CompilerInvocation and
AnalysisManager, allowing the StringMap of configuration values to
be propagated.

llvm-svn: 162978
2012-08-31 04:36:05 +00:00
Ted Kremenek a5770cd1fa Move AnalyzerOptions.h into 'Core' StaticAnalyzer sub-library.
llvm-svn: 162977
2012-08-31 04:35:58 +00:00
Eli Friedman 324adad966 Make a bunch of methods on Lexer private.
llvm-svn: 162970
2012-08-31 02:29:37 +00:00
Dmitri Gribenko 3ca956f715 Comment HTML tag name machers: move from StringSwitch to an efficient
TableGen-generated string matcher.

llvm-svn: 162969
2012-08-31 02:21:44 +00:00
Jordan Rose cc0b1bfa56 [analyzer] Ensure that PathDiagnostics profile the same regardless of path.
PathDiagnostics are actually profiled and uniqued independently of the
path on which the bug occurred. This is used to merge diagnostics that
refer to the same issue along different paths, as well as by the plist
diagnostics to reference files created by the HTML diagnostics.

However, there are two problems with the current implementation:

1) The bug description is included in the profile, but some
   PathDiagnosticConsumers prefer abbreviated descriptions and some
   prefer verbose descriptions. Fixed by including both descriptions in
   the PathDiagnostic objects and always using the verbose one in the profile.

2) The "minimal" path generation scheme provides extra information about
   which events came from macros that the "extensive" scheme does not.
   This resulted not only in different locations for the plist and HTML
   diagnostics, but also in diagnostics being uniqued in the plist output
   but not in the HTML output. Fixed by storing the "end path" location
   explicitly in the PathDiagnostic object, rather than trying to find the
   last piece of the path when the diagnostic is requested.

This should hopefully finish unsticking our internal buildbot.

llvm-svn: 162965
2012-08-31 00:36:26 +00:00
Jordan Rose 7444f5d826 [analyzer] Fix a crash in plist-html generation introduced in r162939.
Basically, do the correct thing to fix the XML generation error, rather
than making it even worse by unilaterally dereferencing a null pointer.

llvm-svn: 162964
2012-08-31 00:36:20 +00:00
Eli Friedman 34866c7719 Change the representation of builtin functions in the AST
(__builtin_* etc.) so that it isn't possible to take their address.
Specifically, introduce a new type to represent a reference to a builtin
function, and a new cast kind to convert it to a function pointer in the
operand of a call.  Fixes PR13195.

llvm-svn: 162962
2012-08-31 00:14:07 +00:00
Fariborz Jahanian cd278ffa28 objective-C ARC: under -Wexplicit-ownership-type diagnose those
method parameter types which are reference to an objective-C
pointer to object with no explicit ownership. // rdar://10907090

llvm-svn: 162959
2012-08-30 23:56:02 +00:00
Anna Zaks a8017eca1a [analyzer] Refactor the logic that determines if a functions should be
reanalyzed.

The policy on what to reanalyze should be in AnalysisConsumer with the
rest of visitation order logic.

There is no reason why ExprEngine needs to pass the Visited set to
CoreEngine, it can populate it itself.

llvm-svn: 162957
2012-08-30 23:42:02 +00:00
Anna Zaks 830c48ed54 [analyzer] Remove cast inside dyn_cast.
llvm-svn: 162951
2012-08-30 22:55:32 +00:00
Anna Zaks e9b0231152 [analyzer] Make analyzer-ipa=dynamic-bifurcate the default.
There are two tests regressions that come from the fact that the Retain
Count checker does not cancel out inlining of ObjC methods.

llvm-svn: 162950
2012-08-30 22:42:59 +00:00
Anna Zaks b504f44d60 [analyzer] Fixup for r162935 as per Jordan's review.
Thanks for catching this!

llvm-svn: 162949
2012-08-30 22:42:41 +00:00
Eli Friedman 5c27c4cef0 Switch a couple getAs uses to castAs.
llvm-svn: 162948
2012-08-30 22:22:09 +00:00
Douglas Gregor a3d3fe9be6 The presence of a user-*declared* constructor makes the default
constructor not user provided (and, therefore, non-trivial). Fixes
<rdar://problem/11736429>.

llvm-svn: 162947
2012-08-30 21:47:37 +00:00
Jordan Rose 03fac27bab [analyzer] Plist diagnostics: Fix a case where we fail to close an XML tag.
If the current path diagnostic does /not/ have files associated with it, we
were simply skipping on to the next diagnostic with 'continue'. But that
also skipped the close tag for the diagnostic's <dict> node.

Part of fixing our internal analyzer buildbot.

llvm-svn: 162939
2012-08-30 20:43:09 +00:00
Richard Trieu 73e306e548 Add -Wduplicate-enum warning. Clang will emit this warning when an implicitly
initiated enum constant has the same value as another enum constant.

For instance:
enum test { A, B, C = -1, D, E = 1 };
Clang will warn that:
 A and D both have value 0
 B and E both have value 1

A few exceptions are made to keep the noise down.  Enum constants which are
initialized to another enum constant, or an enum constant plus or minus 1 will
not trigger this warning.  Also, anonymous enums are not checked.

llvm-svn: 162938
2012-08-30 20:32:24 +00:00
Douglas Gregor 8bea83a866 Extend the "__is_pod" hack, which demotes various type trait keywords
(__is_pod, __is_signed, etc.) to normal identifiers if they are
encountered in certain places in the grammar where we know that prior
versions of libstdc++ or libc++ use them, to still allow the use of
these keywords as type traits. Fixes <rdar://problem/9836262> and PR10184.

llvm-svn: 162937
2012-08-30 20:04:43 +00:00
Manuel Klimek fdf98763ac Fixes a bug for binding memoized match results.
Intorduces an abstraction for DynTypedNode which makes
is impossible to create in ways that introduced the bug;
also hides the implementation details of the template
magic away from the user and prepares the code for adding
QualType and TypeLoc bindings, as well as using DynTypedNode
instead of overloads for child and ancestor matching.

getNodeAs<T> was changed towards a non-pointer type, as
we'll want QualType and TypeLoc nodes to be returned
by value (the alternative would be to create new storage
which is prohibitively costly if we want to use it for
child / ancestor matching).

DynTypedNode is moved into a new header ASTTypeTraits.h,
as it is completely independent of the rest of the matcher
infrastructure - if the need comes up, we can move it to
a more common place.

The interface for users before the introduction of the
common storage change remains the same, minus the introduced
bug, for which a regression test was added.

llvm-svn: 162936
2012-08-30 19:41:06 +00:00