Douglas Gregor [Sat, 27 Aug 2011 06:37:51 +0000 (06:37 +0000)]
Take an entirely different approach to handling the "parsing" of
__import__ within the preprocessor, since the prior one foolishly
assumed that Preprocessor::Lex() was re-entrant. We now handle
__import__ at the top level (only), after macro expansion. This should
fix the buildbot failures.
John McCall [Sat, 27 Aug 2011 01:09:30 +0000 (01:09 +0000)]
The lvalue-to-rvalue on structs in C++ is actually part
of default argument promotion and needs to happen unconditionally.
This is particularly semantically important in C++0x.
Douglas Gregor [Fri, 26 Aug 2011 23:56:07 +0000 (23:56 +0000)]
Introduce support for a simple module import declaration, which
loads the named module. The syntax itself is intentionally hideous and
will be replaced at some later point with something more
palatable. For now, we're focusing on the semantics:
- Module imports are handled first by the preprocessor (to get macro
definitions) and then the same tokens are also handled by the parser
(to get declarations). If both happen (as in normal compilation),
the second one is redundant, because we currently have no way to
hide macros or declarations when loading a module. Chris gets credit
for this mad-but-workable scheme.
- The Preprocessor now holds on to a reference to a module loader,
which is responsible for loading named modules. CompilerInstance is
the only important module loader: it now knows how to create and
wire up an AST reader on demand to actually perform the module load.
- We search for modules in the include path, using the module name
with the suffix ".pcm" (precompiled module) for the file name. This
is a temporary hack; we hope to improve the situation in the
future.
Chad Rosier [Fri, 26 Aug 2011 21:28:44 +0000 (21:28 +0000)]
[driver] When generating temporary files allow a prefix to be added. In many
cases we want the prefix to be the original file name less the suffix. For an
input such as test.c to named temporary would be something like test-3O4Clq.o
Part of <rdar://problem/8314451>
Douglas Gregor [Fri, 26 Aug 2011 21:23:06 +0000 (21:23 +0000)]
When we're deserializing declarations lexically stored in a RecordDecl
after having already deserialized the fields, clear out the fields
first. This makes sure that we keep all of the declarations in the
lexical context (including those implicitly added by later
type-checking) within the same list. A test case for this behavior is
coming as part of another commit; testing for this problem in
isolation is a nightmare.
John McCall [Fri, 26 Aug 2011 07:31:35 +0000 (07:31 +0000)]
Since the 'is aliased' bit is critical for correctness in C++, it
really shouldn't be optional. Fix the remaining place where a
temporary was being passed as potentially-aliased memory.
Jeffrey Yasskin [Fri, 26 Aug 2011 00:41:31 +0000 (00:41 +0000)]
Handle CXXTempObjectRegion in StackAddrEscapeChecker.
Also convert stack-addr-ps.cpp to use the analyzer instead of just Sema, now
that it doesn't crash, and extract the stack-block test into another file since
it errors, and that prevents the analyzer from running.
Much to everyone's surprise, the default constructor for TypeResult produces
an instance with Invalid == false. This seems like a decision we may want to
revisit.
John McCall [Thu, 25 Aug 2011 23:04:34 +0000 (23:04 +0000)]
Track whether an AggValueSlot is potentially aliased, and do not
emit call results into potentially aliased slots. This allows us
to properly mark indirect return slots as noalias, at the cost
of requiring an extra memcpy when assigning an aggregate call
result into a l-value. It also brings us into compliance with
the x86-64 ABI.
Douglas Gregor [Thu, 25 Aug 2011 22:54:01 +0000 (22:54 +0000)]
Eliminate the -chained-pch flag and all of the frontend and libclang options associated with it. Chained PCH is the only way to build a PCH file that includes another PCH file
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.