Douglas Gregor [Sat, 17 Sep 2011 00:05:03 +0000 (00:05 +0000)]
With modules, we can end up loading a new module after we've seen an
arbitrary amount of code. This forces us to stage the AST writer more
strictly, ensuring that we don't assign a declaration ID to a
declaration until after we're certain that no more modules will get
loaded.
In Microsoft mode, warn if an indirect goto jump over a variable initialization.
Also add a test case for the non Microsoft case because such test didn't exist.
Fix massive LiveVariables regression (due to LiveVariables rewrite) by addressing two performance problems:
- Speed of "merge()", which merged data flow facts. This was doing a set canonicalization on every insertion, which was super slow.
To fix this, we use ImmutableSetRef.
- Visit CFGBlocks in reverse postorder. This is a huge speedup, as on some test cases the algorithm would take many iterations
to converge.
This contains a bunch of copy-paste from UninitializedValues.cpp and ThreadSafety.cpp. The idea
was to get something working first, and then refactor the common logic for all three files into
a separate analysis/library entry point.
Anna Zaks [Fri, 16 Sep 2011 19:18:30 +0000 (19:18 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 5 of ?):
- Get rid of PathDiagnosticLocation(SourceRange r,..) constructor by providing a bunch of create methods.
- The PathDiagnosticLocation(SourceLocation L,..), which is used by crate methods, will eventually become private.
- Test difference is in the case when the report starts at the beginning of the function. We used to represent that point as a range of the very first token in the first statement. Now, it's just a single location representing the first character of the first statement.
Eli Friedman [Thu, 15 Sep 2011 23:15:27 +0000 (23:15 +0000)]
Tweak *mmintrin.h so that they don't make any bad assumptions about alignment (which probably has little effect in practice, but better to get it right). Make the load in _mm_loadh_pi and _mm_loadl_pi a single LLVM IR instruction to make optimizing easier for CodeGen.
Douglas Gregor [Thu, 15 Sep 2011 22:00:41 +0000 (22:00 +0000)]
Add an experimental flag -fauto-module-import that automatically turns
#include or #import direcctives of framework headers into module
imports of the corresponding framework module.
Anna Zaks [Thu, 15 Sep 2011 20:06:34 +0000 (20:06 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 4 of ?):
- The closing brace is always a single location, not a range.
- The test case previously had a location key 57:1 followed by a range [57:1 - 57:1].
Douglas Gregor [Thu, 15 Sep 2011 19:48:59 +0000 (19:48 +0000)]
Eliminate the list of modules from the preprocessor options. This was
used back when we had an -import-module command-line option, but it's
no longer used (or useful).
Anna Zaks [Thu, 15 Sep 2011 18:56:07 +0000 (18:56 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 2 of ?):
- Fix a fixme and move the logic of creating a PathDiagnosticLocation corresponding to a ProgramPoint into a PathDiagnosticLocation constructor.
- Rename PathDiagnosticLocation::create to differentiate from the added constructor.
Douglas Gregor [Thu, 15 Sep 2011 18:47:32 +0000 (18:47 +0000)]
When we load the first module, make sure that we wire up the ASTConsumer to the newly-created ASTReader. This makes sure that CodeGen sees the declarations it is interested in
[PCH] Overhaul how preprocessed entities are [de]serialized.
-Use an array of offsets for all preprocessed entities
-Get rid of the separate array of offsets for just macro definitions;
for references to macro definitions use an index inside the preprocessed
entities array.
-Deserialize each preprocessed entity lazily, at first request; not in bulk.
Paves the way for binary searching of preprocessed entities that will offer
efficiency and will simplify things on the libclang side a lot.
John McCall [Thu, 15 Sep 2011 06:49:18 +0000 (06:49 +0000)]
Rewrite this loop to use partial destruction; I'm not sure it's
possible for that to matter right now, but eventually I think we'll
need to unify this better, and then it might. Also, use a more
efficient looping structure.
Anna Zaks [Thu, 15 Sep 2011 01:08:34 +0000 (01:08 +0000)]
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 2 of ?):
- Modify all PathDiagnosticLocation constructors that take Stmt to also requre LocationContext.
- Add a constructor which should be used in case there is no valid statement/location (it will grab the location of the enclosing function).
Douglas Gregor [Wed, 14 Sep 2011 20:28:46 +0000 (20:28 +0000)]
Teach the driver to always pass down a module cache path. If none is
supplied, use something derived from the system's temporary
directory. Depends on LLVM r139725.
Thread safety: adding additional documentation to the main thread safety interface, and making the destructor for the thread safety handler pure virtual
Anna Zaks [Wed, 14 Sep 2011 17:48:01 +0000 (17:48 +0000)]
[analyzer] After CFG has been linearized, we can have a situation where an ExpoledNode has an invalid SourceLocation (which has no correspondence in the source code). This commit is the first step to solve this problem.
- It adds LocationContext to the PathDiagnosticLocation object and uses it to lookup the enclosing statement with a valid location.
- So far, the LocationContext is only available when the object is constructed from the ExplodedNode.
- Already found some subtle bugs(in plist-output-alternate.m) where the intermediate diagnostic steps were not previously shown.
Anna Zaks [Wed, 14 Sep 2011 00:25:17 +0000 (00:25 +0000)]
[analyzer] Refactor: Make PathDiagnosticLocation responsible for creating a valid object given an ExploadedNode (the same logic can be reused by other checkers).
Douglas Gregor [Tue, 13 Sep 2011 23:15:45 +0000 (23:15 +0000)]
For modules, use a hash of the compiler version, language options, and
target triple to separate modules built under different
conditions. The hash is used to create a subdirectory in the module
cache path where other invocations of the compiler (with the same
version, language options, etc.) can find the precompiled modules.
John McCall [Tue, 13 Sep 2011 23:08:34 +0000 (23:08 +0000)]
In general, don't look through explicit casts when trying
to find the called declaration. Explicit casts can radically
change the semantics of a call, and it's no longer really a
builtin call any more than it would be a builtin call if you stored
the function pointer into a variable and called that.
[libclang] Introduce clang_getPresumedLocation which works like clang_getExpansionLocation
but takes into account #line directives coming from preprocessed files.
[PCH] Fix a regression that r139441 introduced (decls were getting passed
to the consumer without being fully deserialized).
The regression was on compiling boost.python and it was too difficult to get a reduced
test case unfortunately.
Also modify the logic of how objc methods are getting passed to the consumer;
codegen depended on receiving objc methods before the implementation decl.
Since the interesting objc methods are ones with a body and such methods only
exist inside an ObjCImplDecl, deserialize and pass to consumer all the methods
of ObCImplDecl when we see one.
John McCall [Tue, 13 Sep 2011 18:49:24 +0000 (18:49 +0000)]
A strong property of block type has "copy" setter semantics, not "retain".
This is consistent with the behavior of assigning into a __strong l-value,
and it's also necessary for ensuring that the ivar doesn't end up a dangling
reference. We decided not to change the behavior of "retain" properties, but
just to make them warnings/errors when of block type.
Douglas Gregor [Tue, 13 Sep 2011 18:26:39 +0000 (18:26 +0000)]
Switch the serialization of LangOptions over to use the .def file. We
should no longer have the serialization of LangOptions out of sync
with the structure itself (yay).
[libclang]
-Allow cursor visitation of an attribute using its source range
-Add C++ 'final' and 'override' attributes as cursor kinds
-Simplify the logic that marks 'final' and 'override' attributes as tokens.
Douglas Gregor [Tue, 13 Sep 2011 17:21:33 +0000 (17:21 +0000)]
Switch LangOptions over to a .def file that describes header of the
language options. Use that .def file to declare the LangOptions class
and initialize all of its members, eliminating a source of annoying
initialization bugs.
Switch -Wreturn-type to completely rely on the CFG model of no-return.
This deletes a bunch of crufty code, and allows more logic sharing
between the analyzer and the warnings.
John McCall [Tue, 13 Sep 2011 07:33:34 +0000 (07:33 +0000)]
Don't use native atomics on ivars whose size is not a power of two,
even on architectures that support unaligned access (which is the
only way this is otherwise legal, given that ivars apparently do
not honor alignment attributes).