Douglas Gregor [Thu, 25 Aug 2011 22:30:56 +0000 (22:30 +0000)]
Introduce a -cc1 option "-emit-module", that creates a binary module
from the given source. -emit-module behaves similarly to -emit-pch,
except that Sema is somewhat more strict about the contents of
-emit-module. In the future, there are likely to be more interesting
differences.
Douglas Gregor [Thu, 25 Aug 2011 21:19:59 +0000 (21:19 +0000)]
Clean up the reloading of identifier information following the load of
a top-level module. This code is still horrible and should go away,
but we're not there yet.
Douglas Gregor [Thu, 25 Aug 2011 20:58:51 +0000 (20:58 +0000)]
Move file validation in the ASTReader from "top of chain" validation
to "when loading a particular module" validation, since it was only
validating local information anyway. This shouldn't change anything.
Douglas Gregor [Thu, 25 Aug 2011 20:47:51 +0000 (20:47 +0000)]
Factor the Module and ModuleManager classes out into separate headers
and .cpp files, since ASTReader.cpp was getting way too large. No
functionality change.
Chad Rosier [Thu, 25 Aug 2011 17:33:03 +0000 (17:33 +0000)]
[driver] Do not add -kext to the link command line when compiling with
-fapple-kext.
Fixes <rdar://problem/10013310>. Reverts <rdar://problem/7809940>.
Douglas Gregor [Thu, 25 Aug 2011 15:28:26 +0000 (15:28 +0000)]
Remove a bogus assertion from the AST reader, which assumed that
redeclarations of a particular entity would occur in source
order. Friend declarations that occur within class templates (or
member classes thereof) do not follow this, nor would modules. Big
thanks to Erik Verbruggen for reducing this problem from the Very
Large Qt preamble testcase he found.
Douglas Gregor [Thu, 25 Aug 2011 14:51:20 +0000 (14:51 +0000)]
Use the module manager's search facility to look for methods with a
given selector, rather than walking the chain backwards. Teach its
visitor how to merge multiple result sets into a single result set,
combining the results of selector lookup in several different modules
into a single result set.
Anna Zaks [Thu, 25 Aug 2011 00:32:42 +0000 (00:32 +0000)]
[analyzer] MacOSKeychainAPIChecker: Add the custom BugReport visitor(which highlights the allocation site) to all the relevant reports within the checker.
Jordy Rose [Thu, 25 Aug 2011 00:10:37 +0000 (00:10 +0000)]
[analyzer] Move the RetainSummaryManager from CFRefCount to RetainReleaseChecker.
Because Checkers live for an entire translation unit, this persists summary caches across multiple code bodies and avoids repeated initialization (but probably at the cost of memory). This removes the last references from RetainReleaseChecker to CFRefCount.
blocks - capturing logic of byref block variable's expression
statement initializer makes safe assumption when a substatement
is encounterred (with a fix me).
Douglas Gregor [Wed, 24 Aug 2011 21:56:08 +0000 (21:56 +0000)]
Don't force the complete deserialization of the visible-declarations
table when serializing an AST file. This was a holdover from the days
before chained PCH, and is a complete waste of time and storage
now. It's a good thing it's useless, because I have no idea how I
would have implemented MaterializeVisibleDecls efficiently in the
presence of modules.
Douglas Gregor [Wed, 24 Aug 2011 21:27:34 +0000 (21:27 +0000)]
Introduce a depth-first search of modules into the module manager,
which supports both pre-order and post-order traversal via a visitor
mechanism. Use this depth-first search with a post-order traversal to
give predictable ordering semantics when walking all of the lexical
declarations in the translation unit.
Eventually, module imports will occur in the source code rather than
at the beginning, and we'll have to revisit this walk.
Anna Zaks [Wed, 24 Aug 2011 20:31:06 +0000 (20:31 +0000)]
[analyzer] Allow checker writes to specify that no region should be accosiated with the report. (Useful when we report an error on endOfPath or deadSymbols, when the range of the last expression might have nothing to do with the error.)
Jordy Rose [Wed, 24 Aug 2011 19:10:50 +0000 (19:10 +0000)]
[analyzer] Remove unused DoNothingByRef and the special case for CFDictionaryCreate.
This is a very small regression (actually introduced in r138309) because it won't catch leaks of objects passed by reference to CFDictionaryCreate (they're considered to have escaped and are ignored). If this is important we can put in a specific eval::Call to restore the functionality.
Douglas Gregor [Wed, 24 Aug 2011 19:03:07 +0000 (19:03 +0000)]
In the AST reader, switch name lookup within a DeclContect over to the
module DAG-based lookup scheme. This required some reshuffling, so
that each module stores its own mapping from DeclContexts to their
lexical and visible sets for those DeclContexts (rather than one big
"chain").
Overall, this allows simple qualified name lookup into the translation
unit to gather results from multiple modules, with the lookup results
in module B shadowing the lookup results in module A when B imports A.
Walking all of the lexical declarations in a module DAG is still a
mess; we'll end up walking the loaded module list backwards, which
works fine for chained PCH but doesn't make sense in a DAG. I'll
tackle this issue as a separate commit.
Jordy Rose [Wed, 24 Aug 2011 18:56:32 +0000 (18:56 +0000)]
[analyzer] Slightly clean up the fix in 138432, so that it doesn't depend on the relative ordering of path-sensitive and path-insensitive checks. Still not ideal, but I think a real fix would require infrastructure that doesn't exist yet.
Jordy Rose [Wed, 24 Aug 2011 09:02:37 +0000 (09:02 +0000)]
[analyzer] Fix potential crasher with RAII. No functionality change. (No test because this particular circumstance requires an impossible series of events, but this is future-proofing.)
Jordy Rose [Wed, 24 Aug 2011 05:47:39 +0000 (05:47 +0000)]
[analyzer] Reapply 138382 and 138388 (reverted in 138419 and 138420). The issue seems to have been with the uninitialized variable fixed in 138424; a fix for another Heisencrasher coming soon.
Anna Zaks [Wed, 24 Aug 2011 00:06:27 +0000 (00:06 +0000)]
[analyzer] MacOSKeychainAPIChecker: Add reasoning about functions which MIGHT deallocate the memory region allocated with SecKeychain APIs. Specifically, when the buffer is passed to CFStringCreateWithBytesNoCopy along with a custom deallocator, which might potentially correctly release the memory.
Anna Zaks [Tue, 23 Aug 2011 23:56:12 +0000 (23:56 +0000)]
[analyzer] MacOSKeychainAPIChecker: Retrieve the memory region which we are tracking even when it's no longer a SymbolicRegion, for example, when it is cast to char*.
Ted Kremenek [Tue, 23 Aug 2011 23:05:11 +0000 (23:05 +0000)]
Start reworking -Wunreachable-code. The original analysis had serious flaws with how it
handled SCC's of dead code, or simply having false negatives by overly suppressing warnings.
Eli Friedman [Tue, 23 Aug 2011 22:24:57 +0000 (22:24 +0000)]
Refactor and fix checking for initialization of flexible array members. The old version had the checks scattered across the code, missed some checks, and had a couple nasty bugs in existing checks.
Fixes PR10648 and another similar accepts-invalid bug.
Amend r138129 (reduction of SLocEntries) which introduced performance regression due
to increased calls to SourceManager::getFileID. (rdar://9992664)
Use a slightly different approach that is more efficient both in terms of speed
(no extra getFileID calls) and in SLocEntries reduction.
Comparing pre-r138129 and this patch we get:
For compiling SemaExpr.cpp reduction of SLocEntries by 26%.
For the boost enum library:
-SLocEntries -34% (note that this was -5% for r138129)
-Memory consumption -50%
-PCH size -31%
Reduced SLocEntries also benefit the hot function SourceManager::getFileID,
evident by the reduced "FileID scans".
Jordy Rose [Tue, 23 Aug 2011 20:55:48 +0000 (20:55 +0000)]
[analyzer] Move function retain-count effect summary log from CFRefCount to RetainReleaseChecker, and then explicitly provide the summary log when creating CFRefReports. No functionality change.
Ted Kremenek [Tue, 23 Aug 2011 20:30:50 +0000 (20:30 +0000)]
Fix regression in -Wuninitialized involving VLAs. It turns out that we were modeling sizeof(VLAs)
incorrectly in the CFG, and also the static analyzer. This patch regresses the analyzer a bit, but
that needs to be followed up with a better solution.
Jordy Rose [Tue, 23 Aug 2011 19:43:16 +0000 (19:43 +0000)]
[analyzer] Move ReturnStmt retain-count analysis from CFRefCount to RetainReleaseChecker. Tweak CFRefReport to reflect that fact that ReturnStmt checks are pre-statement, not post-statement. No intended functionality change.
Caitlin Sadowski [Tue, 23 Aug 2011 18:46:34 +0000 (18:46 +0000)]
Thread-safety analysis: adding in a basic lockset tracking system. This
system flags an error when unlocking a lock which was not held, locking
the same lock twice, having a different lockset on each iteration of a
loop, or going out of scope while still holding a lock. In order to
successfully use the lockset, this patch also makes sure that attribute
arguments are attached correctly for later parsing.
This patch was also worked on by DeLesley Hutchins.
Note: This patch has been reviewed by Chandler Carruth and Jeffrey
Yasskin. Feel free to provide post-commit review comments for a
subsequent patch.
Jordy Rose [Tue, 23 Aug 2011 04:27:15 +0000 (04:27 +0000)]
[analyzer] Only allocate retain summaries for interesting functions/messages. This is a minor saving of memory but doesn't seem to cost any performance.
For the test case added to function-redecl.cpp, we were previously complaining
about a mismatch in the parameter types, since the definition used the
typedef'd type.
Jordy Rose [Mon, 22 Aug 2011 23:48:23 +0000 (23:48 +0000)]
[analyzer] Migrate the handling of retain-count-related RetEffects and ArgEffects from CFRefCount to RetainReleaseChecker. No intended functionality change.