Douglas Gregor [Sat, 12 Nov 2011 00:24:49 +0000 (00:24 +0000)]
Tweak the module map file test slightly, by putting one of the headers
into a submodule. Submodules aren't actually supported anywhere else,
but we do parse them, so this verifies that we're at least seeing
through them properly.
Douglas Gregor [Sat, 12 Nov 2011 00:22:19 +0000 (00:22 +0000)]
Implement a minor optimization when loading module maps to satisfy a
module import: don't re-check for a loaded module unless we've
actually loaded a new module map file. Already-loaded module map files
aren't interesting.
Douglas Gregor [Sat, 12 Nov 2011 00:05:07 +0000 (00:05 +0000)]
When searching for a module, speculatively load module maps to see if
the module is described in one of the module maps in a search path or
in a subdirectory off the search path that has the same name as the
module we're looking for.
Douglas Gregor [Fri, 11 Nov 2011 23:20:24 +0000 (23:20 +0000)]
Teach the search for modules to consider modules described by a module
map, so long as they have an umbrella header. This makes it possible
to introduce a module map + umbrella header for a given set of
headers, to turn it into a module.
There are two major deficiencies here: first, we don't go hunting for
module map files when we just see a module import (so we won't know
about the modules described therein). Second, we don't yet have a way
to build modules that don't have umbrella headers, or have incomplete
umbrella headers.
Douglas Gregor [Fri, 11 Nov 2011 22:18:48 +0000 (22:18 +0000)]
Wire up the mapping from header files mentioned in module maps over to
the corresponding (top-level) modules. This isn't actually useful yet,
because we don't yet have a way to build modules out of module maps.
Richard Smith [Fri, 11 Nov 2011 19:29:23 +0000 (19:29 +0000)]
Extend -Wno-bind-to-temporary-copy and -Wno-{unnamed,local}-type-template-args
to disable the corresponding -Wc++98-compat warnings in addition to the C++11
extension warnings, so that people already using these flags can switch to C++11
mode and turn on -Wc++98-compat.
Douglas Gregor [Fri, 11 Nov 2011 19:10:28 +0000 (19:10 +0000)]
Introduce basic support for parsing module map files.
Module map files provide a way to map between headers and modules, so
that we can layer a module system on top of existing headers without
changing those headers at all.
This commit introduces the module map file parser and the module map
that it generates, and wires up the module map file parser so that
we'll automatically find module map files as part of header
search. Note that we don't yet use the information stored in the
module map.
Sean Callanan [Fri, 11 Nov 2011 17:39:52 +0000 (17:39 +0000)]
When importing an ObjCInterfaceDecl, ensure that
superclass information is imported before validating
it. This fixes spurious "incompatible superclasses"
errors in LLDB.
Ted Kremenek [Fri, 11 Nov 2011 15:19:48 +0000 (15:19 +0000)]
Tweak CXLoadedDiagnosticSetImpl::makeString() to include an extra null character, and change the creation of the FixIT's string to again just rely on this string (instead of duplicating it when calling createCXString).
Richard Smith [Fri, 11 Nov 2011 04:05:33 +0000 (04:05 +0000)]
Constant expression evaluation: support for constexpr member functions. This
reinstates r144273; a combination of r144333's fix for NoOp rvalue-to-lvalue
casts and some corresponding changes here resolve the regression which that
caused.
This patch also adds support for some additional forms of member function call,
along with additional testing.
John McCall [Fri, 11 Nov 2011 03:19:12 +0000 (03:19 +0000)]
Be sure to insulate block literals from any cleanups in their
enclosing full-expressions. It is somewhat amazing that
this hasn't come up as a problem before.
Ted Kremenek [Fri, 11 Nov 2011 00:46:43 +0000 (00:46 +0000)]
[serialized diagnostics]: add test cases for serialized diagnostics, including a test case for no issues, multiple issues, and
a single issue. Along the way, tweak c-index-test -read-diagnostics output so it is easier to tell what diagnostics are
child diagnostics.
Cut down the number of callbacks to more generic ones. Clients can check
an enum to find out what kind of declaration it is and they can call functions
to get more specific information than the generic provided info.
Ted Kremenek [Fri, 11 Nov 2011 00:10:55 +0000 (00:10 +0000)]
[static analyzer] be more specific when running removeDeadBindings. Instead of seeing if the predecessor node was a non-StmtPoint, check if it is specifically a BlockEntrance node.
Richard Smith [Thu, 10 Nov 2011 23:32:36 +0000 (23:32 +0000)]
Implicit casts from rvalue to lvalue are not meaningful. Don't accidentally add
them when performing a const conversion on the implicit object argument for a
member operator call on an rvalue.
No change to the testsuite: the test for this change is that the added
assertion does not fire any more.
Ted Kremenek [Thu, 10 Nov 2011 23:26:10 +0000 (23:26 +0000)]
[static analyzer]: only call RemoveDeadBindings() when analyzing non-Expr stmts, entering a basic block, or analyzing non-consumed expressions. This sigificantly speeds up analysis time, and reduces analysis time down to 27% less than before we linearized the CFG.
Pete Cooper [Thu, 10 Nov 2011 21:45:06 +0000 (21:45 +0000)]
Add invariant.load metadata to loads from selector references. Allows these loads to later be moved/combined in the optimizer. Fixes <rdar://problem/6027699>
John McCall [Thu, 10 Nov 2011 10:43:54 +0000 (10:43 +0000)]
Whenever explicitly activating or deactivating a cleanup, we
need to provide a 'dominating IP' which is guaranteed to
dominate the (de)activation point but which cannot be avoided
along any execution path from the (de)activation point to
the push-point of the cleanup. Using the entry block is
bad mojo.
John McCall [Thu, 10 Nov 2011 09:22:44 +0000 (09:22 +0000)]
Fix a subtle bug with cleanups: when activating
a previously-inactive cleanup, not only do we need a
flag variable, but we should also force the cleanup to
query the flag variable. However, we only need to do
this when we're activating in a context that's
conditionally executed; otherwise, we may safely
assume that the cleanup is dominated by the activation
point.
John McCall [Thu, 10 Nov 2011 08:15:53 +0000 (08:15 +0000)]
Enter the cleanups for a block outside the enclosing
full-expression. Naturally they're inactive before we enter
the block literal expression. This restores the intended
behavior that blocks belong to their enclosing scope.
There's a useful -O0 / compile-time optimization that we're
missing here with activating cleanups following straight-line
code from their inactive beginnings.
Richard Smith [Thu, 10 Nov 2011 06:34:14 +0000 (06:34 +0000)]
Constant expression evaluation: support for evaluation of structs and unions of
literal types, as well as derived-to-base casts for lvalues and
derived-to-virtual-base casts.
John McCall [Thu, 10 Nov 2011 05:35:25 +0000 (05:35 +0000)]
There's no good reason to track temporaries in ExprWithCleanups,
but it is sometimes useful to track blocks. Do so. Also
optimize the storage of these expressions.
Richard Smith [Thu, 10 Nov 2011 03:30:42 +0000 (03:30 +0000)]
Temporary fix for a performance problem Eli spotted. The APValue representation
is currently too inefficient to allow us to use it for array initializers, but
fortunately we usually don't yet need to evaluate such initializers.
Nick Lewycky [Wed, 9 Nov 2011 04:25:21 +0000 (04:25 +0000)]
Minor cleanup, mostly reindenting. Remove one helper function that just called
the other helper functions, since we already differentiated the cases it was
testing between. No functionality change.
Fix an issue that Duncan discovered on a specific (no longer current)
version of Ubuntu. It has a very broken multiarch configuration, and so
we need special logic to handle it correctly. Fixing and testing this
uncovered a few other trivial issues with the logic that are fixed as
well.
I added tests to cover this as it is hard to notice if you install
recent versions of the OS.
John McCall [Wed, 9 Nov 2011 03:17:26 +0000 (03:17 +0000)]
Emit the copy and dipose helpers for ARC __strong
block-typed __block variables using objc_retainBlock
and objc_dispose. Previously we were using
_Block_object_assign and _Block_object_destroy
with BLOCK_BYREF_CALLER, which causes the runtime
to completely ignore the retain and release.
In most cases this doesn't cause catastrophe
because the retain/release are balanced and
because the block in the variable was copied
upon assignment there. However, the stack
copy of the variable will be released when
it goes out of scope, which is a problem if
that value was released due to an assignment
to the heap copy. Similarly, a leak can occur
if the variable is assigned after the copy to
the heap.
In certain cases ASTReader would call the normal DiagnosticsEngine API to initialize
the state of diagnostic pragmas but DiagnosticsEngine would try to compare source locations
leading to crash because the main FileID was not yet initialized.
Yet another case of the ASTReader trying to use the normal APIs and inadvertently breaking
invariants. Fix this by having the ASTReader set up the internal state directly.
Anna Zaks [Tue, 8 Nov 2011 19:56:35 +0000 (19:56 +0000)]
[analyzer] Remove redundant check from DivZeroChecker
Analysis by Ted:
"
if (stateZero && !stateNotZero) {
is checking to see if:
(A) "it is possible for the value to be zero" (stateZero)
AND
(B) "it is not possible for the value to be non-zero" (!stateNotZero)
That said, the only way for both B to be true AND A to be false is if the path is completely infeasible by the time we reach the divide-by-zero check. For the most part (all cases?), such cases should automatically get pruned out at branches (i.e., an infeasible path gets dropped), which is the case in our tests. So the question is whether or not such an infeasible path might not get dropped earlier? I can't envision any right now.
Indeed, the rest of the checker assumes that if the bug condition didn't fire then 'stateNotZero' is non-NULL:
Douglas Gregor [Tue, 8 Nov 2011 19:45:38 +0000 (19:45 +0000)]
Mark the overloaded atomic builtins as having custom type checking,
which they do. This avoids all of the default argument promotions that
we (1) don't want, and (2) undo during that custom type checking, and
makes sure that we don't run into trouble during template
instantiation. Fixes PR11320.
Add a default system include of '/include'. This isn't particularly
useful when using Clang as a system-compiler, but its harmless. When
using Clang as a cross-compiler, this can be very handy as quite a few
toolchains ship their libc headers here rather than under
'/usr/include'.
For reference, this is the beginning of my work to also make the Clang
driver more suitable as a cross-compiler.