Commit Graph

38746 Commits

Author SHA1 Message Date
Dmitri Gribenko 767ea0ff4a CommentBriefParser: remove dead store. Found by Clang Analyzer.
llvm-svn: 159673
2012-07-03 18:10:20 +00:00
Hal Finkel 6b984f084c Add additional architecture defines for PPC targets.
Patch by Andy Gibbs.

llvm-svn: 159665
2012-07-03 16:51:04 +00:00
Argyrios Kyrtzidis 4cf2ffe28b [libclang] Protect against a race condition where a thread
may be destroying an ASTUnit while cleanupOnDiskMapAtExit is
getting called.

rdar://11781241

llvm-svn: 159664
2012-07-03 16:30:52 +00:00
NAKAMURA Takumi da94a2d901 clang/utils/TableGen/ClangAttrEmitter.cpp: Fix abuse of StringRef (from getValueAsString()).
llvm-svn: 159662
2012-07-03 14:45:09 +00:00
Matt Beaumont-Gay 36af16affd Silence warning in -Asserts build
llvm-svn: 159635
2012-07-03 03:55:58 +00:00
Nico Weber 4b18c3ff40 Share ConvertUTF8toWide() between Lex and CodeGen.
llvm-svn: 159634
2012-07-03 02:24:52 +00:00
Nico Weber b8124d1af1 Rename -Wself-assign-memvar to -Wself-assign-field to improve local consistency a bit.
(cf -Wunused-private-field and several other existing -field diagnostics.)

llvm-svn: 159633
2012-07-03 02:03:06 +00:00
Chandler Carruth c4702dac1c Remove a redundant assignment to the FDecl variable from *inside* it's
initializer.

I really feel like Clang should warn about this, but I can't describe
a good reason. GCC will warn on this in some cases under
-Wsequence-point, but it actually seems like a false positive for that
warning....

llvm-svn: 159631
2012-07-03 00:15:11 +00:00
John McCall 4e8ca4fa14 Significantly simplify CGExprAgg's logic about ignored results:
if we want to ignore a result, the Dest will be null.  Otherwise,
we must copy into it.  This means we need to ensure a slot when
loading from a volatile l-value.

With all that in place, fix a bug with chained assignments into
__block variables of aggregate type where we were losing insight into
the actual source of the value during the second assignment.

llvm-svn: 159630
2012-07-02 23:58:38 +00:00
James Dennett fc7c677c8d Documentation cleanup:
* Added file header documentation with \file and \brief;
* Cleaned up existing doc comments and added/annotated \brief summaries.

llvm-svn: 159629
2012-07-02 23:57:26 +00:00
James Dennett 0bb4164ce8 Documentation cleanup: Delete a duplicated/malformed doc comment.
llvm-svn: 159628
2012-07-02 23:56:17 +00:00
Argyrios Kyrtzidis b6df682194 [libclang] Introduce clang_Cursor_isDynamicCall which,
given a cursor pointing to a C++ method call or an ObjC message,
returns non-zero if the method/message is "dynamic", meaning:

  For a C++ method: the call is virtual.
  For an ObjC message: the receiver is an object instance, not 'super' or a
  specific class.

rdar://11779185

llvm-svn: 159627
2012-07-02 23:54:36 +00:00
Fariborz Jahanian 577574ab88 objective-c: just as we have done for method definitions,
c-functions declared in implementation should have their 
parsing delayed until the end so, they can access forward
declared private methods. // rdar://10387088

llvm-svn: 159626
2012-07-02 23:37:09 +00:00
Richard Smith b721e301df -Wuninitialized: assume that an __attribute__((returns_twice)) function might
initialize any variable. This is extremely conservative, but is sufficient for
now.

llvm-svn: 159620
2012-07-02 23:23:04 +00:00
James Dennett c7a646fc01 Documentation cleanup:
* Primarily, added \brief to most of include/clang/Basic, instead of prefixing
  the comments with "DeclaredName - ";
* Made some brief summaries significantly briefer;
* Fixed up some erroneous uses of \see and \arg;
* Fixed up some extraneous backslashes in \code...\endcode blocks;
* Fixed up some typos/spelling errors.

llvm-svn: 159616
2012-07-02 23:17:34 +00:00
Richard Smith 16830043fa test/Driver/crash-report.c: don't fail if there are no files left behind by a previous run of this test!
llvm-svn: 159615
2012-07-02 23:11:27 +00:00
DeLesley Hutchins ab0d4e6cd8 Thread safety analysis: fixed bug that occurs when very silly people
use scoped_lockable without putting unlock_function on the
destructor.

llvm-svn: 159609
2012-07-02 22:26:29 +00:00
Jordan Rose a4ee064cf3 [analyzer] Introduce CXXAllocatorCall to handle placement arg invalidation.
This is NOT full-blown support for operator new, but removes some nasty
duplicated code introduced in r158784.

llvm-svn: 159608
2012-07-02 22:21:47 +00:00
DeLesley Hutchins 6e6dbb7618 Thread safety analysis: fixed incorrect error message at the end of a locks_required function.
llvm-svn: 159607
2012-07-02 22:16:54 +00:00
DeLesley Hutchins 2a15baf968 Thread safety analysis: don't warn in case of duplicate annotation.
llvm-svn: 159606
2012-07-02 22:12:12 +00:00
David Blaikie a6b4db812c Improve crash reporting test coverage.
This adds validation that the
* repro source is only rewrite-includes processed, not fully preprocessed.
* repro script contains macro definitions (-DFOO=BAR).

Based on suggestions/help by Matt Beaumont-Gay.

llvm-svn: 159605
2012-07-02 22:07:20 +00:00
DeLesley Hutchins c4a6e51596 Thread Safety Analysis: turn off checking within trylock functions.
llvm-svn: 159601
2012-07-02 21:59:24 +00:00
Matt Beaumont-Gay f019075271 Add a warning flag for "'extern' variable has an initializer".
llvm-svn: 159600
2012-07-02 21:58:14 +00:00
Chandler Carruth dc2e4bcad3 Extend a workaround for a CMake bug in LLVM's r159593 to apply to
a Clang target which hits the same bug directly.

llvm-svn: 159598
2012-07-02 21:46:03 +00:00
Jordan Rose e8d5567426 [analyzer] If 'super' is known to be nil, we can still mark its range.
llvm-svn: 159596
2012-07-02 21:41:56 +00:00
Jordan Rose 62146f67b7 Revert "Remove unused member (& consequently unused parameter) in SA's Call code."
...and instead add an accessor. We're not using this today, but it's something
that should probably stay in the source for potential clients, and it doesn't
cost a lot. (ObjCPropertyAccess is only created on the stack, and right now
there's only ever one alive at a time.)

This reverts r159581 / commit 8e674e1da34a131faa7d43dc3fcbd6e49120edbe.

llvm-svn: 159595
2012-07-02 21:41:53 +00:00
Chandler Carruth 3bf1d5d1de We support a mode where the Clang regression tests are run but not the
Clang unit tests. It's not clear why we support this mode in builds
where LLVM is available (LLVM itself does not), but at least this makes
us support it correctly.

This also fixes a long-standing bug where we would pass the unit test
param flag to lit in the standalone build even though the standalone
build *never* has the unittests built and ready for testing.

llvm-svn: 159594
2012-07-02 21:37:04 +00:00
David Blaikie df9582cca5 Include -D files in crash report repro scripts. (PR13255)
Now that we're only using -frewrite-includes rather than full preprocessing
when producing repro source files, we should also include command line macro
definitions in the repro script.

I don't have a test case for this because I'm not sure if/how I can open the
crash report file when the name is only known by scraping the crash report
output. Suggestions welcome if anyone thinks it'd be helpful.

llvm-svn: 159592
2012-07-02 21:28:00 +00:00
Jordan Rose d39e5f1463 In blocks, only pretend that enum constants have enum type if necessary.
In C, enum constants have the type of the enum's underlying integer type,
rather than the type of the enum. (This is not true in C++.) Thus, when a
block's return type is inferred from an enum constant, it is incompatible
with expressions that return the enum type.

In r158899, I told block returns to pretend that enum constants have enum
type, like in C++. Doug Gregor pointed out that this can break existing code.

Now, we don't check the types of return statements until the end of the block.
This lets us go back and add implicit casts in blocks with mixed enum
constants and enum-typed expressions.

<rdar://problem/11662489> (again)

llvm-svn: 159591
2012-07-02 21:19:23 +00:00
Eli Friedman c9f439461b When we're looking for redeclarations which might provide a definition in CodeGen, make sure we examine all the redeclarations. PR13252.
llvm-svn: 159586
2012-07-02 21:05:30 +00:00
Ted Kremenek b4204310f4 Make this test invariant to future changes of the max loop unrolling count.
llvm-svn: 159585
2012-07-02 21:02:22 +00:00
Douglas Gregor b9b8b81ef2 Be more eager about setting the 'Invalid' bit on an invalid class
template instantiation. I wasn't able to reproduce this down to
anything small enough to put in our test suite, but it's "obviously"
okay to set the invalid bit earlier and precludes a
known-broken-but-not-marked-broken class from being used elsewhere.

llvm-svn: 159584
2012-07-02 21:00:41 +00:00
Chandler Carruth e8f69b733a Clone a bit of LIT flag defaults from the LLVM CMake file into the
standalone section of the Clang CMake files.

This will likely make the lit runs in Clang much more suitable to IDEs
such as Xcode and MSVC when operating in a standalone mode.

llvm-svn: 159582
2012-07-02 20:52:55 +00:00
David Blaikie 977a35644e Remove unused member (& consequently unused parameter) in SA's Call code.
This member became unused in r159559.

llvm-svn: 159581
2012-07-02 20:44:57 +00:00
Abramo Bagnara b1cdde7d21 Reintroduced FieldDecl public methods setBitWidth and removeBitWidth.
llvm-svn: 159579
2012-07-02 20:35:48 +00:00
Ted Kremenek de21a1c964 Bail out the LiveVariables analysis when the CFG is very large, as
we are encountering some scalability issues with memory usage.   The
appropriate long term fix is to make the analysis more scalable, but
this will at least prevent the analyzer swapping when
analyzing very large functions.

llvm-svn: 159578
2012-07-02 20:21:52 +00:00
Ted Kremenek 146ef384da Fix subtle bug in AnalysisConsumer where we would not analyze functions whose parent
in the call graph had been inlined but for whatever reason we did not inline some
of its callees.

Also, fix a related traversal bug where we meant to do a BFS of the callgraph but
instead were doing a DFS.

llvm-svn: 159577
2012-07-02 20:21:48 +00:00
Chandler Carruth 6b963db39a Switch from using a lit.cfg-generator variable to the real variable in
the standalone mode. We've changed scoping and sequencing of variables
being defined and that cause this to start to be unset breaking some
cmake users. Thanks to Jordan Rose for the report.

The fix also makes the condition on the preceding line much more
sensible. =D

llvm-svn: 159576
2012-07-02 20:14:59 +00:00
Douglas Gregor 271205cedb Reduce default template instantiation depth to 512; we're blowing out
the stack too often with 1024. Fixes <rdar://problem/11678534>.

llvm-svn: 159573
2012-07-02 19:56:23 +00:00
Jordan Rose 682b31621f [analyzer] Convert existing checkers to use check::preCall and check::postCall.
llvm-svn: 159563
2012-07-02 19:28:21 +00:00
Jordan Rose afe7c2c2bf [analyzer] Add generic preCall and postCall checks.
llvm-svn: 159562
2012-07-02 19:28:16 +00:00
Jordan Rose f3c12ac3b1 [analyzer] Convert CXXConstructExpr over to use CallEvent for evaluation.
llvm-svn: 159561
2012-07-02 19:28:12 +00:00
Jordan Rose cbeef55886 [analyzer] Use CallEvent for inlining and call default-evaluation.
llvm-svn: 159560
2012-07-02 19:28:09 +00:00
Jordan Rose 547060b30b [analyzer] Finish replacing ObjCMessage with ObjCMethodDecl and friends.
The preObjCMessage and postObjCMessage callbacks now take an ObjCMethodCall
argument, which can represent an explicit message send (ObjCMessageSend) or an
implicit message generated by a property access (ObjCPropertyAccess).

llvm-svn: 159559
2012-07-02 19:28:04 +00:00
Jordan Rose 6bad4905d7 [analyzer] Begin replacing ObjCMessage with ObjCMethodCall and friends.
Previously, the CallEvent subclass ObjCMessageInvocation was just a wrapper
around the existing ObjCMessage abstraction (over message sends and property
accesses). Now, we have abstract CallEvent ObjCMethodCall with subclasses
ObjCMessageSend and ObjCPropertyAccess.

In addition to removing yet another wrapper object, this should make it easy
to add a ObjCSubscriptAccess call event soon.

llvm-svn: 159558
2012-07-02 19:27:56 +00:00
Jordan Rose 7ab0182e33 [analyzer] Move the last bits of CallOrObjCMessage over to CallEvent.
This involved refactoring some common pointer-escapes code onto CallEvent,
then having MallocChecker use those callbacks for whether or not to consider
a pointer's /ownership/ as escaping. This still needs to be pinned down, and
probably we want to make the new argumentsMayEscape() function a little more
discerning (content invalidation vs. ownership/metadata invalidation), but
this is a good improvement.

As a bonus, also remove CallOrObjCMessage from the source completely.

llvm-svn: 159557
2012-07-02 19:27:51 +00:00
Jordan Rose 2995349f3e [analyzer] Convert CallAndMessageChecker and ObjCSelfInitChecker to CallEvent.
Both of these got uglier rather than cleaner because we don't have preCall and
postCall yet; properly wrapping a CallExpr in a CallEvent requires doing a bit
of deconstruction on the callee. Even when we have preCall and postCall we may
want to expose the current CallEvent to pre/postStmt<CallExpr>.

llvm-svn: 159556
2012-07-02 19:27:46 +00:00
Jordan Rose eec1539a31 [analyzer] Convert RetainCountChecker to use CallEvent as much as possible.
This ended allowing quite a bit of cleanup, and some minor changes.

- CallEvent makes it easy to use hasNonZeroCallbackArg more aggressively, which
  we check in order to avoid false positives with callbacks that might release
  the object.
- In order to support this for functions which consume their arguments, there
  are two new ArgEffects: DecRefAndStopTracking and DecRefMsgAndStopTracking.
  These act just like StopTracking, except that if the object only had a
  return count of +1 it's now considered released instead (so we still get
  use-after-free messages).
- On the plus side, we no longer have to special-case
  +[NSObject performSelector:withObject:afterDelay:] and friends.
- The use of IdentifierInfos in the method summary cache is now hidden; only
  the ObjCInterfaceDecl gets passed around most of the time.
- Since we cache all "simple" summaries and check every function call, there is
  no real benefit to having NULL stand in for default summaries anymore.
- Whitespace, unused methods, etc.

Even more simplification to come when we get check::postCall and can unify all
these other post* checks.

llvm-svn: 159555
2012-07-02 19:27:43 +00:00
Jordan Rose 742920c8e7 [analyzer] Add a new abstraction over all types of calls: CallEvent
This is intended to replace CallOrObjCMessage, and is eventually intended to be
used for anything that cares more about /what/ is being called than /how/ it's
being called. For example, inlining destructors should be the same as inlining
blocks, and checking __attribute__((nonnull)) should apply to the allocator
calls generated by operator new.

llvm-svn: 159554
2012-07-02 19:27:35 +00:00
Argyrios Kyrtzidis 442dd80715 [PCH] Make sure that all newly introduced visible decls in a DeclContext
coming from an AST file are registered for serialization.

A static data member instantiation of in a chained PCH could be missed
when serializing decls; the result was that when emitting the visible decls
map of its DeclContext, we would use a DeclID that was not actually emitted,
leading to crashes or hangs.

Fix this by making sure such decls are always registered for serialization.
Also introduce extra sanity checks to make sure we don't register new
declarations or types after we have serialized the types/decls block.

rdar://11728990

llvm-svn: 159550
2012-07-02 19:19:01 +00:00