Benjamin Kramer [Sat, 12 May 2012 21:10:52 +0000 (21:10 +0000)]
Add support for __attribute__((hot)) and __attribute__((cold)).
Currently cold functions are marked with the "optsize" attribute in CodeGen
so they are always optimized for size. The hot attribute is just ignored,
LLVM doesn't have a way to express hotness at the moment.
Gregory Szorc [Sat, 12 May 2012 20:49:13 +0000 (20:49 +0000)]
[clang.py] Followup to TranslationUnit refactor
* Document index argument in TranslationUnit.from_source
* Add numeric error code to TranslationUnitSaveError string representation
* Use None instead of [] for default argument value in
TranslationUnit.codeComplete
Jordy Rose [Sat, 12 May 2012 17:32:56 +0000 (17:32 +0000)]
Only check NSArray/NSDictionary boxing method params once.
Once we've found a "good" method, we don't need to check its argument types
again. (Even if we might have later found a "bad" method, we were already
caching the method we first looked up.)
Douglas Gregor [Fri, 11 May 2012 23:01:43 +0000 (23:01 +0000)]
Make sure that we recognize __attribute__((align)) as a synonym for
__attribute__((aligned)). Fixes <rdar://problem/11435441>, a
regression I introduced in r156003. This is the narrow fix; a more
comprehensive fix is coming.
Richard Smith [Fri, 11 May 2012 22:20:10 +0000 (22:20 +0000)]
When diagnosing inaccessible temporary destructors in decltype expressions, use
the correct type and the correct source location in the diagnostic. Spotted by
Johannes Schaub!
Richard Smith [Fri, 11 May 2012 05:16:41 +0000 (05:16 +0000)]
PR11857: When the wrong number of arguments are provided for a function
which expects exactly one argument, include the name of the argument in
the diagnostic text. Patch by Terry Long!
[objc] When boxing a BOOL/NSInteger/NSUInteger type, use the corresponding
numberWithBool:/numberWithInteger:/numberWithUnsignedInteger: NSNumber selectors.
Ted Kremenek [Thu, 10 May 2012 22:02:39 +0000 (22:02 +0000)]
Fix insidious RegionStore bug where we (a) didn't handle vector types and (b) had
a horrible bug in GetLazyBindings where we falsely appended a field suffix when traversing 3 or more
layers of lazy bindings. I don't have a reduced test case yet; but I have added the original source
to an internal regression test suite. I'll see about coming up with a reduced test case.
Fix an assertion hit when the serialized diagnostics writer receive a diagnostic
from the frontend when the location is invalid and the SourceManager null.
Instead of keeping the SourceManager object in DiagnosticRenderer, propagate it
to the calls accordingly (as reference when it is expected to not be null, or pointer
when it may be null).
This effectively makes DiagnosticRenderer not tied to a specific SourceManager,
removing a hack from TextDiagnosticPrinter.
Rafael Espindola [Thu, 10 May 2012 02:50:16 +0000 (02:50 +0000)]
Fix an old (2009) FIXME:
// FIXME: This needs to happen before we merge declarations. Then,
// let attribute merging cope with attribute conflicts.
This was already being done for variables, but for functions we were merging
then first and then applying the attributes. To avoid duplicating merging
logic, some of the helpers in SemaDeclAttr.cpp become methods that can
handle merging two attributes in one decl or inheriting attributes from one
decl to another.
With this change we are now able to produce errors for variables with
incompatible visibility attributes or warn about unused dllimports in
variables.
This changes the attribute list iteration back to being in reverse source
code order, as that matches what decl merging does and avoids differentiating
the two cases is the merge*Attr methods.
Anna Zaks [Thu, 10 May 2012 01:37:40 +0000 (01:37 +0000)]
[analyzer] Do not highlight the range of the statement in case of leak.
We report a leak at a point a leaked variable is no longer accessible.
The statement that happens to be at that point is not relevant to the
leak diagnostic and, thus, should not be highlighted.
Richard Smith [Wed, 9 May 2012 23:51:36 +0000 (23:51 +0000)]
RecursiveASTVisitor:
We don't create any declaration to mark the explicit instantiation of function
templates other than the instantiation itself, so visit that when traversing
the function template decl.
This is a temporary fix, pending the creation of a Decl node to represent the
explicit instantiation.
Richard Smith [Wed, 9 May 2012 20:55:26 +0000 (20:55 +0000)]
Push the knowledge that we are parsing a type-id/type-name further into the
parser, and use it to emit better diagnostics in cases where an identifer
can't be looked up as a type name.
Richard Smith [Wed, 9 May 2012 18:56:43 +0000 (18:56 +0000)]
Stop AltiVec parsing from going down the 'implicit int' codepath as part of its
normal parse for token sequences like 'vector pixel foo'. This incidentally also
fixes a couple of wrong-parse issues.
Simon Atanasyan [Wed, 9 May 2012 16:18:30 +0000 (16:18 +0000)]
Declare abstract class ArgumentsAdjuster. This abstract interface describes
a command line argument adjuster, which is responsible for command line
arguments modification before the arguments are used to run a frontend action.
Define class ClangSyntaxOnlyAdjuster implements ArgumentsAdjuster interface.
This class converts input command line arguments to the "syntax check only"
variant.
[AST/libclang] Speed up clang_getOverriddenCursors() considerably by reserving a bit
in ObjCMethodDecl to indicate whether the method does not override any other method,
which is the majority of cases.
That way we can avoid unnecessary work doing lookups, especially when PCH is involved.
Richard Smith [Wed, 9 May 2012 05:17:00 +0000 (05:17 +0000)]
A little tweak to the SFINAE condition reporting. Don't say:
candidate template ignored: substitution failed [with T = int]: no type named 'type' in 'std::enable_if<false, void>'
Instead, just say:
candidate template ignored: disabled by 'enable_if' [with T = int]
... and point at the enable_if condition which (we assume) failed.
This is applied to all cases where the user writes 'typename enable_if<...>::type' (optionally prefixed with a nested name specifier), and 'enable_if<...>' names a complete class type which does not have a member named 'type', and this results in a candidate function being ignored in a SFINAE context. Thus it catches 'std::enable_if', 'std::__1::enable_if', 'boost::enable_if' and 'llvm::enable_if'.
Richard Trieu [Wed, 9 May 2012 00:21:34 +0000 (00:21 +0000)]
Update the SelfReferenceChecker. Refactored some of the visitor methods.
Added support for conditional operators and tightened the exclusion of the
unary operator from all operators to only the address of operator.
Anna Zaks [Tue, 8 May 2012 23:40:38 +0000 (23:40 +0000)]
[analyzer] We currently do not fully support CompoundLiterals in
RegionStore, so be explicit about it and generate UnknownVal().
This is a hack to ensure we never produce undefined values for a value
coming from a compound value. (The undefined values can lead to
false positives.)
Ted Kremenek [Tue, 8 May 2012 21:49:54 +0000 (21:49 +0000)]
Having RegionStore lower field bindings to raw offsets, just like ElementRegions. This is a bit
disruptive, but it allows RegionStore to better "see" through casts that reinterpret arrays of values
as structs. Fixes <rdar://problem/11405978>.
John McCall [Tue, 8 May 2012 21:41:25 +0000 (21:41 +0000)]
Bind cleanups after doing l2r conversion on the operand of a
@throw expression; l2r conversion can introduce new cleanups
in certain cases, like when the expression is an ObjC property
reference of retainable type in ARC.
Anna Zaks [Tue, 8 May 2012 21:19:21 +0000 (21:19 +0000)]
[analyzer] SelfInit: Stop tracking self if it's assigned a value we
don't reason about.
Self is just like a local variable in init methods, so it can be
assigned anything like result of static functions, other methods ... So
to suppress false positives that result in such cases, stop tracking the
checker-specific state after self is being assigned to (unless the
value is't being assigned to is either self or conforms to our rules).
This change does not invalidate any existing regression tests.
Gregory Szorc [Tue, 8 May 2012 05:56:38 +0000 (05:56 +0000)]
[clang.py] TranslationUnit API improvements
* TranslationUnit reading and parsing now implemented as
TranslationUnit.from_ast() and TranslationUnit.from_source().
* Index.parse() and Index.read() implemented through above.
* Index.parse() and Index.read() now raise a TanslationUnitLoadException
instead of returning None if a TranslationUnit could not be
instantiated. This is backwards incompatible.
* Ability to save TranslationUnits via TranslationUnit.save().
* TranslationUnit now holds onto Index instance that created. This means
the Index can't be GC'd until the TranslationUnit is itself GC'd,
making memory management thoughtless.
* Don't use [] as a default argument value, as the initial value used is
reused for the duration of the program.
Jordy Rose [Tue, 8 May 2012 03:27:16 +0000 (03:27 +0000)]
[analyzer] Rework both constraint managers to handle mixed-type comparisons.
This involves keeping track of three separate types: the symbol type, the
adjustment type, and the comparison type. For example, in "$x + 5 > 0ULL",
if the type of $x is 'signed char', the adjustment type is 'int' and the
comparison type is 'unsigned long long'. Most of the time these three types
will be the same, but we should still do the right thing when the
comparison value is out of range, and wraparound should be calculated in
the adjustment type.
This also re-disables an out-of-bounds test; we were extracting the symbol
from non-additive SymIntExprs, but then throwing away the integer.
Sorry for the large patch; both the basic and range constraint managers needed
to be updated together, since they share code in SimpleConstraintManager.