John McCall [Sat, 5 Sep 2009 07:56:18 +0000 (07:56 +0000)]
Overhaul the mangler to use a visitor pattern, at least for types. We can safely
ignore non-canonical type classes, but apparently we need to know how to mangle
dependent names.
John McCall [Sat, 5 Sep 2009 06:31:47 +0000 (06:31 +0000)]
Start emitting ElaboratedTypes in C++ mode. Support the effort in various
ways: remove elab types during desugaring, enhance pretty-printing to allow
tags to be suppressed without suppressing scopes, look through elab types
when associating a typedef name with an anonymous record type.
John McCall [Sat, 5 Sep 2009 00:15:47 +0000 (00:15 +0000)]
Basic support for representing elaborated type specifiers
directly in the AST. The current thinking is to create these
only in C++ mode for efficiency. But for now, they're not being
created at all; patch to follow.
This will let us do things like verify that tags match during
template instantation, as well as signal that an elaborated type
specifier was used for clients that actually care.
Optimally, the TypeLoc hierarchy should be adjusted to carry tag
location information as well.
Douglas Gregor [Fri, 4 Sep 2009 22:48:11 +0000 (22:48 +0000)]
Improve the AST representation and semantic analysis for extern
templates. We now distinguish between an explicit instantiation
declaration and an explicit instantiation definition, and know not to
instantiate explicit instantiation declarations. Unfortunately, there
is some remaining confusion w.r.t. instantiation of out-of-line member
function definitions that causes trouble here.
Douglas Gregor [Fri, 4 Sep 2009 19:04:08 +0000 (19:04 +0000)]
Don't generate any code for an explicit call to a trivial destructor.
Now that parsing, semantic analysis, and (I think) code generation of
pseudo-destructor expressions and explicit destructor calls works,
update the example-dynarray.cpp test to destroy the objects it
allocates and update the test to actually compile + link.
The code seems correct, but the Clang-compiled version dies with a
malloc error. Time to debug!
Douglas Gregor [Fri, 4 Sep 2009 18:29:40 +0000 (18:29 +0000)]
If a destructor is referenced or a pseudo-destructor expression is
formed without a trailing '(', diagnose the error (these expressions
must be immediately called), emit a fix-it hint, and fix the code.
Douglas Gregor [Fri, 4 Sep 2009 05:53:02 +0000 (05:53 +0000)]
Introduce an egregious hack to fix PR4828.
The problem this change addresses is that we treat __is_pod and
__is_empty as keywords in C++, because they are built-in type traits
in GCC >= 4.3. However, GNU libstdc++ 4.2 (and possibly earlier
versions) define implementation-detail struct templates named __is_pod
and __is_empty.
This commit solves the problem by recognizing
struct __is_pod
and
struct __is_empty
as special token sequences. When one of these token sequences is
encountered, the keyword (__is_pod or __is_empty) is implicitly
downgraded to an identifier so that parsing can continue. This is an
egregious hack, but it has the virtue of "just working" whether
someone is using libstdc++ 4.2 or not, without the need for special
flags.
Douglas Gregor [Fri, 4 Sep 2009 05:04:07 +0000 (05:04 +0000)]
Actually initialize HasQualifier and HasExplicitTemplateArgumentList in the EmptyShell constructor for MemberExpr. Should clear up some valgrind failures in PCH reading
Anders Carlsson [Thu, 3 Sep 2009 22:56:02 +0000 (22:56 +0000)]
If the alignment of the chosen field in a union is greater than the alignment of the union, we need to use a packed LLVM struct. Fixes <rdar://problem/7184250>.
Douglas Gregor [Thu, 3 Sep 2009 21:38:09 +0000 (21:38 +0000)]
Improve template instantiation for member access expressions that
involve qualified names, e.g., x->Base::f. We now maintain enough
information in the AST to compare the results of the name lookup of
"Base" in the scope of the postfix-expression (determined at template
definition time) and in the type of the object expression.
Mark constructors used in initialization of base(s) and fields
as referecned with location where they are used. Still
need to look at destructor aspects of them.
Issue diagnostics in variety of situations involving
reference/const data members when user has declared
the constructor. This necessitated some non-minor
refactoring.
Douglas Gregor [Thu, 3 Sep 2009 16:14:30 +0000 (16:14 +0000)]
Improved handling for dependent, qualified member access expressions, e.g.,
t->Base::f
where t has a dependent type. We save the nested-name-specifier in the
CXXUnresolvedMemberExpr then, during instantiation, substitute into
the nested-name-specifier with the (transformed) object type of t, so
that we get name lookup into the type of the object expression.
Note that we do not yet retain information about name lookup into the
lexical scope of the member access expression, so several regression
tests are still disabled.
Steve Naroff [Thu, 3 Sep 2009 15:49:00 +0000 (15:49 +0000)]
- Add back some harmless code that part of a reverted commit (r80859). I'll investigate the lifetime snafu (with ASTUnit) separately.
- Traverse category methods, add a "class ref" and make the little test harness a bit more flexible.
Daniel Dunbar [Thu, 3 Sep 2009 05:59:35 +0000 (05:59 +0000)]
Revert "Remove redundant local variable (use newly created instance data).", the
previous commit this depends on is breaking x86_64-apple-darwin10 and Linux tests.
Fix regression introduced in r80786 and reported in PR 4867. We should use
'dyn_cast' instead of 'cast' as the denominator value could be UnknownVal (and
is not guaranteed to be a DefinedVal).
This patch does the following.
1) Issue digsnostics in non-fragile ABI, when an expression
evaluates to an interface type (except when it is used to
access a non-fragile ivar).
2) Issue unsupported error in fragile ABI when an expression
evaluates to an interface type (except when it is used to
access a fragile ivar).
Douglas Gregor [Wed, 2 Sep 2009 23:58:38 +0000 (23:58 +0000)]
Add a wicked little test-case that illustrates what we have to deal
with to properly support member access expressions in templates. This
test is XFAIL'd, because we get it completely wrong, but I've made the
minimal changes to the representation to at least avoid a crash.
Douglas Gregor [Wed, 2 Sep 2009 22:59:36 +0000 (22:59 +0000)]
Rewrite of our handling of name lookup in C++ member access expressions, e.g.,
x->Base::f
We no longer try to "enter" the context of the type that "x" points
to. Instead, we drag that object type through the parser and pass it
into the Sema routines that need to know how to perform lookup within
member access expressions.
We now implement most of the crazy name lookup rules in C++
[basic.lookup.classref] for non-templated code, including performing
lookup both in the context of the type referred to by the member
access and in the scope of the member access itself and then detecting
ambiguities when the two lookups collide (p1 and p4; p3 and p7 are
still TODO). This change also corrects our handling of name lookup
within template arguments of template-ids inside the
nested-name-specifier (p6; we used to look into the scope of the
object expression for them) and fixes PR4703.
I have disabled some tests that involve member access expressions
where the object expression has dependent type, because we don't yet
have the ability to describe dependent nested-name-specifiers starting
with an identifier.
Also fix a checker context bug: the Dst set is not always empty initially.
Because in GRExprEngine::CheckerVisit(), *CurrSet is used repeatedly.
So we removed the Dst.empty() condition in ~CheckerContext() when deciding
whether to do autotransision.
Douglas Gregor [Wed, 2 Sep 2009 13:05:45 +0000 (13:05 +0000)]
When parsing typename specifiers (with either the identifier or
simple-template-id form), check whether the scope specifier is
computable as a declaration context rather than checking whether it is
dependent, so that we properly cope with members of the current
instantiation.
Improve testing for typename specifiers that terminate in a
simpe-template-id.
Still use BadArg bugtype in the checker. This saves us implement registerInitialVisitors
in the BugReport.
When all internal bug checking logic are moved to checkers, BuiltinBug will
not reference GRExprEngine, and FlushReports() will be not necessary, since
all bugs are emitted into the equivalent classes immediately.
Replace uses of ImmutableSet in SymbolReaper with DenseSet. This was
motivated from Shark profiles that shows that 'markLive' was very
heavy when using --analyzer-store=region. On my benchmark file, this
reduces the analysis time for --analyzer-store=region from 19.5s to
13.5s and for --analyzer-store=basic from 5.3s to 3.5s. For the
benchmark file, this is a reduction of about 30% analysis time for
both analysis modes (a huge win).
John McCall [Wed, 2 Sep 2009 02:15:17 +0000 (02:15 +0000)]
When adding a friend class declaration to the lookup tables, use the access specifier
of any previous declaration in case we replace it in a class's declaration table.
Fixes bug 4858. This sort of thing makes me reconsider putting friend declarations in
declaration lists.
John McCall [Wed, 2 Sep 2009 00:55:30 +0000 (00:55 +0000)]
Ensure that the tag decls of friend decls aren't added to the friending class's
decl list, and remove some workarounds that were due to this. Thanks to Eli for
pointing this out and providing the test case.