Commit Graph

40508 Commits

Author SHA1 Message Date
Dmitri Gribenko 49fdf8d3f5 Comment parsing: don't treat typedef to a typedef to a function as a
'function-like' type that can be annotated with \param.

Thanks to Eli Friedman for noticing!

llvm-svn: 163985
2012-09-15 21:13:36 +00:00
Dmitri Gribenko a664e5b88f Use LLVM_DELETED_FUNCTION in place of 'DO NOT IMPLEMENT' comments.
llvm-svn: 163983
2012-09-15 20:20:27 +00:00
Dmitri Gribenko ecee975834 Make PTHManager properly noncopyable.
llvm-svn: 163982
2012-09-15 20:16:46 +00:00
Dmitri Gribenko 75f8498074 Address a long-standing FIXME: remove an unused copy constructor and make
UnqualifiedId() properly noncopyable.

llvm-svn: 163981
2012-09-15 19:23:53 +00:00
Craig Topper c9ee1d0287 Fix includes of llvm and clang files that used angle brackets.
llvm-svn: 163980
2012-09-15 18:47:51 +00:00
Dmitri Gribenko 98f93adefc Add bindings for clang_getCompletionBriefComment to cindex.py.
llvm-svn: 163966
2012-09-15 11:56:32 +00:00
Richard Smith e00921a0a4 const _Atomic(T) is not an atomic type, so do not allow it as the type 'A' in
C11 7.17's atomic operations. GNU's __atomic_* builtins do allow const-qualified
atomics, though (!!) so don't restrict those.

llvm-svn: 163964
2012-09-15 06:09:58 +00:00
Ted Kremenek b184a36aad Revert "Utilize new build system support in Xcode 4.5 for easier interposition"
It's not clear if this is working yet on the buildbot.  Reverting until we have
time to investigate.

llvm-svn: 163963
2012-09-15 05:51:10 +00:00
Jordan Rose fa9e4badce -Warc-retain-cycles: warn at variable initialization as well as assignment.
Specifically, this should warn:

  __block block_t a = ^{ a(); };

Furthermore, this case which previously warned now does not, since the value
of 'b' is captured before the assignment occurs:

  block_t b; // not __block
  b = ^{ b(); };

(This will of course warn under -Wuninitialized, as before.)

<rdar://problem/11015883>

llvm-svn: 163962
2012-09-15 02:48:31 +00:00
Argyrios Kyrtzidis 945a819326 Allow disabling PCH validation when loading an AST file by checking
an environment variable for debugging purposes.

llvm-svn: 163958
2012-09-15 01:10:20 +00:00
Daniel Dunbar 1608097324 compiler-rt/darwin: Install asan_osx_dynamic with the other runtime libraries.
llvm-svn: 163941
2012-09-14 21:30:17 +00:00
Argyrios Kyrtzidis 617108990d In StringLiteral::setString make sure that we copy the number of
bytes of the buffer and not the size of the string, otherwise we
may overwrite the buffer if there is a mismatch between the size
of the string and the CharByteWidth, and assertions are disabled.

The bug where this could occur was fixed in r163931.
Related to rdar://12069503

llvm-svn: 163939
2012-09-14 21:17:41 +00:00
Argyrios Kyrtzidis 9e1fb5632a [libclang] When loading an AST file, make sure to apply the language options
to the target info.

Related to rdar://12069503.

llvm-svn: 163931
2012-09-14 20:24:53 +00:00
Ted Kremenek 460602e252 Utilize new build system support in Xcode 4.5 for easier interposition
of a build without needing to use ccc-analyzer.

llvm-svn: 163927
2012-09-14 19:06:33 +00:00
Jordan Rose c87e690372 scan-build: Determine the location of the clang binary before printing help.
We need the clang executable to print the list of available checkers.

llvm-svn: 163925
2012-09-14 18:59:03 +00:00
Richard Smith da83703ed4 Fix some dead stores which the static analyzer warned about. No functionality
change (the problematic cases in ParseDecl.cpp are currently impossible).

llvm-svn: 163920
2012-09-14 18:27:01 +00:00
Richard Smith 21f06f0fcb When diagnosing multiple mem-initializers in a delegating ctor, point to the delegating initializer, not to the first initializer. For good measure, also highlight the other initializer.
llvm-svn: 163919
2012-09-14 18:21:10 +00:00
Fariborz Jahanian d7ffdecec1 Test removed.
llvm-svn: 163918
2012-09-14 17:51:34 +00:00
Fariborz Jahanian 35227ea365 objective-C arc: remove -Warc-abi in its entirety.
// rdar://10554025

llvm-svn: 163917
2012-09-14 17:48:35 +00:00
Ted Kremenek efc32c0857 Fix copy-paste error in manpage. Should be -stdlib=library.
llvm-svn: 163914
2012-09-14 17:20:56 +00:00
Douglas Gregor 8beb26e4fa Add missing test from r163874.
llvm-svn: 163910
2012-09-14 16:38:59 +00:00
Dmitri Gribenko ad45ad6fe9 Comment parsing: don't parse comment marker followed by a digit as a command
since no Doxygen command starts with a digit.

llvm-svn: 163909
2012-09-14 16:35:35 +00:00
Dmitri Gribenko 578865b73c Comment parsing: support the "\invariant" command.
llvm-svn: 163905
2012-09-14 15:37:29 +00:00
Simon Atanasyan d44138808f Do not use "lib32" directory to create a library/object files
paths when target is MIPS 32-bit.

The patch reviewed by Chandler Carruth.

llvm-svn: 163898
2012-09-14 11:27:24 +00:00
Douglas Gregor 5c65f62a1e Fix warning on qualified typedef with 'unused' attribute, from Jason Haslam!
llvm-svn: 163874
2012-09-14 05:10:40 +00:00
Douglas Gregor 0064c5968f In debugger mode, allow comparisons between pointers and integers
without a cast. Fixes <rdar://problem/11830912>.

llvm-svn: 163873
2012-09-14 04:35:37 +00:00
Douglas Gregor 6d149412c8 As we do with base and member initializers in a dependent class, delay
type checking for non-static data member initializers in a dependent
class, because our ASTs lose too much information to when
type-checking an initializer. Fixes <rdar://problem/11974632>,
although the result is still rather unsatisfactory.

llvm-svn: 163871
2012-09-14 04:20:37 +00:00
Bob Wilson 1ec4a5e190 Improve the driver title as shown in the --help message. <rdar://12297538>
llvm-svn: 163870
2012-09-14 03:35:42 +00:00
Eli Friedman 00755e9554 Fix thunk emission for covariant virtual functions in cases which require
both a virtual and a non-virtual offset. PR13832.

llvm-svn: 163866
2012-09-14 01:45:09 +00:00
Eli Friedman 48a3291675 Fix line endings.
llvm-svn: 163865
2012-09-14 01:19:01 +00:00
Eli Friedman 21530f7c4e Fix abbreviation for CharacterLiteral in AST serialization. PR13806.
llvm-svn: 163863
2012-09-14 00:51:36 +00:00
Douglas Gregor c7203ba19c When computing the decltype of an expression, consider Objective-C
ivar and property references as member accesses and produce the actual
type of the declaration. Fixes <rdar://problem/12031582>.

llvm-svn: 163858
2012-09-13 23:40:46 +00:00
Richard Smith 31b617d7f0 Fix incorrect comment.
llvm-svn: 163850
2012-09-13 22:10:19 +00:00
Richard Smith 86a6ae8398 Fix up after r163846. Sorry!
llvm-svn: 163849
2012-09-13 22:03:58 +00:00
Douglas Gregor 1af8ad49fd Actually rebuild function types properly when adjusting the function
type of an instantiation.

llvm-svn: 163848
2012-09-13 22:01:49 +00:00
Richard Smith ca24ed473b Revert r163829. The world (or libstdc++, at least) is not ready.
llvm-svn: 163846
2012-09-13 22:00:12 +00:00
Douglas Gregor 89f593a14c When we substitute into the type of a function based on the
TypeSourceInfo, we may have lost some adjustments made to the type of
that function due to declaration merging. Adjust the resulting type
correspondingly. Fixes PR12948 / <rdar://problem/11552434>.

llvm-svn: 163845
2012-09-13 21:56:43 +00:00
Dmitri Gribenko 0b1a96a876 Comment to XML conversion: we try not to emit empty <Discussion> elements, but
it is not possible to guarantee that without duplicating logic or buffering
<Discussion> element contents.  So, allow empty <Discussion> elements in schema.

llvm-svn: 163842
2012-09-13 21:32:58 +00:00
Richard Smith b9c5a60045 Implement C++11 [conv.prom]p4: an enumeration with a fixed underlying type has
integral promotions to both its underlying type and to its underlying type's
promoted type. This matters now that boolean conversions aren't permitted in
converted constant expressions (a la DR1407): an enumerator with a fixed
underlying type of bool still can be.

llvm-svn: 163841
2012-09-13 21:18:54 +00:00
Douglas Gregor c5c01a60c2 Don't perform template argument deduction against invalid templates;
it's likely to lead to a crash later on. Fixes PR12933 /
<rdar://problem/11525335>.

llvm-svn: 163838
2012-09-13 21:01:57 +00:00
Dmitri Gribenko b37d5e8a95 Comment parsing: handle \deprecated command. It is a block command, but it
should be fine to use it without further explanations in the attached
paragraph, so the warning about empty paragraph was turned off for it.

llvm-svn: 163836
2012-09-13 20:36:01 +00:00
Fariborz Jahanian a55f658a88 remove duplicate code.
llvm-svn: 163833
2012-09-13 20:26:40 +00:00
Douglas Gregor 43bc036e8a Promote the warning about extra qualification on a declaration from a
warning to an error. C++ bans it, and both GCC and EDG diagnose it as
an error. Microsoft allows it, so we still warn in Microsoft
mode. Fixes <rdar://problem/11135644>.

llvm-svn: 163831
2012-09-13 20:16:20 +00:00
Richard Smith b67ada6687 Remove speculative fix for C++ core issue 1407, since it was resolved as NAD.
llvm-svn: 163829
2012-09-13 19:55:13 +00:00
Ted Kremenek 5371c73cdf Fix grammar.
llvm-svn: 163828
2012-09-13 19:48:51 +00:00
Richard Smith 7696571d2b Recover properly after a parse error in a static_assert declaration.
llvm-svn: 163826
2012-09-13 19:12:50 +00:00
Richard Smith 659d38bcd5 Use a "better" unicode character, to avoid buildbot breakage on bots which can print some unicode characters.
llvm-svn: 163825
2012-09-13 19:10:51 +00:00
Fariborz Jahanian 1dfeacefbc Move back the stuff about missing ownership attribute warning
to SemaDeclObjC and apply some simplification per John's
comment. // rdar://12280826

llvm-svn: 163824
2012-09-13 18:53:14 +00:00
Richard Smith fab4b1a40c Make TextDiagnostic more robust against SourceLocations which point into the
middle of UTF-8 characters, and avoid walking to such positions when adjusting
column ranges for display. Fixes a couple of hangs when rendering diagnostics.

llvm-svn: 163820
2012-09-13 18:37:50 +00:00
Ted Kremenek e5c0a9bad4 When warning about unsafe uses of dispatch_once, specially handle the
crazy case where dispatch_once gets redefined as a macro that calls
_dispatch_once (which calls the real dispatch_once).  Users want to
see the warning in their own code.

Fixes <rdar://problem/11617767>

llvm-svn: 163816
2012-09-13 18:18:37 +00:00
Fariborz Jahanian bf38d880d6 Move no explicit ownership warning to SemaType.cpp.
// rdar://12280826

llvm-svn: 163813
2012-09-13 17:29:07 +00:00
Ted Kremenek 12c7799c55 Add tests for r163778.
llvm-svn: 163812
2012-09-13 17:25:51 +00:00
Silviu Baranga 157f7c6742 This patch introduces A15 as a target in Clang.
llvm-svn: 163804
2012-09-13 15:06:00 +00:00
NAKAMURA Takumi 3de4e8987e ASTMatchersMacros.h: Appease msvc.
llvm-svn: 163798
2012-09-13 14:28:23 +00:00
Daniel Jasper a6bc1f6d35 Create initial support for matching and binding NestedNameSpecifier(Loc)s.
Review: http://llvm-reviews.chandlerc.com/D39
llvm-svn: 163794
2012-09-13 13:11:25 +00:00
Dmitri Gribenko 8994e0c03d Fix Doxygen misuse: refer to parameter names in paragraphs correctly (\arg is
not what most people want -- it starts a new paragraph).

llvm-svn: 163793
2012-09-13 13:11:20 +00:00
Manuel Klimek 024e075597 Add missing accessor.
llvm-svn: 163792
2012-09-13 12:44:47 +00:00
Ted Kremenek b47e6bc597 Conditionally parse documentation comments in system headers by
passing -fretain-comments-from-system-headers.  By default, the
compiler no longer parses such documentation comments, as they
can result in a noticeable compile time/PCH slowdown.

Fixes <rdar://problem/11860820>.

llvm-svn: 163778
2012-09-13 06:41:18 +00:00
Eric Christopher 17674ec8c6 Properly link libpthread_p when using profiling on OpenBSD.
Patch by Brad Smith.

llvm-svn: 163777
2012-09-13 06:32:34 +00:00
NAKAMURA Takumi 4a7a5610ce InitHeaderSearch.cpp: [mingw] Handle DOSish paths only on Win32 hosts.
llvm-svn: 163776
2012-09-13 05:53:23 +00:00
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
Richard Trieu a9fe99a174 Add two new functions to Qualifiers.
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Removes the common qualifiers from L and R and returns them in a new Qualifier.
This will be used in template diffing.

void removeQualifiers(Qualifiers Q)
Removes the qualifiers in Q from the current qualifier.
This replaces the current underlying implementation of operator- and
operator -= which only performed bit masking.

llvm-svn: 163752
2012-09-12 23:13:31 +00:00
Chad Rosier 24f3a14026 Whitespace.
llvm-svn: 163751
2012-09-12 23:03:48 +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 2010d437f9 [analyzer] Re-add reinterpret_cast virtual call test case from r163644.
We mostly just don't want to crash analyzing this test case; it's likely
the code found here will actually crash if compiled and run.

llvm-svn: 163746
2012-09-12 21:50:56 +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 063df00cae objective-C++ test for my previous patch.
// rdar://12280826

llvm-svn: 163741
2012-09-12 21:27:26 +00:00
Daniel Jasper d6b82cba05 Rename isA to isSameOrDerivedFrom.
There are two evils we can choose from:
- Name overlap between isA-matcher and llvm::isa<>()
- Bad name for what the isA-matcher currently does

After some discussion we have agreed to go with the latter evil.

Review: http://llvm-reviews.chandlerc.com/D40
llvm-svn: 163740
2012-09-12 21:14:15 +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
Chad Rosier e4e6424255 Fix test case for Release builds.
llvm-svn: 163737
2012-09-12 20:13:11 +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 fb901cac60 [ms-inline asm] Add a test case.
llvm-svn: 163731
2012-09-12 18:34:34 +00:00
Chad Rosier bb8795e100 [ms-inline asm] Test case for r163729.
llvm-svn: 163730
2012-09-12 18:25:06 +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 342cb7385c Comment parsing: recognize more Doxygen commands
llvm-svn: 163723
2012-09-12 17:02:40 +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
NAKAMURA Takumi cb0a08ac77 clang/test: [PR13820] Suppress LLP64-incompatible tests for ObjC with +Asserts.
llvm-svn: 163709
2012-09-12 14:26:42 +00:00
NAKAMURA Takumi bf05d8dd91 clang/test/CodeGen/2008-01-25-ZeroSizedAggregate.c: [PR8833] Add REQUIRES: LP64. It fails with +Asserts for Win64.
llvm-svn: 163708
2012-09-12 14:26:34 +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
NAKAMURA Takumi f331aa9c00 clang/test/CodeGenObjC: [PR13820] Suppress LLP64-incompatible tests.
llvm-svn: 163701
2012-09-12 10:45:52 +00:00
NAKAMURA Takumi 6223834f1f clang/test/SemaCXX/dcl_ambig_res.cpp: [PR13819] It requires LP64 for now due to __SIZE_TYPE__.
llvm-svn: 163700
2012-09-12 10:45:46 +00:00
NAKAMURA Takumi fcd16e36c8 clang/test: [PR8833] Introduce the feature "LP64" to suppress LLP64-incompatible tests.
I think some of them could be rewritten to fit also LLP64.

llvm-svn: 163699
2012-09-12 10:45:40 +00:00
NAKAMURA Takumi efbb1ab92a clang/test/PCH/missing-file.cpp: Try to suppress accidental false on Windows.
%t.h might be touched by scanners as a hot file on Windows, to fail to remove %.h with single run.

llvm-svn: 163697
2012-09-12 10:38:08 +00:00
NAKAMURA Takumi 6bbc981d37 clang/test/lit.cfg: Fix a typo in comment.
llvm-svn: 163696
2012-09-12 10:38:03 +00:00
Evgeniy Stepanov ffeb6e0f77 Fix a test failure.
llvm-svn: 163691
2012-09-12 09:39:37 +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
Ted Kremenek b8cae9fddf Post new checker build.
llvm-svn: 163680
2012-09-12 05:11:29 +00:00
Chandler Carruth 66a34a6a45 Adjust some analyzer tests to place widely shared inputs inside of an
'Inputs' subdirectory.

The general desire has been to have essentially all of the non-test
input files live in such directories, with some exceptions for obvious
and common patterns like 'foo.c' using 'foo.h'.

This came up because our distributed test runner couldn't find some of
the headers, for example with stl.cpp.

No functionality changed, just shuffling around here.

llvm-svn: 163674
2012-09-12 01:11:10 +00:00
Chandler Carruth 575037f0de Fix up more "$t"s in this test that should be "%t"s.
llvm-svn: 163673
2012-09-12 01:11:05 +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
Rafael Espindola ef1707c013 Fix namespace nesting and remove windows line endings.
llvm-svn: 163620
2012-09-11 14:17:47 +00:00
Chandler Carruth 482942ed08 Just revert r163605 for now. It broke the build and had some
questionable elements to the patch.

llvm-svn: 163609
2012-09-11 10:40:21 +00:00
David Chisnall d81825aed7 Select the correct, or, failing that, compatible, dialect when invoked as cc,
c89, c99, and so on.  No change to the default dialect when invoked as clang /
clang++.

llvm-svn: 163605
2012-09-11 09:58:54 +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
Douglas Gregor fa50b1054d Fix typo in comment
llvm-svn: 163597
2012-09-11 06:30:16 +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
Anna Zaks 4f9c460874 [analyzer] Do not count calls to small functions when computing stack
depth.

We only want to count how many substantial functions we inlined. This
is an improvement to r163558.

llvm-svn: 163571
2012-09-10 23:35:11 +00:00
Argyrios Kyrtzidis e60e408661 [PCH] Add a null check to avoid crashing.
Unfortunately, no test case. rdar://11960120

llvm-svn: 163566
2012-09-10 23:28:22 +00:00
David Blaikie 60761490f2 Provide fixed target triples to make test results consistent across ARM hosts.
Patch by David Tweed, review by myself and John McCall.

llvm-svn: 163564
2012-09-10 23:06:08 +00:00
Argyrios Kyrtzidis 68e87e1360 [libclang] Do index 'extern' declarations inside functions.
rdar://12257073

llvm-svn: 163563
2012-09-10 22:58:04 +00:00
Anna Zaks 5446f4dfb1 [analyzer] Add an option to enable/disable objc inlining.
llvm-svn: 163562
2012-09-10 22:56:41 +00:00
Ted Kremenek eedc12a140 Revert "Remove clang man page reference to -Oz. It's not an option we want people to use, and is around for historical reasons."
This should be discussed more first.

llvm-svn: 163560
2012-09-10 22:50:05 +00:00
Anna Zaks 14ce52492f [analyzer] Add ipa-always-inline-size option (with 3 as the default).
The option allows to always inline very small functions, whose size (in
number of basic blocks) is set using -analyzer-config
ipa-always-inline-size option.

llvm-svn: 163558
2012-09-10 22:37:19 +00:00
David Blaikie 6154ef97a3 Fix PR13784: instantiation of an abstract class in a conditional operator.
A couple of missing "RequireNonAbstractType" calls in conditional operator
handling. I looked for opportunities to tie this check in to all relevant
callers of PerformCopyInitialization (couldn't be all callers since this is
called for base subobject copying too, where it's acceptable to copy abstract
types) but the callers varied too much & in many cases had substantial code
or conditionals on the RequireNonAbstractType call, the
PerformCopyInitialization call, or the code between the two calls.

llvm-svn: 163555
2012-09-10 22:05:41 +00:00
Argyrios Kyrtzidis 54b102985d Move the null check outside of the loop, no functionality change.
llvm-svn: 163553
2012-09-10 22:04:26 +00:00
Argyrios Kyrtzidis f89a92702f [PCH] When loading fields from external storage make sure to also
load in the IndirectField declarations as well.

Field designators in initializer lists depend on traversing the fields
decl chain to find the indirect fields.

Fixes rdar://12239321

llvm-svn: 163552
2012-09-10 22:04:22 +00:00
Jordan Rose c6fcbf06a6 [analyzer] Make the defaults explicit for each of the new config options.
Also, document both new inlining options in IPA.txt.

llvm-svn: 163551
2012-09-10 21:54:24 +00:00
Jordan Rose 1e0e4001c8 [analyzer] For now, don't inline C++ standard library functions.
This is a (heavy-handed) solution to PR13724 -- until we know we can do
a good job inlining the STL, it's best to be consistent and not generate
more false positives than we did before. We can selectively whitelist
certain parts of the 'std' namespace that are known to be safe.

This is controlled by analyzer config option 'c++-stdlib-inlining', which
can be set to "true" or "false".

This commit also adds control for whether or not to inline any templated
functions (member or non-member), under the config option
'c++-template-inlining'. This option is currently on by default.

llvm-svn: 163548
2012-09-10 21:27:35 +00:00
Dmitri Gribenko 76bb5cabfa Remove redundant semicolons which are null statements.
llvm-svn: 163546
2012-09-10 21:20:09 +00:00
Dmitri Gribenko 7acbf00f96 Comment AST: TableGen'ize all command lists in CommentCommandTraits.cpp.
Now we have a list of all commands.  This is a good thing in itself, but it
also enables us to easily implement typo correction for command names.

With this change we have objects that contain information about each command,
so it makes sense to resolve command name just once during lexing (currently we
store command names as strings and do a linear search every time some property
value is needed).  Thus comment token and AST nodes were changed to contain a
command ID -- index into a tables of builtin and registered commands.  Unknown
commands are registered during parsing and thus are also uniformly assigned an
ID.  Using an ID instead of a StringRef is also a nice memory optimization
since ID is a small integer that fits into a common bitfield in Comment class.

This change implies that to get any information about a command (even a command
name) we need a CommandTraits object to resolve the command ID to CommandInfo*.
Currently a fresh temporary CommandTraits object is created whenever it is
needed since it does not have any state.  But with this change it has state --
new commands can be registered, so a CommandTraits object was added to
ASTContext.

Also, in libclang CXComment has to be expanded to include a CXTranslationUnit
so that all functions working on comment AST nodes can get a CommandTraits
object.  This breaks binary compatibility of CXComment APIs.

Now clang_FullComment_getAsXML(CXTranslationUnit TU, CXComment CXC) doesn't
need TU parameter anymore, so it was removed.  This is a source-incompatible
change for this C API.

llvm-svn: 163540
2012-09-10 20:32:42 +00:00
Ted Kremenek 8ba803d8d3 Remove clang man page reference to -Oz. It's not an option we want people to use, and is around for historical reasons.
llvm-svn: 163538
2012-09-10 20:10:37 +00:00
DeLesley Hutchins 5ff1644e62 Thread-safety analysis: differentiate between two forms of analysis; a precise
analysis that may give false positives because it is confused by aliasing, and
a less precise analysis that has fewer false positives, but may have false
negatives.  The more precise warnings are enabled by -Wthread-safety-precise.
An additional note clarify the warnings in the precise case.

llvm-svn: 163537
2012-09-10 19:58:23 +00:00
Ted Kremenek 83e480f50f Now that I have a test file to work with, disable the Filecheck part of this test.
llvm-svn: 163536
2012-09-10 19:50:17 +00:00
Ted Kremenek a8755da8b3 Correctly 'cat' out test files.
llvm-svn: 163534
2012-09-10 19:13:08 +00:00
Ted Kremenek a0fa5d6564 Fix another case where we should be using isBeforeInTranslationUnit().
llvm-svn: 163533
2012-09-10 19:07:56 +00:00
Ted Kremenek 54fd079265 Add a few more cases where we should be using isBeforeInTranslationUnit().
llvm-svn: 163531
2012-09-10 19:02:33 +00:00
Ted Kremenek fc57cdf5b8 As a debugging aid to unbreak the buildbots, cat the plist files so I can view them on different builders.
llvm-svn: 163529
2012-09-10 18:38:43 +00:00
Fariborz Jahanian d6876b20e7 More tweaking and test cases for call to super
annotations. // rdar://6386358

llvm-svn: 163525
2012-09-10 18:04:25 +00:00
Ted Kremenek e46c74f3ec Re-enable FileCheck testing of retain-release.m test, and force
a C++ dialect.  Let's see if this is the portability issue with this test.

llvm-svn: 163524
2012-09-10 17:35:24 +00:00
Fariborz Jahanian b05417e1e1 objective-C: Improving diagnostocs for missing call to
super's annotated methods. // rdar://6386358

llvm-svn: 163517
2012-09-10 16:51:09 +00:00
Ted Kremenek 1f9e7f4f91 Temporarily disable FileCheck part of this test.
llvm-svn: 163515
2012-09-10 15:16:32 +00:00
Douglas Gregor c5c5734d19 Allow vector types in pseudo-destructor expressions. Fixes PR13798.
llvm-svn: 163514
2012-09-10 14:57:06 +00:00
Alexander Kornienko 02f481c42f Workaround for MacOSX build failure with gcc <= 4.4
Summary:
A better solution to http://llvm.org/bugs/show_bug.cgi?id=13777
Named namespace + more unique name to make ODR violations unlikely.

Reviewers: chandlerc, doug.gregor, klimek

Reviewed By: doug.gregor

CC: cfe-commits

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

llvm-svn: 163513
2012-09-10 14:54:38 +00:00
Ted Kremenek 6c7a5eae6d Revert "Revert Ted's r163489 and r163490, due to breakage."
I need to see how this breaks on other platforms when I fix the issue
that Benjamin Kramer pointed out.

This includes r163489 and r163490, plus a two line change.

llvm-svn: 163512
2012-09-10 14:50:55 +00:00
Benjamin Kramer 199f8da3ae Make helper functions static.
llvm-svn: 163505
2012-09-10 11:57:16 +00:00
Evgeniy Stepanov c9cde48f3a Wrong crtbegin/crtend pair used for PIE on Android.
Android uses the same flavour of crt*.o for PIE and non-PIE executables, and a
different one for DSOs. GNU/Linux, on the other hand, uses one set of crt*.o
for non-PIE executables, and another for both PIE executables and DSOs.

llvm-svn: 163500
2012-09-10 10:30:12 +00:00
NAKAMURA Takumi 6eb1399088 Revert Ted's r163489 and r163490, due to breakage.
r163489, "Take another crack at stabilizing the emission order of analyzer"
r163490, "Use isBeforeInTranslationUnitThan() instead of operator<."

llvm-svn: 163497
2012-09-10 09:17:27 +00:00
Simon Atanasyan 464a7f7e89 MIPS: Use -march=arch option to select either generic MIPS ISA,
or the name of a particular processor.

The patch reviewed by Douglas Gregor.

llvm-svn: 163492
2012-09-10 08:32:41 +00:00
Ted Kremenek f1fc8ce65d Use isBeforeInTranslationUnitThan() instead of operator<.
llvm-svn: 163490
2012-09-10 06:56:07 +00:00
Ted Kremenek 3d92699d3c Take another crack at stabilizing the emission order of analyzer
diagnostics without using FoldingSetNodeIDs.  This is done
by doing a complete recursive comparison of the PathDiagnostics.

Note that the previous method of comparing FoldingSetNodeIDs did
not end up relying on unstable things such as pointer addresses, so
I suspect this may still have some issues on various buildbots because
I'm not sure if the true source of non-determinism has been eliminated.
The tests pass for me, so the only way to know is to commit this change
and see what happens.

llvm-svn: 163489
2012-09-10 06:20:06 +00:00
Ted Kremenek deb885a03f Have PathDiagnosticPiece::getString() return a StringRef instead
of a std::string.

llvm-svn: 163488
2012-09-10 06:19:53 +00:00
Ted Kremenek 9b9ee2a616 Indent the "message" key in analyzer plist output.
llvm-svn: 163487
2012-09-10 06:19:43 +00:00
Ted Kremenek dc1f6bc454 Add handy script for updating plist FileCheck expected output for
analyzer tests.

llvm-svn: 163486
2012-09-10 06:19:34 +00:00
Dmitri Gribenko 1d0f567f64 RawCommentList: don't copy the whole new RawComment to LastComment each time.
We just need a single SourceLocation for previous comment end.

llvm-svn: 163482
2012-09-09 20:47:31 +00:00
Ted Kremenek e9764d8f91 Remove dead method ProgramState::MarshalState().
llvm-svn: 163479
2012-09-09 14:55:59 +00:00
Abramo Bagnara 136404985c Added missing const.
llvm-svn: 163477
2012-09-09 10:21:24 +00:00
Abramo Bagnara 0678294dba Fixed support for disabled wchar_t and added an appropriate test.
llvm-svn: 163476
2012-09-09 10:13:32 +00:00
NAKAMURA Takumi e06bc926bb clang/test/Sema/format-strings-scanf.c: Relax a couple of expressions with expected-warning-re to let matched for Win32 targets.
- format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'
- format specifies type 'wchar_t **' (aka 'unsigned short **') but the argument has type 'float *'

llvm-svn: 163468
2012-09-08 12:06:00 +00:00
Anton Korobeynikov e6f74094b5 Add some ARM EABI preprocessor builtins tests
llvm-svn: 163467
2012-09-08 08:45:10 +00:00
Anton Korobeynikov 26b1388293 Do not construct StringRef from NULL argument.
llvm-svn: 163465
2012-09-08 08:22:13 +00:00
Anton Korobeynikov e98c4dbd1e Provide some ACLE C defines. This should fix PR13796
llvm-svn: 163464
2012-09-08 08:08:27 +00:00
Ted Kremenek 6ed296661a Try disabling the FileCheck part of the retain-release.m test to see if it fixes the buildbots.
llvm-svn: 163462
2012-09-08 07:40:15 +00:00
Ted Kremenek e7ec4ef48d Fix bug in BugReporter::RemoveUneededCalls() where "prunable"
PathDiagnosticEventPieces were *always* pruned.  Instead, they
are suppose to only be pruned if the entire call gets pruned.

llvm-svn: 163460
2012-09-08 07:18:18 +00:00
Richard Smith 639b8d05dd When a bad UTF-8 encoding or bogus escape sequence is encountered in a
string literal, produce a diagnostic pointing at the erroneous character
range, not at the start of the literal.

llvm-svn: 163459
2012-09-08 07:16:20 +00:00
Ted Kremenek b724ea5c2e This test does not require --exact-match from FileCheck.
llvm-svn: 163456
2012-09-08 04:29:08 +00:00
Ted Kremenek b0d1c70258 Attempt (again) to stabilize the order of the emission of diagnostics
of the analyzer by using the FullProfile() of a PathDiagnostic
for ordering them.

llvm-svn: 163455
2012-09-08 04:26:37 +00:00
Jordan Rose 2f9cc04251 Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.
As a corollary to the previous commit, even when an extension is
available, we can still offer a fixit to the standard modifier.

llvm-svn: 163453
2012-09-08 04:00:12 +00:00
Jordan Rose 92303592c3 Format strings: %Ld isn't available on Darwin or Windows.
This seems to be a GNU libc extension; we offer a fixit to %lld on
these platforms.

<rdar://problem/11518237>

llvm-svn: 163452
2012-09-08 04:00:03 +00:00
Richard Smith 4d1458ed38 -fcatch-undefined-behavior: Factor emission of the creation of, and branch to,
the trap BB out of the individual checks and into a common function, to prepare
for making this code call into a runtime library. Rename the existing EmitCheck
to EmitTypeCheck to clarify it and to move it out of the way of the new
EmitCheck.

llvm-svn: 163451
2012-09-08 02:08:36 +00:00
Jordan Rose 5481cfefa6 [analyzer] ObjCSelfInitChecker should always clean up in postCall checks.
ObjCSelfInitChecker stashes information in the GDM to persist it across
function calls; it is stored in pre-call checks and retrieved post-call.
The post-call check is supposed to clear out the stored state, but was
failing to do so in cases where the call did not have a symbolic return
value.

This was actually causing the inappropriate cache-out from r163361.
Per discussion with Anna, we should never actually cache out when
assuming the receiver of an Objective-C message is non-nil, because
we guarded that node generation by checking that the state has changed.
Therefore, the only states that could reach this exact ExplodedNode are
ones that should have merged /before/ making this assumption.

r163361 has been reverted and the test case removed, since it won't
actually test anything interesting now.

llvm-svn: 163449
2012-09-08 01:47:28 +00:00
Jordan Rose bd94e5d815 [analyzer] Add debug output for ObjCSelfInitChecker's state.
No functionality change.

llvm-svn: 163448
2012-09-08 01:47:11 +00:00
Ted Kremenek a9f89b1c31 Revert "Add plist output for retain-release.m in addition to -verify checking."
llvm-svn: 163447
2012-09-08 01:25:02 +00:00
Ted Kremenek 1fdcfcdf13 Revert "Attempt to make the PathDiagnostic emission order more deterministic by"
llvm-svn: 163446
2012-09-08 01:25:00 +00:00
Ted Kremenek af4cc7eab1 Revert "Further tweaks to hopefully make the PathDiagnostic emission more deterministic."
llvm-svn: 163445
2012-09-08 01:24:53 +00:00
Jordan Rose 5860e329a4 [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.

llvm-svn: 163444
2012-09-08 01:24:53 +00:00
Jordan Rose dd5e8c4975 [analyzer] Symbolic regions are live if any subregions are live.
RegionStoreManager was only treating a SymbolicRegion's symbel as live
if there was a binding referring to the region itself.

No test case because constraints are currently not being cleaned out
of the constraint manager at all (even if the symbol is legitimately dead).

llvm-svn: 163443
2012-09-08 01:24:49 +00:00
Jordan Rose aaf8318480 [analyzer] Cast the result of a placement new-expression to the correct type.
This is necessary because further analysis will assume that the SVal's
type matches the AST type. This caused a crash when trying to perform
a derived-to-base cast on a C++ object that had been new'd to be another
object type.

Yet another crash in PR13763.

llvm-svn: 163442
2012-09-08 01:24:38 +00:00
Anna Zaks 044f3e2694 [analyzer] Address John's code review for r163407.
Teach malloc sizeof checker to find type inconsistencies in multi-
dimensional arrays.

llvm-svn: 163438
2012-09-08 00:09:02 +00:00
Fariborz Jahanian 566fff0dac objective-C: introduce __attribute((objc_requires_super)) on method
in classes. Use it to flag those method implementations which don't
contain call to 'super' if they have 'super' class and it has the method
with this attribute set. This is wip. // rdar://6386358

llvm-svn: 163434
2012-09-07 23:46:23 +00:00
John McCall cfa4e9bdf3 In ARC, if we're emitting assembly markers for calls to
objc_retainAutoreleasedReturnValue, we need to also be killing
them during return peepholing.  Make sure we recognize an
intervening bitcast, but more importantly, assert if we can't
find the asm marker at all.  rdar://problem/12133032

llvm-svn: 163431
2012-09-07 23:30:50 +00:00
Ted Kremenek a11a741e2f Further tweaks to hopefully make the PathDiagnostic emission more deterministic.
llvm-svn: 163430
2012-09-07 23:13:11 +00:00
Alexander Kornienko 767cd03bbe Fixed http://llvm.org/bugs/show_bug.cgi?id=13777
llvm-svn: 163429
2012-09-07 22:44:34 +00:00
Ted Kremenek 244e1d7d0f Remove ProgramState::getSymVal(). It was being misused by Checkers,
with at least one subtle bug in MacOSXKeyChainAPIChecker where the
calling the method was a substitute for assuming a symbolic value
was null (which is not the case).

We still keep ConstraintManager::getSymVal(), but we use that as
an optimization in SValBuilder and ProgramState::getSVal() to
constant-fold SVals.  This is only if the ConstraintManager can
provide us with that information, which is no longer a requirement.
As part of this, introduce a default implementation of
ConstraintManager::getSymVal() which returns null.

For Checkers, introduce ConstraintManager::isNull(), which queries
the state to see if the symbolic value is constrained to be a null
value.  It does this without assuming it has been implicitly constant
folded.

llvm-svn: 163428
2012-09-07 22:31:01 +00:00
Ted Kremenek 334ad6ac13 Attempt to make the PathDiagnostic emission order more deterministic by
looking at PathPieces.

llvm-svn: 163427
2012-09-07 22:24:24 +00:00
Ted Kremenek bfd22b4155 Add default implementation of ConstraintManager::getSymVal() and a doxygen comment.
llvm-svn: 163426
2012-09-07 22:24:21 +00:00
Ted Kremenek 58ec11612c Remove ConstraintManager:isEqual(). It is no longer used.
llvm-svn: 163425
2012-09-07 22:24:18 +00:00
Ted Kremenek 9df430c46d Add plist output for retain-release.m in addition to -verify checking.
llvm-svn: 163418
2012-09-07 20:31:32 +00:00
Chad Rosier 37a8563f36 Ampersand goes with identifier.
llvm-svn: 163410
2012-09-07 19:49:55 +00:00
Jordan Rose 8dc77398a1 [analyzer] Use cast<> instead of getAs<> for a CFGElement known to be a CFGStmt.
When adding the next statement to the CoreEngine's work list, we take care
of all the special cases first. We certainly shouldn't be building
PostStmts with null statements (the diagnostics machinery assumes such
StmtPoints do not exist), and we should find out sooner if we're missing
a special case.

A refinement of r163402 that should help prevent further issues like PR13760.

llvm-svn: 163409
2012-09-07 19:48:09 +00:00
Abramo Bagnara 9c93a4a3e0 Moved back getCharAndSizeNoWarn to public area.
llvm-svn: 163408
2012-09-07 19:43:13 +00:00
Anna Zaks 694be01519 [analyzer] Fix a false positive in sizeof malloc checker.
Don't warn when the sizeof argument is an array with the same element
type as the pointee of the return type.

llvm-svn: 163407
2012-09-07 19:20:13 +00:00
Ted Kremenek a8d0ca070f Add test case for <rdar://problem/12075238>, which recently got fixed by changes to RegionStore.
llvm-svn: 163406
2012-09-07 19:09:51 +00:00
Chad Rosier ea3157f1e4 Whitespace.
llvm-svn: 163404
2012-09-07 18:46:57 +00:00
Chad Rosier 78af00f675 Bring buildbots back. Fix scoping issue and coding style from r163397.
llvm-svn: 163403
2012-09-07 18:44:15 +00:00
Jordan Rose 3c2713accf [analyzer] Don't use the address of a temporary CFGElement.
GCC destroys temporary objects more aggressively than clang, so this
results in incorrect behavior when compiling GCC Release builds.

We could avoid this issue under C++11 by preventing getAs from being
called when 'this' is an rvalue:

  template<class ElemTy> const ElemTy *getAs() const & { ... }
  template<class ElemTy> const ElemTy *getAs() const && = delete;

Unfortunately, we do not have compatibility macros for this behavior yet.

This will hopefully fix PR13760 and PR13762.

llvm-svn: 163402
2012-09-07 18:36:17 +00:00
DeLesley Hutchins a5a00e830a Thread-safety analysis: Add support for selectively turning off warnings
within part of a particular method.

llvm-svn: 163397
2012-09-07 17:34:53 +00:00
Anna Zaks 67e0062b7c [analyzer] Explain why we need condition 8.
llvm-svn: 163394
2012-09-07 16:22:09 +00:00
Roman Divacky c337b8244d Attempt to pacify Windows buildbots.
llvm-svn: 163389
2012-09-07 13:52:05 +00:00
Roman Divacky a3c5024277 Link to crtend.S when PIE in the FreeBSD driver. Patch by Brooks Davis!
llvm-svn: 163388
2012-09-07 13:36:21 +00:00
Manuel Klimek cc0637c2b6 Adds a first iteration of the basic AST matcher documentation landing page.
llvm-svn: 163387
2012-09-07 13:13:53 +00:00
Manuel Klimek 8bad94765a Introduces anchors into LibASTMatchersReference.html.
This allows linking to LibASTMatchersRefernce.html#<matcher><N>Anchor to
link to the N'the declaration of a matcher and automatically expand
its documentation.

llvm-svn: 163386
2012-09-07 13:10:32 +00:00
Daniel Jasper f49d1e0070 Change the behavior of the isDerivedFrom-matcher to not match on the
class itself. This caused some confusion (intuitively, a class is not
derived from itself) and makes it hard to write certain matchers, e.g.
"match and bind any pair of base and subclass".

The original behavior can be achieved with a new isA-matcher.  Similar
to all other matchers, this matcher has the same behavior and name as
the corresponding AST-entity - in this case the isa<>() function.

llvm-svn: 163385
2012-09-07 12:48:17 +00:00
Manuel Klimek 3ca12c5b54 Implements hasAncestor.
Implements the hasAncestor matcher. This builds
on the previous patch that introduced DynTypedNode to build up
a parent map for an additional degree of freedom in the AST traversal.

The map is only built once we hit an hasAncestor matcher, in order
to not slow down matching for cases where this is not needed.

We could implement some speed-ups for special cases, like building up
the parent map as we go and only building up the full map if we break
out of the already visited part of the tree, but that is probably
not going to be worth it, and would make the code significantly more
complex.

Major TODOs are:
- implement hasParent
- implement type traversal
- implement memoization in hasAncestor

llvm-svn: 163382
2012-09-07 09:26:10 +00:00
Ted Kremenek b2f6e69af9 Revert "Rework the retain-release.m test to use FileCheck and the "text" output"
Apparently the output of this test is not deterministic.  Needs investigation.

llvm-svn: 163377
2012-09-07 07:40:40 +00:00
Ted Kremenek 3f58774c8d Fix off-by-one bug in diagnostic prose of ObjCContainersASTChecker.
While the check itself should count 0-based for the parameter index,
the diagnostic should be 1-based (first, second, third, not start at 0).

Fixes <rdar://problem/12249569>.

llvm-svn: 163375
2012-09-07 07:13:08 +00:00
Ted Kremenek 891bcdb644 ExplodedGraph::shouldCollectNode() should not collect nodes for non-Expr Stmts
(as this previously was the case before this was refactored).  We also shouldn't
need to specially handle BinaryOperators since the eagerly-assume heuristic tags
such nodes.

llvm-svn: 163374
2012-09-07 06:56:18 +00:00
Ted Kremenek 74eb55a23d Rework the retain-release.m test to use FileCheck and the "text" output
of the analyzer, as the RetainReleaseChecker has many fine-grain
path diagnostic events that were not being checked.  This uncovered
an inconsistency between the path diagnostics between Objective-C
and Objective-C++ code in ConditionBRVisitor that was fixed in a recent
patch.

llvm-svn: 163373
2012-09-07 06:51:47 +00:00
Ted Kremenek 7c15040e98 Fix bug in ConditionBRVisitor where for C++ (and not C) we were not ignoring
implicit pointer-to-boolean conversions in condition expressions.  This would
result in inconsistent diagnostic emission between C and C++.

A consequence of this is now ConditionBRVisitor and TrackConstraintBRVisitor may
emit redundant diagnostics, for example:

  "Assuming pointer value is null" (TrackConstraintBRVisitor)
  "Assuming 'p' is null" (ConditionBRVisitor)

We need to reconcile the two, and perhaps prefer one over the other in some
cases.

llvm-svn: 163372
2012-09-07 06:51:37 +00:00
Richard Smith 1fde8ece37 PR9023: A template template parameter whose template parameter list contains an
unexpanded parameter pack is a pack expansion. Thus, as with a non-type template
parameter which is a pack expansion, it needs to be expanded early into a fixed
list of template parameters.

Since the expanded list of template parameters is not itself a parameter pack,
it is permitted to appear before the end of the template parameter list, so also
remove that restriction (for both template template parameter pack expansions and
non-type template parameter pack expansions).

llvm-svn: 163369
2012-09-07 02:06:42 +00:00
Jordan Rose 81456d9f6d [analyzer] Fail gracefully when the dynamic type is outside the hierarchy.
With some particularly evil casts, we can get an object whose dynamic type
is not actually a subclass of its static type. In this case, we won't even
find the statically-resolved method as a devirtualization candidate.

Rather than assert that this situation cannot occur, we now simply check
that the dynamic type is not an ancestor or descendent of the static type,
and leave it at that.

This error actually occurred analyzing LLVM: CallEventManager uses a
BumpPtrAllocator to allocate a concrete subclass of CallEvent
(FunctionCall), but then casts it to the actual subclass requested
(such as ObjCMethodCall) to perform the constructor.

Yet another crash in PR13763.

llvm-svn: 163367
2012-09-07 01:19:42 +00:00
Ted Kremenek c008db99d7 Teach RetainCountChecker that CFPlugInInstanceCreate does not
return a CF object at all.

Fixes <rdar://problem/9566345>

llvm-svn: 163362
2012-09-06 23:47:02 +00:00
Jordan Rose 7e97996f4e [analyzer] Don't crash if we cache out while evaluating an ObjC message.
A bizarre series of coincidences led us to generate a previously-seen
node in the middle of processing an Objective-C message, where we assume
the receiver is non-nil. We were assuming that such an assumption would
never "cache out" like this, and blithely went on using a null ExplodedNode
as the predecessor for the next step in evaluation.

Although the test case committed here is complicated, this could in theory
happen in other ways as well, so the correct fix is just to test if the
non-nil assumption results in an ExplodedNode we've seen before.

<rdar://problem/12243648>

llvm-svn: 163361
2012-09-06 23:44:36 +00:00
Anna Zaks 772ee1ebad [analyzer] Assert that StmtPoint should be created with a non-null Stmt.
llvm-svn: 163358
2012-09-06 23:30:29 +00:00
Anna Zaks a2f970baa6 [analyzer] testing: add a build mode to allow C++11 testing.
llvm-svn: 163357
2012-09-06 23:30:27 +00:00
Ted Kremenek 2a786959b1 Refine diagnostics for leaks reported when returning an object
via function/method with [CF,NS]_RETURNS_NOT_RETAINED.

Fixes <rdar://problem/11379000>.

llvm-svn: 163355
2012-09-06 23:03:07 +00:00
Ted Kremenek cadd9f186a Tweak DeadStoresChecker to not warn about dead stores to variables that
are used in EH code.  Right now the CFG doesn't support exceptions well,
so we need this hack to avoid bogus dead store warnings.

Fixes <rdar://problem/12147586>

llvm-svn: 163353
2012-09-06 22:32:48 +00:00
Sam Panzer 22a3fe1b9c Clarified diagnostics for range-based for loops with invalid ranges
llvm-svn: 163350
2012-09-06 21:50:08 +00:00
Jordan Rose 2bc9674b0a [analyzer] Don't attempt to devirtualize calls to base class destructors.
CXXDestructorCall now has a flag for when it is a base destructor call.
Other kinds of destructor calls (locals, fields, temporaries, and 'delete')
all behave as "whole-object" destructors and do not behave differently
from one another (specifically, in these cases we /should/ try to
devirtualize a call to a virtual destructor).

This was causing crashes in both our internal buildbot, the crash still
being tracked in PR13765, and some of the crashes being tracked in PR13763,
due to a assertion failure. (The behavior under -Asserts happened to be
correct anyway.)

Adding this knowledge also allows our DynamicTypePropagation checker to do
a bit less work; the special rules about virtual method calls during a
destructor only require extra handling during base destructors.

llvm-svn: 163348
2012-09-06 20:37:08 +00:00
Chad Rosier 46b0a0adbe [ms-inline asm] Output empty asm statements for the directives we don't
handle.  Otherwise, the AsmParser will explode if we try to generate an
object files.

llvm-svn: 163345
2012-09-06 19:56:25 +00:00
Chad Rosier c05d2c908d [ms-inline asm] The IR representation of inline assembly enumerates the input
and output expressions much like that in GNU-style inline assembly. Output
expressions are first.  Do this for MS-style inline asms.

llvm-svn: 163342
2012-09-06 19:35:00 +00:00
Fariborz Jahanian 979780f68f refactoring + objective-C specific test for my last patch.
// rdar://12233989

llvm-svn: 163338
2012-09-06 18:38:58 +00:00
Richard Smith 09b031fbc0 Don't try to check override control for invalid member functions. Fixes a crash in a corner case. Patch by Olivier Goffart!
llvm-svn: 163337
2012-09-06 18:32:18 +00:00
Derek Schuff 09338a250a Use custom ABIInfo for le32/PNaCl argument codegen
This patch uses a new ABIInfo implementation specific to the le32
target, rather than falling back to DefaultABIInfo. Its behavior is
basically the same, but it also allows the regparm argument attribute.
It also includes basic tests for argument codegen and attributes.

llvm-svn: 163333
2012-09-06 17:37:28 +00:00
Enrico Granata 4e0b1eda9a Enabling the UTF conversion routines that were previously conditionally ifdef'ed out. This change is required to support enhancements in the LLDB data formatters
llvm-svn: 163331
2012-09-06 17:03:42 +00:00
Aaron Ballman 9c00446d2a Fixing the return type information for objc_sync_enter and objc_sync_exit. Patch thanks to Joe Ranieri!
llvm-svn: 163330
2012-09-06 16:44:16 +00:00
Fariborz Jahanian 66c93f443d c: make __attribute__((unused)) transitive.
Don't warn if annotated decl is used inside another
   unused. // rdar://12233989

llvm-svn: 163329
2012-09-06 16:43:18 +00:00
Jakob Stoklund Olesen 83859e7728 Tighten up regexps some more.
These tests were failing for me because the .* was greedily matching up
to the /libexec/ld-elf.so.1" later on the same line.

llvm-svn: 163328
2012-09-06 16:29:03 +00:00
Roman Divacky 6d6c3110b5 Remove unused typedefs. Found by gcc48.
llvm-svn: 163327
2012-09-06 16:14:37 +00:00
Roman Divacky e637711ae0 Dont cast away const needlessly. Found by gcc48 -Wcast-qual.
llvm-svn: 163325
2012-09-06 15:59:27 +00:00
Alexey Samsonov 0fcf09ede6 Update AddressSanitizer docs
llvm-svn: 163303
2012-09-06 09:49:03 +00:00
Jordan Rose 6912a326b3 Fix a mistake in an HTML example code snippet.
Caught by Kurt Arnlund!

llvm-svn: 163286
2012-09-06 02:19:13 +00:00
Richard Smith aa31b4b816 PR13775: When checking for a tag type being shadowed by some other declaration,
don't trample over the caller's LookupResult in the case where the check fails.

llvm-svn: 163281
2012-09-06 01:37:56 +00:00