Douglas Gregor [Tue, 11 May 2010 08:41:30 +0000 (08:41 +0000)]
A DeclRefExpr that refers to a member function or a static data member
of the current instantiation is value-dependent. The C++ standard
fails to enumerate this case and, therefore, we missed it. Chandler
did all of the hard work of reducing the last remaining
Boost.PtrContainer failure (which had to do with static initialization
in the Serialization library) down to this simple little test.
While I'm at it, clean up the dependence rules for template arguments
that are declarations, and implement the dependence rules for template
argument packs.
Chandler Carruth [Tue, 11 May 2010 08:02:08 +0000 (08:02 +0000)]
Add a test for a subtle instantiation pattern that showed up within a Boost
miscompile reduction. Clang already handles this correctly, but let's make sure
it stays that way.
John McCall [Mon, 10 May 2010 23:27:23 +0000 (23:27 +0000)]
Refactor the constant-evaluator so that it only supports a single form
of constant-evaluation. Formerly you could control whether it accepted
local l-values or not; now it always evaluates local l-values in the core
routines, but filters them out where consumed by the top-level routines.
This will make it much easier to cache evaluability.
Ted Kremenek [Mon, 10 May 2010 20:40:08 +0000 (20:40 +0000)]
Start converting pieces of DeclarationNameTable to be allocated using ASTContext's allocator.
While DeclarationNameTable doesn't leak, it uses 'malloc' too often. Start with having
'CXXLiteralOperatorNames' allocated using ASTContext's allocator and add a 'DoDestroy()' method
to DeclarationNameTable that is called by ~ASTContext.
Chris Lattner [Sun, 9 May 2010 05:36:05 +0000 (05:36 +0000)]
pchify CXXMemberCallExpr correctly. Before it would serialize
and deserialize as a CallExpr which is close, but ends up
deserializing with the wrong stmt class.
Douglas Gregor [Sat, 8 May 2010 23:34:38 +0000 (23:34 +0000)]
Fix a silly bootstrap-breaking thinko, where we were trying to convert
non-existent condition expressions to boolean values during template
instantiation.
Douglas Gregor [Sat, 8 May 2010 23:05:03 +0000 (23:05 +0000)]
Improve our handling of the -Wunused-variable warning in templates. In
particular, don't complain about unused variables that have dependent
type until instantiation time, so that we can look at the type of the
variable. Moreover, only complain about unused variables that have
neither a user-declared constructor nor a non-trivial destructor.
Anders Carlsson [Sat, 8 May 2010 22:35:05 +0000 (22:35 +0000)]
Add a SizeOfLargestEmptySubobject member to ASTRecordLayout. For C++ classes this will hold the largest empty subobject or 0 if the class doesn't have any empty subobjects.
Douglas Gregor [Sat, 8 May 2010 22:20:28 +0000 (22:20 +0000)]
When instantiating statements that involve conditions (if, while, do,
for, and switch), be careful to construct the full expressions as soon
as we perform template instantation, so we don't either forget to call
temporary destructors or destroy temporaries at the wrong time. This
is the template-instantiation analogue to r103187, during which I
hadn't realized that the issue would affect the handling of these
constructs differently inside and outside of templates.
Douglas Gregor [Sat, 8 May 2010 19:15:54 +0000 (19:15 +0000)]
Improve overload-candidate diagnostic for a function template that
failed because the explicitly-specified template arguments did not
match its template parameters, e.g.,
Douglas Gregor [Sat, 8 May 2010 18:13:28 +0000 (18:13 +0000)]
When template argument deduction fails because the call had too
many/too few arguments, use the same diagnostic we use for arity
mismatches in non-templates (but note that it's a function template).
Douglas Gregor [Sat, 8 May 2010 17:41:32 +0000 (17:41 +0000)]
When printing a non-viable overload candidate that failed due to
conflicting deduced template argument values, give a more specific
reason along with those values, e.g.,
Devang Patel [Fri, 7 May 2010 23:05:55 +0000 (23:05 +0000)]
If there is not any debug info for type then do not emit debug info for this variable.
A recent change to tightly verify debug info prepared by FE caught this.
This fixes unittest build.
Douglas Gregor [Fri, 7 May 2010 22:11:34 +0000 (22:11 +0000)]
Introduce a recursive AST visitor that makes it trivial to recursively
walk an entire AST, including all of the types, declarations,
statements, and expressions, and allowing one to easily override the
behavior of the walk at any particular node kind.
John McCall [Fri, 7 May 2010 22:08:54 +0000 (22:08 +0000)]
The FP constant evaluator was missing a few cases of unary operators that return floats
but whose operand isn't a float: specifically, __real__ and __imag__. Instead
of filtering these out, just implement them.
Chris Lattner [Fri, 7 May 2010 20:35:24 +0000 (20:35 +0000)]
clean up isBeforeInTranslationUnit by factoring out some common
code into a MoveUpIncludeHierarchy helper, and use the helper to
fix a case involving macros which regressed from my recent patch.
Douglas Gregor [Fri, 7 May 2010 19:42:26 +0000 (19:42 +0000)]
Reapply the reference-binding patch applied below, along with a fix to
ensure that we complete the type when we need to look at constructors
during reference binding.
When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion.
Chris Lattner [Fri, 7 May 2010 05:51:13 +0000 (05:51 +0000)]
reimplement the guts of SourceManager::isBeforeInTranslationUnit
to be algorithmically faster and avoid an std::map. This routine
basically boils down to finding the nearest common ancestor in a
tree, and we (implicitly) have information about nesting depth,
use it!
This wraps up rdar://7948633 - SourceManager::isBeforeInTranslationUnit has poor performance
Chris Lattner [Fri, 7 May 2010 01:17:07 +0000 (01:17 +0000)]
reimplement the caching in the SourceManager::isBeforeInTranslationUnit()
method to be correct. Right now it correctly computes the cache, then
goes ahead and computes the result the hard way, then asserts that they
match. Next I'll actually turn it on.
Douglas Gregor [Fri, 7 May 2010 00:28:31 +0000 (00:28 +0000)]
When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion.
Douglas Gregor [Thu, 6 May 2010 23:13:35 +0000 (23:13 +0000)]
Do not give implicitly-defined virtual members functions
available_externally linkage, since they may not have been given a
strong definition in another translation unit. Without this patch, the
following test case fails to link with a GCC-compiled libstdc++:
#include <sstream>
int main() { std::basic_stringbuf<char> bs; }
Douglas Gregor [Thu, 6 May 2010 22:18:21 +0000 (22:18 +0000)]
The global variable for the VTT might not have external linkage; allow
us to find local variables, too. Fixes the last remaining
Boost.Rational failure.