Commit Graph

26980 Commits

Author SHA1 Message Date
NAKAMURA Takumi 72f05bccc9 clang/lib/Analysis/ObjCNoReturn.cpp: Fix [-Wnewline-eof]
llvm-svn: 163775
2012-09-13 05:53:17 +00:00
Jordan Rose 4c266aa371 Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.
<rdar://problem/12061922>

llvm-svn: 163772
2012-09-13 02:11:15 +00:00
Jordan Rose 510260c2bf Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).
These will warn under -Wformat-non-iso, and will still be rejected
outright on other platforms.

<rdar://problem/12061922>

llvm-svn: 163771
2012-09-13 02:11:03 +00:00
Anna Zaks f6a5d793d2 [analyzer] Don't reimplement an existing function.
Thanks Jordan.

llvm-svn: 163762
2012-09-13 00:37:12 +00:00
Ted Kremenek edf22edca0 Teach -Wuninitialized to recognize common "noreturn" idioms in
Objective-C related to NSException.

Fixes <rdar://problem/12287498>

I debated whether or not this logic should be sunk into the CFG
itself.  It's not clear if we should, as different analyses may
wish to have different policies.  We can re-evaluate this in the
future.

llvm-svn: 163760
2012-09-13 00:21:35 +00:00
Ted Kremenek 8b3f938697 Refactor logic in ExprEngine for detecting 'noreturn' methods
in NSException to a helper object in libAnalysis that can also
be used by Sema.  Not sure if the predicate name 'isImplicitNoReturn'
is the best one, but we can massage that later.

No functionality change.

llvm-svn: 163759
2012-09-13 00:21:31 +00:00
Chad Rosier f83315fd4a Add a few FIXMEs.
llvm-svn: 163758
2012-09-13 00:20:37 +00:00
Chad Rosier b261a50b40 [ms-inline asm] Handle the enumeration of input and output expressions in a
more robust way to address a few FIXMEs.

The initial implementation, r163342, built the IR asm string and then tried to
patch things on the fly without enough context.  Specifically, it didn't skip
mnemonics nor did it track with assembly instruction an expression was related
to.  The new implementation patches the operands and then builds the final
IR string.

llvm-svn: 163756
2012-09-13 00:06:55 +00:00
Eric Christopher 31ce693f93 Reapply:
Make clang emit a flag for DW_AT_object_pointer for the artificial
    args where it should (implicit first arguments). FileCheck-ize a
    test as well and update tests to take into account the object
    pointer flag.

    rdar://9797999

llvm-svn: 163755
2012-09-12 23:36:49 +00:00
Anna Zaks 5d2964e770 [analyzer] Do not report use of undef on "return foo();" when the return type is void.
Fixes a false positive found by analyzing LLVM code base.

llvm-svn: 163750
2012-09-12 22:57:40 +00:00
Anna Zaks 75cfbb60a8 [analyzer] Fix another false positive in malloc realloc logic.
llvm-svn: 163749
2012-09-12 22:57:34 +00:00
Anna Zaks e663b80975 [analyzer] Teach UndefOrNullArgVisitor to track parent regions.
llvm-svn: 163748
2012-09-12 22:57:30 +00:00
Jordan Rose 5297748e3f [analyzer] Fix another use of the address of a temporary, like r163402.
Again, GCC is more aggressive about reusing temporary space than we are,
leading to Release build crashes for this undefined behavior.

PR13710 (though it may not be the only problem there)

llvm-svn: 163747
2012-09-12 22:48:08 +00:00
Jordan Rose d44977ef64 [analyzer] Handle when the dynamic type is worse than the static type.
Currently we don't update the dynamic type of a C++ object when it is
cast. This can cause the situation above, where the static type of the
region is now known to be a subclass of the dynamic type.

Once we start updating DynamicTypeInfo in response to the various kinds
of casts in C++, we can re-add this assert to make sure we don't miss
any cases. This work is tracked by <rdar://problem/12287087>.

In -Asserts builds, we will simply not return any runtime definition
when our DynamicTypeInfo is known to be incorrect like this.

llvm-svn: 163745
2012-09-12 21:48:17 +00:00
Jordan Rose 99c6c2b4e2 Revert "[analyzer] Use the static type for a virtual call if the dynamic type is worse."
Using the static type may be inconsistent with later calls. We should just
report that there is no inlining definition available if the static type is
better than the dynamic type. See next commit.

This reverts r163644 / 19d5886d1704e24282c86217b09d5c6d35ba604d.

llvm-svn: 163744
2012-09-12 21:48:13 +00:00
Fariborz Jahanian 70b8bd8ad6 objective-C arc: don't issue no explicit ownership warning when
__autoreleasing is explicitely added to param type.
// rdar://12280826

llvm-svn: 163738
2012-09-12 20:34:47 +00:00
Eric Christopher 48f782bbd2 Revert "Make clang emit a flag for DW_AT_object_pointer for the artificial"
this should be done on the subprogram, not the variable.

llvm-svn: 163733
2012-09-12 18:42:10 +00:00
Chad Rosier 57cd91f683 [ms-inline asm] If we have a single asm operand that maps to multiple
MCOperands then iterate over all of then when computing clobbers, inputs and
outputs.

On x86 the 1-to-many mapping is a memory operand that includes a BaseReg(reg),
MemScale(imm), MemIndexReg(reg), an Expr(MCExpr or imm) and a MemSegReg(reg).
Invalid register (Op.getReg() == 0) are not considered when computing clobber.

llvm-svn: 163728
2012-09-12 18:14:25 +00:00
Dmitri Gribenko 00bcdd3192 Fix a couple of Doxygen issues pointed out by -Wdocumentation.
llvm-svn: 163722
2012-09-12 17:01:48 +00:00
Ted Kremenek 191ffd35a0 Revert "objective-C: warn under a flag if missing argument"
We plan on discussing this more, but we shouldn't have it in the compiler
in an incomplete state.

llvm-svn: 163720
2012-09-12 16:50:35 +00:00
Ted Kremenek 632a6432f5 Revert "objective-C: warn if selector has nothing but bare"
We plan on discussing this more.

llvm-svn: 163719
2012-09-12 16:50:30 +00:00
Joerg Sonnenberger 85e2bbc3f8 Claim --param ssp-buffer-size, even if the stack protector is not
active.

llvm-svn: 163705
2012-09-12 13:51:14 +00:00
Evgeniy Stepanov cac6aaab0d Make -faddress-sanitizer on Android link to the new-style runtime.
llvm-svn: 163689
2012-09-12 09:09:08 +00:00
Ted Kremenek 26774b15f6 Convert a few more getAs cases to castAs where we immediately call a member function.
llvm-svn: 163684
2012-09-12 06:50:29 +00:00
Ted Kremenek ba22a035ad Fix regression where "looping back to the head of" PathDiagnosticEvents
were not emitted.

Fixes <rdar://problem/12280665>.

llvm-svn: 163683
2012-09-12 06:22:18 +00:00
Ted Kremenek 7979ccf35a Teach -Wuninitialized to recognize __attribute__((analyzer_noreturn))
for halting the propagation of uninitialized value tracking along
a path.  Unlike __attribute__((noreturn)), this attribute (which
is used by clients of the static analyzer) can be used to annotate
functions that essentially never return, but in rare cares may be
allowed to return for (special) debugging purposes.  This attribute
has been shown in reducing false positives in the static analyzer
by pruning false postives, and is equally applicable here.

Handling this attribute in the CFG itself is another option, but
this is not something all clients (e.g., possibly -Wunreachable-code)
would want to see.

Addresses <rdar://problem/12281583>.

llvm-svn: 163681
2012-09-12 05:53:43 +00:00
Richard Smith b15fe3a5e4 PR13811: Add a FunctionParmPackExpr node to handle references to function
parameter packs where the reference is not being expanded but the pack has
been. Previously, Clang would segfault in such cases.

llvm-svn: 163672
2012-09-12 00:56:43 +00:00
Eric Christopher 1d292e59d3 Make clang emit a flag for DW_AT_object_pointer for the artificial
args where it should (implicit first arguments). FileCheck-ize a
test as well and update tests to take into account the object
pointer flag.

rdar://9797999

llvm-svn: 163668
2012-09-12 00:27:32 +00:00
Chad Rosier a4f52e16a5 [ms-inline asm] isDef/NumDefs in this context only refer to register definitions, not memory definitions.
llvm-svn: 163666
2012-09-11 23:53:48 +00:00
Chad Rosier 911d50fe4e [ms-inline asm] As of r163657 this check is unnecessary.
llvm-svn: 163665
2012-09-11 23:48:00 +00:00
Chad Rosier ee94a2ebd5 [ms-inline asm] Don't consider tokens or immediates when computing clobbers, inputs and outputs.
llvm-svn: 163657
2012-09-11 23:13:15 +00:00
DeLesley Hutchins 138568b60a Thread-safety analysis: fix bug in expression matching code.
llvm-svn: 163656
2012-09-11 23:04:49 +00:00
Fariborz Jahanian 822ab6b2e4 objective-C: warn if selector has nothing but bare
':' in its name. // rdar://8366823

llvm-svn: 163650
2012-09-11 21:27:45 +00:00
Jordan Rose a522f1cf8b Revert "[analyzer] Disable STL inlining. Blocked by PR13724."
While PR13724 is still an issue, it's not actually an issue in the STL.
We can keep this option around in case there turn out to be widespread
false positives due to poor modeling of the C++ standard library functions,
but for now we'd like to get more data.

This reverts r163633 / c6baadceec1d5148c20ee6c902a102233c547f62.

llvm-svn: 163647
2012-09-11 20:26:49 +00:00
Dmitri Gribenko 9304d86329 Comment parsing: handle non-builtin commands correctly. After semantic
analysis registers a command, it becomes a "known" command for the lexer, since
it has an ID.  Having this freedom of choice to register a command is a good
thing since BriefParser does not need this.

But the parser should still invoke the correct semantic analysis method
(actOnUnknownCommand) in this case.

llvm-svn: 163646
2012-09-11 19:22:03 +00:00
Jordan Rose e35fdeb330 [analyzer] Use the static type for a virtual call if the dynamic type is worse.
reinterpret_cast does not provide any of the usual type information that
static_cast or dynamic_cast provide -- only the new type. This can get us
in a situation where the dynamic type info for an object is actually a
superclass of the static type, which does not match what CodeGen does at all.
In these cases, just fall back to the static type as the best possible type
for devirtualization.

Should fix the crashes on our internal buildbot.

llvm-svn: 163644
2012-09-11 18:47:13 +00:00
DeLesley Hutchins 93cddf3cdc Fix warning from r163642
llvm-svn: 163643
2012-09-11 18:32:12 +00:00
DeLesley Hutchins 781fe380c3 Thread safety analysis: fix bug related to lock_returned attribute
on templates.

llvm-svn: 163642
2012-09-11 18:27:46 +00:00
Fariborz Jahanian 66d2e88799 objective-C: warn under a flag if missing argument
name results in unintended selector name. 
// rdar://12263549

llvm-svn: 163634
2012-09-11 17:24:26 +00:00
Anna Zaks 464493fbf4 [analyzer] Disable STL inlining. Blocked by PR13724.
llvm-svn: 163633
2012-09-11 17:15:39 +00:00
Douglas Gregor 18e1b52964 Switch a SmallPtrSet/SmallVector pair over to SetVector.
llvm-svn: 163600
2012-09-11 07:19:42 +00:00
Douglas Gregor 3d05040cc1 Remove unused macro definition
llvm-svn: 163598
2012-09-11 06:33:46 +00:00
Richard Smith c030bcdf62 Remove some redundancy from constant aggregate emission. No functionality change.
llvm-svn: 163595
2012-09-11 05:51:06 +00:00
Argyrios Kyrtzidis e552941316 [libclang] Fix getting a cursor inside an angled #include directive.
Fixed by pointing the end location of the preprocessed entity for the #include
at the closing '>', instead of the start of '<'.

rdar://11113134

llvm-svn: 163588
2012-09-11 02:17:21 +00:00
Eric Christopher 13453d32ff Update comment and space.
llvm-svn: 163586
2012-09-11 01:36:56 +00:00
Eric Christopher 5296db0805 The type of the self and cmd variables should be artificial. (Note
that the types aren't artificial the args are, but this is currently
represented by an artificial type.)

Found by inspection.

llvm-svn: 163585
2012-09-11 01:36:54 +00:00
Chad Rosier bd7fdadb90 [ms-inline asm] Add $$ before numeric constants in the IR.
llvm-svn: 163581
2012-09-11 00:51:28 +00:00
Eli Friedman de4f470125 Fix buffer overflow.
llvm-svn: 163578
2012-09-11 00:36:26 +00:00
Jordan Rose 12f669e3cd [analyzer] Member function calls that use qualified names are non-virtual.
C++11 [expr.call]p1: ...If the selected function is non-virtual, or if the
  id-expression in the class member access expression is a qualified-id,
  that function is called. Otherwise, its final overrider in the dynamic type
  of the object expression is called.

<rdar://problem/12255556>

llvm-svn: 163577
2012-09-11 00:31:02 +00:00
Anna Zaks 1ded453e36 [analyzer] Turn stl inlining back on.
The one reported bug, which was exposed by stl inlining, is addressed in
r163558.

llvm-svn: 163574
2012-09-10 23:59:02 +00:00