Commit Graph

29995 Commits

Author SHA1 Message Date
Evgeniy Stepanov 2e7d6cd0ec Fix uninitialized read of CalleeWithThisReturn.
CalleeWithThisReturn can be left initialized if HasThisReturn() is false.
This change reverses the order of checks in EmitFunctionEpilog such that
CalleeWithThisReturn is only examined when it has a meaningful value.

Found with MemorySanitizer.

llvm-svn: 178015
2013-03-26 13:44:29 +00:00
Richard Trieu 8fbd91d445 Handle CXXOperatorCallExpr when checking self referrnce during initialization of
class types.

llvm-svn: 177987
2013-03-26 03:41:40 +00:00
Chandler Carruth b45836a231 The IRReader header is now part of its own library. Update the include
line and the library dependencies to reflect this.

llvm-svn: 177972
2013-03-26 02:25:54 +00:00
Richard Smith 7447af48b1 Implement special-case name lookup for inheriting constructors: member
using-declarations with names which look constructor-like are interpreted as
constructor names.

llvm-svn: 177957
2013-03-26 01:15:19 +00:00
Richard Smith 74bb2d2285 Remove some no-op static_casts.
llvm-svn: 177954
2013-03-26 00:54:11 +00:00
Fariborz Jahanian 36b1e5ce82 Objective-C: Property declaration overiding one in
its super class or protocols inherit their 
availability/deprecated attribute. // rdar://13467644

llvm-svn: 177948
2013-03-25 23:59:42 +00:00
Douglas Gregor a3890528d6 <rdar://problem/13395022> Strip references when extracting an initializer_list's element type during application of an initialization sequence.
llvm-svn: 177944
2013-03-25 23:47:01 +00:00
Douglas Gregor ea306a14f4 <rdar://problem/13185264> Don't crash when attempting to redundantly initialize a member of an anonymous union.
llvm-svn: 177941
2013-03-25 23:28:23 +00:00
Douglas Gregor c060b4cfa2 <rdar://problem/13358795> Teach CMake to check Subversion version information at build time, not configure time.
llvm-svn: 177939
2013-03-25 23:16:38 +00:00
Ted Kremenek cd3d440b82 For printf checking, handle nested typedefs for darwin-specific checking.
Fixes <rdar://problem/13491605>.

llvm-svn: 177931
2013-03-25 22:28:37 +00:00
Douglas Gregor 780420ea4e <rdar://problem/13459871> Allow forward declaration of enums with a fixed underlying type in Objective-C (as well as C++11).
llvm-svn: 177930
2013-03-25 22:22:35 +00:00
Douglas Gregor 37da327c6a Use <time.h> rather than <sys/time.h>
llvm-svn: 177924
2013-03-25 21:51:16 +00:00
Matt Beaumont-Gay 07544fa55f Fix a layering violation introduced in r177705.
llvm-svn: 177922
2013-03-25 21:32:02 +00:00
Nick Lewycky 966b19951f Try harder to be signal-safe inside our signal handler. The most prominent behavioural
difference is that we no longer clean the token before emitting it. This fixes a bug where
clang hangs in the middle of crashing because the crash handler calls malloc from inside
a crash that happened inside of free.

llvm-svn: 177919
2013-03-25 21:24:30 +00:00
Douglas Gregor 527b1c95df <rdar://problem/13434605> Periodically prune the module cache so that it does not grow forever.
llvm-svn: 177918
2013-03-25 21:19:16 +00:00
Bill Wendling c4fc3a2ba5 Emit an error message instead of crashing when dereferencing an incomplete pointer type.
If the ASM statement is dereferencing an incomplete pointer type, issue an error
instead of crashing.
<rdar://problem/12700799>

llvm-svn: 177915
2013-03-25 21:09:49 +00:00
Chad Rosier 651c1839ee IR-gen should not generate an MMX types unless the code is explicitly using MMX
intrinsics.
rdar://13213542

llvm-svn: 177911
2013-03-25 21:00:27 +00:00
Anna Zaks f60f2fb142 [analyzer] Set concrete offset bindings to UnknownVal when processing symbolic offset binding, even if no bindings are present.
This addresses an undefined value false positive from concreteOffsetBindingIsInvalidatedBySymbolicOffsetAssignment.

Fixes PR14877; radar://12991168.

llvm-svn: 177905
2013-03-25 20:43:24 +00:00
Anton Yartsev 13df03624b [analyzer] Adds cplusplus.NewDelete checker that check for memory leaks, double free, and use-after-free problems of memory managed by new/delete.
llvm-svn: 177849
2013-03-25 01:35:45 +00:00
Jordan Rose d1d8929370 [analyzer] Teach ConstraintManager to ignore NonLoc <> NonLoc comparisons.
These aren't generated by default, but they are needed when either side of
the comparison is tainted.

Should fix our internal buildbot.

llvm-svn: 177846
2013-03-24 20:25:22 +00:00
Benjamin Kramer ef89ae016d Simplify code. No functionality change.
llvm-svn: 177842
2013-03-24 16:04:55 +00:00
Rafael Espindola 7976446c2c Reject -no-integrated-as on windows.
llvm-svn: 177840
2013-03-24 15:06:53 +00:00
Guy Benyei fb36ede52e Generate metadata to implement the -cl-kernel-arg-info option.
OpenCL 1.2 spec. 5.7.3.

llvm-svn: 177839
2013-03-24 13:58:12 +00:00
Nadav Rotem 1da30944a6 Make clang to mark static stack allocations with lifetime markers to enable a more aggressive stack coloring.
Patch by John McCall with help by Shuxin Yang.
rdar://13115369

llvm-svn: 177819
2013-03-23 06:43:35 +00:00
Bob Wilson a20a1dad7f Revert svn r176894 and r177658.
Changing -ccc-install-dir to affect cc1's resource-dir setting broke our
internal LNT tests. After discussing the situation with Jim, we've decided to
pursue an alternate approach. We really want the resource-dir to be located
relative to clang, even when using -ccc-install-dir, but we're going to
add a fallback setting for the libc++ headers if they don't exist alongside
the compiler.

llvm-svn: 177815
2013-03-23 05:17:59 +00:00
John McCall eff1884274 Under ARC, when we're passing the address of a strong variable
to an out-parameter using the indirect-writeback conversion,
and we copied the current value of the variable to the temporary,
make sure that we register an intrinsic use of that value with
the optimizer so that the value won't get released until we have
a chance to retain it.

rdar://13195034

llvm-svn: 177813
2013-03-23 02:35:54 +00:00
Richard Trieu 3cee413b4a Strip off local qualifiers when converting from RecordType to
TemplateSpecializationType during template type diffing.  This allows the
correct printing of diffing qualifiers on templates.

llvm-svn: 177809
2013-03-23 01:38:36 +00:00
Jordan Rose 8828d356fb [analyzer] Teach constraint managers about unsigned comparisons.
In C, comparisons between signed and unsigned numbers are always done in
unsigned-space. Thus, we should know that "i >= 0U" is always true, even
if 'i' is signed. Similarly, "u >= 0" is also always true, even though '0'
is signed.

Part of <rdar://problem/13239003> (false positives related to std::vector)

llvm-svn: 177806
2013-03-23 01:21:33 +00:00
Jordan Rose 8eca04b24e [analyzer] Loc-Loc operations (subtraction or comparison) produce a NonLoc.
For two concrete locations, we were producing another concrete location and
then casting it to an integer. We should just create a nonloc::ConcreteInt
to begin with.

No functionality change.

llvm-svn: 177805
2013-03-23 01:21:29 +00:00
Jordan Rose 59d179e9d2 [analyzer] Also transform "a < b" to "(b - a) > 0" in the constraint manager.
We can support the full range of comparison operations between two locations
by canonicalizing them as subtraction, as in the previous commit.

This won't work (well) if either location includes an offset, or (again)
if the comparisons are not consistent about which region comes first.

<rdar://problem/13239003>

llvm-svn: 177803
2013-03-23 01:21:23 +00:00
Jordan Rose 604d0bbba5 Add reverseComparisonOp and negateComparisonOp to BinaryOperator.
...and adopt them in the analyzer.

llvm-svn: 177802
2013-03-23 01:21:20 +00:00
Jordan Rose 8e6b6c0c2f [analyzer] Translate "a != b" to "(b - a) != 0" in the constraint manager.
Canonicalizing these two forms allows us to better model containers like
std::vector, which use "m_start != m_finish" to implement empty() but
"m_finish - m_start" to implement size(). The analyzer should have a
consistent interpretation of these two symbolic expressions, even though
it's not properly reasoning about either one yet.

The other unfortunate thing is that while the size() expression will only
ever be written "m_finish - m_start", the comparison may be written
"m_finish == m_start" or "m_start == m_finish". Right now the analyzer does
not attempt to canonicalize those two expressions, since it doesn't know
which length expression to pick. Doing this correctly will probably require
implementing unary minus as a new SymExpr kind (<rdar://problem/12351075>).

For now, the analyzer inverts the order of arguments in the comparison to
build the subtraction, on the assumption that "begin() != end()" is
written more often than "end() != begin()". This is purely speculation.

<rdar://problem/13239003>

llvm-svn: 177801
2013-03-23 01:21:16 +00:00
Jordan Rose 3b4c3ea2fb [analyzer] Use SymExprs to represent '<loc> - <loc>' and '<loc> == <loc>'.
We just treat this as opaque symbols, but even that allows us to handle
simple cases where the same condition is tested twice. This is very common
in the STL, which means that any project using the STL gets spurious errors.

Part of <rdar://problem/13239003>.

llvm-svn: 177800
2013-03-23 01:21:05 +00:00
Fariborz Jahanian be8bc67b66 documentation parsing: when providing code completion comment
for a getter used in property-dot syntax, if geter has its own
comment use it. // rdar://12791315

llvm-svn: 177797
2013-03-23 01:10:45 +00:00
Anna Zaks 130df4b0a4 [analyzer] Warn when a nil key or value are passed to NSMutableDictionary and ensure it works with subscripting.
llvm-svn: 177789
2013-03-23 00:39:21 +00:00
Anna Zaks 911a7c9e03 [analyzer] Correct the stale comment.
llvm-svn: 177788
2013-03-23 00:39:17 +00:00
Richard Smith f3e624ca73 If a .syms file is available alongside a sanitizer runtime, pass it to the
linker via --dynamic-list instead of using --export-dynamic. This reduces the
size of the dynamic symbol table, and thus of the binary (in some cases by up
to ~30%).

llvm-svn: 177783
2013-03-23 00:30:08 +00:00
Bill Wendling b3b4a37138 Use RequireCompleteType() instead of isIncompleteType().
isIncompleteType() returns true or false for template types depending on whether
the type is instantiated yet. In this context, that's arbitrary. The better way
to check for a complete type is RequireCompleteType().

Thanks to Eli Friedman for noticing this!

<rdar://problem/12700799>

llvm-svn: 177768
2013-03-22 21:33:46 +00:00
Douglas Gregor 11ef0b7778 <rdar://problem/13479539> Only rebuild the global module cache when we're allowed to.
This eliminates excessive rebuilds of the global module cache.

llvm-svn: 177766
2013-03-22 21:26:48 +00:00
Jordan Rose 25fac2f6dc Revert "[analyzer] Break cycles (optionally) when trimming an ExplodedGraph."
The algorithm used here was ridiculously slow when a potential back-edge
pointed to a node that already had a lot of successors. The previous commit
makes this feature unnecessary anyway.

This reverts r177468 / f4cf6b10f863b9bc716a09b2b2a8c497dcc6aa9b.

Conflicts:

	lib/StaticAnalyzer/Core/BugReporter.cpp

llvm-svn: 177765
2013-03-22 21:15:33 +00:00
Jordan Rose f342adef47 [analyzer] Use a forward BFS instead of a reverse BFS to find shortest paths.
For a given bug equivalence class, we'd like to emit the report with the
shortest path. So far to do this we've been trimming the ExplodedGraph to
only contain relevant nodes, then doing a reverse BFS (starting at all the
error nodes) to find the shortest paths from the root. However, this is
fairly expensive when we are suppressing many bug reports in the same
equivalence class.

r177468-9 tried to solve this problem by breaking cycles during graph
trimming, then updating the BFS priorities after each suppressed report
instead of recomputing the whole thing. However, breaking cycles is not
a cheap operation because an analysis graph minus cycles is still a DAG,
not a tree.

This fix changes the algorithm to do a single forward BFS (starting from the
root) and to use that to choose the report with the shortest path by looking
at the error nodes with the lowest BFS priorities. This was Anna's idea, and
has the added advantage of requiring no update step: we can just pick the
error node with the next lowest priority to produce the next bug report.

<rdar://problem/13474689>

llvm-svn: 177764
2013-03-22 21:15:28 +00:00
Jordan Rose 73aa6f2178 [analyzer] Fix ExprEngine::ViewGraph to handle C++ initializers.
Debugging aid only, no functionality change.

llvm-svn: 177762
2013-03-22 21:15:16 +00:00
Argyrios Kyrtzidis eb663daeff [PCH/Modules] De/Serialize MacroInfos separately than MacroDirectives.
-Serialize the macro directives history into its own section
-Get rid of the macro updates section
-When de/serializing an identifier from a module, associate only one macro per
 submodule that defined+exported it.

llvm-svn: 177761
2013-03-22 21:12:57 +00:00
Argyrios Kyrtzidis 4f32da1ef5 [modules] When a MacroInfo object is deserialized, allocate and store its submodule ID.
llvm-svn: 177760
2013-03-22 21:12:51 +00:00
Reid Kleckner 407e8b642b [ms-cxxabi] Implement member data pointers for non-dynamic classes
Summary:
For non-dynamic classes (no virtual bases), member data pointers are
simple offsets from the base of the record.  Dynamic classes use an
aggregate for member data pointers and are therefore currently
unsupported.

Unlike Itanium, the ms ABI uses 0 to represent null for polymorphic
classes.  Non-polymorphic classes use -1 like Itanium, since 0 is a
valid field offset.

Reviewers: rjmccall

CC: timurrrr, cfe-commits

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

llvm-svn: 177753
2013-03-22 19:02:54 +00:00
Douglas Gregor 603cd869f7 <rdar://problem/13479539> Simplify ModuleManager/GlobalModuleIndex interaction to eliminate a pile of extraneous stats().
The refactoring in r177367 introduced a serious performance bug where
the "lazy" resolution of module file names in the global module index
to actual module file entries in the module manager would perform
repeated negative stats(). The new interaction requires the module
manager to inform the global module index when a module file has been
loaded, eliminating the extraneous stat()s and a bunch of bookkeeping
on both sides.

llvm-svn: 177750
2013-03-22 18:50:14 +00:00
Fariborz Jahanian 1fcf4921af documentation parsing. Provide code completion comment
for self.GetterName where GetterName is the getter method 
for a property with name different from the property name 
(declared via a property getter attribute) // rdar://12791315

llvm-svn: 177744
2013-03-22 17:55:27 +00:00
Daniel Jasper dd9276e464 Better fix for r177725.
It turns out that

-foo;

can be an objective C method declaration. So instead of the previous
solution, recognize objective C methods only if we are in a declaration
scope.

llvm-svn: 177740
2013-03-22 16:55:40 +00:00
Daniel Jasper bc0fa39d69 Align comments to surrounding unformatted comments.
Before:
int a; // not formatted
// formatting this line only

After:
int a; // not formatted
       // formatting this line only

This makes clang-format stable independent of whether the whole
file or single lines are formatted in most cases.

llvm-svn: 177739
2013-03-22 16:25:51 +00:00
Reid Kleckner 9cffbc1873 [cxxabi] Get ptrdiff_t from the CodeGenModule instead of caching it
As the comment says, it's a little silly to cache it in the ABI code.

llvm-svn: 177738
2013-03-22 16:13:10 +00:00
Daniel Jasper 399d1ee5a0 More precisely recognize ObjC method declarations.
Otherwise, +/- and the beginning of constants can be recognized
incorrectly.

Before:  #define A - 1
After:   #define A -1
llvm-svn: 177725
2013-03-22 10:44:43 +00:00
Daniel Jasper 689ae01244 Fix DeclRefExpr::getFoundDecl() for usages by reference.
llvm-svn: 177721
2013-03-22 10:01:35 +00:00
Daniel Jasper 5521365248 Make clang-format understand more line comments.
Apparently one needs to set LangOptions.LineComment.

Before "//* */" got reformatted to "/ /* */" as the lexer was returning
the token sequence (slash, comment). This could also lead to weird other
stuff, e.g. for people that like to using comments like:
//****************

llvm-svn: 177720
2013-03-22 10:01:29 +00:00
Alexey Bataev a769e07232 OpenMP threadprivate directive parsing and semantic analysis
llvm-svn: 177705
2013-03-22 06:34:35 +00:00
John McCall cda8083309 Warn about attempts to reinterpret_cast between two types that are
hierarchy-related at a possibly nonzero offset.

Patch by Alexander Zinenko!

llvm-svn: 177698
2013-03-22 02:58:14 +00:00
John McCall eaef89b197 Fix a crash-on-valid where a block capture copy expression was
picking up cleanups from earlier in the statement.  Also fix a
crash-on-invalid where a reference to an invalid decl from an
enclosing scope was causing an expression to fail to build, but
only *after* a cleanup was registered from that statement,
causing an assertion downstream.

The crash-on-valid is rdar://13459289.

llvm-svn: 177692
2013-03-22 02:10:40 +00:00
Richard Smith 48366f7af9 ubsan: Pass floating-point arguments to the runtime by value if they fit the
value argument. If not, be sure we don't accidentally use a dynamic alloca.

llvm-svn: 177690
2013-03-22 00:47:07 +00:00
Douglas Gregor 96efb4a442 <rdar://problem/13479214> Make Clang's <stddef.h> robust against system headers defining size_t/ptrdiff_t/wchar_t.
Clang's <stddef.h> provides definitions for the C standard library
types size_t, ptrdiff_t, and wchar_t. However, the system's C standard
library headers tend to provide the same typedefs, and the two
generally avoid each other using the macros
_SIZE_T/_PTRDIFF_T/_WCHAR_T. With modules, however, we need to see
*all* of the places where these types are defined, so provide the
typedefs (ignoring the macros) when modules are enabled.

llvm-svn: 177686
2013-03-22 00:10:49 +00:00
Douglas Gregor 23c7d67de2 <rdar://problem/13477190> Give the Clang module cache directory some structure, so it's easier to find.
We now put the Clang module cache in
<system-temp-directory>/org.llvm.clang/ModuleCache. Perhaps some day
there will be other caches under <system-temp-directory>/org.llvm.clang>.

llvm-svn: 177671
2013-03-21 21:48:48 +00:00
David Blaikie 9db060485c Fix indentation
llvm-svn: 177665
2013-03-21 21:35:15 +00:00
Fariborz Jahanian 1446b34629 Objective-C: Tighten the rules when warning
is issused for on overriding 'readwrite'
property which is not auto-synthesized.
Buttom line is that if hueristics determine
that there will be a user implemented setter,
no warning will be issued. // rdar://13388503

llvm-svn: 177662
2013-03-21 20:50:53 +00:00
Benjamin Kramer 3d0235e16e Remove unused variable.
llvm-svn: 177657
2013-03-21 19:47:38 +00:00
Benjamin Kramer 5fbe2629ff Avoid warnings from compilers that think you can drop off the end of a fully covered switch.
llvm-svn: 177656
2013-03-21 19:45:46 +00:00
Jordan Rose e4bdb1016e [analyzer] Print return values from debug.DumpCalls checker.
Debug utility only, no functionality change.

llvm-svn: 177649
2013-03-21 18:16:59 +00:00
Alexander Kornienko 547a9f5264 Better block comment formatting.
Summary:
1. When splitting one-line block comment, use indentation and *s.
2. Remove trailing whitespace from all lines of a comment, not only the ones being splitted.
3. Add backslashes for all lines if a comment is used insed a preprocessor directive.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 177635
2013-03-21 12:28:10 +00:00
Alexander Potapenko 5700f40d80 [ASan] Let the users to invoke `clang -fsanitize=address` to link binaries targeting the iOS simulator.
llvm-svn: 177633
2013-03-21 10:49:06 +00:00
Douglas Gregor 0339a64a40 <rdar://problem/13037793> Allow the names of modules to differ from the name of their subdirectory in the include path.
llvm-svn: 177621
2013-03-21 01:08:50 +00:00
John McCall 433c2e64f8 Further weaken block conversion rules to permit blocks with
enum return type to be converted to blocks with any integer type
of the same size.

rdar://13463504

llvm-svn: 177613
2013-03-21 00:10:07 +00:00
Richard Smith cff3cde28b Split ubsan runtime into three pieces (clang part):
* libclang_rt-san-* is sanitizer_common, and is linked in only if no other
   sanitizer runtime is present.
 * libclang_rt-ubsan-* is the piece of the runtime which doesn't depend on
   a C++ ABI library, and is always linked in.
 * libclang_rt-ubsan_cxx-* is the piece of the runtime which depends on a
   C++ ABI library, and is only linked in when linking a C++ binary.

This change also switches us to using -whole-archive for the ubsan runtime
(which is made possible by the above split), and switches us to only linking
the sanitizer runtime into the main binary and not into DSOs (which is made
possible by using -whole-archive).

The motivation for this is to only link a single copy of sanitizer_common
into any binary. This is becoming important now because we want to share
more state between multiple sanitizers in the same process (for instance,
we want a single shared output mutex).

The Darwin ubsan runtime is unchanged; because we use a DSO there, we don't
need this complexity.

llvm-svn: 177605
2013-03-20 23:49:07 +00:00
Reid Kleckner 831b71e0b5 [ms-cxxabi] Mangle function pointer template arguments correctly
Reviewers: rjmccall

CC: timurrrr, llvm-commits

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

llvm-svn: 177589
2013-03-20 22:29:42 +00:00
Jordan Rose 3b6af191d8 [analyzer] Appease buildbots: include template arguments in base class ref.
llvm-svn: 177583
2013-03-20 21:44:17 +00:00
James Dennett 83942a9bf8 Documentation cleanup for MacroInfo.
* Clarify what MacroInfo::isBuiltinMacro means, as it really means something
  more like "isMagicalMacro" or "requiresProcessingBeforeExpansion" -- the
  macros defined in "<built-in>" are not considered built-in by this function;
* Escape __LINE__ as \__LINE__ in Doxygen comments so that the underscores
  don't get replaced by *bold* output;
* Turn comments in MacroInfo.cpp into non-Doxygen comments, so that they
  don't result in duplicated/badly formatted Doxygen output;
* Clean up a bunch of \brief formatting, and add a \file comment for
  MacroInfo.h.

llvm-svn: 177581
2013-03-20 21:30:03 +00:00
Douglas Gregor fb9126578e <rdar://problem/12368093> Extend module maps with a 'conflict' declaration, and warn when a newly-imported module conflicts with an already-imported module.
llvm-svn: 177577
2013-03-20 21:10:35 +00:00
Jordan Rose 28c68a2d07 [analyzer] Don't invalidate globals when there's no call involved.
This fixes some mistaken condition logic in RegionStore that caused
global variables to be invalidated when /any/ region was invalidated,
rather than only as part of opaque function calls. This was only
being used by CStringChecker, and so users will now see that strcpy()
and friends do not invalidate global variables.

Also, add a test case we don't handle properly: explicitly-assigned
global variables aren't being invalidated by opaque calls. This is
being tracked by <rdar://problem/13464044>.

llvm-svn: 177572
2013-03-20 20:36:01 +00:00
Jordan Rose 5d22fcb257 [analyzer] Track malloc'd memory into struct fields.
Due to improper modelling of copy constructors (specifically, their
const reference arguments), we were producing spurious leak warnings
for allocated memory stored in structs. In order to silence this, we
decided to consider storing into a struct to be the same as escaping.
However, the previous commit has fixed this issue and we can now properly
distinguish leaked memory that happens to be in a struct from a buffer
that escapes within a struct wrapper.

Originally applied in r161511, reverted in r174468.
<rdar://problem/12945937>

llvm-svn: 177571
2013-03-20 20:35:57 +00:00
Jordan Rose 5413aaa791 [analyzer] Invalidate regions indirectly accessible through const pointers.
In this case, the value of 'x' may be changed after the call to indirectAccess:

  struct Wrapper {
    int *ptr;
  };

  void indirectAccess(const Wrapper &w);

  void test() {
    int x = 42;
    Wrapper w = { x };

    clang_analyzer_eval(x == 42); // TRUE
    indirectAccess(w);
    clang_analyzer_eval(x == 42); // UNKNOWN
  }

This is important for modelling return-by-value objects in C++, to show
that the contents of the struct are escaping in the return copy-constructor.

<rdar://problem/13239826>

llvm-svn: 177570
2013-03-20 20:35:53 +00:00
Jordan Rose 153c81b7c4 [analyzer] Remove strip of ElementRegion in CallEvent::invalidateRegions.
This is a bit of old code trying to deal with the fact that functions that
take pointers often use them to access an entire array via pointer
arithmetic. However, RegionStore already conservatively assumes you can use
pointer arithmetic to access any part of a region.

Some day we may want to go back to handling this specifically for calls,
but we can do that in the future.

No functionality change.

llvm-svn: 177569
2013-03-20 20:35:48 +00:00
Fariborz Jahanian 0b171939dc Do the error recovery for @end only.
I am not sure how much we can improve for
when a randon ObjC keyword is thrown into the
ivar decl. block. // rdar://6854840

llvm-svn: 177553
2013-03-20 18:45:49 +00:00
Fariborz Jahanian 089f39ec06 Objective-C [qoi] more gracefull recovery when
'}' is missing for the ivar declarations.
// rdar://6854840

llvm-svn: 177549
2013-03-20 18:09:33 +00:00
David Blaikie 5e026f55e9 PR7256: Provide a fixit for incorrect destructor declarations
Fix by Ismail Pazarbasi (ismail.pazarbasi@gmail.com), review by Dmitri Gribenko.

llvm-svn: 177546
2013-03-20 17:42:13 +00:00
Douglas Gregor 2bb719f3a9 Only introduce the SDKSettings.plist dependency in modules/PCH files that don't depend on any other modules or PCH files.
llvm-svn: 177542
2013-03-20 16:59:53 +00:00
Manman Ren 0175461296 Exploit this-return of a callsite in a this-return function.
For constructors/desctructors that return 'this', if there exists a callsite
that returns 'this' and is immediately before the return instruction, make
sure we are using the return value from the callsite.

We don't need to keep 'this' alive through the callsite. It also enables
optimizations in the backend, such as tail call optimization.

Updated from r177211.
rdar://12818789

llvm-svn: 177541
2013-03-20 16:59:38 +00:00
Alexander Kornienko 674be0a3da Support for pointers-to-members usage via .*
Summary: Added support for pointers-to-members usage via .* and a few tests.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 177537
2013-03-20 16:41:56 +00:00
Daniel Jasper 291f936351 Remove assertion that can be triggered on bad input.
clang-format can't do anything useful, so it should leave the remainder
of the line unchanged, but it should not assert/segfault.

llvm-svn: 177530
2013-03-20 15:58:10 +00:00
Daniel Jasper 1a32a61ad4 Fix infinite-loop in unwrapped line parser.
Discovered when accidentally formatting a python file :-).

llvm-svn: 177527
2013-03-20 15:12:38 +00:00
Daniel Jasper 66dc2ec30b Do not consider comments when adjusting to local indent style.
Before (when only reformatting "int b"):
int a; // comment
       // comment
       int b;

After:
int a; // comment
       // comment
int b;

This also fixes llvm.org/PR15433.

llvm-svn: 177524
2013-03-20 14:31:47 +00:00
Daniel Jasper aab220f307 Reduce penalty for breaks after "(" for functions with parameters.
Before:
  aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
  aaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 177521
2013-03-20 13:53:11 +00:00
Daniel Jasper d1ae3588c6 Add extra indentation for multiline comparisons.
This seems to be generally more desired.

Before:
if (aaaaaaaa &&
    bbbbbbbb >
    cccccccc) {}
After:
if (aaaaaaaa &&
    bbbbbbbb >
        cccccccc) {}

Also: Some formatting cleanup on clang-format's files.
llvm-svn: 177514
2013-03-20 12:37:50 +00:00
Daniel Jasper a127512cb4 Don't remove all indentation when in #defines.
Otherwise, this can become hard to read.

Before: #define A \
        case 1:
After:  #define A \
           case 1:
llvm-svn: 177509
2013-03-20 10:23:53 +00:00
Daniel Jasper b8914dd471 Improve formatting of function types in template parameters.
Before: A<int * (int)>;
After:  A<int *(int)>;
llvm-svn: 177505
2013-03-20 09:53:18 +00:00
Hans Wennborg c5f4c36029 Fix redundant comparison in gcc::Common::ConstructJob.
We were checking "Arch == llvm::Triple::x86_64 || Arch
== llvm::Triple::x86_64", but the rhs should actually check for
powerpc64.

Found while experimenting with a potential new Clang warning.

llvm-svn: 177496
2013-03-20 07:34:27 +00:00
John McCall 80de23edf4 Remove some dead code.
Patch by Stephen Lin!

llvm-svn: 177490
2013-03-20 06:22:14 +00:00
Douglas Gregor 8d93242709 Make sure that Module::ConfigMacrosExhaustive gets initialized and deserialized correctly.
This fixes regressions introduced in r177466 that caused several
module tests to fail sporadically.

llvm-svn: 177481
2013-03-20 03:59:18 +00:00
Richard Smith 22c7c4131a Teach statement / declaration disambiguation about C++11-style generalized initializers.
llvm-svn: 177480
2013-03-20 03:35:02 +00:00
Rafael Espindola 7cf32219a7 Remove the Tools DensMap from the toolchain.
Each toolchain has a set of tools, but they are all of known types. It can
have a linker, an assembler, a "clang" (compile, analyze, ...) a non-clang
compiler, etc.

Instead of keeping a map, just have member variable for each type of tool.

llvm-svn: 177479
2013-03-20 03:05:54 +00:00
Nick Lewycky 6f15b290b5 The flag "-coverage-function-names-in-data" is actually backwards -- we do
emit function names in .gcda files by default, and the flag turns that off!
Rename the flag to make it match what it actually does. This keeps the default
format compatible with gcc 4.2.

Also add a test for this flag.

llvm-svn: 177475
2013-03-20 02:14:38 +00:00
John McCall 3c581bf152 Don't look outside the innermost enclosing namespace when
performing unqualified lookup for a friend class declaration.

rdar://13393749

llvm-svn: 177473
2013-03-20 01:53:00 +00:00
Reid Kleckner 5251886cd8 [ms-cxxabi] Fix assertion on unhandled function template arg types
This code was changed in r158376 to get template argument source info
for better diagnostics, but the current code asserts for any kind of
unsupported template argument before it can issue a diagnostic.  This change
goes back to the Itanium implementation of isTemplate() and puts the argument
index into the diagnostic instead of a source location.

Review URL: http://llvm-reviews.chandlerc.com/D553

llvm-svn: 177471
2013-03-20 01:40:23 +00:00
Nick Lewycky c02bbb61e1 Make clang emit linkage names in debug info for subprograms when coverage info
is enabled. Also add a new -test-coverage cc1 flag which makes testing coverage
possible and add our first clang-side coverage test.

llvm-svn: 177470
2013-03-20 01:38:16 +00:00
Jordan Rose 86e04ceaad [analyzer] Re-apply "Do part of the work to find shortest bug paths up front".
With the assurance that the trimmed graph does not contain cycles,
this patch is safe (with a few tweaks), and provides the performance
boost it was intended to.

Part of performance work for <rdar://problem/13433687>.

llvm-svn: 177469
2013-03-20 00:35:37 +00:00
Jordan Rose 34e19a1d1d [analyzer] Break cycles (optionally) when trimming an ExplodedGraph.
Having a trimmed graph with no cycles (a DAG) is much more convenient for
trying to find shortest paths, which is exactly what BugReporter needs to do.

Part of the performance work for <rdar://problem/13433687>.

llvm-svn: 177468
2013-03-20 00:35:31 +00:00
Douglas Gregor 35b13ece23 <rdar://problem/10796651> Introduce configuration macros into module maps.
Configuration macros are macros that are intended to alter how a
module works, such that we need to build different module variants
for different values of these macros. A module can declare its
configuration macros, in which case we will complain if the definition
of a configation macro on the command line (or lack thereof) differs
from the current preprocessor state at the point where the module is
imported. This should eliminate some surprises when enabling modules,
because "#define CONFIG_MACRO ..." followed by "#include
<module/header.h>" would silently ignore the CONFIG_MACRO setting. At
least it will no longer be silent about it.

Configuration macros are eventually intended to help reduce the number
of module variants that need to be built. When the list of
configuration macros for a module is exhaustive, we only need to
consider the settings for those macros when building/finding the
module, which can help isolate modules for various project-specific -D
flags that should never affect how modules are build (but currently do).

llvm-svn: 177466
2013-03-20 00:22:05 +00:00
Anna Zaks 3f4fad92fe [analyzer] Do not believe lazy binding when symbolic region types do not match
This fixes a crash when analyzing LLVM that was exposed by r177220 (modeling of
trivial copy/move assignment operators).

When we look up a lazy binding for “Builder”, we see the direct binding of Loc at offset 0.
Previously, we believed the binding, which led to a crash. Now, we do not believe it as
the types do not match.

llvm-svn: 177453
2013-03-19 22:38:09 +00:00
Jordan Rose 431e4e4d0e Revert "[analyzer] Do part of the work to find shortest bug paths up front."
The whole reason we were doing a BFS in the first place is because an
ExplodedGraph can have cycles. Unfortunately, my removeErrorNode "update"
doesn't work at all if there are cycles.

I'd still like to be able to avoid doing the BFS every time, but I'll come
back to it later.

This reverts r177353 / 481fa5071c203bc8ba4f88d929780f8d0f8837ba.

llvm-svn: 177448
2013-03-19 22:10:35 +00:00
Fariborz Jahanian 1c5d4c54a9 Objective-C [qoi]: Provide improved parse diagnostics when
closing rbrace is missing in an ObjC class declaration.
Can do beter than this, but it involves addition of
overhead which will be present in correct code.
// rdar://6854840

llvm-svn: 177435
2013-03-19 20:27:40 +00:00
Daniel Jasper 2bd32ca92a Fix indentation for case: // comment.
Before:
switch (x) {
case 1:
    // Do amazing stuff
    {
  g();
  f();
}
}

After:
switch (x) {
case 1:
  // Do amazing stuff
  {
    g();
    f();
  }
}

llvm-svn: 177420
2013-03-19 18:33:58 +00:00
Alexander Kornienko afcef33de7 Split long lines in multi-line comments.
Summary: This is implementation for /* */ comments only.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

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

llvm-svn: 177415
2013-03-19 17:41:36 +00:00
Rafael Espindola 513499d0ad Don't try to set attributes in alias, they have none.
llvm-svn: 177402
2013-03-19 15:03:47 +00:00
Rafael Espindola a0851a2cb0 Revert r177329.
If this should not happen, we should have an assert.
If it should happen, we should have a test and remove the comment.

In no case should we have this self inconsistent code.

llvm-svn: 177399
2013-03-19 14:32:23 +00:00
Rafael Espindola a5981ba8ef Go back to using the integrated assembler on windows ever when passed
-no-integrated-as. It is the only assembler we have there.

llvm-svn: 177398
2013-03-19 14:23:00 +00:00
Alexey Samsonov b2b0e3f00a [ASan] Make -fsanitize=address always imply -fsanitize=init-order
llvm-svn: 177391
2013-03-19 10:48:37 +00:00
John McCall 5ec7e7def3 Add a clarifying note when a return statement is rejected because
we expect a related result type.

rdar://12493140

llvm-svn: 177378
2013-03-19 07:04:25 +00:00
Douglas Gregor 2f1806e83f Minor optimization to r177367 to treat a module with missing dependencies as out-of-date rather than missing.
llvm-svn: 177369
2013-03-19 00:38:50 +00:00
Rafael Espindola d15a8918fb Finish refactoring the tool selection logic.
The general pattern now is that Foobar::constructTool only creates tools
defined in the tools::foobar namespace and then delegates to the parent.

The remaining duplicated code is now in the tools themselves.

llvm-svn: 177368
2013-03-19 00:36:57 +00:00
Douglas Gregor 7029ce1a0c <rdar://problem/13363214> Eliminate race condition between module rebuild and the global module index.
The global module index was querying the file manager for each of the
module files it knows about at load time, to prune out any out-of-date
information. The file manager would then cache the results of the
stat() falls used to find that module file.

Later, the same translation unit could end up trying to import one of the
module files that had previously been ignored by the module cache, but
after some other Clang instance rebuilt the module file to bring it
up-to-date. The stale stat() results in the file manager would
trigger a second rebuild of the already-up-to-date module, causing
failures down the line.

The global module index now lazily resolves its module file references
to actual AST reader module files only after the module file has been
loaded, eliminating the stat-caching race. Moreover, the AST reader
can communicate to its caller that a module file is missing (rather
than simply being out-of-date), allowing us to simplify the
module-loading logic and allowing the compiler to recover if a
dependent module file ends up getting deleted.

llvm-svn: 177367
2013-03-19 00:28:20 +00:00
Richard Smith 4af40c4083 PR15383: When -fsanitize=float-cast-overflow checks a float-to-int conversion,
it wasn't taking into account that the float should be truncated *before* the
range check happens. Thus (unsigned)-0.99 and (unsigned char)255.9 have defined
behavior and should not be trapped.

llvm-svn: 177362
2013-03-19 00:01:12 +00:00
Rafael Espindola 0add40ed7d Centralize the logic for using the integrated assembler.
llvm-svn: 177360
2013-03-18 23:56:07 +00:00
Fariborz Jahanian abbcbaeb4c documentation comment parsing. Added couple of
top-level HeaderDoc tags @functiongroup and
@methodgroup to doc. tags recognized.
// rdar://12379114 

llvm-svn: 177358
2013-03-18 23:45:52 +00:00
Richard Smith 9cf21ae068 Diagnose uses of 'alignof' on functions in -pedantic mode.
llvm-svn: 177354
2013-03-18 23:37:25 +00:00
Jordan Rose 2d0edec994 [analyzer] Do part of the work to find shortest bug paths up front.
Splitting the graph trimming and the path-finding (r177216) already
recovered quite a bit of performance lost to increased suppression.
We can still do better by also performing the reverse BFS up front
(needed for shortest-path-finding) and only walking the shortest path
for each report. This does mean we have to walk back up the path and
invalidate all the BFS numbers if the report turns out to be invalid,
but it's probably still faster than redoing the full BFS every time.

More performance work for <rdar://problem/13433687>

llvm-svn: 177353
2013-03-18 23:34:37 +00:00
Jordan Rose ee47a5bd92 [analyzer] Replace uses of assume() with isNull() in BR visitors.
Also, replace a std::string with a SmallString.

No functionality change.

llvm-svn: 177352
2013-03-18 23:34:32 +00:00
David Blaikie 1dc4a3dfd6 PR15539: Record "evaluating if/elif condition" flag in the right place
The previous implementation missed the case where the elif condition was
evaluated from the context of an #ifdef that was false causing PR15539.

llvm-svn: 177345
2013-03-18 23:22:28 +00:00
Argyrios Kyrtzidis c00f43a33f [frontend] Initialize the diagnostic client before loading an ast file.
Issue reported by Tom Honermann!
http://llvm.org/bugs/show_bug.cgi?id=15377

llvm-svn: 177336
2013-03-18 22:55:24 +00:00
Richard Smith b1402ae94e Add missing diagnostic for a nested-name-specifier on a free-standing type definition. Bump some related diagnostics from warning to extension in C++, since they're errors there. Add some missing checks for function specifiers on non-function declarations.
llvm-svn: 177335
2013-03-18 22:52:47 +00:00
Argyrios Kyrtzidis ca370b0d1f [PCH] Fix assertion hit related to enum decls inside templated funtions.
Report and suggested fix by Tom Honermann!
http://llvm.org/bugs/show_bug.cgi?id=13020

llvm-svn: 177330
2013-03-18 22:23:49 +00:00
Reed Kotler 7ee730414d This code works around what appears to be a bug in another part of clang.
I have filed http://llvm.org/bugs/show_bug.cgi?id=15538 against clang.
This code is safer anyway because "cast" assumes you really know that
it's okay to make the cast. In this case isa should not be false and
dyn_cast should not return null as far as I understand. But everything
else is valid so I did not want to revert my previous patch for attributes
mips16/nomips16 or use an llvm_unreachable here which would make a number
of our tests fail for mips.

llvm-svn: 177329
2013-03-18 22:18:00 +00:00
Richard Smith c2bc61b006 Bring inheriting constructor implementation up-to-date with current defect
reports, and implement implicit definition of inheriting constructors.
Remaining missing features: inheriting constructor templates, implicit
exception specifications for inheriting constructors, inheriting constructors
from dependent bases.

llvm-svn: 177320
2013-03-18 21:12:30 +00:00
Rafael Espindola 260e28d65a Centralize the recording of which tools have been constructed.
llvm-svn: 177319
2013-03-18 20:48:54 +00:00
Anna Zaks 6457ad2335 [analyzer] Warn when a ‘nil’ object is added to NSArray or NSMutableArray.
llvm-svn: 177318
2013-03-18 20:46:56 +00:00
Fariborz Jahanian e0a75d67a3 Objective-C modern translator. Don't put line info
into the pre-preprocessed file to be passed to
modern translator when compiling in no debug mode.
// rdar://13138170

llvm-svn: 177311
2013-03-18 19:41:18 +00:00
Rafael Espindola c8e3a0162b Use early returns when checking if we already constructed a tool and when
delegating to Generic_GCC::SelectTool (it already updates the tool map).

llvm-svn: 177305
2013-03-18 18:50:01 +00:00
Rafael Espindola 30212ab363 Remove unused argument.
llvm-svn: 177303
2013-03-18 18:19:46 +00:00
Rafael Espindola 84b588b25c Pass an ArgList to every toolchain constructor. Remove the useIntegratedAs
argument.

llvm-svn: 177301
2013-03-18 18:10:27 +00:00
Rafael Espindola 878d2da6ab Inline ShouldUseIntegratedAssembler and move the documentation to
useIntegratedAs.

llvm-svn: 177300
2013-03-18 17:58:22 +00:00
Rafael Espindola 248e219760 Refactor a bit of duplicated code to useIntegratedAs.
llvm-svn: 177299
2013-03-18 17:52:57 +00:00
Rafael Espindola 88b55ead59 Remove unused argument.
llvm-svn: 177293
2013-03-18 17:25:58 +00:00
Rafael Espindola 2f69d405cc Remove unused argument.
llvm-svn: 177287
2013-03-18 15:33:26 +00:00
Daniel Jasper 850677d94a Fix clang-format segfault.
When annotating "lines" starting with ":", clang-format would segfault.
This could actually happen in valid code, e.g.
  #define A :

llvm-svn: 177283
2013-03-18 12:50:26 +00:00
Anton Korobeynikov 2bed8472d1 Make sure to use same EABI version for external assembler as for integrated as.
Patch by Andrew Turner!

llvm-svn: 177252
2013-03-18 07:59:20 +00:00
Manman Ren c089074aa5 revert r177211 due to its potential issues
llvm-svn: 177222
2013-03-16 04:47:38 +00:00
Jordan Rose 3d7b7f5268 [analyzer] Model trivial copy/move assignment operators with a bind as well.
r175234 allowed the analyzer to model trivial copy/move constructors as
an aggregate bind. This commit extends that to trivial assignment
operators as well. Like the last commit, one of the motivating factors here
is not warning when the right-hand object is partially-initialized, which
can have legitimate uses.

<rdar://problem/13405162>

llvm-svn: 177220
2013-03-16 02:14:06 +00:00
Argyrios Kyrtzidis 3065a0fce4 Remove -Wspellcheck and replace it with a diagnostic option.
Thanks to Richard S. for pointing out that the warning would show up
with -Weverything.

llvm-svn: 177218
2013-03-16 01:40:35 +00:00
Jordan Rose 7a007bfbad [analyzer] Separate graph trimming from creating the single-path graph.
When we generate a path diagnostic for a bug report, we have to take the
full ExplodedGraph and limit it down to a single path. We do this in two
steps: "trimming", which limits the graph to all the paths that lead to
this particular bug, and "creating the report graph", which finds the
shortest path in the trimmed path to any error node.

With BugReporterVisitor false positive suppression, this becomes more
expensive: it's possible for some paths through the trimmed graph to be
invalid (i.e. likely false positives) but others to be valid. Therefore
we have to run the visitors over each path in the graph until we find one
that is valid, or until we've ruled them all out. This can become quite
expensive.

This commit separates out graph trimming from creating the report graph,
performing the first only once per bug equivalence class and the second
once per bug report. It also cleans up that portion of the code by
introducing some wrapper classes.

This seems to recover most of the performance regression described in my
last commit.

<rdar://problem/13433687>

llvm-svn: 177216
2013-03-16 01:07:58 +00:00
Jordan Rose 0833c84a50 [analyzer] Eliminate InterExplodedGraphMap class and NodeBackMap typedef.
...in favor of this typedef:

  typedef llvm::DenseMap<const ExplodedNode *, const ExplodedNode *>
          InterExplodedGraphMap;

Use this everywhere the previous class and typedef were used.

Took the opportunity to ArrayRef-ize ExplodedGraph::trim while I'm at it.

No functionality change.

llvm-svn: 177215
2013-03-16 01:07:53 +00:00
Jordan Rose 5315931105 [analyzer] Don't repeat a bug equivalence class if every report is invalid.
I removed this check in the recursion->iteration commit, but forgot that
generatePathDiagnostic may be called multiple times if there are multiple
PathDiagnosticConsumers.

llvm-svn: 177214
2013-03-16 01:07:47 +00:00
Manman Ren 58dd990c11 Exploit this-return of a callsite in a this-return function.
For constructors/desctructors that return 'this', if there exists a callsite
that returns 'this' and is immediately before the return instruction, make
sure we are using the return value from the callsite.

We don't need to keep 'this' alive through the callsite. It also enables
optimizations in the backend, such as tail call optimization.

rdar://12818789

llvm-svn: 177211
2013-03-16 00:11:09 +00:00
Richard Trieu 64ab30392d Improve template diffing handling of default integer values.
When the template argument is both default and value dependent, the expression
retrieved for the default argument cannot be evaluated, thus never matching
any argument value.  To get the proper value, get the template argument
from the desugared template specialization.  Also, output the original
expression to provide more information about the argument mismatch.

llvm-svn: 177209
2013-03-15 23:55:09 +00:00
Anna Zaks 0e4513b030 [analyzer] Address a TODO in the StreamChecker; otherwise the output is non-deterministic.
llvm-svn: 177207
2013-03-15 23:34:31 +00:00
Anna Zaks bda130f02a [analyzer] Use isLiveRegion to determine when SymbolRegionValue is dead.
Fixes a FIXME, improves dead symbol collection, suppresses a false positive,
which resulted from reusing the same symbol twice for simulation of 2 calls to the same function.

Fixing this lead to 2 possible false negatives in CString checker. Since the checker is still alpha and
the solution will not require revert of this commit, move the tests to a FIXME section.

llvm-svn: 177206
2013-03-15 23:34:29 +00:00
Anna Zaks e0f1a0f0d8 [analyzer] BugReporterVisitors: handle the case where a ternary operator is wrapped in a cast.
llvm-svn: 177205
2013-03-15 23:34:25 +00:00
Anna Zaks 313b101e27 [analyzer] Address Jordan’s review of r177138 (a micro optimization)
llvm-svn: 177204
2013-03-15 23:34:22 +00:00
Ted Kremenek 90d7fa12d0 Fix buffer underrun (invalid read) triggered during diagnostic rendering. The test would overflow when computing '0 - 1'.
I don't have a good testcase for this that does not depend on system headers.
It did not trigger with preprocessed output, and I had trouble reducing the example.

Fixes <rdar://problem/13324594>.

Thanks to Michael Greiner for reporting this issue.

llvm-svn: 177201
2013-03-15 23:09:37 +00:00
Argyrios Kyrtzidis 0aef0f032f [modules] Don't record the macros from the predefines buffer.
These will be available in the current translation unit anyway, for
modules they only waste space and deserialization time.

llvm-svn: 177197
2013-03-15 22:43:10 +00:00
Douglas Gregor 49491f7861 <rdar://problem/13426257> Introduce SDKSettings.plist as an input file dependency for PCH/modules.
When we're building a precompiled header or module against an SDK on
Darwin, there will be a file SDKSettings.plist in the sysroot. Since
stat()'ing every system header on which a module or PCH file depends
is performance suicide, we instead stat() just SDKSettings.plist. This
hack works well on Darwin; it's unclear how we want to handle this on
other platforms. If there is a canonical file, we should use it; if
not, we either have to take the performance hit of stat()'ing system
headers repeatedly or roll the dice by not checking anything.

llvm-svn: 177194
2013-03-15 22:15:07 +00:00
Ted Kremenek e943ce1ace Simplify print logic, per feedback from Jordan Rose.
llvm-svn: 177193
2013-03-15 22:02:46 +00:00
Ted Kremenek b7d7dd4dbf Enhance -Wtautological-constant-out-of-range-compare to include the name of the enum constant.
This is QoI.  Fixes <rdar://problem/13076064>.

llvm-svn: 177190
2013-03-15 21:50:10 +00:00
Jordan Rose e42122e6b4 [analyzer] Make GRBugReporter::generatePathDiagnostic iterative, not recursive.
The previous generatePathDiagnostic() was intended to be tail-recursive,
restarting and trying again if a report was marked invalid. However:
 (1) this leaked all the cloned visitors, which weren't being deleted, and
 (2) this wasn't actually tail-recursive because some local variables had
     non-trivial destructors.

This was causing us to overflow the stack on inputs with large numbers of
reports in the same equivalence class, such as sqlite3.c. Being iterative
at least prevents us from blowing out the stack, but doesn't solve the
performance issue: suppressing thousands (yes, thousands) of paths in the
same equivalence class is expensive. I'm looking into that now.

<rdar://problem/13423498>

llvm-svn: 177189
2013-03-15 21:41:55 +00:00
Jordan Rose a45fc81180 [analyzer] Collect stats on the max # of bug reports in an equivalence class.
We discovered that sqlite3.c currently has 2600 reports in a single
equivalence class; it would be good to know if this is a recent
development or what.

(For the curious, the different reports in an equivalence class represent
the same bug found along different paths. When we're suppressing false
positives, we need to go through /every/ path to make sure there isn't a
valid path to a bug. This is a flaw in our after-the-fact suppression,
made worse by the fact that that function isn't particularly optimized.)

llvm-svn: 177188
2013-03-15 21:41:53 +00:00
Jordan Rose 06f68eda4d [analyzer] Include opcode in dumping a SymSymExpr.
For debugging use only; no functionality change.

llvm-svn: 177187
2013-03-15 21:41:50 +00:00
Jordan Rose ecaa7d2c3d [analyzer] Look through ExprWhenCleanups when trying to track a NULL.
Silences a few false positives in LLVM.

llvm-svn: 177186
2013-03-15 21:41:46 +00:00
Jordan Rose 755a2ffd79 Add some assertions to appease the static analyzer.
No functionality change.

llvm-svn: 177185
2013-03-15 21:41:35 +00:00
David Blaikie c28422445a Remove unnecessary default in covered switch over enum
This cleans up the Clang -Werror build that was broken by r177180.

llvm-svn: 177184
2013-03-15 21:12:54 +00:00
Daniel Dunbar 99514845df [AST] Add a fast path to ConstantArrayType::getNumAddressingBits().
- This fast path is almost 100% effective on real code, and lets us avoid
   multiple allocations of 128-bit APSInt objects in the common case.

 - As with any overflow-check-skipping-code, I'd appreciate someone double
   checking my logic.

llvm-svn: 177183
2013-03-15 20:55:27 +00:00
Fariborz Jahanian 28c781f039 c: perform integer overflow check on all binary
operations. // rdar://13423975

llvm-svn: 177181
2013-03-15 20:47:07 +00:00
Richard Trieu b4cff1184a Refactor template diffing to store an enum that records which type of
difference is stored inside a DiffNode.  This should not change any
diagnostic messages.

llvm-svn: 177180
2013-03-15 20:35:18 +00:00
Edwin Vane 34794c5b3d ClangTool output cleanup
Information messages sent to stdout by ClangTool now only happen when the
-debug flag is set.

Error messages that used to go to stdout now go to stderr.

Author: Ariel J Bernal <ariel.j.bernal@intel.com>
llvm-svn: 177177
2013-03-15 20:14:01 +00:00
Bob Wilson c8541f2bf2 Revert "Remove a pointless assertion."
This reverts commit r177158.

I'm blindly reverting this because it appears to be breaking numerous
buildbots.  I'll reapply if it doesn't turn out to be the culprit.

llvm-svn: 177165
2013-03-15 17:12:43 +00:00
Adrian Prantl 5acf8a3ac5 Force column info only for direct inlined functions. This should strike
the balance between expected behavior and compatibility with the gdb
testsuite.
(GDB gets confused if we break an expression into multiple debug
stmts so we enable this behavior only for inlined functions. For the
full experience people can still use -gcolumn-info.)

llvm-svn: 177164
2013-03-15 17:09:05 +00:00
Fariborz Jahanian 1c150a0d0d c: Also chek for integer overflow for '%' operator.
llvm-svn: 177163
2013-03-15 17:03:56 +00:00
Fariborz Jahanian 352eeafa0a c: add the missing binary operatory when checking
for integer overflow. // rdar://13423975

llvm-svn: 177162
2013-03-15 16:36:04 +00:00
Sylvestre Ledru e0bf581a81 Take in account the triplet 'powerpc-linux-gnuspe' for PowerPC SPE. Done for the port of Debian on this arch. More information on: http://wiki.debian.org/PowerPCSPEPort Patch by Roland Stigge
llvm-svn: 177161
2013-03-15 16:22:43 +00:00
Nico Weber 966b331251 Remove a pointless assertion.
FindNodeOrInsertPos() is called 10 lines earlier already, and the function
early-returns there if the result is != 0. InsertPos isn't recomputed after
that check, so this assert is always trivially true. (And it has nothing to
do with if T is canonical or not.)

llvm-svn: 177158
2013-03-15 15:02:37 +00:00
Daniel Jasper 9b33424d6f Improve formatting of chained calls.
clang-format already prevented sequences like:
  ...
  SomeParameter).someFunction(
  ...

as those are quite confusing. This failed on:
  ...
  SomeParameter).someFunction(otherFunction(
  ...

Fixed in this patch.

llvm-svn: 177157
2013-03-15 14:57:30 +00:00
Alexander Kornienko 79d6c72e0e Indent all lines in a multi-line comment by the same amount.
Summary:
Do this to avoid spoling nicely formatted multi-line comments (e.g.
with code examples or similar stuff).

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 177153
2013-03-15 13:42:02 +00:00
Anna Zaks e9c43ffb2a [analyzer] Refactor checks in IDC visitor for consistency and speed
llvm-svn: 177138
2013-03-15 01:15:14 +00:00
Anna Zaks 913b0d0078 [analyzer] Teach trackNullOrUndef to look through ternary operators
Allows the suppression visitors trigger more often.

llvm-svn: 177137
2013-03-15 01:15:12 +00:00
Richard Smith ad1bbb93d1 PR15290: 'this' is not permitted in the declaration of a friend function,
therefore references to members should not be transformed into implicit uses of
'this'. Patch by Ismail Pazarbasi!

llvm-svn: 177134
2013-03-15 00:41:52 +00:00
Fariborz Jahanian 95236b50ce Diagnose about extern "C" functions returning c++ objects
on first declaration only. // rdar://13364028

llvm-svn: 177127
2013-03-14 23:09:00 +00:00
Argyrios Kyrtzidis 3e56dd4fc9 Don't try to typo-correct 'super' in an objc method.
This created 2 issues:

1) Performance issue, since typo-correction with PCH/modules is rather expensive.
2) Correctness issue, since if it managed to "correct" 'super' then bogus compiler errors would
be emitted, like this:

3.m:8:3: error: unknown type name 'super'; did you mean 'super1'?
  super.x = 0;
  ^~~~~
  super1
t3.m:5:13: note: 'super1' declared here
typedef int super1;
            ^
t3.m:8:8: error: expected identifier or '('
  super.x = 0;
       ^

llvm-svn: 177126
2013-03-14 22:56:43 +00:00
Anna Zaks 2672a4cc0c [analyzer] Change the way in which IDC Visitor decides to kick in and make sure it attaches in the given edge case
In the test case below, the value V is not constrained to 0 in ErrorNode but it is in node N.
So we used to fail to register the Suppression visitor.

We also need to change the way we determine that the Visitor should kick in because the node N belongs to
the ExplodedGraph and might not be on the BugReporter path that the visitor sees. Instead of trying to match the node,
turn on the visitor when we see the last node in which the symbol is ‘0’.

llvm-svn: 177121
2013-03-14 22:31:56 +00:00
Adrian Prantl 616bef4ad1 Always declare the .block_descriptor parameter, not just the local copy.
Un-breaks gdb's invoke-block behavior.

llvm-svn: 177118
2013-03-14 21:52:59 +00:00
Douglas Gregor 7c5c3789c5 [PR15513/<rdar://problem/13409707>] Template arguments in diagnostics aren't always known at compile time.
llvm-svn: 177110
2013-03-14 20:44:43 +00:00
Adrian Prantl 51936dd0bc Allocate stack storage for .block_descriptor and captured self at -O0.
This way the register allocator will not optimize away the debug info
for captured variables.

Fixes rdar://problem/12767564

llvm-svn: 177086
2013-03-14 17:53:33 +00:00
Manuel Klimek b64d6b7fee Implements memoization for ancestor matching.
This yields a log(#ast_nodes) worst-case improvement with matchers like
stmt(unless(hasAncestor(...))).

Also made the order of visitation for ancestor matches BFS, as the most
common use cases (for example finding the closest enclosing function
definition) rely on that.

llvm-svn: 177081
2013-03-14 16:33:21 +00:00
Alexander Kornienko dd8ed854a0 Multi-line comment alignment
Summary:
Aligns continuation lines of multi-line comments to the base
indentation level +1:
class A {
  /*
   * test
   */
  void f() {}
};

The first revision is work in progress. The implementation is not yet complete.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 177080
2013-03-14 16:10:54 +00:00
Daniel Jasper f38a0ace2d Slightly improve formatting of longer pipe statements.
The stronger binding of a string ending in :/= does not really make
sense if it is the only character.

Before:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa
             << "=" << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

After:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << "="
             << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

llvm-svn: 177075
2013-03-14 14:00:17 +00:00
Daniel Jasper 40aacf4872 Basic support for formatting asm() statments.
llvm-svn: 177073
2013-03-14 13:45:21 +00:00
Alexey Samsonov 881d150cc7 [ASan] Make -fsanitize=address imply -fsanitize=init-order (if the latter is not explicitly disabled).
llvm-svn: 177061
2013-03-14 12:13:27 +00:00
Daniel Jasper ae9076457e Fix dereference formatting in for-loops.
Before: for (char **a = b; * a; ++a) {}
After:  for (char **a = b; *a; ++a) {}
llvm-svn: 177037
2013-03-14 10:50:25 +00:00
Joey Gouly 0608ae89a2 Add support for the 'endian' attribute for OpenCL.
llvm-svn: 177035
2013-03-14 09:54:43 +00:00
Daniel Jasper bf4755bb28 Improve formatting of trailing annotations.
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((
    unused));

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    __attribute__((unused));

llvm-svn: 177034
2013-03-14 09:50:46 +00:00
Nick Lewycky c8bf8249ce Update GCOVProfiling pass creation for API change in r177002. No functionality change.
llvm-svn: 177004
2013-03-14 05:14:01 +00:00
John McCall e68672fed2 Flag that friend function definitions are "late parsed" so that
template instantiation will still consider them to be definitions
if we instantiate the containing class before we get around
to parsing the friend.

This seems like a legitimate use of "late template parsed" to me,
but I'd appreciate it if someone responsible for the MS feature
would look over this.

This file already appears to access AST nodes directly, which
is arguably not kosher in the parser, but the performance of this
path matters enough that perpetuating the sin is justifiable.
Probably we ought to reconsider this policy for very simple
manipulations like this.

The reason this entire thing is necessary is that
function template instantiation plays some very gross games
in order to not associate an instantiated function template
with the class it came from unless it's a definition, and
the reason *that's* necessary is that the AST currently
cannot represent the instantiation history of individual
function template declarations, but instead tracks it in
common for the entire function template.  That probably
prevents us from correctly reporting ill-formed calls to
ambiguously instantiated friend function templates.

rdar://12350696

llvm-svn: 177003
2013-03-14 05:13:41 +00:00
Argyrios Kyrtzidis 59852367b4 [modules] Don't write the UnusedFileScopedDecls vector to the module file.
llvm-svn: 177001
2013-03-14 04:45:00 +00:00
Argyrios Kyrtzidis ffb3558beb [modules] Check for delegating constructor cycles when building a module and don't write them out to the module file.
llvm-svn: 177000
2013-03-14 04:44:56 +00:00
Rafael Espindola 0e0d00976f Avoid computing the linkage too early. Don't invalidate it.
Before this patch we would compute the linkage lazily and cache it. When the
AST was modified in ways that could change the value, we would invalidate the
cache.

That was fairly brittle, since any code could ask for the a linkage before
the correct value was available.

We should change the API to one where the linkage is computed explicitly and
trying to get it when it is not available asserts.

This patch is a first step in that direction. We still compute the linkage
lazily, but instead of invalidating a cache, we assert that the AST
modifications didn't change the result.

llvm-svn: 176999
2013-03-14 03:07:35 +00:00
Bill Wendling dabafea7d6 Have these attriubtes set to 'true' or 'false'.
The back-end cannot differentiate between functions that are from a .ll file and
those generated from the front-end. We cannot then take the non-precense of
these attributes as a "false" value. Have the front-end explicitly set the value
to 'true' or 'false' depending upon what is actually set.

llvm-svn: 176985
2013-03-13 22:24:33 +00:00
Argyrios Kyrtzidis b146baabad [Modules] Don't eagerly load and associate all the module header files.
In a module-enabled Cocoa PCH file, we spend a lot of time stat'ing the headers
in order to associate the FileEntries with their modules and support implicit
module import.

Use a more lazy scheme by enhancing HeaderInfoTable to store extra info about
the module that a header belongs to, and associate it with its module only when
there is a request for loading the header info for a particular file.

Part of rdar://13391765

llvm-svn: 176976
2013-03-13 21:13:51 +00:00
Argyrios Kyrtzidis 3c5305c15e [Modules] Resolve top-headers of modules lazily.
This allows resolving top-header filenames of modules to FileEntries when
we need them, not eagerly.

Note that that this breaks ABI for libclang functions
clang_Module_getTopLevelHeader / clang_Module_getNumTopLevelHeaders
but this is fine because they are experimental and not widely used yet.

llvm-svn: 176975
2013-03-13 21:13:43 +00:00
Reed Kotler 3d5966f31b Cause the mips16/nomips16 attribute to be passed to LLVM from Clang
in the LLVM assembly language output.

llvm-svn: 176971
2013-03-13 20:40:30 +00:00