Commit Graph

26814 Commits

Author SHA1 Message Date
Chad Rosier bbbe9ab876 [ms-inline asm] Make the AsmStmt class non-virtual.
llvm-svn: 162768
2012-08-28 17:43:23 +00:00
Michael Liao 48f498fccf Fix PR13704
- The increment needs to be signed value to preserve the original value when
  its data type is larger than 64-bit integer.

llvm-svn: 162766
2012-08-28 16:55:13 +00:00
Hans Wennborg f4ad232921 Warn about suspicious implicit conversions from floating point to bool
This warns in two specific situations:

1) For potentially swapped function arguments, e.g.

     void foo(bool, float);
     foo(1.7, false);

2) Misplaced brackets around function call arguments, e.g.

     bool InRange = fabs(a - b < delta);

   Where the last argument in a function call is implicitly converted
   from bool to float, and the function returns a float which gets
   implicitly converted to bool.

Patch by Andreas Eckleder!

llvm-svn: 162763
2012-08-28 15:44:30 +00:00
Roman Divacky afe2f23a3c Cleanup FreeBSD linking and add support for -pie.
Path by Brooks Davis, tests and fixes from me.

llvm-svn: 162761
2012-08-28 15:09:03 +00:00
Rafael Espindola 3dd531dbd4 Fix for assertion when solving unresolved templates.
Patch by Magee, Josh.

llvm-svn: 162737
2012-08-28 04:13:54 +00:00
Dmitri Gribenko 4364fcf026 Fix a -Wdocumentation warning.
llvm-svn: 162730
2012-08-28 02:49:14 +00:00
Dmitri Gribenko 557a8d568b Merging consecutive comments: be more conservative.
Should fix part 2 of PR13374.

llvm-svn: 162723
2012-08-28 01:20:53 +00:00
Jordan Rose a0f7d35afe [analyzer] Rename addTrackNullOrUndefValueVisitor to trackNullOrUndefValue.
This helper function (in the clang::ento::bugreporter namespace) may add more
than one visitor, but conceptually it's tracking a single use of a null or
undefined value and should do so as best it can.

Also, the BugReport parameter has been made a reference to underscore that
it is non-optional.

llvm-svn: 162720
2012-08-28 00:50:51 +00:00
Jordan Rose 72c5515bab [analyzer] Refactor FindLastStoreBRVisitor to not find the store ahead of time.
As Anna pointed out to me offline, it's a little silly to walk backwards through
the graph to find the store site when BugReporter will do the exact same walk
as part of path diagnostic generation.

llvm-svn: 162719
2012-08-28 00:50:45 +00:00
Jordan Rose 5090904d6c [analyzer] If the last store into a region came from a function, step into it.
Previously, if we were tracking stores to a variable 'x', and came across this:

x = foo();

...we would simply emit a note here and stop. Now, we'll step into 'foo' and
continue tracking the returned value from there.

<rdar://problem/12114689>

llvm-svn: 162718
2012-08-28 00:50:42 +00:00
Jordan Rose e537cc05f5 [analyzer] Rename CallEvent::mayBeInlined to CallEvent::isCallStmt.
The two callers are using this in order to be conservative, so let's just
clarify the information that's actually being provided here. This is not
related to inlining decisions in any way.

No functionality change.

llvm-svn: 162717
2012-08-28 00:50:38 +00:00
Chad Rosier a1b5c8c6a1 [ms-inline asm] Hoist more common code into the AsmStmt base class. Add stubs
with FIXMEs for unimplemented features.  No functional change intended.

llvm-svn: 162716
2012-08-28 00:24:05 +00:00
Chad Rosier 6100ae120c [ms-inline asm] Add virtual function, getClobber, that returns a StringRef.
More work towards unifying asm stmt codegen.

llvm-svn: 162712
2012-08-27 23:47:56 +00:00
Chad Rosier d9fb09a91b [ms-inline asm] Rename getClobber to getClobberStringLiteral. No functional
change intended.

llvm-svn: 162710
2012-08-27 23:28:41 +00:00
Benjamin Kramer 29f9a00732 CodeGen: Hoist check from recursive function to its only callsite.
Suggested by Roman Divacky.

llvm-svn: 162702
2012-08-27 22:07:02 +00:00
Benjamin Kramer 46cbe77b49 CodeGen: When emitting stores for an initializer, only emit a GEP if we really need the store.
This avoids emitting many dead GEPs for large zero-initialized arrays.

llvm-svn: 162701
2012-08-27 21:35:58 +00:00
Simon Atanasyan ec4b1c194b MIPS: Use -G option to specify MIPS section threshold. Translate it
to the -mllvm -mips-ssection-threshold=<value> pair and pass to the frontend.
The patch suggested by Carl Norum.

llvm-svn: 162697
2012-08-27 20:55:56 +00:00
Chad Rosier 3b0c2607ef [ms-inline asm] Rename GenerateAsmString to generateAsmString to conform with
coding standards.  Also, add stub for MSAsmStmt class as part of unifying 
codegen logic for AsmStmts.

llvm-svn: 162696
2012-08-27 20:23:31 +00:00
Jordan Rose 1a61674f5a [analyzer] Look through casts when trying to track a null pointer dereference.
Also, add comments to addTrackNullOrUndefValueVisitor.

Thanks for the review, Anna!

llvm-svn: 162695
2012-08-27 20:18:30 +00:00
Chad Rosier fe3352e0bc [ms-inline asm] Hoist common logic into the AsmStmt base class.
llvm-svn: 162692
2012-08-27 19:38:01 +00:00
Chad Rosier aeff2299c3 [ms-inline asm] Add a new base class, AsmStmt, for the GCCAsmStmt and MSAsmStmt
classes.

llvm-svn: 162691
2012-08-27 18:56:36 +00:00
Jordan Rose 561919e5bd [analyzer] Don't inline constructors for objects allocated with operator new.
Because the CXXNewExpr appears after the CXXConstructExpr in the CFG, we don't
actually have the correct region to construct into at the time we decide
whether or not to inline. The long-term fix (discussed in PR12014) might be to
introduce a new CFG node (CFGAllocator) that appears before the constructor.

Tracking the short-term fix in <rdar://problem/12180598>.

llvm-svn: 162689
2012-08-27 18:39:22 +00:00
Anna Zaks 7d2babc046 [analyzer] More internal stats collection.
llvm-svn: 162687
2012-08-27 18:38:32 +00:00
John McCall 64044c3a81 Use cast<> instead of static_cast. Patch by Timur Iskhodzhanov!
llvm-svn: 162683
2012-08-27 18:12:29 +00:00
Jordan Rose c93183042f [analyzer] Inline constructors for any object with a trivial destructor.
This allows us to better reason about status objects, like Clang's own
llvm::Optional (when its contents are trivially destructible), which are
often intended to be passed around by value.

We still don't inline constructors for temporaries in the general case.

<rdar://problem/11986434>

llvm-svn: 162681
2012-08-27 17:50:07 +00:00
Simon Atanasyan 8f06f2fbbf Support MIPS DSP Rev2 intrinsics.
The patch reviewed by Akira Hatanaka.

llvm-svn: 162669
2012-08-27 12:29:20 +00:00
John McCall 9320707aac Tweak the ARC-requires-10.6 diagnostic according to Jordan's review.
llvm-svn: 162651
2012-08-27 01:56:21 +00:00
Eli Friedman 48ddcf2cb5 Fix a CodeGen bug where we would skip zero-initialization for
array new with a non-trivial constructor. Pointed out in PR13380.

llvm-svn: 162643
2012-08-25 07:11:29 +00:00
Richard Smith a374bf0ae1 Remove spurious string literal for bool argument.
llvm-svn: 162642
2012-08-25 05:43:00 +00:00
Francois Pichet fb5d242d25 _HAS_CHAR16_T_LANGUAGE_SUPPORT is not predefined MSVC macro.
llvm-svn: 162641
2012-08-25 05:27:04 +00:00
John McCall a5f46fbcf9 Fix the CC-matching logic for instance methods in the MS ABI.
Patch by Timur Iskhodzhanov!

llvm-svn: 162639
2012-08-25 02:00:03 +00:00
John McCall 3351dc397b Fix the mangling of function pointers in the MS ABI.
Patch by Timur Iskhodzhanov!

llvm-svn: 162638
2012-08-25 01:12:56 +00:00
Jordan Rose 0a0aa84da3 [analyzer] Use the common evalBind infrastructure for initializers.
This allows checkers (like the MallocChecker) to process the effects of the
bind. Previously, using a memory-allocating function (like strdup()) in an
initializer would result in a leak warning.

This does bend the expectations of checkBind a bit; since there is no
assignment expression, the statement being used is the initializer value.
In most cases this shouldn't matter because we'll use a PostInitializer
program point (rather than PostStmt) for any checker-generated nodes, though
we /will/ generate a PostStore node referencing the internal statement.
(In theory this could have funny effects if someone actually does an
assignment within an initializer; in practice, that seems like it would be
very rare.)

<rdar://problem/12171711>

llvm-svn: 162637
2012-08-25 01:06:23 +00:00
Richard Smith 3e056dea1b -fcatch-undefined-behavior: add the -ftrapv checks to the set of things caught
by this mode, and also check for signed left shift overflow. The rules for the
latter are a little subtle:

 * neither C89 nor C++98 specify the behavior of a signed left shift at all
 * in C99 and C11, shifting a 1 bit into the sign bit has undefined behavior
 * in C++11, with core issue 1457, shifting a 1 bit *out* of the sign bit has
   undefined behavior

As of this change, we use the C99 rules for all C language variants, and the
C++11 rules for all C++ language variants. Once we have individual
-fcatch-undefined-behavior= flags, this should be revisited.

llvm-svn: 162634
2012-08-25 00:32:28 +00:00
Chad Rosier de70e0ef45 [ms-inline asm] As part of a larger refactoring, rename AsmStmt to GCCAsmStmt.
No functional change intended.

llvm-svn: 162632
2012-08-25 00:11:56 +00:00
Richard Smith a6a03369da Remove RequireCompleteType call which was made redundant by r162586.
llvm-svn: 162630
2012-08-24 23:51:39 +00:00
Chad Rosier e30d4994f2 [ms-inline asm] Update the AST Reader/Writer for MS-style inline asms.
llvm-svn: 162629
2012-08-24 23:51:02 +00:00
Fariborz Jahanian 1cfbe7a240 objective-C: Do not warn if align attribute on method
declaration is not provided. It is only necessary on
the method implementation. // rdar://11593375

llvm-svn: 162628
2012-08-24 23:50:13 +00:00
Richard Smith 24adaee6bc Fix integer unsigned behavior in clang due to signed left shift overflow.
llvm-svn: 162626
2012-08-24 23:43:39 +00:00
John McCall e91aec7a57 When computing the effective context for access control,
make sure we walk up the DC chain for the current context,
rather than allowing ourselves to get switched over to the
canonical DC chain.  Fixes PR13642.

llvm-svn: 162616
2012-08-24 22:54:02 +00:00
Chad Rosier 175ea24e38 [ms-inline asm] Change the -fenable-experimental-ms-inline-asm option from a
CodeGen option to a LangOpt option.  In turn, hoist the guard into the parser 
so that we avoid the new (and fairly unstable) Sema/AST/CodeGen logic.  This
should restore the behavior of clang to that prior to r158325.
<rdar://problem/12163681>

llvm-svn: 162602
2012-08-24 21:42:51 +00:00
Benjamin Kramer c5d00f61b6 Remove unnecessary calls to c_str.
llvm-svn: 162590
2012-08-24 20:43:21 +00:00
John McCall 7d8b041999 Instantiate class template specializations during ADL.
llvm-svn: 162586
2012-08-24 20:38:34 +00:00
Fariborz Jahanian fd5cf6cf26 objective-C: When checking for valid overriden property
in class extension, assume default is rewdwrite and don't
issue any diagnostics, privided other ownership models
are ok.

llvm-svn: 162583
2012-08-24 20:10:53 +00:00
Ted Kremenek 7c65b8f22a Rename the "experimental" checker package to "alpha". We will then refine
this group into "alpha" and "beta" to distinguish between checkers in
different levels of premature state.

llvm-svn: 162582
2012-08-24 19:46:03 +00:00
Ted Kremenek 5bc38bad73 Rework how PathDiagnosticConsumers pass knowledge of what files they
generated for a given diagnostic to another.  Because PathDiagnostics
are specific to a give PathDiagnosticConsumer, store in
a FoldingSet a unique hash for a PathDiagnostic (that will be the same
for the same bug for different PathDiagnosticConsumers) that
stores a list of files generated.  This can then be read by the
other PathDiagnosticConsumers.

This fixes breakage in the PLIST-HTML output.

llvm-svn: 162580
2012-08-24 19:35:19 +00:00
Chad Rosier 0f8487c632 Fix 80-column violation.
llvm-svn: 162575
2012-08-24 18:31:16 +00:00
Dmitri Gribenko 219bd1554f Comment diagnostics: for unresolved parameters, do not suggest parameter fixit
with parameter that is documented.

Fixes PR13670, <rdar://problem/12155840>.

llvm-svn: 162570
2012-08-24 17:45:39 +00:00
Chad Rosier 14836bab36 [ms-inline asm] Refactor code. No functional change intended.
llvm-svn: 162568
2012-08-24 17:05:45 +00:00
Chad Rosier 1e17cf9c22 [ms-inline asm] Generate the Input/Output expressions using
Sema::ActOnIdExpression().

llvm-svn: 162564
2012-08-24 16:38:58 +00:00
Jordan Rose 51c27163c0 [analyzer] If we dereference a NULL that came from a function, show the return.
More generally, any time we try to track where a null value came from, we
should show if it came from a function. This usually isn't necessary if
the value is symbolic, but if the value is just a constant we previously
just ignored its origin entirely. Now, we'll step into the function and
recursively add a visitor to the returned expression.

<rdar://problem/12114609>

llvm-svn: 162563
2012-08-24 16:34:31 +00:00
Chad Rosier ab24b6e24e Fix 80-column violation.
llvm-svn: 162560
2012-08-24 15:51:10 +00:00
Benjamin Kramer c215e76f78 Push ArrayRef through the Expr hierarchy.
No functionality change.

llvm-svn: 162552
2012-08-24 11:54:20 +00:00
NAKAMURA Takumi d574ac2f4d Fix the definition of JSONAnchorSource. MSVC mangles variable symbols, and "volatile" affects.
llvm-svn: 162550
2012-08-24 10:39:28 +00:00
Ted Kremenek 64fea5fc8f Teach CFG that 'if (x & 0)' and 'if (x * 0)' is an unfeasible branch.
Fixes <rdar://problem/11005770>.

llvm-svn: 162545
2012-08-24 07:42:09 +00:00
Daniel Jasper 6ed1f85c24 Use LLVM's plugin registry to enable registering new compilation
databases. Move JSONCompilationDatabase.h to its own files and
register it as plugin.

llvm-svn: 162541
2012-08-24 05:50:27 +00:00
Anna Zaks fe6eb67b12 [analyzer] Fix realloc related bug in the malloc checker.
When reallocation of a non-allocated (not owned) symbol fails do not
expect it to be freed.

llvm-svn: 162533
2012-08-24 02:28:20 +00:00
Anna Zaks 6fb4b055fb [analyzer] Remove unnecessary code.
This code has been added a while ago and removing it does not trigger
any test failures. The false positives it was trying to suppress are
probably handled by other logic (ex: special handling of delegates).

llvm-svn: 162529
2012-08-24 01:39:13 +00:00
Richard Smith 69d0d2626a New -fcatch-undefined-behavior features:
* when checking that a pointer or reference refers to appropriate storage for a type, also check the alignment and perform a null check
 * check that references are bound to appropriate storage
 * check that 'this' has appropriate storage in member accesses and member function calls

llvm-svn: 162523
2012-08-24 00:54:33 +00:00
Alexander Kornienko 4bcd58b87d Updated LibTooling.html, minor improvements in CommonOptionsParser
llvm-svn: 162521
2012-08-24 00:39:14 +00:00
Chad Rosier fe31e626ca [ms-inline asm] Add the basic APIs for Exprs to the MSAsmStmt AST. Next we need
generate the Input/Output expressions using Sema::ActOnIdExpression().

llvm-svn: 162509
2012-08-24 00:07:09 +00:00
Anna Zaks 3d5d3d3e2c [analyzer] Make analyzer less aggressive when dealing with [self init].
With inlining, retain count checker starts tracking 'self' through the
init methods. The analyser results were too noisy if the developer
did not follow 'self = [super init]' pattern (which is common
especially in older code bases) - we reported self init anti-pattern AND
possible use-after-free. This patch teaches the retain count
checker to assume that [super init] does not fail when it's not consumed
by another expression. This silences the retain count warning that warns
about possibility of use-after-free when init fails, while preserving
all the other checking on 'self'.

llvm-svn: 162508
2012-08-24 00:06:12 +00:00
Dmitri Gribenko 907f6b8c06 Comment semantic analysis: treat function typedefs as functions so that one can
use \param and \returns in documentation.

Fixes PR13533.

llvm-svn: 162507
2012-08-24 00:05:30 +00:00
Dmitri Gribenko dd28e7930c Fix a few -Wdocumentation warnings.
llvm-svn: 162506
2012-08-24 00:01:24 +00:00
Benjamin Kramer cc4c49dd63 Now that ASTMultiPtr is nothing more than a array reference, make it a MutableArrayRef.
This required changing all get() calls to data() and using the simpler constructors.

llvm-svn: 162501
2012-08-23 23:38:35 +00:00
Jordan Rose 434f132060 [analyzer] For now, treat pointers-to-members as non-null void * symbols.
Until we have full support for pointers-to-members, we can at least
approximate some of their use by tracking null and non-null values.
We thus treat &A::m_ptr as a non-null void * symbol, and MemberPointer(0)
as a pointer-sized null constant.

This enables support for what is sometimes called the "safe bool" idiom,
demonstrated in the test case.

llvm-svn: 162495
2012-08-23 23:01:43 +00:00
Jordan Rose 081af085eb [analyzer] Handle UserDefinedConversion casts in C++.
This is trivial; the UserDefinedConversion always wraps a CXXMemberCallExpr
for the appropriate conversion function, so it's just a matter of
propagating that value to the CastExpr itself.

llvm-svn: 162494
2012-08-23 23:01:39 +00:00
Benjamin Kramer f062343889 Remove ASTOwningVector, it doesn't own anything and provides no value over SmallVector.
llvm-svn: 162492
2012-08-23 22:51:59 +00:00
Dmitri Gribenko 91bbf41914 Attaching comments to decls: since it was decided that Decl::isImplicit should
not be set for implicit instantiations, remove the FIXME.  This should be the
last bit for PR13634.  The actual fix happened in r162238.

Motivation: it might be misleading to mark implicit instantiations as
Decl::isImplicit = true.  Because then, in order to be consistent, we should
mark all instantiated members as implicit.  But the user did actually type the
declaration for the member, but the compiler played with it a little bit.

llvm-svn: 162488
2012-08-23 22:40:40 +00:00
Benjamin Kramer 62b95d88dc Rip out remnants of move semantic emulation and smart pointers in Sema.
These were nops for quite a while and only lead to confusion. ASTMultiPtr
now behaves like a proper dumb array reference.

llvm-svn: 162475
2012-08-23 21:35:17 +00:00
Ted Kremenek 2883175e4c Change a bunch of cases where we do "getAs<...>->doSomething()" to
"castAs<...>->doSomething()".  The analyzer was flagging these
as potential null dereferences, which is technically true.  The
invariants appear to be that these casts should never fail, so
let's use castAs<> instead and avoid a runtime check.

llvm-svn: 162468
2012-08-23 20:46:57 +00:00
Richard Smith 7aed66bbee When disambiguating an expression-statement from a declaraton-statement, if the
statement starts with an identifier for which name lookup will fail either way,
look at later tokens to disambiguate in order to improve error recovery.

llvm-svn: 162464
2012-08-23 20:19:14 +00:00
Chad Rosier 59df25b659 [ms-inline asm] Remove an unused argument. This logic can now be reused by the
ms-style inline asms.

llvm-svn: 162463
2012-08-23 20:00:18 +00:00
Jordan Rose e5d5393efc [analyzer] Support C++ default arguments if they are literal values.
A CXXDefaultArgExpr wraps an Expr owned by a ParmVarDecl belonging to the
called function. In general, ExprEngine and Environment ought to treat this
like a ParenExpr or other transparent wrapper expression, with the inside
expression evaluated first.

However, if we call the same function twice, we'd produce a CFG that contains
the same wrapped expression twice, and we're not set up to handle that. I've
added a FIXME to the CFG builder to come back to that, but meanwhile we can
at least handle expressions that don't need to be explicitly evaluated:
literals. This probably handles many common uses of default parameters:
true/false, null, etc.

Part of PR13385 / <rdar://problem/12156507>

llvm-svn: 162453
2012-08-23 18:10:53 +00:00
Dmitri Gribenko adba9be7c5 Fix a bunch of -Wdocumentation warnings.
llvm-svn: 162452
2012-08-23 17:58:28 +00:00
Chad Rosier 8e0744312b [ms-inline asm] Rename a few induction variables to avoid confusion and silence
a gcc warning.

llvm-svn: 162444
2012-08-23 15:44:35 +00:00
David Chisnall 12d8135cd5 Fix transposed optional / required in Objective-C metadata (GNUstep runtime)
Patch by Niels Grewe!

llvm-svn: 162441
2012-08-23 12:17:21 +00:00
Eli Friedman 5d14c48dbb Attempt to fix clang bootstrap (broken by r162425).
llvm-svn: 162440
2012-08-23 11:27:56 +00:00
Richard Smith 802c4b7015 Fix undefined behavior: member function calls where 'this' is a null pointer.
llvm-svn: 162430
2012-08-23 06:16:52 +00:00
Douglas Gregor 7bdc8ae20b array_pod_sort on the addresses of declaration pointers leads to
inconsistent ordering of results; instead, use use SmallPtrSet to
eliminate duplicates.

llvm-svn: 162429
2012-08-23 05:05:18 +00:00
Richard Smith 9db4b0020c Fix undefined behavior: don't call ObjCInterfaceDecl::isArcWeakrefUnavailable
on a null pointer. (This function happens to work for a null 'this' pointer, so
no test.)

llvm-svn: 162427
2012-08-23 04:53:18 +00:00
Eli Friedman a5dd5684dc Use the alignment from lvalue emission to more accurately compute the alignment
of a pointer for builtin emission, instead of just depending on the type of the
pointee.  <rdar://problem/11314941>.

llvm-svn: 162425
2012-08-23 03:10:17 +00:00
Matt Beaumont-Gay 1e774bc835 Don't recycle loop variables (to keep GCC happy).
llvm-svn: 162424
2012-08-23 01:51:18 +00:00
Chad Rosier 0cf0615571 Fix 80-column violation.
llvm-svn: 162416
2012-08-23 00:12:51 +00:00
Ted Kremenek 78094caa56 Fix an assortment of doxygen comment issues found by -Wdocumentation.
llvm-svn: 162412
2012-08-22 23:50:41 +00:00
Chad Rosier f4958d1f10 [ms-inline asm] Compute the inputs and outputs. No test case (yet) as this
requires codegen support.

llvm-svn: 162410
2012-08-22 23:42:09 +00:00
Dmitri Gribenko 107618a6cb Comment parsing: parse "<blah" as an HTML tag only if "blah" is a known tag
name.  This should reduce the amount of warning false positives about bad HTML
in comments when the comment author intended to put a reference to a template.
This change will also enable us parse the comment as intended in these cases.

Fixes part 1 of PR13374.

llvm-svn: 162407
2012-08-22 22:56:08 +00:00
Anna Zaks 9159e16f21 [analyzer] Fixup to r162399. Initialize the member variable.
llvm-svn: 162405
2012-08-22 22:47:58 +00:00
Chad Rosier dc5311aab6 [ms-inline asm] Refactor code so that we can begin computing the Inputs/Outputs.
No functional change intended.

llvm-svn: 162403
2012-08-22 22:10:51 +00:00
Anna Zaks 5a5a1755f2 [analyzer] Add osx.cocoa.NonNilReturnValue checker.
The checker adds assumptions that the return values from the known APIs
are non-nil. Teach the checker about NSArray/NSMutableArray/NSOrderedSet
objectAtIndex, objectAtIndexedSubscript.

llvm-svn: 162398
2012-08-22 21:19:56 +00:00
Chad Rosier eb7deb2851 [ms-inline asm] Add comments.
llvm-svn: 162396
2012-08-22 21:12:19 +00:00
Chad Rosier 53d79d9905 [ms-inline asm] Add comments.
llvm-svn: 162394
2012-08-22 21:08:06 +00:00
Chad Rosier bb365caf80 [ms-inline asm] Add helper function. No functional change intended.
llvm-svn: 162393
2012-08-22 21:04:07 +00:00
Chad Rosier 6b6a8a363b [ms-inline asm] Simplify logic. No functional change intended.
llvm-svn: 162392
2012-08-22 20:57:07 +00:00
Alexander Kornienko 01387267c7 Reverted clang-check to fully supported CommandLine Library use-case: global
static variables.

llvm-svn: 162391
2012-08-22 20:52:52 +00:00
Chad Rosier 060c0ea89a [ms-inline asm] Compute the token range for each instruction within the asm.
Eventually, we'll need a way of mapping tokens (and their IdentifierInfo*) to
the operands computed by buildMSAsmPieces().

llvm-svn: 162388
2012-08-22 20:30:58 +00:00
Ted Kremenek 326702f1a1 Despite me asking Jordan to do r162313, revert it. We can provide
another way to whitelist these special cases.  This is an intermediate patch.

llvm-svn: 162386
2012-08-22 19:58:20 +00:00
Chad Rosier a766697f4e [ms-inline asm] Simplify logic. No functional change intended.
llvm-svn: 162385
2012-08-22 19:50:28 +00:00
Ted Kremenek a056d62961 Remove BasicConstraintManager. It hasn't been in active service for a while.
As part of this change, I discovered that a few of our tests were not testing
the RangeConstraintManager.  Luckily all of those passed when I moved them
over to use that constraint manager.

llvm-svn: 162384
2012-08-22 19:47:13 +00:00
Chad Rosier d997bd1422 [ms-inline asm] Start sending non-simple inline asms to the AsmParser.
The parser still can't handle all cases, so fall back to emitting a simple
MSAsmStmt if we get into trouble.

llvm-svn: 162382
2012-08-22 19:18:30 +00:00
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