Commit Graph

40584 Commits

Author SHA1 Message Date
Chad Rosier c30eb1c282 [driver] Add support for the -fno-fast-math option.
rdar://12299433

llvm-svn: 164638
2012-09-25 22:03:25 +00:00
Argyrios Kyrtzidis 341de09dcd [libclang] Do a AST concurrency check in clang_indexTranslationUnit_Impl.
llvm-svn: 164626
2012-09-25 19:29:50 +00:00
Argyrios Kyrtzidis 2f45853f2f Improve upon r164450 and localize the logic of updating the type of
a function decl inside the ASTNodeImporter::VisitFunctionDecl function.

llvm-svn: 164625
2012-09-25 19:26:39 +00:00
Dmitri Gribenko 511288b2b5 Optimize NumericLiteralParser::GetIntegerValue().
It does a conservative estimate on the size of numbers that can fit into
uint64_t.  This bound is improved.

llvm-svn: 164624
2012-09-25 19:09:15 +00:00
Jordan Rose 902f02db72 [analyzer] Add tests for symbolic expression liveness.
There are very few tests here because SValBuilder is fairly aggressive
about not building SymExprs that we can't evaluate, which saves memory
and CPU but also makes it very much tied to the current constraint
manager. We should probably scale back here and let things decay to
UnknownVal later on.

bitwise-ops.c tests that for the SymExprs we do create, we persist our
assumptions about them. traversal-path-unification.c tests that we do
clean out constraints on arbitrary SymExprs once they have actually died.

llvm-svn: 164623
2012-09-25 19:03:09 +00:00
Jordan Rose db72e2fc37 Reapply "[analyzer] Remove constraints on dead symbols as part of removeDeadBindings."
Previously, we'd just keep constraints around forever, which means we'd
never be able to merge paths that differed only in constraints on dead
symbols.

Because we now allow constraints on symbolic expressions, not just single
symbols, this requires changing SymExpr::symbol_iterator to include
intermediate symbol nodes in its traversal, not just the SymbolData leaf
nodes.

This depends on the previous commit to be correct. Originally applied in
r163444, reverted in r164275, now being re-applied.

llvm-svn: 164622
2012-09-25 19:03:06 +00:00
Jordan Rose 60d704ab4a [analyzer] Calculate liveness for symbolic exprs as well as atomic symbols.
No tests, but this allows the optimization of removing dead constraints.
We can then add tests that we don't do this prematurely.

<rdar://problem/12333297>

Note: the added FIXME to investigate SymbolRegionValue liveness is
tracked by <rdar://problem/12368183>. This patch does not change the
existing behavior.

llvm-svn: 164621
2012-09-25 19:03:01 +00:00
Douglas Gregor 24ff3bc392 Under certain terrible circumstances (<rdar://problem/10805775>),
top-level frameworks can actually be symlinked over to embedded
frameworks, and accessed via the top-level framework's headers. In
this case, we need to determine that the framework was *actually* an
embedded framework, so we can load the appropriate top-level module.

llvm-svn: 164620
2012-09-25 18:29:14 +00:00
Alexander Kornienko 1d26c02722 Macro history (de-)serialization. Deserialization currently reads only the latest macro definition. Needs more work.
Summary: Passes all tests (+ the new one with code completion), but needs a thorough review in part related to modules.

Reviewers: doug.gregor

Reviewed By: alexfh

CC: cfe-commits, rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D41

llvm-svn: 164610
2012-09-25 17:18:14 +00:00
Bob Wilson 24719e3236 Examine the last, not the first, instruction from the MC matcher.
If an MS-style inline asm is matched to multiple instructions, e.g., with a
a WAIT-prefix, then we need to examine the operands of the last instruction
instruction, not the prefix instruction.

llvm-svn: 164608
2012-09-25 16:30:16 +00:00
Douglas Gregor e6a82d9018 -iframework should allow separate arguments.
llvm-svn: 164607
2012-09-25 16:13:41 +00:00
Douglas Gregor c83de30add Introduce builtin macros to determine whether we're building a
specific module (__building_module(modulename)) and to get the name of
the current module as an identifier (__MODULE__). 

Used to help headers behave differently when they're being included as
part of building a module. Oh, the irony.

llvm-svn: 164605
2012-09-25 15:44:52 +00:00
Alexander Kornienko dcaf4a3a4b A minor doc fix.
llvm-svn: 164601
2012-09-25 12:42:05 +00:00
Hans Wennborg c980408c71 Fix failing test/Sema/wchar.c on ARM.
Currently Sema/wchar.c fails because WCHAR_T_TYPE is defined as int,
however on ARM wchar_t is unsigned int.

This patch changes that, so this test passes for ARM.

Patch by Joey Gouly!

llvm-svn: 164598
2012-09-25 10:11:17 +00:00
John McCall 82fb892019 When performing a ::delete of an object with a virtual destructor,
be sure to delete the complete object pointer, not the original
pointer.  This is necessary if the base being deleted is at a
non-zero offset in the complete object.  This is only required
for objects with virtual destructors because deleting an object
via a base-class subobject when the base does not have a virtual
destructor is undefined behavior.

Noticed while reviewing the last four years of cxx-abi-dev
activity.

llvm-svn: 164597
2012-09-25 10:10:39 +00:00
NAKAMURA Takumi 924ce0d9aa clang/test/CodeGenCXX/microsoft-*: Fix for -Asserts.
llvm-svn: 164594
2012-09-25 09:53:18 +00:00
John McCall f652e9a6b0 Implement Mike Herrick's proposed noexcept mangling.
llvm-svn: 164593
2012-09-25 09:10:17 +00:00
John McCall 0f999f329c In the MS ABI, ctors return 'this'. Patch by Dmitry Sokolov.
llvm-svn: 164592
2012-09-25 08:00:39 +00:00
John McCall bf4a7d7193 Add the Microsoft __is_interface_class type trait.
Patch by Andy Gibbs!

llvm-svn: 164591
2012-09-25 07:32:49 +00:00
John McCall db632ac004 Fix for r163013 regression and further __interface enhancement.
Patch by Andy Gibbs!

llvm-svn: 164590
2012-09-25 07:32:39 +00:00
John McCall b0433eeb2e During jump-scope checking, build an ExprWithCleanups immediately
into the enclosing scope;  this is a more accurate model but is
(I believe) unnecessary in my test case due to other flaws.
However, one of those flaws is now intentional:  blocks which
appear in return statements can be trivially observed to not
extend in lifetime past the return, and so we can allow a jump
past them.  Do the necessary magic in IR-generation to make
this work.

llvm-svn: 164589
2012-09-25 06:56:03 +00:00
Richard Smith 88d67f3412 Fix crash when a decltype expression in a trailing return type refers to the
function being instantiated. An error recovery codepath was recursively
performing name lookup (and triggering an unbounded stack of template
instantiations which blew out the stack before hitting the depth limit).

Patch by Wei Pan!

llvm-svn: 164586
2012-09-25 04:46:05 +00:00
Eli Friedman cda3db801f Delete some code which is, as far as I can tell, dead.
llvm-svn: 164580
2012-09-25 01:02:42 +00:00
Anna Zaks 4396c54c14 [analyzer] Fix a buildbot crash triggered by turning on dynamic
dispatch.

llvm-svn: 164579
2012-09-25 00:31:43 +00:00
Richard Smith 60f2e1efb8 Don't produce diagnostics for missing ctor-initializers during template
instantiations if we encountered errors parsing some of the initializers.

llvm-svn: 164578
2012-09-25 00:23:05 +00:00
Eli Friedman bdd5753bda Handle C++ functional casts in a similar way to C-style casts in
unused expression warnings.  <rdar://problem/12359208>.

llvm-svn: 164569
2012-09-24 23:02:26 +00:00
Chad Rosier 93b3eb7793 Update for r164567.
llvm-svn: 164568
2012-09-24 22:58:50 +00:00
Fariborz Jahanian 61740f6649 objective-C: use 'instance variables' as plural when referring
to the feature.

llvm-svn: 164566
2012-09-24 22:51:51 +00:00
Fariborz Jahanian 14fd801f8f objective-C: remove use of 'ivar' in favor of
'instance variable' in text of all diagnostics
for objective-C: // rdar://12352442

llvm-svn: 164559
2012-09-24 22:00:36 +00:00
Ted Kremenek 3d0ec38cb4 Add clarifying comment.
llvm-svn: 164557
2012-09-24 21:17:14 +00:00
Dmitri Gribenko 2e0e3f37be More tests for r164545 (change extension warning about 'long long').
llvm-svn: 164556
2012-09-24 21:09:05 +00:00
Dmitri Gribenko b8e9e7507e StringRef'ize Preprocessor::CreateString().
llvm-svn: 164555
2012-09-24 21:07:17 +00:00
Dmitri Gribenko ae07f72017 Replace raw call to snprintf() by llvm streams.
llvm-svn: 164554
2012-09-24 20:56:28 +00:00
Bob Wilson 317be45091 Replace an assertion with an error for empty __asm statements.
llvm-svn: 164551
2012-09-24 19:57:59 +00:00
Bob Wilson 0fc64f0b11 Fix a comment typo and clean up formatting.
llvm-svn: 164550
2012-09-24 19:57:55 +00:00
Douglas Gregor e769d862ee Make sure that we don't end up making an #undef'd macro visible after
the fact. Test cases will come when we're actually (de-)serializing
macro history.

llvm-svn: 164549
2012-09-24 19:56:18 +00:00
Argyrios Kyrtzidis 5eae073cb1 [libclang] Bring CXCursor_AsmStmt back as an alias for CXCursor_GCCAsmStmt.
This was renamed in r162632 which was badness because the C API needs to be stable.
rdar://12360096

llvm-svn: 164547
2012-09-24 19:27:20 +00:00
Dmitri Gribenko 61b4b7f0f3 Include 'long long' extension warning in the LongLong group so that it can be
silenced by -Wno-long-long.  Thanks Richard Smith for the fix idea!

llvm-svn: 164546
2012-09-24 19:05:10 +00:00
Dmitri Gribenko 1cd2305703 Change the wording of the extension warning from
> 'long long' is an extension when C99 mode is not enabled
to
> 'long long' is a C++11 extension
while compiling in C++98 mode.

llvm-svn: 164545
2012-09-24 18:19:21 +00:00
Anna Zaks b9828203df [analyzer] Really turn on dynamic-bifurcation on by default.
Thanks to Byoungyoung for realizing taht we are not passing the default
option correctly.

llvm-svn: 164543
2012-09-24 17:43:47 +00:00
Anna Zaks e20b201dda [analyzer] Remove unused.
llvm-svn: 164542
2012-09-24 17:43:44 +00:00
Anna Zaks 3533a54a97 [analyzer]Prevent infinite recursion(assume->checker:evalAssume->assume)
(Unfortunately, I do not have a good reduced test case for this.)

llvm-svn: 164541
2012-09-24 17:43:41 +00:00
Alexander Potapenko 34b46ca48e Use an explicit target to test that source fortification is off when building for Darwin with -faddress-sanitizer.
llvm-svn: 164485
2012-09-24 10:25:24 +00:00
Dmitri Gribenko 7ba91723e7 Small cleanup of literal semantic analysis: hiding 'char *' pointers behind
StringRef makes code cleaner.  Also, make the temporary buffer smaller:
512 characters is unreasonably large for integer literals.

llvm-svn: 164484
2012-09-24 09:53:54 +00:00
Chandler Carruth ed2a284977 Update the Clang tests which run with a full optimization pipeline for
the new SROA pass. This is a benign change: the order of PHI nodes
changed.

llvm-svn: 164481
2012-09-24 01:10:25 +00:00
NAKAMURA Takumi f5a898c305 unittests/AST/StmtPrinterTest.cpp: Suppress a LP64-assumed test, "0x100000000i128 => 4294967296L", for now.
LONG_MAX is 2147483647L on common 32 bit and LLP64 (Windows x64).

llvm-svn: 164478
2012-09-24 00:34:18 +00:00
Dmitri Gribenko 24bef9a4e9 As a followup for r164303, add some tests for printing literals that test
printing directly rather than through a complicated machinery of ObjC rewriter.

llvm-svn: 164477
2012-09-23 20:29:07 +00:00
Rafael Espindola 151a957fb0 Implement ToolChain::IsUnwindTablesDefault to reduce code duplication a bit.
llvm-svn: 164473
2012-09-23 03:05:41 +00:00
Rafael Espindola 66431cd10f On Hexagon getArchName() never returns x86_64, simplify the function.
llvm-svn: 164470
2012-09-22 22:58:57 +00:00
Rafael Espindola ccaa3b6eb2 Use pipes.
llvm-svn: 164469
2012-09-22 22:51:00 +00:00
Rafael Espindola c326427905 Use FileCheck.
llvm-svn: 164468
2012-09-22 22:30:04 +00:00
Dmitri Gribenko 1da8886915 Comment sema: warn when comment has \deprecated but declaration does not have a
deprecation attribute ('deprecated', 'availability' or 'unavailable').

This warning is under a separate flag, -Wdocumentation-deprecated-sync, so it
can be turned off easily while leaving other -Wdocumentation warnings on.

llvm-svn: 164467
2012-09-22 21:47:50 +00:00
Dmitri Gribenko d0885d2941 Remove superfluous \namespace command.
llvm-svn: 164466
2012-09-22 21:44:37 +00:00
Dmitri Gribenko b947e8239f Fix cindex.py compatibility with older libclang.so
The issue is that we were calling clang_getCompletionBriefComment
unconditionally.  New we check if this function is available before calling it.

llvm-svn: 164464
2012-09-22 17:52:29 +00:00
Rafael Espindola a7b9698b3d Use FileCheck.
llvm-svn: 164462
2012-09-22 15:26:38 +00:00
Rafael Espindola 08f1ebb2b7 Fix pr13749. There is still a lot of code using getArchName that should be
using getArch, but I will try to fix them one at time to add tests.

llvm-svn: 164460
2012-09-22 15:04:11 +00:00
Abramo Bagnara 6cba23a649 Avoid multiple atomic builtin declaration.
llvm-svn: 164454
2012-09-22 09:05:22 +00:00
Argyrios Kyrtzidis b41791d848 When importing a FunctionProtoType::ExtProtoInfo, its ExceptionSpecDecl can point to the
FunctionDecl that we are importing the FunctionProtoType for, in which case we'll have
infinite recursion when importing.

Initially create a FunctionProtoType with null ExceptionSpecDecl/ExceptionSpecTemplate and
update the type in ASTNodeImporter::VisitFunctionDecl after the FunctionDecl has been created.

llvm-svn: 164450
2012-09-22 01:58:06 +00:00
Jordan Rose 52de8eec01 [analyzer] Suppress bugs whose paths go through the return of a null pointer.
This is a heuristic intended to greatly reduce the number of false
positives resulting from inlining, particularly inlining of generic,
defensive C++ methods that live in header files. The suppression is
triggered in the cases where we ask to track where a null pointer came
from, and it turns out that the source of the null pointer was an inlined
function call.

This change brings the number of bug reports in LLVM from ~1500 down to
around ~300, a much more manageable number. Yes, some true positives may
be hidden as well, but from what I looked at the vast majority of silenced
reports are false positives, and many of the true issues found by the
analyzer are still reported.

I'm hoping to improve this heuristic further by adding some exceptions
next week (cases in which a bug should still be reported).

llvm-svn: 164449
2012-09-22 01:25:06 +00:00
Jordan Rose 4ac7cba404 [analyzer] Track a null value back through FindLastStoreBRVisitor.
Also, tidy up the other tracking visitors so that they mark the right
things as interesting and don't do extra work.

llvm-svn: 164448
2012-09-22 01:25:00 +00:00
Jordan Rose fa92f0f298 [analyzer] Always allow BugReporterVisitors to see the bug path.
Before, PathDiagnosticConsumers that did not support actual path output
would (sensibly) cause the generation of the full path to be skipped.
However, BugReporterVisitors may want to see the path in order to mark a
BugReport as invalid.

Now, even for a path generation scheme of 'None' we will still create a
trimmed graph and walk backwards through the bug path, doing no work other
than passing the nodes to the BugReporterVisitors. This isn't cheap, but
it's necessary to properly do suppression when the first path consumer does
not support path notes.

In the future, we should try only generating the path and visitor-provided
path notes once, or at least only creating the trimmed graph once.

llvm-svn: 164447
2012-09-22 01:24:56 +00:00
Jordan Rose 5a751b993f [analyzer] Allow a BugReport to be marked "invalid" during path generation.
This is intended to allow visitors to make decisions about whether a
BugReport is likely a false positive. Currently there are no visitors
making use of this feature, so there are no tests.

When a BugReport is marked invalid, the invalidator must provide a key
that identifies the invaliation (intended to be the visitor type and a
context pointer of some kind). This allows us to reverse the decision
later on. Being able to reverse a decision about invalidation gives us more
flexibility, and allows us to formulate conditions like "this report is
invalid UNLESS the original argument is 'foo'". We can use this to
fine-tune our false-positive suppression (coming soon).

llvm-svn: 164446
2012-09-22 01:24:53 +00:00
Jordan Rose 6f3d2f0acd [analyzer] Look through OpaqueValueExprs when tracking a nil value.
This allows us to show /why/ a particular object is nil, even when it is
wrapped in an OpaqueValueExpr.

llvm-svn: 164445
2012-09-22 01:24:49 +00:00
Jordan Rose 106b037a85 [analyzer] Better path notes for null pointers passed as arguments.
Rather than saying "Null pointer value stored to 'foo'", we now say
"Passing null pointer value via Nth parameter 'foo'", which is much better.
The note is also now on the argument expression as well, rather than the
entire call.

This paves the way for continuing to track arguments back to their sources.

<rdar://problem/12211490>

llvm-svn: 164444
2012-09-22 01:24:46 +00:00
Jordan Rose c102b35b44 Use llvm::getOrdinalSuffix to print ordinal numbers in diagnostics.
Just a refactoring of common infrastructure. No intended functionality change.

llvm-svn: 164443
2012-09-22 01:24:42 +00:00
Jordan Rose 1d64a49855 [analyzer] Check that an ObjCIvarRefExpr's base is non-null even as an lvalue.
Like with struct fields, we want to catch cases like this early,
so that we can produce better diagnostics and path notes:

  PointObj *p = nil;
  int *px = &p->_x; // should warn here
  *px = 1;

llvm-svn: 164442
2012-09-22 01:24:38 +00:00
Jordan Rose 04dcb7235f [analyzer] Check that a member expr is valid even when the result is an lvalue.
We want to catch cases like this early, so that we can produce better
diagnostics and path notes:

  Point *p = 0;
  int *px = &p->x; // should warn here
  *px = 1;

llvm-svn: 164441
2012-09-22 01:24:33 +00:00
Richard Smith 6d12af7410 Fix bug which sometimes resulted in further diagnostics being produced after a
fatal error. Previously, if a fatal error was followed by a diagnostic which
was suppressed due to a SFINAETrap, we'd forget that we'd seen a fatal error.

llvm-svn: 164437
2012-09-22 00:53:56 +00:00
Chad Rosier 90cad09ba5 [ms-inline asm] Use mnemonicIsValid() in a helpful assert.
llvm-svn: 164421
2012-09-21 22:22:39 +00:00
Eric Christopher a52a6a8351 Mark the passed in "self" for a block as an object pointer so
that the backend can mark it as the representative pointer for
the block.

rdar://12001329

llvm-svn: 164418
2012-09-21 22:18:42 +00:00
Argyrios Kyrtzidis 89df5ecaf2 Fix build errors.
llvm-svn: 164417
2012-09-21 22:17:13 +00:00
Argyrios Kyrtzidis 9c71b1e0be [AST importer] Do a correct import of a FunctionProtoType::ExtProtoInfo, don't pass
nodes from the imported ASTContext.

rdar://12348924

llvm-svn: 164416
2012-09-21 22:04:02 +00:00
Fariborz Jahanian 974c948049 objective-C: when diagnosing deprecated/unavailable usage of
setter or getter backing a deprecated/unavailable property,
also not location of the property. // rdar://12324295

llvm-svn: 164412
2012-09-21 20:46:37 +00:00
Rafael Espindola 86792438dc Call CGM.SetLLVMFunctionAttributesForDefinition on thunks so that they get
attributes like uwtable. Without uwtable a stack unwinder would be unable
to go past the thunks.

llvm-svn: 164411
2012-09-21 20:39:32 +00:00
Simon Atanasyan 2efe53e448 Add four new command line options for MIPS CPU selection:
-mips32, -mips32r2, -mips64, -mips64r2.

The patch reviewed by Eric Christopher.

llvm-svn: 164410
2012-09-21 20:19:32 +00:00
Douglas Gregor 55023de547 Fix a typo in the PCH internals documentation
llvm-svn: 164409
2012-09-21 20:16:09 +00:00
Ted Kremenek e7ad535e66 Experiment in BodyFarm of structuring AST creation calls in a hierarchy,
so that they visually look like an AST dump.

llvm-svn: 164401
2012-09-21 18:33:56 +00:00
Ted Kremenek f465dc1553 Create helper method in BodyFarm for creating simple assignments.
llvm-svn: 164400
2012-09-21 18:33:54 +00:00
Ted Kremenek dff3553e3c Add helper method in BodyFarm to create unary dereferences.
llvm-svn: 164399
2012-09-21 18:33:52 +00:00
Ted Kremenek ca90ea5ed0 Add helper method to BodyFarm for creating lvalue-to-rvalue conversions.
llvm-svn: 164397
2012-09-21 18:13:27 +00:00
Ted Kremenek 69bcb82c59 Add helper method to BodyFarm for creatinging integral casts.
llvm-svn: 164396
2012-09-21 18:13:23 +00:00
DeLesley Hutchins 10958cae09 Thread-safety analysis: better handling of unreachable blocks. Fixes a bug
where a call to function marked 'noreturn' is followed by unreachable
implicit destructor calls.

llvm-svn: 164394
2012-09-21 17:57:00 +00:00
Ted Kremenek 61e2f2d6ec Re-enable faux-bodies by default.
Try this again, now that r164392 is in place.

llvm-svn: 164393
2012-09-21 17:55:34 +00:00
Ted Kremenek 7241813bd7 Use helper method to create DeclRefExprs in BodyFarm, hopefully allevating
them being correctly constructed.

llvm-svn: 164392
2012-09-21 17:54:35 +00:00
Ted Kremenek 2b5c83ca8f Add some structuring comments. No functionality change.
llvm-svn: 164391
2012-09-21 17:54:32 +00:00
Chad Rosier 26820c0b5a Update comment.
llvm-svn: 164390
2012-09-21 17:50:09 +00:00
Rafael Espindola ad5fec30d1 Use MapVectors to make the order we mark virtual functions used by a vtable
deterministic. Fixes pr13868.

llvm-svn: 164382
2012-09-21 17:15:24 +00:00
Bill Wendling e63adc5476 Update for encapsulating the "construct*AlignmentFromInt" methods.
llvm-svn: 164374
2012-09-21 16:07:49 +00:00
NAKAMURA Takumi 443eef47ef Revert r164364, "Flip "faux-bodies" in the analyzer on by default to flush out bugs."
It crashed test/Analysis/Output/blocks.m on some hosts.

llvm-svn: 164368
2012-09-21 12:00:42 +00:00
Hans Wennborg 61b2ffa60f Make warnings about uninitialized fields include the field name.
This makes the wording more informative, and consistent with the other
warnings about uninitialized variables.

Also, me and David who reviewed this couldn't figure out why we would
need to do a lookup to get the name of the variable; so just print the
name directly.

llvm-svn: 164366
2012-09-21 08:58:33 +00:00
Ted Kremenek e460a4ea2d Flip "faux-bodies" in the analyzer on by default to flush out bugs.
llvm-svn: 164364
2012-09-21 06:14:37 +00:00
Ted Kremenek 089c5510b8 Simplify getRuntimeDefinition() back to taking no arguments.
llvm-svn: 164363
2012-09-21 06:13:13 +00:00
Craig Topper e479428546 Doxygen-ify a comment.
llvm-svn: 164360
2012-09-21 04:33:26 +00:00
David Blaikie 348df509a0 PR13890: Warn on abstract final classes.
llvm-svn: 164359
2012-09-21 03:21:07 +00:00
Argyrios Kyrtzidis 6fa1682368 [PCH] After deserializing a DeclContext, if it has external lexical decls but not
external visible decls, call DeclContext::setMustBuildLookupTable so that the
"lazy decls" bit of the LookupPtr is set.

Previously, in non-C++, if there were no new declarations causing the "lazy decls" bit
to be set, then DeclContext::lookups_begin() would fail to return the decls from the PCH.

Fixes rdar://12316296.

llvm-svn: 164351
2012-09-21 01:30:00 +00:00
Ted Kremenek d81a4a18b4 Add faux-body support for dispatch_once().
llvm-svn: 164348
2012-09-21 00:52:24 +00:00
Jim Grosbach 11b6fe5e9c ARM: Use a dedicated intrinsic for vector bitwise select.
The expression based expansion too often results in IR level optimizations
splitting the intermediate values into separate basic blocks, preventing
the formation of the VBSL instruction as the code author intended. In
particular, LICM would often hoist part of the computation out of a loop.

rdar://11011471

llvm-svn: 164342
2012-09-21 00:18:30 +00:00
Jim Grosbach d3608f433a Tidy up. Trailing whitespace and 80 columns.
llvm-svn: 164341
2012-09-21 00:18:27 +00:00
Ted Kremenek 14f779c4d6 Implement faux-body-synthesis of well-known functions in the static analyzer when
their implementations are unavailable.  Start by simulating dispatch_sync().

This change is largely a bunch of plumbing around something very simple.  We
use AnalysisDeclContext to conjure up a fake function body (using the
current ASTContext) when one does not exist.  This is controlled
under the analyzer-config option "faux-bodies", which is off by default.

The plumbing in this patch is largely to pass the necessary machinery
around.  CallEvent needs the AnalysisDeclContextManager to get
the function definition, as one may get conjured up lazily.

BugReporter and PathDiagnosticLocation needed to be relaxed to handle
invalid locations, as the conjured body has no real source locations.
We do some primitive recovery in diagnostic generation to generate
some reasonable locations (for arrows and events), but it can be
improved.

llvm-svn: 164339
2012-09-21 00:09:11 +00:00
Ted Kremenek 96ea28046c Constify method.
llvm-svn: 164338
2012-09-21 00:09:05 +00:00
Ted Kremenek 108c8de2e3 Ensure that the Decl* wrapped by an AnalysisDeclContext cannot be changed after
construction.

llvm-svn: 164337
2012-09-21 00:09:03 +00:00
Ted Kremenek f9f3d60605 Remove unused fields.
llvm-svn: 164336
2012-09-21 00:09:01 +00:00
Douglas Gregor 12cda633be Serialize the 'IsConstexpr' bit of VarDecls. Fixes <rdar://problem/12328814>.
llvm-svn: 164335
2012-09-20 23:43:29 +00:00
DeLesley Hutchins fcb0ffa622 Thread-safety analysis: fix bug where shared trylock was treated
as exclusive.

llvm-svn: 164332
2012-09-20 23:14:43 +00:00
DeLesley Hutchins b78aeed26e Thread safety analysis: properly canonicalize calls to virtual methods within
lock expressions.

llvm-svn: 164324
2012-09-20 22:18:02 +00:00
Richard Smith a05b3b5435 If the range in a for range statement doesn't have a viable begin/end function,
but can be dereferenced to form an expression which does have viable begin/end
functions, then typo-correct the range, even if something else goes wrong with
the statement (such as inaccessible begin/end or the wrong type of loop
variable).

In order to ensure we recover correctly and produce any followup diagnostics in
this case, redo semantic analysis on the for-range statement outside of the
diagnostic trap, after issuing the typo-correction.

llvm-svn: 164323
2012-09-20 21:52:32 +00:00
David Blaikie 7c70fe60aa Fix typo. (s/Explided/Exploded/)
Patch by Sean McBride.

llvm-svn: 164318
2012-09-20 20:59:21 +00:00
Fariborz Jahanian 2f4e33aba2 Improvements to my patch in r164143 per
Richard's comments. // rdar://12202422

llvm-svn: 164316
2012-09-20 19:36:41 +00:00
David Blaikie 85568adcee Make the wchar_t promotion test consistent across different hosts by specifying a target triple.
This test behavior differs depending (at least) on whether
sizeof(wchar_t) == sizeof(int) or not.

When they are equal, the first redeclaration will fail because decltype(+L'x')
is unsigned int instead of the expected int. This occurs on ARM.

llvm-svn: 164315
2012-09-20 18:57:53 +00:00
David Blaikie 1db86e1f6b Remove a test that is non-portable (cannot be execute on cross builds, for example)
While it might be nice to have a quick end-to-end sanity test, it's just not
really the right place for it & would require more work to enable lit to
provide a detection flag ("XFAIL: cross" or similar) than the value we get from
having this test. Early on it might've made more sense, but these days we've
got some pretty good coverage across the stack with more targeted tests.

llvm-svn: 164314
2012-09-20 18:42:02 +00:00
David Blaikie 6590220181 Include types when a definition's type differs from a prior declaration.
This is some really old code (took me a while to find the test cases) & the
diagnostic text is slightly incorrect (it should really only apply to
re/declarations/, redefinitions are an error regardless of whether the types
match). Not sure if anyone cares about it, though.

For now this just makes the diagnostic more clear in less obvious cases where
the type of a declaration might not be explicitly written (eg: because it
uses decltype)

llvm-svn: 164313
2012-09-20 18:38:57 +00:00
Daniel Jasper 87c3d369f1 Add some matchers for basic AST nodes.
Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D45

llvm-svn: 164304
2012-09-20 14:12:57 +00:00
Benjamin Kramer 8a52676b85 StmtPrinter: Print floating point literals with the right suffix to disambiguate them from integers.
Based on a patch by Olaf Krzikalla, UDL fixes by me.

llvm-svn: 164303
2012-09-20 14:07:17 +00:00
Nico Weber acbea3a2b4 Be more consistent about ending suggestions with a '?'
llvm-svn: 164301
2012-09-20 13:02:00 +00:00
NAKAMURA Takumi 77369457e0 clang/test/Analysis: Fix the declaration of strlen() for 32 bit targets.
- Inputs/system-header-simulator.h: Declare strlen() with size_t.

  - malloc-interprocedural.c: Move the definition of size_t into the header above.

Then XFAIL can be pruned.

llvm-svn: 164300
2012-09-20 11:03:56 +00:00
Alexander Potapenko b4f819086a Disable source fortification on Darwin with AddressSanitizer.
ASan doesn't play well with -D_FORTIFY_SOURCE, which is enabled by default starting at OS X 10.7

llvm-svn: 164299
2012-09-20 10:10:01 +00:00
Daniel Jasper d2247528f5 Provide better error messages for incorrect matchers.
By changing the conversion operator into a conversion constructor, we
can enabled based on the template parameters leading to better error
messages. E.g.: stmt(decl()) will now create an error message including:

  note: candidate function not viable: no known conversion from
  'clang::ast_matchers::internal::BindableMatcher<clang::Decl>' to 'const
  clang::ast_matchers::internal::Matcher<clang::Stmt>' for 1st argument

llvm-svn: 164298
2012-09-20 09:24:58 +00:00
NAKAMURA Takumi 4aa6a010d2 test/Analysis/malloc-interprocedural.c: Mark it as XFAIL: cygwin,mingw,msvc for now. Investigating.
llvm-svn: 164295
2012-09-20 08:44:12 +00:00
Eli Friedman 847f3ca350 The keywords "true" and "false" shouldn't warn under -Wundef.
llvm-svn: 164279
2012-09-20 02:38:38 +00:00
Jordan Rose d6e5fd52f0 [analyzer] MallocChecker should not do post-call checks on inlined functions.
If someone provides their own function called 'strdup', or 'reallocf', or
even 'malloc', and we inlined it, the inlining should have given us all the
malloc-related information we need. If we then try to attach new information
to the return value, we could end up with spurious warnings.

<rdar://problem/12317671>

llvm-svn: 164276
2012-09-20 01:55:32 +00:00
Jordan Rose ae134c6449 Revert "[analyzer] Remove constraints on dead symbols as part of removeDeadBindings."
While we definitely want this optimization in the future, we're not
currently handling constraints on symbolic /expressions/ correctly.
These should stay live even if the SymExpr itself is no longer referenced
because could recreate an identical SymExpr later. Only once the SymExpr
can no longer be recreated -- i.e. a component symbol is dead -- can we
safely remove the constraints on it.

This liveness issue is tracked by <rdar://problem/12333297>.

This reverts r163444 / 24c7f98828e039005cff3bd847e7ab404a6a09f8.

llvm-svn: 164275
2012-09-20 01:54:56 +00:00
Eli Friedman 8f5e983029 Handle lambdas where the lambda-declarator is an explicit "(void)". PR13854.
llvm-svn: 164274
2012-09-20 01:40:23 +00:00
Richard Smith a31a89a38e Per C++11 [class.friend]p3, the 'friend' keyword must appear first in a
non-function friend declaration. Patch by Josh Magee!

llvm-svn: 164273
2012-09-20 01:31:00 +00:00
Richard Smith b6d516e7bd PR13881: Add -Wzero-length-array for zero length array extension, and move it into -Wgnu.
llvm-svn: 164272
2012-09-20 01:02:05 +00:00
Eli Friedman ee2ff1cb96 Fix a small FIXME involving template partial ordering and
member function templates with an rvalue ref qualifier.

llvm-svn: 164267
2012-09-19 23:52:13 +00:00
Eli Friedman 3b5774ab0f Fix function template partial ordering rules for static vs. non-static
functions.

llvm-svn: 164263
2012-09-19 23:27:04 +00:00
Benjamin Kramer 75e4bb1d87 ccc-analyzer: pass -stdlib=libc++ through to the analyzer.
Otherwise clang can't analyze code that relies on features provided by libc++.

llvm-svn: 164262
2012-09-19 22:56:24 +00:00
Eric Christopher 173d91092a Grammar.
llvm-svn: 164260
2012-09-19 22:40:44 +00:00
Eric Christopher bdb1abb72a Update and expand comment.
llvm-svn: 164254
2012-09-19 22:01:42 +00:00
Eric Christopher 7106ec3ecb Handle a captured this for the debug information as well.
llvm-svn: 164253
2012-09-19 21:47:34 +00:00
Eric Christopher 0f143ae8af Fix awkward comment.
llvm-svn: 164252
2012-09-19 21:47:29 +00:00
DeLesley Hutchins 132f8f6959 Thread-safety analysis: Fix warning when EXCLUSIVE_LOCKS_REQUIRED
is placed on a function that has no path to the exit block.

llvm-svn: 164244
2012-09-19 19:49:40 +00:00
DeLesley Hutchins a15e1b4f63 Thread-safety analysis: fix ICE when EXCLUSIVE_LOCKS_REQUIRED or
LOCKS_EXCLUDED is used on a method with a name that is is not a simple
identifier.

llvm-svn: 164242
2012-09-19 19:18:29 +00:00
David Blaikie 2fc4161a84 Fix ABI dependent tests by providing an explicit target triple.
Patch by Joey Gouly.

llvm-svn: 164239
2012-09-19 18:46:03 +00:00
Fariborz Jahanian eed5e32d41 Fix test better way.
llvm-svn: 164234
2012-09-19 16:20:17 +00:00
Alexander Kornienko 66fb1fb073 Added link to HowToSetupToolingForLLVM.html. Added missing #include to the example.
llvm-svn: 164226
2012-09-19 15:17:49 +00:00
Rafael Espindola 51f3c4eadc Add some typedefs for clarity.
llvm-svn: 164223
2012-09-19 14:11:44 +00:00
Benjamin Kramer 53750b1865 ASTWriter: Tighten up assertions when emitting a declaration name.
clang has recently started to warn about the enum compares:
lib/Serialization/ASTWriter.cpp:2760:31: warning: comparison of literal 256 with expression of type
'clang::DeclarationName::NameKind' is always true [-Wtautological-constant-out-of-range-compare]

llvm-svn: 164220
2012-09-19 13:40:40 +00:00
Benjamin Kramer 6ca4210d3a Update clang for API change.
llvm-svn: 164218
2012-09-19 13:13:52 +00:00
Craig Topper e6706e40bb Remove Context argument from TemplateDeductionInfo constructor. It was no longer needed after the unused Context member was removed in r164104.
llvm-svn: 164196
2012-09-19 02:26:47 +00:00
Eli Friedman 2b4896ff8e Test for r164186.
llvm-svn: 164187
2012-09-19 01:35:20 +00:00
Eli Friedman d564afb0ad Add the TypeSourceInfo for the lambda call operator to the lambda's
definition info; it needs to be there because the mangler needs to
access it before we're finished defining the lambda class.
PR12808.

llvm-svn: 164186
2012-09-19 01:18:11 +00:00
Hal Finkel 455ba73752 Add the freescale_ppc64_tree that should have been included in r164177.
llvm-svn: 164179
2012-09-18 22:53:24 +00:00
Hal Finkel f358791e27 Add C/C++ header locations for the Freescale SDK.
The Freescale SDK is based on OpenEmbedded, and this might be useful
for other OpenEmbedded-based configurations as well.

With minor modifications, patch by Tobias von Koch!

llvm-svn: 164177
2012-09-18 22:25:07 +00:00
Hal Finkel f6d6cb0218 Add e500mc and e5500 to the list of valid PPC CPU names.
Patch by Tobias von Koch!

llvm-svn: 164176
2012-09-18 22:25:03 +00:00
Eli Friedman 14f082b69d Fix a small bug in the way we handle builtin candidates for
relational operators of enumeration type.  From the gcc testsuite.

llvm-svn: 164171
2012-09-18 21:52:24 +00:00
Eli Friedman e979db1583 Add an extra check for invalid decls in the lambda semantic analysis to avoid a crash. PR13860.
llvm-svn: 164168
2012-09-18 21:11:30 +00:00
Benjamin Kramer 87cdfaf895 Remove invalid double colon in test case was previously ignored by FileCheck.
llvm-svn: 164167
2012-09-18 20:59:03 +00:00
Fariborz Jahanian 282071efcc minor refactoring of my last check-in.
llvm-svn: 164145
2012-09-18 17:46:26 +00:00
Fariborz Jahanian b1885425c4 c: warn when an integer value comparison with an
integral expression have the obvious result.
Patch reviewed by John McCall off line.
// rdar://12202422

llvm-svn: 164143
2012-09-18 17:37:21 +00:00