Eli Friedman [Tue, 24 Nov 2009 05:28:59 +0000 (05:28 +0000)]
Teach Evaluate to handle member expressions referring to enum constants and
static member constants. No significant visible difference at the moment
because it conservatively assumes the base has side effects. I'm planning to
use this for CodeGen.
Anders Carlsson [Tue, 24 Nov 2009 05:08:52 +0000 (05:08 +0000)]
It is common for vtables to contain pointers to functions that have either incomplete return types or incomplete argument types.
Handle this by returning the llvm::OpaqueType for those cases, which CodeGenModule::GetOrCreateLLVMFunction knows about, and treats as being an "incomplete function".
Douglas Gregor [Mon, 23 Nov 2009 23:44:04 +0000 (23:44 +0000)]
Explicitly track the condition variable within an "if" statement,
rather than burying it in a CXXConditionDeclExpr (that occassionally
hides behind implicit conversions). Similar changes for
switch, while, and do-while will follow, then the removal of
CXXConditionDeclExpr. This commit is the canary.
Ted Kremenek [Mon, 23 Nov 2009 22:22:01 +0000 (22:22 +0000)]
Clean up the Checker API a little more, resolving some hidden bugs
along the way. Important changes:
1) To generate a sink node, use GenerateSink(); GenerateNode() is for
generating regular transitions. This makes the API clearer and also
allows us to use the 'bool' option to GenerateNode() for a different
purpose.
2) GenerateNode() now automatically adds the generated node to the
destination ExplodedNodeSet (autotransition) unless the client
specifies otherwise with a bool flag. Several checkers did not call
'addTransition()' after calling 'GenerateNode()', causing the
simulation path to be prematurely culled when a non-fail stop bug was
encountered.
3) Add variants of GenerateNode()/GenerateSink() that take neither a
Stmt* or a GRState*; most callers of GenerateNode() just pass in the
same Stmt* as provided when the CheckerContext object is created; we
can just use that the majority of the time. This cleanup also allows
us to potentially coelesce the APIs for evaluating branches and
end-of-paths (which currently directly use builders).
4) addTransition() no longer needs to be called except for a few
cases. We now have a variant of addTransition() that takes a
GRState*; this allows one to propagate the updated state without
caring about generating a new node explicitly. This nicely cleaned up
a bunch of cases that called autoTransition() with a bunch of
conditional logic surround the call (that common logic has now been
swallowed up by addTransition() itself).
Ted Kremenek [Mon, 23 Nov 2009 18:12:03 +0000 (18:12 +0000)]
Tweak UndefBranchChecker to register the most nested "undefined" expression with bugreporter::registerTrackNullOrUndefValue instead of the condition itself.
Make 'SEL' pointer to a builtin type and not an
objective-c pointer type. This was a serious mishap and
luckily, Ted's test caught that (and patch fixes the test case).
Sebastian Redl [Mon, 23 Nov 2009 17:18:46 +0000 (17:18 +0000)]
Intercept sizeof and alignof references before they get into ASTContext methods. This fixes a crash when writing sizeof(Incomplete&), and lets ASTContext's methods do the right thing for CodeGen, which fixes PR5590.
Douglas Gregor [Mon, 23 Nov 2009 12:52:47 +0000 (12:52 +0000)]
Canonical template arguments that are template template parameters by
their template parameter depth and position, so that we can match
redeclarations appropriately. Fixes PR5527 and PR5528.
Douglas Gregor [Mon, 23 Nov 2009 12:39:54 +0000 (12:39 +0000)]
Improve type-checking of templates by distinguishing between members
of the current instantiation and members of an unknown specialization
when type-checking a qualified-if expression.
Douglas Gregor [Mon, 23 Nov 2009 12:11:45 +0000 (12:11 +0000)]
Tolerate extraneous "template<>" headers better, downgrading the
complaint to a warning and providing a helpful node in the case where
the "template<>" header is redundant because the corresponding
template-id refers to an explicit specialization. C++0x might still
change this behavior, and existing practice is all over the place on
the number of "template<>" headers actually needed.
Sean Hunt [Sun, 22 Nov 2009 07:05:50 +0000 (07:05 +0000)]
Use intptr_t rather than long so that this test will not fail on LLP64 systems,
where long is only 32-bits and so a reinterpret_cast would be ill-formed.
John McCall [Sun, 22 Nov 2009 02:49:43 +0000 (02:49 +0000)]
If a C++ qualified id is followed by a postfix suffix, it is never the direct
operand of an addressof operator, and so we should not treat it as an abstract
member-pointer expression and therefore suppress the implicit member access.
This is really a well-formedness constraint on expressions: a DeclRefExpr of
a FieldDecl or a non-static CXXMethodDecl (or template thereof, or unresolved
collection thereof) should not be allowed in an arbitrary location in the AST.
Arguably it shouldn't be allowed anywhere and we should have a different expr
node type for this. But unfortunately we don't have a good way of enforcing
this kind of constraint right now.
This patch implements objective-c's 'SEL' type as a built-in
type and fixes a long-standing code gen. crash reported in
at least two PRs and a radar. (radar 7405040 and pr5025).
There are couple of remaining issues that I would like for
Ted. and Doug to look at:
Ted, please look at failure in Analysis/MissingDealloc.m.
I have temporarily added an expected-warning to make the
test pass. This tests has a declaration of 'SEL' type which
may not co-exist with the new changes.
Doug, please look at a FIXME in PCHWriter.cpp/PCHReader.cpp.
I think the changes which I have ifdef'ed out are correct. They
need be considered for in a few Indexer/PCH test cases.
Daniel Dunbar [Sat, 21 Nov 2009 09:17:15 +0000 (09:17 +0000)]
Mangler: Sketch mangling for TemplateArgument::Declaration kind.
- Several important FIXMEs related to whether arguments are expressions or external names, and the mangling of extern "C" names (c.f., PR5522).
Daniel Dunbar [Sat, 21 Nov 2009 09:14:52 +0000 (09:14 +0000)]
Mangler: Lift shouldMangleDeclName predicate out of CXXNameMangler::mangle.
- Sometimes we have to mangle things we wouldn't normally (e.g., because they appear in a template expression).
- This also tidies up the predicate to be more obvious what is getting mangled.
Daniel Dunbar [Sat, 21 Nov 2009 09:06:22 +0000 (09:06 +0000)]
IRgen: Switch the C++ mangler interfaces to take the SmallVector to write into,
instead of requiring clients to make a raw_svector_ostream, which is just an
implementation detail.
John McCall [Sat, 21 Nov 2009 08:51:07 +0000 (08:51 +0000)]
"Incremental" progress on using expressions, by which I mean totally ripping
into pretty much everything about overload resolution in order to wean
BuildDeclarationNameExpr off LookupResult::getAsSingleDecl(). Replace
UnresolvedFunctionNameExpr with UnresolvedLookupExpr, which generalizes the
idea of a non-member lookup that we haven't totally resolved yet, whether by
overloading, argument-dependent lookup, or (eventually) the presence of
a function template in the lookup results.
Incidentally fixes a problem with argument-dependent lookup where we were
still performing ADL even when the lookup results contained something from
a block scope.
Incidentally improves a diagnostic when using an ObjC ivar from a class method.
This just fell out from rewriting BuildDeclarationNameExpr's interaction with
lookup, and I'm too apathetic to break it out.
The only remaining uses of OverloadedFunctionDecl that I know of are in
TemplateName and MemberExpr.
Sean Hunt [Sat, 21 Nov 2009 08:43:09 +0000 (08:43 +0000)]
Added rudimentary C++0x attribute support.
The following attributes are currently supported in C++0x attribute
lists (and in GNU ones as well):
- align() - semantics believed to be conformant to n3000, except for
redeclarations and what entities it may apply to
- final - semantics believed to be conformant to CWG issue 817's proposed
wording, except for redeclarations
- noreturn - semantics believed to be conformant to n3000, except for
redeclarations
- carries_dependency - currently ignored (this is an optimization hint)
Ted Kremenek [Sat, 21 Nov 2009 02:52:12 +0000 (02:52 +0000)]
Add RegionStore test case that shows that floating point values are also implicitly tracked for undefined values. (test case for <rdar://problem/6811085>).
Ted Kremenek [Sat, 21 Nov 2009 02:17:47 +0000 (02:17 +0000)]
Add another test case to show the precision of RegionStore over
BasicStore. In this example, BasicStore would lose information about
the pointer in path after '*path++', causing the analyzer to falsely
flag a null dereference. This addresses <rdar://problem/7191542>.
Douglas Gregor [Sat, 21 Nov 2009 02:07:55 +0000 (02:07 +0000)]
Implement C++ [temp.param]p2 correctly, looking ahead when we see a
"typename" parameter to distinguish between non-type and type template
parameters. Fixes the actual bug in PR5559.