Граф коммитов

36629 Коммитов

Автор SHA1 Сообщение Дата
Nuno Lopes b3198a841e add -fbounds-checking option.
When enabled, clang generates bounds checks for array and pointers dereferences. Work to follow in LLVM's backend.

OK'ed by Chad; thanks for the review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156431 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 22:10:46 +00:00
Ted Kremenek 4213e389d6 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>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156428 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 21:49:54 +00:00
Ted Kremenek 7dbbc2178f When creating lazy bindings in RegionStore, propagate existing lazy bindings instead of creating new ones.
This is a functionality optimization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156427 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 21:49:51 +00:00
Ted Kremenek 6341931b14 Include address of Store in graphviz output of ExplodedGraph.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156426 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 21:49:47 +00:00
John McCall d1376ee094 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156425 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 21:41:25 +00:00
Anna Zaks 6a2a1865f8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156420 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 21:19:21 +00:00
Fariborz Jahanian 20e181a3ec modern objc translation. objc_getClass() and objc_getMetaClass()
prototypes should both return  `struct objc_class *`.
// rdar://11375495



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156418 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 20:55:55 +00:00
Eric Christopher a135f2ca67 The address of a vla is actually complex and requires a dereference.
Part of rdar://11352000

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156407 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 18:56:47 +00:00
Eric Christopher 3a89bfbeed Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156406 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 18:56:42 +00:00
Douglas Gregor 5f164afca3 Fix fmin*/fmax* library builtin signatures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156396 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 18:29:52 +00:00
Fariborz Jahanian 5ea66619a3 Fixes a typo. note_xxx not not_xxx.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156391 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 18:03:39 +00:00
Hans Wennborg 101d4e0c8f Make -Wformat accept printf("%hhx", c); with -funsigned-char
For "%hhx", printf expects an unsigned char. This makes Clang
accept a 'char' argument for that also when using -funsigned-char.

This fixes PR12761.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156388 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 17:21:31 +00:00
Gregory Szorc fd04a6a882 [clang.py] Remove trailing whitespace from recent commits
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156373 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 06:01:34 +00:00
Gregory Szorc fbf620bc2b [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156372 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 05:56:38 +00:00
Ted Kremenek c319c585c0 Teach the analyzer about CXXScaleValueInitExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156369 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 05:13:40 +00:00
Jordy Rose fad5de9d67 Clean up SemaDeclAttr for high-warnings build.
Includes a real potential initialization problem.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156363 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 03:27:22 +00:00
Jordy Rose 2cbc12fa24 [analyzer] BasicConstraintManager: drop NE-constraints once we have a value.
This could conceivably cut down on state proliferation, although we don't
use BasicConstraintManager by default anymore. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156362 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 03:27:20 +00:00
Jordy Rose 1d8db493f8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156361 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 03:27:16 +00:00
Jordy Rose d3b6d99cd5 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156360 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 03:26:58 +00:00
Nuno Lopes 4ccf0043c6 hopefully unbreak some buildbots
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156357 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 01:54:53 +00:00
Argyrios Kyrtzidis ae5ac1f5bd [libclang] Map 'id'/'Class'/'SEL' to the corresponding CXType kinds.
rdar://11357807

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156352 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 01:22:12 +00:00
Douglas Gregor 7032265efe Robustify test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156349 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 00:29:04 +00:00
Rafael Espindola 258796e3c7 Add missing 'y'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156348 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 00:28:39 +00:00
Douglas Gregor cc889664de 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156347 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 00:14:45 +00:00
Ted Kremenek c91fdf662d Teach the static analyzer that NSLog() and friends do not hold on to object references (thus extending their lifetime).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156346 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 00:12:09 +00:00
Rafael Espindola 9b79fc9c57 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.

As a bonus we now warn on the dllimport in

void __attribute__((dllimport)) foo13();
void __attribute__((dllexport)) foo13();

as does gcc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156343 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 23:58:18 +00:00
Anna Zaks ca11510d39 [analyzer]Turn on MallocSizeOfChecker by default; shorten the diagnostic
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156341 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 23:30:29 +00:00
Argyrios Kyrtzidis 428499e6f5 [libclang] Actually commit the changes to make libclang's RecursiveASTVisitor
data-recursive for statements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156339 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 23:23:03 +00:00
Argyrios Kyrtzidis 98180d49bd [libclang] Put the RecursiveASTVisitor in libclang in a cxindex namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156331 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 22:22:58 +00:00
Argyrios Kyrtzidis e377d71d81 Un-revert r156142, "[libclang] Bring back BodyIndexer::TraverseCXXOperatorCallExpr".
It was reverted on r156253.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156330 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 22:16:49 +00:00
Argyrios Kyrtzidis dec35a9848 [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.

rdar://11179167

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156329 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 22:16:46 +00:00
Chandler Carruth 1785c36ee6 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156322 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 20:46:58 +00:00
Nuno Lopes 9eecef16fe make this test a little more useful. I'll add more tests for bound checking once -fbounds-checking patch gets in
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156321 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 20:23:03 +00:00
Anna Zaks 6400f02ab2 [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.

PR12509, radar://11390991

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156320 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 19:40:49 +00:00
Anna Zaks 51a31ca9a9 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156315 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 18:40:26 +00:00
Nuno Lopes d7fb96e3bf 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156311 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 17:57:00 +00:00
Anna Zaks 41a669a300 [analyzer]Fixup r156215: use StopTracking summary instead of ScratchArgs
As per Jordy's and Ted's comment, use the default StopTracking summary
instead of adding all arguments to ScratchArs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156310 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 17:47:09 +00:00
Douglas Gregor fcf7f9fdcb Revert r156097, which appears to be causing some breakage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156304 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 14:17:47 +00:00
Manuel Klimek ed5ee48872 Fix includes for unices that don't have chdir declared transitively.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156302 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 10:02:55 +00:00
Manuel Klimek 3b6e319c05 Includes direct.h for windows compilation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156301 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 09:45:46 +00:00
Manuel Klimek 00f3c4f499 Fixes resolution of relative paths when running clang tools.
The chdir is not the perfect fix, as it is thread hostile. The
real fix will be to make -working-dir work correctly, which will
take time to implement. Before that, the tooling library cannot
be used concurrently.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156299 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 09:17:48 +00:00
Abramo Bagnara 0265555a0f Fixed UserDefinedLiteral source locations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156298 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 09:06:16 +00:00
Richard Smith b8590f3572 When we suppress an error due to SFINAE, stash the diagnostic away with the
overload candidate, and include its message in any subsequent 'candidate not
viable due to substitution failure' note we may produce.

To keep the note small (since the 'overload resolution failed' diagnostics are
often already very verbose), the text of the SFINAE diagnostic is included as
part of the text of the note, and any notes which were attached to it are
discarded.

There happened to be spare space in OverloadCandidate into which a
PartialDiagnosticAt could be squeezed, and this patch goes to lengths to avoid
unnecessary PartialDiagnostic copies, resulting in no slowdown that I could
measure. (Removal in passing of some PartialDiagnostic copies has resulted in a
slightly smaller clang binary overall.) Even on a torture test, I was unable to
measure a memory increase of above 0.2%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156297 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 09:03:25 +00:00
Craig Topper 4a7376d00d Convert AVX non-temporal store builtins to LLVM-native IR. This was previously done for SSE builtins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156296 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 06:25:45 +00:00
John McCall 13489673b8 Change how we suppress access control in explicit instantiations
so that we actually accumulate all the delayed diagnostics.  Do
this so that we can restore those diagnostics to good standing
if it turns out that we were wrong to suppress, e.g. if the
tag specifier is actually an elaborated type specifier and not
a declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156291 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 06:16:58 +00:00
John McCall 3f152e6507 There is no reason for these methods to be out-of-line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156290 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 06:16:49 +00:00
John McCall 9257664568 Refactor DelayedDiagnostics so that it keeps diagnostics in
separate pools owned by the RAII objects that keep pushing
decl state.  This gives us quite a bit more flexibility.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156289 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 06:16:41 +00:00
Manuel Klimek 667fd80de4 - Adding lexical_parent and semantic_parent properties to clang.cindex.Cursor
- Two new tests (one for each property), require libclang built from r155858 or later to pass
- New test utility function (get_cursors) that gets all the nodes with a specific spelling.

Patch by Evan Pipho.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156286 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 05:56:03 +00:00
Aaron Ballman 0a84e7a4d6 Updating the test case based on previous patch
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156275 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 01:10:33 +00:00
Richard Smith d079abfb5e A union can have a constexpr defaulted default constructor, if it has an
in-class initializer for one of its fields. Value-initialization of such
a type should use the in-class initializer!

The former was just a bug, the latter is a (reported) standard defect.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156274 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 01:07:30 +00:00