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.
Jordy Rose [Tue, 8 May 2012 03:26:58 +0000 (03:26 +0000)]
[analyzer] Add an abstraction for the bit width and signedness of an APSInt. No functionality change.
There are more parts of the analyzer that could use the convenience of APSIntType, particularly the constraint engine, but that needs a fair amount of rewriting to handle mixed-type constraints anyway.
Douglas Gregor [Tue, 8 May 2012 00:14:45 +0000 (00:14 +0000)]
Introduce a new libclang API to determine the platform availability of
a given entity, so that we can tell when the entity was
introduced/deprecated/obsoleted on each platform for which we have an
annotation. Addresses <rdar://problem/11365715>.
Process attributes in the order they appear in the source code. This make clang
match gcc behavior for two conflicting visibilities in the same decl. It also
makes handling of dllimport/dllexport more natural.
[libclang] Use a copy of the data-recursive RecursiveASTVisitor inside libclang.
This is temporary until we settle on how to make the main RecursiveASTVisitor safe.
There are some modifications on the original version, to avoid extreme memory usage
when compiling for release.
Remove the 'intrin.h' builtin header file and its tests for now.
After discussion with several people, including Doug Gregor, we've
decided to change our approach here. If you have questions about this
header file, the commit removing it, etc., please reach out to me
off-list.
Anna Zaks [Mon, 7 May 2012 19:40:49 +0000 (19:40 +0000)]
[analyzer] Fix a crash in triggered by OSAtomicChecker.
SValBuilder should return an UnknownVal() when comparison of int and ptr
fails. Previous to this commit, it went on assuming that we are dealing
with pointer arithmetic.
Anna Zaks [Mon, 7 May 2012 18:40:26 +0000 (18:40 +0000)]
[analyzer] Fixup for r155244: PurgeDeadSymbols should subclass StmtPoint
To solve the inconsistency pointed out in Erik's review, refactor class
hierarchy of ProgramPoints so that PreStmtPurgeDeadSymbols and
PostStmtPurgeDeadSymbols both subclass from StmtPoint instead of
PostStmt.
Nuno Lopes [Mon, 7 May 2012 17:57:00 +0000 (17:57 +0000)]
remove code to add bound checks for simple array accesses, since those are already covered by the check with the objectsize builtin
remove the comparison of objectsize with -1. since it's an unsigned comparison, it will always succeed if objectsize returns -1, which is enough to have the check removed