Commit Graph

26814 Commits

Author SHA1 Message Date
Dmitri Gribenko bfda9f75d6 ASTContext::getCommentForDecl: add comment.
llvm-svn: 162374
2012-08-22 18:12:19 +00:00
Dmitri Gribenko 90631809cb Attaching comments to declarations: when documentation is requested for an
implicit instantiation, look for documentation attached to the template.

llvm-svn: 162371
2012-08-22 17:44:32 +00:00
Benjamin Kramer fc6eb7d383 Reduce duplicated hash map lookups.
llvm-svn: 162361
2012-08-22 15:37:55 +00:00
Rafael Espindola 0c6c405e23 Merge existing attributes before processing pragmas in friend template
declarations.
Fixes pr13662.

llvm-svn: 162360
2012-08-22 14:52:14 +00:00
Benjamin Kramer 7f19035fe0 Fix typo in debug method.
llvm-svn: 162352
2012-08-22 08:38:23 +00:00
Ted Kremenek 6269888166 Rename 'unbindLoc()' (in ProgramState) and 'Remove()' to
'killBinding()'.  The name is more specific, and one just forwarded
to the other.

Add some doxygen comments along the way.

llvm-svn: 162350
2012-08-22 06:37:46 +00:00
Ted Kremenek d94854a42e Rename 'currentX' to 'currX' throughout analyzer and libAnalysis.
Also rename 'getCurrentBlockCounter()' to 'blockCount()'.

This ripples a bunch of code simplifications; mostly aesthetic,
but makes the code a bit tighter.

llvm-svn: 162349
2012-08-22 06:26:15 +00:00
Ted Kremenek d227833cba Rename 'getConjuredSymbol*' to 'conjureSymbol*'.
No need to have the "get", the word "conjure" is a verb too!
Getting a conjured symbol is the same as conjuring one up.

This shortening is largely cosmetic, but just this simple changed
cleaned up a handful of lines, making them less verbose.

llvm-svn: 162348
2012-08-22 06:26:06 +00:00
Ted Kremenek 1afcb7442f Remove Store::bindDecl() and Store::bindDeclWithNoInit(), and
all forwarding methods.

This functionality is already covered by bindLoc().

llvm-svn: 162346
2012-08-22 06:00:18 +00:00
Ted Kremenek 2cd56c4c6e Rename 'BindCompoundLiteral' to 'bindCompoundLiteral' and
add doxygen comments.

llvm-svn: 162345
2012-08-22 06:00:12 +00:00
Ted Kremenek 086011f8c0 Remove stale header file.
llvm-svn: 162341
2012-08-22 04:42:05 +00:00
Ted Kremenek 34d39287b5 Consilidate SmallPtrSet count() followed by insert() into a single insert().
llvm-svn: 162330
2012-08-22 00:02:08 +00:00
Chad Rosier bbdd467895 [ms-inline asm] Remove the patchMSAsmStrings function. After some discussion
between Bob, Jim, Eric and I, we've decided to take a slightly different
approach.

llvm-svn: 162327
2012-08-21 23:09:21 +00:00
Matt Beaumont-Gay 64621ea530 Add an llvm_unreachable to pacify GCC's -Wreturn-type.
llvm-svn: 162325
2012-08-21 22:27:18 +00:00
Chad Rosier b958037958 [ms-inline asm] Have buildMSAsmString build a vector of unmodified AsmStrings.
Add a new static function, buildMSAsmPieces, that will break these strings down
into mnemonic and operands.  Upon a match failure, the idea is to use the
ErrorInfo from MatchInstructionImpl to inspect the mnemonic/operand and 
decide a course of action.  Unfortunately, there's no easy way to test this at
the moment.

llvm-svn: 162321
2012-08-21 21:56:39 +00:00
Fariborz Jahanian ea262f7936 change function name in my last patch.
// rdar://12103400

llvm-svn: 162320
2012-08-21 21:52:02 +00:00
Fariborz Jahanian 8d1ca5a142 objective-C: Change rules for overriding properties in
class extensions a little. clang now allows readonly property 
with no ownership rule (assign, unsafe_unretained, weak, retain, 
strong, or copy) with a readwrite property with an ownership rule.
// rdar://12103400 

llvm-svn: 162319
2012-08-21 21:45:58 +00:00
Jordan Rose e3e95cdf27 [analyzer] Set the default IPA mode to 'basic-inlining', which excludes C++.
Under -analyzer-ipa=basic-inlining, only C functions, blocks, and C++ static
member functions are inlined -- essentially, the calls that behave like simple
C function calls. This is essentially the behavior in Xcode 4.4.

C++ support still has some rough edges, and we don't want users to be worried
about them if they download and run their own checker. (In particular, the
massive number of false positives for analyzing LLVM comes from inlining
defensively-written code in contexts where more aggressive assumptions are
implicitly made. This problem is not unique to C++, but it is exacerbated by
the higher proportion of code that lives in header files in C++.)

The eventual goal is to be comfortable enough with C++ support (and simple
Objective-C support) to advance to -analyzer-ipa=inlining as the default
behavior. See the IPA design notes for more details.

llvm-svn: 162318
2012-08-21 21:44:21 +00:00
Dmitri Gribenko 75eea89920 CommentBriefParser: allow paragraphs to be separated by line of whitespace.
Skip paragraphs that contain only whitespace.

llvm-svn: 162315
2012-08-21 21:15:34 +00:00
Jordan Rose 81125c4497 [analyzer] Push "references are non-null" knowledge up to the common parent.
This reduces duplication across the Basic and Range constraint managers, and
keeps their internals free of dealing with the semantics of C++. It's still
a little unfortunate that the constraint manager is dealing with this at all,
but this is pretty much the only place to put it so that it will apply to all
symbolic values, even when embedded in larger expressions.

llvm-svn: 162313
2012-08-21 20:52:19 +00:00
Chad Rosier 5111f8650d [ms-inline asm] Do not report a Parser error when matching inline assembly.
llvm-svn: 162307
2012-08-21 19:37:55 +00:00
Fariborz Jahanian f1f36c6a9a Modern objc translator: Fixes a crash in rewriter when rewriting the API
for structure valued method messaging. // rdar://12142241

llvm-svn: 162303
2012-08-21 18:56:50 +00:00
David Blaikie 5bd4c2ace4 Use LLVM_BUILTIN_TRAP instead of lame volatile int traps.
(from a todo mentioned in r159469 & originally suggested by Chandler Carruth)

llvm-svn: 162302
2012-08-21 18:56:49 +00:00
Michael J. Spencer d492219e59 Reduce the amount of state in the Option class by relying on the data from OptTable::Info.
llvm-svn: 162299
2012-08-21 18:51:17 +00:00
Richard Smith a75e1cff0a Switch some realignment calculations over to llvm::RoundUpToAlignment.
llvm-svn: 162297
2012-08-21 18:18:06 +00:00
Chad Rosier 19160b6e39 [ms-inline asm] Expose the ErrorInfo from the MatchInstructionImpl. In general,
this is the index of the operand that failed to match.

llvm-svn: 162296
2012-08-21 18:15:08 +00:00
Dmitri Gribenko a9a2af7893 DeclPrinter, terse mode: don't print function bodies
llvm-svn: 162294
2012-08-21 17:47:24 +00:00
Dmitri Gribenko a93a7e8d5e Rename PrintingPolicy::DontRecurseInDeclContext to PrintingPolicy::TerseOutput
to reflect the intention, not the implementation.

llvm-svn: 162293
2012-08-21 17:36:32 +00:00
Chad Rosier 5e80ced3f6 [ms-inline asm] Append identifier for better debugging.
llvm-svn: 162289
2012-08-21 17:02:27 +00:00
Chad Rosier b84cc6cfa3 [ms-inline asm] Remove this test case and the associated special case code.
llvm-svn: 162288
2012-08-21 17:01:26 +00:00
Chad Rosier db3da83b28 [driver] Add support for the --param ssp-buffer-size= driver option.
PR9673

llvm-svn: 162285
2012-08-21 16:16:06 +00:00
Kostya Serebryany 28a26c8d99 [asan] If we are compiling with ASan, add metadata indicating dynamically initialized globals. Patch by Reid Watson, reviewed by Richard Smith
llvm-svn: 162259
2012-08-21 06:53:28 +00:00
Richard Smith c7520bf785 Fix alignment of array of VarDecl* following array of unsigned in LambdaExpr.
llvm-svn: 162255
2012-08-21 05:42:49 +00:00
John McCall f1249929c8 When performing a trivial copy of a C++ type, we must be careful not
to overwrite objects that might have been allocated into the type's
tail padding.  This patch is missing some potential optimizations where
the destination is provably a complete object, but it's necessary for
correctness.

Patch by Jonathan Sauer.

llvm-svn: 162254
2012-08-21 04:10:00 +00:00
Richard Smith a9f521fd20 Avoid binding a reference to a dereferenced pointer in diagnostic serialization
if a diagnostic is emitted outside of any source file. The fix mirrors the
corresponding code in TextDiagnosticPrinter. This required moving the
functional parts of SDiagRenderer into SDiagWriter so they can be reused in the
non-rendering codepath.

No functionality change.

llvm-svn: 162253
2012-08-21 03:11:53 +00:00
John McCall 3deb1ad40c Screw around with ObjCRuntime some more, changing the
diagnostics for bad deployment targets and adding a few
more predicates.  Includes a patch by Jonathan Schleifer
to enable ARC for ObjFW.

llvm-svn: 162252
2012-08-21 02:47:43 +00:00
Sam Panzer 0f38443616 Better diagnostics for range-based for loops with bad range types.
The old error message stating that 'begin' was an undeclared identifier
is replaced with a new message explaining that the error is in the range
expression, along with which of the begin() and end() functions was
problematic if relevant.

Additionally, if the range was a pointer type or defines operator*,
attempt to dereference the range, and offer a FixIt if the modified range
works.

llvm-svn: 162248
2012-08-21 00:52:01 +00:00
Jordan Rose 075d5d2e99 [analyzer] Assume that reference symbols are non-null.
By doing this in the constraint managers, we can ensure that ANY reference
whose value we don't know gets the effect, even if it's not a top-level
parameter.

llvm-svn: 162246
2012-08-21 00:27:33 +00:00
Dmitri Gribenko 309856ae9f DeclPrinter: add terse output mode and lots of tests
Add a flag PrintingPolicy::DontRecurseInDeclContext to provide "terse" output
from DeclPrinter.  The motivation is to use DeclPrinter to print declarations
in user-friendly format, without overwhelming user with inner detail of the
declaration being printed.

Also add many tests for DeclPrinter.  There are quite a few things that we
print incorrectly: search for WRONG in DeclPrinterTest.cpp -- and these tests
check our output against incorrect output, so that we can fix/refactor/rewrite
the DeclPrinter later.

llvm-svn: 162245
2012-08-20 23:39:06 +00:00
John McCall d8561f058d Fix a pair of bugs relating to properties in ARC.
First, when synthesizing an explicitly strong/retain/copy property
of Class type, don't pretend during compatibility checking that the
property is actually assign.  Instead, resolve incompatibilities
by secretly changing the type of *implicitly* __unsafe_unretained
Class ivars to be strong.  This is moderately evil but better than
what we were doing.

Second, when synthesizing the setter for a strong property of
non-retainable type, be sure to use objc_setProperty.  This is
possible when the property is decorated with the NSObject
attribute.  This is an ugly, ugly corner of the language, and
we probably ought to deprecate it.

The first is rdar://problem/12039404;  the second was noticed by
inspection while fixing the first.

llvm-svn: 162244
2012-08-20 23:36:59 +00:00
Eric Christopher 4a903df403 Reapply:
Author: Eric Christopher <echristo@apple.com>
Date:   Thu Aug 16 23:50:46 2012 +0000

    Add some caching here for the builtin types.

    rdar://12117935

    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162066 91177308-0d34-0410-b5e6-96231b3b80d8

after fixing a thinko.

llvm-svn: 162243
2012-08-20 23:32:17 +00:00
Dmitri Gribenko b1ad993957 Attaching comments to declarations: ignore implicit decls. Decl::isImplicit()
does not return true for all implicit decls currently.

This should fix PR13634 for now, but Decl::isImplicit() should be fixed, too.

llvm-svn: 162238
2012-08-20 22:36:31 +00:00
David Blaikie b6b9623952 Fix -Wswitch warning introduced by r162231
llvm-svn: 162236
2012-08-20 22:22:51 +00:00
Michael J. Spencer ad3ccc3cb0 Make Option non virtual.
llvm-svn: 162231
2012-08-20 21:41:17 +00:00
DeLesley Hutchins f1150d3a16 Thread-safety analysis: fix scoping issues related to 'this', including an
ICE in friend functions.

llvm-svn: 162229
2012-08-20 21:32:18 +00:00
Eli Friedman cf4ab0891d Fix InitListExpr::isStringLiteralInit so it handles various edge cases correctly. PR13643.
llvm-svn: 162226
2012-08-20 20:55:45 +00:00
Jordan Rose 53cb2f327a Code-complete 'weak' for properties under ARC-with-weak-references (or GC)
Also, suggest 'readonly' even if the property has been given an ownership
attribute ('strong', 'weak', etc). This is used when properties are declared
readonly in the public interface but readwrite in a class extension.

<rdar://problem/11500004&11932285>

llvm-svn: 162220
2012-08-20 20:01:13 +00:00
Jordan Rose 2b10f3f8a9 [analyzer] Add comments to ExplodedNode::NodeGroup.
No functionality change.

llvm-svn: 162216
2012-08-20 18:59:46 +00:00
Jordan Rose 4b4613cbec [analyzer] Replace boolean IsSink parameters with 'generateSink' methods.
Generating a sink is significantly different behavior from generating a
normal node, and a simple boolean parameter can be rather opaque. Per
offline discussion with Anna, adding new generation methods is the
clearest way to communicate intent.

No functionality change.

llvm-svn: 162215
2012-08-20 18:43:42 +00:00
Richard Smith 62e6630af9 PR13619: Make sure we're not at EOF before looking at NextToken().
llvm-svn: 162212
2012-08-20 17:37:52 +00:00
Chad Rosier d4e55b8e35 [ms-inline asm] Remove old cruft now that MS-style asms their own code path.
llvm-svn: 162210
2012-08-20 17:11:53 +00:00
Jordan Rose 0a9ea7c70d [analyzer] The result of && or || is always a 1 or 0.
Forgetting to at least cast the result was giving us Loc/NonLoc problems
in SValBuilder (hitting an assertion). But the standard (both C and C++)
does actually guarantee that && and || will result in the actual values
1 and 0, typed as 'int' in C and 'bool' in C++, and we can easily model that.

PR13461

llvm-svn: 162209
2012-08-20 17:04:45 +00:00
Hans Wennborg d799a2b3b9 Better wording for reference self-initialization warning.
llvm-svn: 162198
2012-08-20 08:52:22 +00:00
Jordan Rose 8c1ac0c376 Allow -verify to be used with files that don't have an associated FileEntry.
In Debug builds, VerifyDiagnosticConsumer checks any files with diagnostics
to make sure we got the chance to parse them for directives (expected-warning
and friends). This check previously relied on every parsed file having a
FileEntry, which broke the cling interpreter's test suite.

This commit changes the extra debug checking to mark a file as unparsed
as soon as we see a diagnostic from that file. At the very end, any files
that are still marked as unparsed are checked for directives, and a fatal
error is emitted (as before) if we find out that there were directives we
missed. -verify directives should always live in actual parsed files, not
in PCH or AST files.

Patch by Andy Gibbs, with slight modifications by me.

llvm-svn: 162171
2012-08-18 16:58:52 +00:00
John McCall dd61f2eb6d When mangling a negative number, remember that negating it does not
always yield a positive number.  Just print the negated result as an
unsigned number.

llvm-svn: 162163
2012-08-18 04:51:52 +00:00
Richard Smith 4f605aff7f PR41111, PR5925, PR13210: Teach tentative parsing to annotate identifiers and
nested names as id-expressions, using the annot_primary_expr annotation, where
possible. This removes some redundant lookups, and also allows us to
typo-correct within tentative parsing, and to carry on disambiguating past an
identifier which we can determine will fail lookup as both a type and as a
non-type, allowing us to disambiguate more declarations (and thus offer
improved error recovery for such cases).

This also introduces to the parser the notion of a tentatively-declared name,
which is an identifier which we *might* have seen a declaration for in a
tentative parse (but only if we end up disambiguating the tokens as a
declaration). This is necessary to correctly disambiguate cases where a
variable is used within its own initializer.

llvm-svn: 162159
2012-08-18 00:55:03 +00:00
Jordan Rose a4309c941c [analyzer] Treat C++ 'throw' as a sink.
Our current handling of 'throw' is all CFG-based: it jumps to a 'catch' block
if there is one and the function exit block if not. But this doesn't really
get the right behavior when a function is inlined: execution will continue on
the caller's side, which is always the wrong thing to do.

Even within a single function, 'throw' completely skips any destructors that
are to be run. This is essentially the same problem as @finally -- a CFGBlock
that can have multiple entry points, whose exit points depend on whether it
was entered normally or exceptionally.

Representing 'throw' as a sink matches our current (non-)handling of @throw.
It's not a perfect solution, but it's better than continuing analysis in an
inconsistent or even impossible state.

<rdar://problem/12113713>

llvm-svn: 162157
2012-08-18 00:30:23 +00:00
Jordan Rose a97a99736e [analyzer] Treat @throw as a sink (stop processing).
The CFG approximates @throw as a return statement, but that's not good
enough in inlined functions. Moreover, since Objective-C exceptions are
usually considered fatal, we should be suppressing leak warnings like we
do for calls to noreturn functions (like abort()).

The comments indicate that we were probably intending to do this all along;
it may have been inadvertantly changed during a refactor at one point.

llvm-svn: 162156
2012-08-18 00:30:20 +00:00
Jordan Rose 9f61f8a966 [analyzer] Remove obsolete GenericNodeBuilderRefCount from RetainCountChecker.
This was once an adapter class between callbacks that had CheckerContexts
and those that don't, but for a while now it's essentially just been a
wrapper around a ProgramPointTag. We can just pass the tag around instead.

No functionality change.

llvm-svn: 162155
2012-08-18 00:30:16 +00:00
Jordan Rose 80547386b8 [analyzer] Use PointerUnion to implement ExplodedNode::NodeGroup.
We shouldn't be reinventing our own wheels. This also paves the way for
marking different kinds of sinks.

No functionality change.

llvm-svn: 162154
2012-08-18 00:30:10 +00:00
Eric Christopher ff5760132d Reapply:
Make isa part of objc_object at metadata generation time.

Noticed on inspection.

llvm-svn: 162145
2012-08-17 22:54:57 +00:00
Douglas Gregor c459b5178c When code completion is enabled, don't do any work in
Sema::ActOnEndOfTranslationUnit(). This is a (minor) optimization.

llvm-svn: 162144
2012-08-17 22:17:36 +00:00
Fariborz Jahanian f85f338634 c: privide deprecated warning when __private_extern__ storage
specifier is unsed in a declaration; as it may not make the symbol
local to linkage unit as intended. Suggest using "hidden" visibility 
attribute instead. // rdar://7703982

llvm-svn: 162138
2012-08-17 21:44:55 +00:00
Chad Rosier 571c5e91c4 [ms-inline asm] Update comment.
llvm-svn: 162134
2012-08-17 21:27:25 +00:00
Chad Rosier 0731affaca [ms-inline asm] Extract AsmStmt handling into a separate file, so as to not
pollute SemaStmt with extraneous asm handling logic.

llvm-svn: 162132
2012-08-17 21:19:40 +00:00
Daniel Dunbar 455a0496b2 darwin/driver: Support using SDKROOT to define the default for -isysroot.
- The SDKROOT environment variable is the de facto way to set the default SDK
   for a number of tools, join forces with them.

llvm-svn: 162116
2012-08-17 18:43:50 +00:00
Alexander Kornienko 2018618b4d Fixed crash and added a test and a minor output problem
llvm-svn: 162110
2012-08-17 17:38:39 +00:00
Fariborz Jahanian 91f548b04b c: implement gcc's -Wbad-function-cast which warns
on unsafe cast of a c-function call. This is
a C-only option.

llvm-svn: 162109
2012-08-17 17:22:34 +00:00
Chad Rosier 2da9d6d6cf [ms-inline asm] Instantiate the MCStreamer as a NullStream. We're parsing
instruction, not emitting them, so a NullStream is fine.

llvm-svn: 162105
2012-08-17 16:38:04 +00:00
Hans Wennborg e1fdb059c6 Warn about self-initialization of references.
Initializing a reference with itself, e.g. "int &a = a;" seems like a
very bad idea.

llvm-svn: 162093
2012-08-17 10:12:33 +00:00
Douglas Gregor e3eb777415 Make the spacing of the code completion result for NSDictionary
literals match the spacing introduced by the ObjC modernizer. Fixes
the rest of <rdar://problem/11889572>.

llvm-svn: 162084
2012-08-17 05:40:05 +00:00
Douglas Gregor 5d944dbf1a Don't do jump-scope checking when code completion is enabled. It's
both a waste of time, and prone to crash due to the use of the
error-recovery path in parser. Fixes <rdar://problem/12103608>, which
has been driving me nuts.

llvm-svn: 162081
2012-08-17 05:12:08 +00:00
Eric Christopher 8d9ccdc7a5 Temporarily revert r162066 and r162062 to see if it brings the gdb
bots back.

llvm-svn: 162080
2012-08-17 04:42:07 +00:00
Richard Smith 122a3a8e6f Fix undefined behavior in debug info emission: operator* on WeakVH returns a
reference, so &* on an empty WeakVH binds a reference to a dereferenced null
pointer. So don't do that; we have a perfectly good implicit conversion to
Value*.

llvm-svn: 162079
2012-08-17 04:17:54 +00:00
Richard Smith 2683b4c0fd Switch PTH format from a 7 byte magic number to an 8 byte one, to avoid
misaligned reads throughout the file. Bump PTH format version to 10.

llvm-svn: 162076
2012-08-17 03:55:43 +00:00
Nick Lewycky 2fe6aab788 Fix -Wl,--no-demangle to actually pass the flag to the linker on Linux instead
of silently dropping it on the floor.

llvm-svn: 162075
2012-08-17 03:39:16 +00:00
Richard Smith 034b94a557 Don't forget to apply #pragma pack to partial and explicit specializations of
class templates. This fixes misalignment issues in llvm/Support/Endian.h when
built by Clang.

llvm-svn: 162074
2012-08-17 03:20:55 +00:00
Richard Smith 99eff01fa2 Avoid binding a reference to a dereferenced null pointer, if we try to emit a
diagnostic before we have a source manager.

llvm-svn: 162070
2012-08-17 00:55:32 +00:00
Richard Smith 80b3c5a00e Don't form a null reference when checking for validity of an anonymous
elaborated type specifier in template instantiation: such a specifier is always
valid because it must be specified within the definition of the type.

llvm-svn: 162068
2012-08-17 00:12:27 +00:00
Dmitri Gribenko e4a5a90e8d Add support for "type safety" attributes that allow checking that 'void *'
function arguments and arguments for variadic functions are of a particular
type which is determined by some other argument to the same function call.

Usecases include:
* MPI library implementations, where these attributes enable checking that
  buffer type matches the passed MPI_Datatype;
* for HDF5 library there is a similar usecase as MPI;
* checking types of variadic functions' arguments for functions like
  fcntl() and ioctl().

llvm-svn: 162067
2012-08-17 00:08:38 +00:00
Eric Christopher 476e5a3c9e Add some caching here for the builtin types.
rdar://12117935

llvm-svn: 162066
2012-08-16 23:50:46 +00:00
Eric Christopher c34d391ca2 Remove FIXME, the constraints contain more options than the
current available documentation.

llvm-svn: 162065
2012-08-16 23:50:43 +00:00
Eric Christopher 9e49188a01 Add a missing 'break' to ensure that we reject inline assembly
constraints we don't recognize.

llvm-svn: 162064
2012-08-16 23:50:41 +00:00
Eric Christopher ae6b9d2de3 Random string removal.
llvm-svn: 162063
2012-08-16 23:50:37 +00:00
Eric Christopher 11b4463a94 Make isa part of objc_object at metadata generation time.
Noticed on inspection.

llvm-svn: 162062
2012-08-16 23:50:35 +00:00
Richard Smith 426f78555e Fix misaligned allocation of TemplateParameterList objects.
llvm-svn: 162056
2012-08-16 22:51:34 +00:00
Chad Rosier b899c1b417 [ms-inline asm] Comment.
llvm-svn: 162055
2012-08-16 22:47:10 +00:00
Chad Rosier bf17e01fe5 [ms-inline asm] Extract a helper function, getSpelling(). Also use this on
tokens we don't know how to handle; this should aid when debugging.

llvm-svn: 162053
2012-08-16 22:40:32 +00:00
Fariborz Jahanian 78f565b0a0 objective-C++: issue diagnostic when ivar type is
an abstract c++ class. // rdar://12095239

llvm-svn: 162052
2012-08-16 22:38:41 +00:00
Chad Rosier 50cf25c72d [ms-inline asm] If we don't know how to handle a token then assume this is not a
simple asm.

llvm-svn: 162051
2012-08-16 22:30:02 +00:00
Chad Rosier 3d4b98b4bc [ms-inline asm] Add a helper function, isMSAsmKeyword().
These require special handling, which we don't currently handle.  This is being
put in place to ensure we don't do invalid symbol table lookups or try to parse
invalid assembly.  The test cases just makes sure the latter isn't happening.

llvm-svn: 162050
2012-08-16 22:25:38 +00:00
Sam Panzer 2c4ca0fa7d Removed unused LParenLoc parameter to ActOnCXXForRangeStmt
llvm-svn: 162048
2012-08-16 21:47:25 +00:00
Dmitri Gribenko 2d81b34104 CommentCommandTraits: rename BeginName -> StartName for consistency.
llvm-svn: 162044
2012-08-16 20:16:11 +00:00
Chad Rosier efb2911664 [ms-inline asm] Perform symbol table lookup on variables. The idea is to use
this information to determine valid MC operands.  This will also be used for
semantic analysis.

llvm-svn: 162043
2012-08-16 19:52:25 +00:00
Fariborz Jahanian 5ad9659688 objective-C: deprecate casts of ObjC's SEL
expressions except to void, void * and their
qualified versions. // rdar://12107381

llvm-svn: 162036
2012-08-16 18:33:47 +00:00
Dmitri Gribenko 4ae66a31fe Attaching comments to declarations: parse the comment in context of the
declaration it was attached to.

llvm-svn: 162033
2012-08-16 18:19:43 +00:00
Ted Kremenek 9dcf671d13 Remove #if 0 that has been around for a long time.
llvm-svn: 162030
2012-08-16 17:45:32 +00:00
Ted Kremenek 1e60273eed Remove "range_iterator" from PathDiagnosticPiece and just use ArrayRef<SourceRange> for ranges. This
removes conceptual clutter, and can allow us to easy migrate to C++11 style for-range loops if we
ever move to using C++11 in Clang.

llvm-svn: 162029
2012-08-16 17:45:29 +00:00
Ted Kremenek 9bf9af92a4 Allow multiple PathDiagnosticConsumers to be used with a BugReporter at the same time.
This fixes several issues:

- removes egregious hack where PlistDiagnosticConsumer would forward to HTMLDiagnosticConsumer,
but diagnostics wouldn't be generated consistently in the same way if PlistDiagnosticConsumer
was used by itself.

- emitting diagnostics to the terminal (using clang's diagnostic machinery) is no longer a special
case, just another PathDiagnosticConsumer.  This also magically resolved some duplicate warnings,
as we now use PathDiagnosticConsumer's diagnostic pruning, which has scope for the entire translation
unit, not just the scope of a BugReporter (which is limited to a particular ExprEngine).

As an interesting side-effect, diagnostics emitted to the terminal also have their trailing "." stripped,
just like with diagnostics emitted to plists and HTML.  This required some tests to be updated, but now
the tests have higher fidelity with what users will see.

There are some inefficiencies in this patch.  We currently generate the report graph (from the ExplodedGraph)
once per PathDiagnosticConsumer, which is a bit wasteful, but that could be pulled up higher in the
logic stack.  There is some intended duplication, however, as we now generate different PathDiagnostics (for the same issue)
for different PathDiagnosticConsumers.  This is necessary to produce the diagnostics that a particular
consumer expects.

llvm-svn: 162028
2012-08-16 17:45:23 +00:00
Chad Rosier 592b90a476 [ms-inline asm] Start tracking which tokens are registers and which are
variables, function or label references.  The former is a potential clobber.
The latter is either an input or an output.  Unfortunately, it's difficult to
test this patch at the moment, but the added test case will eventually do so.

llvm-svn: 162026
2012-08-16 17:10:59 +00:00
Richard Smith 235341bc88 Store SourceManager pointer on PrintingPolicy in the case where we're dumping,
and remove ASTContext reference (which was frequently bound to a dereferenced
null pointer) from the recursive lump of printPretty functions. In so doing,
fix (at least) one case where we intended to use the 'dump' mode, but that
failed because a null ASTContext reference had been passed in.

llvm-svn: 162011
2012-08-16 03:56:14 +00:00
Richard Smith 52f04a2e8f Don't constant-fold when pretty-printing alignment attribute. This fixes a
potential crasher -- Context is sometimes a null reference (!!) here.

llvm-svn: 162007
2012-08-16 02:43:29 +00:00
Sam Panzer 04390a63c8 Test commit: deleted whitespace on blank line
llvm-svn: 162006
2012-08-16 02:38:47 +00:00
Richard Smith a5e697653b Fix misaligned allocation of QualifiedTempateName and DependentTemplateName.
llvm-svn: 162005
2012-08-16 01:19:31 +00:00
Tanya Lattner a9dd49fe5b Convert loads and stores of vec3 to vec4 to achieve better code generation. Add test case.
llvm-svn: 162002
2012-08-16 00:10:13 +00:00
Chad Rosier 7dbef3e035 [ms-inline asm] Add inputs and outputs to AST. No functional change.
llvm-svn: 162000
2012-08-16 00:06:53 +00:00
Jordan Rose 6ee44e1f03 [analyzer] Look through all casts when trying to track constraints.
Previously, we were losing path notes (in both text and plist form)
because the interesting DeclRefExpr was buried in a cast.

llvm-svn: 161999
2012-08-16 00:03:33 +00:00
Richard Smith 48c15319f7 Devirtualize calls on glvalues produced by class member access expressions.
Based on a patch by Yin Ma!

llvm-svn: 161998
2012-08-15 22:59:28 +00:00
DeLesley Hutchins 19c722d61d Thread safety analysis: prevent a compiler error in cases where a
late-parsed attribute is attached to an invalid declaration.

llvm-svn: 161997
2012-08-15 22:41:04 +00:00
Jordan Rose 83e4049d39 [analyzer] If we call a C++ method on an object, assume it's non-null.
This is analogous to our handling of pointer dereferences: if we
dereference a pointer that may or may not be null, we assume it's non-null
from then on.

While some implementations of C++ (including ours) allow you to call a
non-virtual method through a null pointer of object type, it is technically
disallowed by the C++ standard, and should not prune out any real paths in
practice.

  [class.mfct.non-static]p1: A non-static member function may be called
    for an object of its class type, or for an object of a class derived
    from its class type...
  (a null pointer value does not refer to an object)

We can also make the same assumption about function pointers.

llvm-svn: 161992
2012-08-15 21:56:23 +00:00
Chad Rosier b32f3d5230 [ms-inline asm] Use a set container to remove redundant clobbers.
llvm-svn: 161991
2012-08-15 21:55:19 +00:00
Chad Rosier 712faa2708 [ms-inline asm] Address a FIXME by computing the number of asm statements when
building the AsmString.

llvm-svn: 161988
2012-08-15 21:08:52 +00:00
Jordan Rose e9753b0640 [analyzer] Even if we are not inlining a virtual call, still invalidate!
Fixes a mistake introduced in r161916.

llvm-svn: 161987
2012-08-15 21:05:15 +00:00
Chad Rosier aa7c1cb5f8 [ms-inline asm] MSVC parses multiple __asm statements on a single line as one
statement.  For example,

  if (x)
    __asm out dx, ax  __asm out dx, ax

results in a single inline asm statement (i.e., both "out dx, ax" statements are
predicated on if(x)).

llvm-svn: 161986
2012-08-15 21:03:27 +00:00
Jordan Rose 5fc5da0578 [analyzer] Correctly devirtualize virtual method calls in constructors.
This is the other half of C++11 [class.cdtor]p4 (the destructor side
was added in r161915). This also fixes an issue with post-call checks
where the 'this' value was already being cleaned out of the state, thus
being omitted from a reconstructed CXXConstructorCall.

llvm-svn: 161981
2012-08-15 20:07:17 +00:00
Matt Beaumont-Gay 22be8d5ab8 Allow 'static' and type qualifiers in K&R parameter type lists.
llvm-svn: 161980
2012-08-15 19:53:19 +00:00
Chad Rosier ecf77b56dd [ms-inline asm] Don't emit newlines as these are ignored by the AsmParser
anyways.  Also, simplify some conditional logic.

llvm-svn: 161977
2012-08-15 19:12:42 +00:00
Fariborz Jahanian 05f4e7181a Patch to warn about __private_extern__ on tentative definitions
as it does something unexpected (but gcc compatible).
Suggest use of __attribute__((visibility("hidden")))
on declaration instead. // rdar://7703982

llvm-svn: 161972
2012-08-15 18:42:26 +00:00
John Criswell edc84507c7 Fix for PR#13606: http://llvm.org/bugs/show_bug.cgi?id=13606
Changed the alignment of an LValue to be 64 bits so that we can handle
alignment values up to half of a 64-bit address space.

llvm-svn: 161971
2012-08-15 18:40:30 +00:00
Chad Rosier 73e325de55 [ms-inline asm] Add support for clobbers in CodeGen.
This is a reapplication of r161914 now that the scoping issue has been resolved
in r161966.

llvm-svn: 161967
2012-08-15 18:12:36 +00:00
Chad Rosier ad34aef449 [ms-inline asm] Capturing loop-scoped (std::string)Reg with a StringRef is bad.
llvm-svn: 161966
2012-08-15 18:09:18 +00:00
Michael Han 1fb908f745 Fix base type of ASTDeclNodeLister.
llvm-svn: 161963
2012-08-15 17:56:58 +00:00
Jordan Rose 9910720851 [analyzer] Don't try to devirtualize if the class is incomplete.
A similar issue to the previous commit, introduced by r161915.

llvm-svn: 161961
2012-08-15 17:33:37 +00:00
Jordan Rose 31c3fa9c24 [analyzer] Only adjust the type of 'this' when we devirtualize a method call.
With reinterpret_cast, we can get completely unrelated types in a region
hierarchy together; this was resulting in CXXBaseObjectRegions being layered
directly on an (untyped) SymbolicRegion, whose symbol was from a completely
different type hierarchy. This was what was causing the internal buildbot to
fail.

Reverts r161911, which merely masked the problem.

llvm-svn: 161960
2012-08-15 17:33:34 +00:00
Chad Rosier b6f46c1af9 [ms-inline asm] Add the left brace source location and improve the pretty
printer.  Patch by Enea Zaffanella <zaffanella@cs.unipr.it>.

llvm-svn: 161958
2012-08-15 16:53:30 +00:00
Hans Wennborg 420052640f Check for improper use of 'static' and type qualifiers in array
declarators.

They are only allowed for function parameters, and then only on the
outermost array type derivation.

llvm-svn: 161934
2012-08-15 07:42:30 +00:00
Eric Christopher d9401e2e58 Revert this to try to bring the i386 bots back.
llvm-svn: 161931
2012-08-15 06:31:06 +00:00
NAKAMURA Takumi 19f29cfc14 clang/lib/Sema/SemaStmt.cpp: Include MCAsmLexer.h to appease msvc to define llvm::AsmToken.
llvm-svn: 161927
2012-08-15 04:19:08 +00:00
Richard Smith beb386aba8 Use the right alignment when allocating NestedNameSpecifier objects.
llvm-svn: 161920
2012-08-15 01:41:43 +00:00
Richard Smith f3bb0b2a9b Fix overallocation and underalignment of ASTTemplateArgumentListInfo objects.
llvm-svn: 161918
2012-08-15 01:22:58 +00:00
Jordan Rose 5132aaeb04 [analyzer] Don't inline dynamic-dispatch methods unless -analyzer-ipa=dynamic.
Previously we were checking -analyzer-ipa=dynamic-bifurcate only, and
unconditionally inlining everything else that had an available definition,
even under -analyzer-ipa=inlining (but not under -analyzer-ipa=none).

llvm-svn: 161916
2012-08-15 00:52:00 +00:00
Jordan Rose 0f6d63be06 [analyzer] Correctly devirtualize virtual method calls in destructors.
C++11 [class.cdtor]p4: When a virtual function is called directly or
  indirectly from a constructor or from a destructor, including during
  the construction or destruction of the class’s non-static data members,
  and the object to which the call applies is the object under
  construction or destruction, the function called is the final overrider
  in the constructor's or destructor's class and not one overriding it in
  a more-derived class.

llvm-svn: 161915
2012-08-15 00:51:56 +00:00
Chad Rosier 2d5d1327c4 [ms-inline asm] Add support for clobbers in CodeGen.
llvm-svn: 161914
2012-08-15 00:43:09 +00:00
Chad Rosier 222ed4b53a [ms-inline asm] Have MC start parsing the asms.
llvm-svn: 161913
2012-08-15 00:42:47 +00:00
Jordan Rose 95c841eaa0 [analyzer] A base class needs a complete definition to provide offsets.
No test case yet; trying to reduce one from a failing internal buildbot.

llvm-svn: 161911
2012-08-15 00:36:44 +00:00
Richard Trieu b7ed89eb94 Check local static variables for self reference on initialization.
llvm-svn: 161909
2012-08-14 23:50:52 +00:00
Chad Rosier 767a7b9ed0 [ms-inline asm] Remove the last bits of LineEnds.
llvm-svn: 161904
2012-08-14 23:14:45 +00:00
Richard Smith 1226c60593 Remove trailing return flag from FunctionTypeLoc, since we now carry that
information on FunctionProtoType. (This also fixes one of *many* misalignment
problems in the TypeLoc hierarchy...)

llvm-svn: 161901
2012-08-14 22:51:13 +00:00
Richard Smith 8a0527d54e Fix undefined behavior: reference bound to dereferenced null pointer.
llvm-svn: 161899
2012-08-14 22:37:22 +00:00
Chad Rosier a6e89aac91 [ms-inline asm] Simplify more logic by using the Token::hasLeadingSpace() and
Token::isAtStartOfLine() APIs.

llvm-svn: 161898
2012-08-14 22:11:17 +00:00
Chad Rosier bba12afe48 [ms-inline asm] Address a potential buffer overflow.
llvm-svn: 161896
2012-08-14 21:48:01 +00:00
Chad Rosier 25e8fe6ae0 [ms-inline asm] Simplify the logic in patchMSAsmString. We no longer need to
track the LineEnds now that single line asm statments aren't merged.

llvm-svn: 161893
2012-08-14 20:58:21 +00:00
Fariborz Jahanian 1ac111989d irgen: inline code for several of complex builtin
calls. // rdar://8315199

llvm-svn: 161891
2012-08-14 20:09:28 +00:00
Chad Rosier c97a6bbfd8 [ms-inline asm] Add a helpful assert.
llvm-svn: 161890
2012-08-14 19:22:06 +00:00
Anna Zaks 6ddb6b1a9a [analyzer]Assume that the properties cannot be overridden when dot
syntax is used.

llvm-svn: 161889
2012-08-14 19:19:18 +00:00
Bob Wilson 2605fef7db Avoid using i64 types for vld1q_lane/vst1q_lane intrinsics.
The backend has to legalize i64 types by splitting them into two 32-bit pieces,
which leads to poor quality code.  If we produce code for these intrinsics that
uses one-element vector types, which can live in Neon vector registers without
getting split up, then the generated code is much better.  Radar 11998303.

llvm-svn: 161879
2012-08-14 17:27:04 +00:00
Dmitri Gribenko b261088a61 Attaching comments to redeclarations: fix wrong assumptions
The reason for the recent fallout for "attaching comments to any redeclaration"
change are two false assumptions:
(1) a RawComment is attached to a single decl (not true for 'typedef struct X *Y'
    where we want the comment to be attached to both X and Y);
(2) the whole redeclaration chain has only a single comment (obviously false, the
    user can put a separate comment for each redeclaration).

To fix (1) I revert the part of the recent change where a 'Decl*' member was
introduced to RawComment.  Now ASTContext has a separate DenseMap for mapping
'Decl*' to 'FullComment*'.

To fix (2) I just removed the test with this assumption.  We might not parse
every comment in redecl chain if we already parsed at least one.

llvm-svn: 161878
2012-08-14 17:17:18 +00:00
Anna Zaks 21487f7ce3 [analyzer] Remove other #if 0 from Retain Count checker.
These date back to 2009, 2011.

llvm-svn: 161876
2012-08-14 15:39:13 +00:00
Anna Zaks dd2b855a6e [analyzer] Remove autorelease pools code from the Retain Count checker.
llvm-svn: 161875
2012-08-14 15:39:09 +00:00
Benjamin Kramer 9299d8c298 Do NOT use inline functions with LLVM_ATTRIBUTE_USED.
The function will be emitted into every single TU including the header!

llvm-svn: 161872
2012-08-14 14:50:32 +00:00
Benjamin Kramer 25885f4657 Remove and simplify unused checking code.
This is already handled by CheckCallingConvAttr.

llvm-svn: 161865
2012-08-14 13:24:39 +00:00
Benjamin Kramer 833fb9f7e3 Fix horribly broken sema of __attribute__((pcs())).
llvm-svn: 161863
2012-08-14 13:13:47 +00:00
Anna Zaks 13883d9e4c [analyzer] Fixup to r161821
llvm-svn: 161854
2012-08-14 05:31:46 +00:00
Richard Smith f995f2ce7c Fix undefined behavior: don't bind a dereferenced null pointer to a reference.
No functionality change.

llvm-svn: 161832
2012-08-14 04:19:29 +00:00
Richard Smith 697cc9e60c Fix undefined behavior in code completion, caught by
-fcatch-undefined-behavior. Don't try to fit 34 different flags
into 32 bits. Also, don't use 32-bit signed left shifts for this.

llvm-svn: 161830
2012-08-14 03:13:00 +00:00
Eli Friedman 1d4c3cfb88 Make __is_convertible_to handle abstract types correctly. PR13591.
llvm-svn: 161828
2012-08-14 02:06:07 +00:00
Richard Smith 7d6d47b862 Fix undefined behavior (and wrong code, as far as I can tell) in NEON builtin
tablegen code, found by -fcatch-undefined-behavior. I would appreciate if
someone more familiar with the NEON code could point me in the direction of how
to write a test for this. We appear to have essentially no test coverage
whatsoever for these builtins.

llvm-svn: 161827
2012-08-14 01:28:02 +00:00
Anna Zaks 23665a1bcf [analyzer] Teach live variable analyzes that super uses self pointer.
llvm-svn: 161822
2012-08-14 00:36:20 +00:00
Anna Zaks aa4acdfdee [analyzer] Disable autorelease pool tracking.
The autorelease pool has not been implemented completely: we were adding
the autoreleased symbols to the state, but never looking at them. Until
we have a complete implementation, remove the overhead and comment out
the unused code.

llvm-svn: 161821
2012-08-14 00:36:17 +00:00
Anna Zaks f5788c7697 [analyzer] Refactor RetainReleaseChecker to go through a function call
to set/get/remove the RefBinding.

No functional change here. Having these setter and getter methods will
make it much easier when replacing the underlining representation of
RefBindings (I just went through the exercise). It makes the code more
readable as well.

llvm-svn: 161820
2012-08-14 00:36:15 +00:00
Anna Zaks 773aa58270 [analyzer] Add getStackFrame() to CheckerContext and ExplodedNode.
llvm-svn: 161819
2012-08-14 00:36:12 +00:00
Jordan Rose e521f93225 [analyzer] Look up DynamicTypeInfo by region instead of symbol.
This allows us to store type info for non-symbolic regions.

No functionality change.

llvm-svn: 161811
2012-08-13 23:59:07 +00:00
Jordan Rose ce6c99a559 [analyzer] Reduce code duplication: make CXXDestructorCall a CXXInstanceCall.
While there is now some duplication between SimpleCall and the CXXInstanceCall
sub-hierarchy, this is much better than copy-and-pasting the devirtualization
logic shared by both instance methods and destructors.

An unfortunate side effect is that there is no longer a single CallEvent type
that corresponds to "calls written as CallExprs". For the most part this is a
good thing, but the checker callback eval::Call still takes a CallExpr rather
than a CallEvent (since we're not sure if we want to allow checkers to
evaluate other kinds of calls). A mistake here will be caught by a cast<> in
CheckerManager::runCheckersForEvalCall.

No functionality change.

llvm-svn: 161809
2012-08-13 23:46:05 +00:00
Jordan Rose 710f6b1259 [analyzer] Be more careful when downcasting for devirtualization.
Virtual base regions are never layered, so simply stripping them off won't
necessarily get you to the correct casted class. Instead, what we want is
the same logic for evaluating dynamic_cast: strip off base regions if possible,
but add new base regions if necessary.

llvm-svn: 161808
2012-08-13 23:46:01 +00:00
Jordan Rose 574ef152fc [analyzer] Handle dynamic_casts that turn out to be upcasts.
This can occur with multiple inheritance, which jumps from one parent to
the other, and with virtual inheritance, since virtual base regions always
wrap the actual object and can't be nested within other base regions.

This also exposed some incorrect logic for multiple inheritance: even if B
is known not to derive from C, D might still derive from both of them.

llvm-svn: 161798
2012-08-13 22:11:42 +00:00
Jordan Rose 07a7ed80cb [analyzer] Don't strip CXXBaseObjectRegions when checking dynamic_casts.
...and /do/ strip CXXBaseObjectRegions when casting to a virtual base class.

This allows us to enforce the invariant that a CXXBaseObjectRegion can always
provide an offset for its base region if its base region has a known class
type, by only allowing virtual bases and direct non-virtual bases to form
CXXBaseObjectRegions.

This does mean some slight problems for our modeling of dynamic_cast, which
needs to be resolved by finding a path from the current region to the class
we're trying to cast to.

llvm-svn: 161797
2012-08-13 22:11:34 +00:00
Chad Rosier 7459543795 [ms-inline asm] Add a helpful assert.
llvm-svn: 161796
2012-08-13 22:04:09 +00:00
Chad Rosier 162b14f326 [ms-inline asm] Address a potential buffer overflow.
llvm-svn: 161793
2012-08-13 21:35:47 +00:00
Richard Smith 47726b2f02 PR13570: When an unresolved overloaded call appeared in a dependent context, we
forgot to set it as being instantiation-dependent as well as being type- and
value-dependent.

llvm-svn: 161791
2012-08-13 21:29:18 +00:00
Manman Ren 6c30e137d0 ARM: enable struct byval for AAPCS-VFP.
rdar://9877866

llvm-svn: 161790
2012-08-13 21:23:55 +00:00
Fariborz Jahanian 7513fa346c c: small refactoring of checking for __attribute__(const))
per Richard's comment.

llvm-svn: 161786
2012-08-13 21:15:02 +00:00
Chad Rosier 65a8e0b69f [ms-inline asm] Have patchMSAsmStrings() return a vector or AsmStrings.
The AsmParser expects a single asm instruction, but valid ms-style inline asm
statements may contain  multiple instructions.

This happens with asm blocks

__asm {
  mov ebx, eax
  mov ecx, ebx
}

or when multiple asm statements are adjacent to one another

__asm mov ebx, eax
__asm mov ecx, ebx

and

__asm mov ebx, eax __asm mov ecx, ebx

Currently, asm blocks are not properly handled.

llvm-svn: 161780
2012-08-13 20:32:07 +00:00
Richard Smith ef8bf4368e Factor out computation of whether a typeid's expression is potentially
evaluated into a CXXTypeid member function. No functionality change.

llvm-svn: 161779
2012-08-13 20:08:14 +00:00
Fariborz Jahanian 794ae1ea77 c: make __has_attribute(const) work for const
function attribute. // rdar://10253857

llvm-svn: 161767
2012-08-13 18:04:58 +00:00
Douglas Gregor 35ceb27fa4 When looking for the comment associated with a declaration, adjust the
'templated' declaration for a function or class template to refer to
the function or class template itself, to which the documentation will
be attached. Fixes PR13593.

llvm-svn: 161762
2012-08-13 16:37:30 +00:00
Douglas Gregor 03b5ebe4cb When the header file search resolves a quoted include to a file in the
current directory, propagate the framework and in-index-header-map
from the including header's information down to the included header's
information. Fixes <rdar://problem/11261291>.

As with everything header-map related, we can't really test this in
isolation within Clang, so it's tested elsewhere.

llvm-svn: 161759
2012-08-13 15:47:39 +00:00
Alexander Kornienko 199cd94f50 Added some preprocessor memory usage stats to -cc1 -print-stats
llvm-svn: 161752
2012-08-13 10:46:42 +00:00
Eric Christopher 921cf137b3 This is always going to be true so the cast isn't necessary.
llvm-svn: 161744
2012-08-13 02:07:42 +00:00
Dmitri Gribenko a43ec186a4 Attaching comments to declarations: find comment attached to any redeclaration
Not only look for the comment near the declaration itself, but also walk the
redeclaration chain: the previous declaration might have had a documentation
comment.

llvm-svn: 161722
2012-08-11 00:51:43 +00:00
Fariborz Jahanian 5e74a1af6f Removed an unused function I added a while back.
llvm-svn: 161714
2012-08-10 22:28:13 +00:00
Jordan Rose 02e5309b35 [analyzer] Strip CXXBaseObjectRegions when devirtualizing method calls.
This was causing a crash when we tried to re-apply a base object region to
itself. It probably also caused incorrect offset calculations in RegionStore.

PR13569 / <rdar://problem/12076683>

llvm-svn: 161710
2012-08-10 22:26:46 +00:00
Jordan Rose 51bcb226a2 [analyzer] Try to devirtualize even if the static callee has no definition.
This mostly affects pure virtual methods, but would also affect parent
methods defined inline in the header when analyzing the child's source file.

llvm-svn: 161709
2012-08-10 22:26:43 +00:00
Jordan Rose 13937b1d7a [analyzer] Add clang_analyzer_checkInlined for debugging purposes.
This check is also accessible through the debug.ExprInspection checker.
Like clang_analyzer_eval, you can use it to test the analyzer engine's
current state; the argument should be true or false to indicate whether or
not you expect the function to be inlined.

When used in the positive case (clang_analyzer_checkInlined(true)), the
analyzer prints the message "TRUE" if the function is ever inlined. However,
clang_analyzer_checkInlined(false) should never print a message; this asserts
that there should be no paths on which the current function is inlined, but
then there are no paths on which to print a message! (If the assertion is
violated, the message "FALSE" will be printed.)

This asymmetry comes from the fact that the only other chance to print a
message is when the function is analyzed as a top-level function. However,
when we do that, we can't be sure it isn't also inlined elsewhere (such as
in a recursive function, or if we want to analyze in both general or
specialized cases). Rather than have all checkInlined calls have an appended,
meaningless "FALSE" or "TOP-LEVEL" case, there is just no message printed.

void clang_analyzer_checkInlined(int);

For debugging purposes only!

llvm-svn: 161708
2012-08-10 22:26:29 +00:00
Chad Rosier baf53f9ff8 [ms-inline asm] Avoid extra allocations by making this an array of StringRefs.
llvm-svn: 161703
2012-08-10 21:36:25 +00:00
Manman Ren 804137fd75 Add comments for turning on byval
llvm-svn: 161702
2012-08-10 21:32:09 +00:00
Chad Rosier f32302a7d9 [ms-inline asm] PatchMSAsmString() doesn't correctly patch non-simple asm
statements.  Therefore, we can't pass the PatchedAsmString to the AsmParser
and expect things to work.

llvm-svn: 161701
2012-08-10 21:27:11 +00:00
Eli Friedman dc009da2a8 Don't emit an invoke whose normal destination is a landingpad. Fixes test
regression on test/CodeGenObjC/2008-10-3-EhValue.m on non-Darwin targets.

llvm-svn: 161700
2012-08-10 21:26:17 +00:00
Fariborz Jahanian f64b4722eb objective-C++: dalyed parsing of ctors with member
initializer list defined inside an objc class
implementation. wip

llvm-svn: 161699
2012-08-10 21:15:06 +00:00
Chad Rosier d6ef704fe4 [ms-inline asm] Fix a memory leak introduced in r161686.
llvm-svn: 161698
2012-08-10 21:06:19 +00:00
Manman Ren d4badd7420 ARM: enable struct byval for AAPCS.
rdar://9877866
PR://13350

llvm-svn: 161694
2012-08-10 20:42:31 +00:00
Fariborz Jahanian 053227f808 objective-C++: delay parsing of ctor with try block
with member initializer list defined inside
an objc implementation block. wip.

llvm-svn: 161692
2012-08-10 20:34:17 +00:00
DeLesley Hutchins 0c90c2bc4b Thread-safety-analysis: adds existential quantification over lock
expressions.  The syntax &MyClass::mutex is interpreted as a
pattern that matches m->mutex for any object m of type MyClass.

llvm-svn: 161691
2012-08-10 20:29:46 +00:00
DeLesley Hutchins 9b1d72f3e3 Thread safety analysis: refactor to support more sophisticated handling
of expressions, and better error messages.

llvm-svn: 161690
2012-08-10 20:19:55 +00:00
Chad Rosier a7020aee00 [ms-inline asm] Add clobbers to AST representation.
llvm-svn: 161686
2012-08-10 19:13:14 +00:00
Dylan Noblesmith 8d48c8c675 Frontend: define _LP64 in a target-independent way
Instead of adding it to each individual subclass in
Targets.cpp, simply check the appropriate target
values.

Where before it was only on x86_64 and ppc64, it's now
also defined on mips64 and nvptx64.

Also add a bunch of negative tests to ensure it is *not*
defined on any other architectures while we're here.

llvm-svn: 161685
2012-08-10 19:12:37 +00:00
Anna Zaks 75f49a9c07 [analyzer] Track if a region can be a subclass in the dynamic type info.
When object is allocated with alloc or init, we assume it cannot be a
subclass (currently used only for bifurcation purposes).

llvm-svn: 161682
2012-08-10 18:55:58 +00:00
Anna Zaks 920af014c1 [analyzer] Optimize dynamic dispatch bifurcation by detecting the cases
when we don't need to split.

In some cases we know that a method cannot have a different
implementation in a subclass:
 - the class is declared in the main file (private)
 - all the method declarations (including the ones coming from super
classes) are in the main file.

This can be improved further, but might be enough for the heuristic.
(When we are too aggressive splitting the state, efficiency suffers.
When we fail to split the state coverage might suffer.)

llvm-svn: 161681
2012-08-10 18:55:53 +00:00
DeLesley Hutchins c9776faa4f Refactor thread safety analysis to use a different data structure
to track locksets.  This is in preparation for further changes.

llvm-svn: 161680
2012-08-10 18:39:05 +00:00
Chad Rosier 3674ebaa6b [ms-inline asm] Use asserts as these calls are now guarded by identical checks.
llvm-svn: 161676
2012-08-10 18:20:12 +00:00
Fariborz Jahanian 8cecfe9fc9 objective-C++: delayed parsing of member function with
function-try-block occuring in objc's implementation
block. wip.

llvm-svn: 161675
2012-08-10 18:10:56 +00:00
Chad Rosier 02a8439730 Whitespace.
llvm-svn: 161673
2012-08-10 17:56:09 +00:00
Fariborz Jahanian 712bb81a6d objective-C++: Delayed parsing of most common
member functions defined inside an objc class
implementation. wip.

llvm-svn: 161667
2012-08-10 15:54:40 +00:00
Joerg Sonnenberger 42cf26883e Add missing cctype includes.
llvm-svn: 161660
2012-08-10 10:58:18 +00:00
Joerg Sonnenberger 8c02a241f4 Decrementing std::string::end is not portable, use array access instead.
llvm-svn: 161659
2012-08-10 10:57:52 +00:00
Benjamin Kramer 3a913ed805 Fix a couple of pedantic gcc warnings.
llvm-svn: 161656
2012-08-10 10:06:13 +00:00
John McCall a0a9689550 Check access to friend declarations. There's a number of different
things going on here that were problematic:
  - We were missing the actual access check, or rather, it was suppressed
    on account of being a redeclaration lookup.
  - The access check would naturally happen during delay, which isn't
    appropriate in this case.
  - We weren't actually emitting dependent diagnostics associated with
    class templates, which was unfortunate.
  - Access was being propagated incorrectly for friend method declarations
    that couldn't be matched at parse-time.

llvm-svn: 161652
2012-08-10 03:15:35 +00:00
Jordan Rose b00073db80 Update VerifyDiagnosticConsumer to only get directives during parsing.
The old behavior was to re-scan any files (like modules) where we may have
directives but won't actually be parsing during the -verify invocation.
Now, we keep the old behavior in Debug builds as a sanity check (though
modules are a known entity), and expect all legitimate directives to come
from comments seen by the preprocessor.

This also affects the ARC migration tool, which captures diagnostics in
order to filter some out. This change adds an explicit cleanup to
CaptureDiagnosticsConsumer in order to let its sub-consumer handle the
real end of diagnostics.

This was originally split into four patches, but the tests do not run
cleanly without all four, so I've combined them into one commit.

Patches by Andy Gibbs, with slight modifications from me.

llvm-svn: 161650
2012-08-10 01:06:16 +00:00
Jordan Rose ea762b0460 Make sure to call EndSourceFile even if we can't continue compiling.
Patch by Andy Gibbs!

llvm-svn: 161649
2012-08-10 01:06:08 +00:00
David Blaikie f5697e5222 Provide isConst/Volatile on CXXMethodDecl.
This also provides isConst/Volatile/Restrict on FunctionTypes to coalesce
the implementation with other callers (& update those other callers).

Patch contributed by Sam Panzer (panzer@google.com).

llvm-svn: 161647
2012-08-10 00:55:35 +00:00
Chad Rosier 1426a81a74 [ms-inline asm] Use the new Inline Asm Non-Standard Dialect attribute.
llvm-svn: 161642
2012-08-10 00:00:34 +00:00
Jordan Rose 637ff0cc0f [analyzer] Merge RegionStore's KillStruct and CopyLazyBindings: BindAggregate.
Both methods need to clear out existing bindings and provide a new default
binding. Originally KillStruct always provided UnknownVal as the default,
but it's allowed symbolic values for quite some time (for handling returned
structs in C).

No functionality change.

llvm-svn: 161637
2012-08-09 22:55:54 +00:00
Jordan Rose a44a55a8f2 [analyzer] Cluster bindings in RegionStore by base region.
This should speed up activities that need to access bindings by cluster,
such as invalidation and dead-bindings cleaning. In some cases all we save
is the cost of building the region cluster map, but other times we can
actually avoid traversing the rest of the store.

In casual testing, this produced a speedup of nearly 10% analyzing SQLite,
with /less/ memory used.

llvm-svn: 161636
2012-08-09 22:55:51 +00:00
Jordan Rose c91e01bc11 [analyzer] Cache the "concrete offset base" for regions with symbolic offsets.
This makes it faster to access and invalidate bindings with symbolic offsets
by only computing this information once.

No intended functionality change.

llvm-svn: 161635
2012-08-09 22:55:37 +00:00
Eli Friedman 5bb2ba0503 Followup to r161546, to unbreak linking on Bitrig. Patch by David Hill.
llvm-svn: 161630
2012-08-09 22:42:04 +00:00
Benjamin Kramer be1bc3c824 CMake: Add the new dependency from libSema to LLVM's libs.
Should fix the failures seen on some linux builders.

llvm-svn: 161629
2012-08-09 22:33:50 +00:00
Chad Rosier d82f647dee [ms-inline asm] Fix comment.
llvm-svn: 161622
2012-08-09 21:28:05 +00:00
Jordan Rose 996d309fb7 [analyzer] A CXXBaseObjectRegion should correspond to a DIRECT base.
An ASTContext's RecordLayoutInfo can only be used to look up offsets of
direct base classes, and we need the offset to make non-symbolic bindings
in RegionStore. This change makes sure that we have one layer of
CXXBaseObjectRegion for each base we are casting through.

This was causing crashes on an internal buildbot.

llvm-svn: 161621
2012-08-09 21:24:02 +00:00
Fariborz Jahanian 656b5a0937 objective-C: refactoring of objc's delayed parsing.
llvm-svn: 161620
2012-08-09 21:12:39 +00:00
Chad Rosier 8640a2a0db [ms-inline asm] Use StringRef here, per Jordan's suggestion.
llvm-svn: 161619
2012-08-09 21:06:32 +00:00
Anna Zaks a0105b2320 [analyzer] Rename the function to better reflect what it actually does.
llvm-svn: 161617
2012-08-09 21:02:45 +00:00
Anna Zaks 8d1f1f3b06 [analyzer] Clarify the values in Dyn. Dispatch Bifurcation map.
llvm-svn: 161616
2012-08-09 21:02:41 +00:00
Chad Rosier 543cb3e93a [ms-inline asm] Simplify logic for empty asm statements.
llvm-svn: 161615
2012-08-09 20:52:43 +00:00
Chad Rosier 11ede938e9 [ms-inline asm] Instantiate the various parts to the AsmParser.
llvm-svn: 161614
2012-08-09 20:47:38 +00:00
Richard Smith 10c6072d61 In 'delete []', the '[]' never starts a lambda. Update a FIXME with a standard reference and add a test.
llvm-svn: 161604
2012-08-09 19:01:51 +00:00
Anna Zaks 85383182ec [analyzer] Improve readability of the dyn. dispatch bifurcation patch
r161552.

As per Jordan's feedback.

llvm-svn: 161603
2012-08-09 18:43:00 +00:00
Dmitri Gribenko ba7aca3b38 Comment to HTML and XML conversion: ignore commands that contain a declaration
as their argument.  For example, \fn, \function, \typedef, \method, \class etc.

llvm-svn: 161601
2012-08-09 18:20:29 +00:00
Chad Rosier d5c43a5f4b [ms-inline asm] Initialize targets and assembly printers/parsers.
llvm-svn: 161595
2012-08-09 17:33:11 +00:00
Fariborz Jahanian db5743d1b4 objective-C: minor refactoring in method
definition parsing logic.

llvm-svn: 161593
2012-08-09 17:15:00 +00:00
Anna Zaks bc6d0ccf92 Unbreak the build.
Declaring "const Decl *Decl" is not a good idea.

llvm-svn: 161567
2012-08-09 02:57:02 +00:00
Anna Zaks 23a6201890 [analyzer] Cleanup of malloc checker.
Remove Escaped state, which is not really necessary. We can just stop
tracking the symbol instead of keeping it around and marking escaped.

llvm-svn: 161557
2012-08-09 00:42:24 +00:00
Eli Friedman e66abdafa6 Fix AAPCS ABI. I can't actually test this, but it restores the behavior from before r159168. PR13562.
llvm-svn: 161554
2012-08-09 00:31:40 +00:00
Anna Zaks 123af098b8 [analyzer] Bifurcate the path with dynamic dispatch.
This is an initial (unoptimized) version. We split the path when
inlining ObjC instance methods. On one branch we always assume that the
type information for the given memory region is precise. On the other we
assume that we don't have the exact type info. It is important to check
since the class could be subclassed and the method can be overridden. If
we always inline we can loose coverage.

Had to refactor some of the call eval functions.

llvm-svn: 161552
2012-08-09 00:21:33 +00:00
Dmitri Gribenko a7b3214c4e Add new file CommentCommandTraits.cpp to CMakeLists.txt.
llvm-svn: 161551
2012-08-09 00:16:26 +00:00
Dmitri Gribenko ca7f80ada0 Comment parsing: extract TableGen'able pieces into new CommandTraits class.
llvm-svn: 161548
2012-08-09 00:03:17 +00:00
Eli Friedman 9fa2885522 clang support for Bitrig (an OpenBSD fork); patch by David Hill.
llvm-svn: 161546
2012-08-08 23:57:20 +00:00
Eli Friedman 934dbbfa11 Minor simplification for r161534.
llvm-svn: 161544
2012-08-08 23:53:27 +00:00
Fariborz Jahanian 18d0a5d509 objective-C: refactor/simplify parsing of delayed
method/c-funcs defined in objc class implementation.
No intended functionality change.

llvm-svn: 161540
2012-08-08 23:41:08 +00:00
Eli Friedman ba01f2bc04 Fix r161534 so it actually builds.
llvm-svn: 161539
2012-08-08 23:35:12 +00:00
Richard Smith ac4e36d1af PR13558: Fix typo 'compatiblity'. Thinking of the children. Apparently.
llvm-svn: 161537
2012-08-08 23:32:13 +00:00
Eli Friedman 89b1f2c7e1 Handle deprecation diagnostics correctly for C struct fields and Objective-C properties/ivars. <rdar://problem/6642337>.
llvm-svn: 161534
2012-08-08 23:04:35 +00:00
Eli Friedman 971bfa11c6 Unify the codepaths for emitting deprecation warnings. The test changes are just to account for us emitting notes more consistently.
llvm-svn: 161528
2012-08-08 21:52:41 +00:00
Anna Zaks 13b0857ad0 Address code review comments for Wstrncat-size warning (r161440).
llvm-svn: 161527
2012-08-08 21:42:23 +00:00
Chad Rosier 5d4d8b746b [ms-inline asm] Use more idiomatic logic. Thanks, Bill.
llvm-svn: 161526
2012-08-08 21:42:11 +00:00
Jordan Rose 742c6079e2 Implicitly annotate __CFStringMakeConstantString with format_arg(1).
We handled the builtin version of this function in r157968, but the builtin
isn't used when compiling as -fno-constant-cfstrings.

This should complete <rdar://problem/6157200>.

llvm-svn: 161525
2012-08-08 21:17:31 +00:00
Chad Rosier 360e1763d5 [ms-inline asm] Add basic codegen support for simple asm stmts. Currently,
only machine specific clobbers are modeled.

llvm-svn: 161524
2012-08-08 21:15:52 +00:00
Eli Friedman 0415f3e138 Don't add attributes for "#pragma pack" and friends to tag declarations which
are not definitions. This follows the behavior of both gcc and earlier
versions of clang. Regression from r156531.  <rdar://problem/12048621>.

llvm-svn: 161523
2012-08-08 21:08:34 +00:00
Chad Rosier b1886eb604 [ms-inline asm] Make sure IsSimple is correctly handled.
llvm-svn: 161522
2012-08-08 21:08:20 +00:00
Chad Rosier 66753b3835 Remove extraneous comment.
llvm-svn: 161521
2012-08-08 20:38:22 +00:00
Chad Rosier 83916498b8 [ms-inline asm] Add a very simple test case. Basically, we're only testing for
crashers at the moment (and coincidentally this case was causing a crash).

llvm-svn: 161520
2012-08-08 20:37:31 +00:00
Chad Rosier 3ed0bd9938 [ms-inline asm] Refactor the logic to generate the AsmString into Sema. No
functional change intended.

llvm-svn: 161518
2012-08-08 19:48:07 +00:00