Douglas Gregor [Tue, 4 May 2010 17:13:42 +0000 (17:13 +0000)]
Introduce a limit on the depth of the macro instantiation backtrace
printed in a diagnostic, similar to the limit we already have on the
depth of the template instantiation backtrace. The macro instantiation
backtrace is limited to 10 "instantiated from:" diagnostics; when it's
longer than that, we'll show the first half, then say how many were
suppressed, then show the second half. The limit can be changed with
-fmacro-instantiation-limit=N, and turned off with N=0.
This eliminates a lot of note spew with libraries making use of the
Boost.Preprocess library.
Douglas Gregor [Tue, 4 May 2010 15:20:55 +0000 (15:20 +0000)]
When creating a call to a base subobject's operator= in an
implicitly-defined copy assignment operator, suppress the protected
access check. This eliminates the remaining failure in the
Boost.SmartPtr library (that was a product of the copy-assignment
generation rewrite) and, presumably, the Boost.TR1 library as well.
John McCall [Tue, 4 May 2010 01:53:42 +0000 (01:53 +0000)]
When inheriting a default argument expression, inherit the full expression,
not just the inner expression. This is important if the expression has any
temporaries. Fixes PR 7028.
Basically a symptom of really tragic method names.
Douglas Gregor [Mon, 3 May 2010 23:29:10 +0000 (23:29 +0000)]
When computing the template arguments for the instantiation of a
friend function template, be sure to adjust the computed template
argument lists based on the location of the definition of the function
template: it's possible that the definition we're instantiating with
and the template declaration that we found when creating the
specialization are in different contexts, which meant that we would
end up using the wrong template arguments for instantiation.
Fixes PR7013; all Boost.DynamicBitset tests now pass.
For the sake of Objective-c++ overload resolution,
treat argument types of objective-c pointer types
which only differ in their protocol qualifiers as
the same type (radar 7925668).
Douglas Gregor [Mon, 3 May 2010 20:22:41 +0000 (20:22 +0000)]
When instantiating a function-local variable definition, introduce the
mapping from the declaration in the template to the instantiated
declaration before transforming the initializer, in case some crazy
lunatic decides to use a variable in its own initializer. Fixes PR7016.
Ted Kremenek [Mon, 3 May 2010 20:16:35 +0000 (20:16 +0000)]
Workaround: Don't add ObjCMethodDecls to the vector of TopLevelDecls since they don't go in
the DeclContext for the translation unit. This is to workaround a fundamental issue in how
ObjC decls (within an @implementation) are parsed before the ObjCContainerDecl is available.
Douglas Gregor [Mon, 3 May 2010 18:51:14 +0000 (18:51 +0000)]
Diagnose unused exception parameters under a different warning group
(-Wunused-exception-parameter) than normal variables, since it's more
common to name and then ignore an exception parameter. This warning is
neither enabled by default nor by -Wall. Fixes <rdar://problem/7931045>.
Douglas Gregor [Mon, 3 May 2010 18:24:37 +0000 (18:24 +0000)]
Complain when we try to initialize an object of Objective-C class type
(which is ill-formed) with an initializer list. Also, change the
fallback from an assertion to a generic error message, which is far
friendlier. Fixes <rdar://problem/7730948>.
Do not issue warning on unimplemented property in the class, if it
conforms to a protocol as one of its super classes does. This is because
conforming super class will implement the property. This implements
new warning rules for unimplemented properties (radar 7884086).
Douglas Gregor [Mon, 3 May 2010 15:32:18 +0000 (15:32 +0000)]
When instantiating a member function declared via a typedef, don't try
to enter the instantiated parameter declarations into the local
instantiation scope; they can't be referenced anyway. Fixes PR7022.
Douglas Gregor [Sat, 1 May 2010 20:49:11 +0000 (20:49 +0000)]
Complete reimplementation of the synthesis for implicitly-defined copy
assignment operators.
Previously, Sema provided type-checking and template instantiation for
copy assignment operators, then CodeGen would synthesize the actual
body of the copy constructor. Unfortunately, the two were not in sync,
and CodeGen might pick a copy-assignment operator that is different
from what Sema chose, leading to strange failures, e.g., link-time
failures when CodeGen called a copy-assignment operator that was not
instantiation, run-time failures when copy-assignment operators were
overloaded for const/non-const references and the wrong one was
picked, and run-time failures when by-value copy-assignment operators
did not have their arguments properly copy-initialized.
This implementation synthesizes the implicitly-defined copy assignment
operator bodies in Sema, so that the resulting ASTs encode exactly
what CodeGen needs to do; there is no longer any special code in
CodeGen to synthesize copy-assignment operators. The synthesis of the
body is relatively simple, and we generate one of three different
kinds of copy statements for each base or member:
- For a class subobject, call the appropriate copy-assignment
operator, after overload resolution has determined what that is.
- For an array of scalar types or an array of class types that have
trivial copy assignment operators, construct a call to
__builtin_memcpy.
- For an array of class types with non-trivial copy assignment
operators, synthesize a (possibly nested!) for loop whose inner
statement calls the copy constructor.
- For a scalar type, use built-in assignment.
This patch fixes at least a few tests cases in Boost.Spirit that were
failing because CodeGen picked the wrong copy-assignment operator
(leading to link-time failures), and I suspect a number of undiagnosed
problems will also go away with this change.
Some of the diagnostics we had previously have gotten worse with this
change, since we're going through generic code for our
type-checking. I will improve this in a subsequent patch.
Douglas Gregor [Sat, 1 May 2010 15:04:51 +0000 (15:04 +0000)]
Added an RAII object that helps set up/tear down the Sema context
information required to implicitly define a C++ special member
function. Use it rather than explicitly setting CurContext on entry
and exit, which is fragile.
Use this RAII object for the implicitly-defined default constructor,
copy constructor, copy assignment operator, and destructor.
John McCall [Sat, 1 May 2010 00:40:08 +0000 (00:40 +0000)]
It turns out that basically every caller to RequireCompleteDeclContext
already knows what context it's looking in. Just pass that context in
instead of (questionably) recalculating it.
Douglas Gregor [Fri, 30 Apr 2010 21:46:38 +0000 (21:46 +0000)]
After substituting a template argument for a non-type template
parameter with pointer-to-member type, we may have to perform a
qualification conversion, since the pointee type of the parameter
might be more qualified than the pointee type of the argument we form
from the declaration. Fixes PR6986.
Douglas Gregor [Fri, 30 Apr 2010 18:55:50 +0000 (18:55 +0000)]
Clean up our handling of local instantiation scopes, which keep track
of the mapping from local declarations to their instantiated
counterparts during template instantiation. Previously, we tried to do
some unholy merging of local instantiation scopes that involved
storing a single hash table along with an "undo" list on the
side... which was ugly, and never handled function parameters
properly.
Now, we just keep separate hash tables for each local instantiation
scope, and "combining" two scopes means that we'll look in each of the
combined hash tables. The combined scope stack is rarely deep, and
this makes it easy to avoid the "undo" issues we were hitting. Also,
I've simplified the logic for function parameters: if we're declaring
a function and we need the function parameters to live longer, we just
push them back into the local instantiation scope where we need them.
Add calling convention related attributes to related declaration. Mark attributes invalid on type related checking so to add them to declarations only when everything is ok.
John McCall [Fri, 30 Apr 2010 07:10:06 +0000 (07:10 +0000)]
An edge from a call expression to the exit block is only an abnormal edge
if *none* of the successors of the call expression is the exit block.
This matters when a call of bool type is the condition of (say) a while
loop in a function with no statements after the loop. This *can* happen
in C, but it's much more common in C++ because of overloaded operators.
Suppresses some substantial number of spurious -Wmissing-noreturn warnings.
Douglas Gregor [Fri, 30 Apr 2010 05:56:50 +0000 (05:56 +0000)]
Introduce a sequence number into class template partial
specializations, which keeps track of the order in which they were
originally declared. We use this number so that we can always walk the
list of partial specializations in a predictable order during matching
or template instantiation. This also fixes a failure in Boost.Proto,
where SourceManager::isBeforeInTranslationUnit was behaving
poorly in inconsistent ways.
John McCall [Fri, 30 Apr 2010 05:56:45 +0000 (05:56 +0000)]
Account for the VTT argument when making an implicit copy constructor for
a class with virtual bases. Just a patch until Sema starts (correctly) doing
most of this analysis.
Douglas Gregor [Fri, 30 Apr 2010 04:39:27 +0000 (04:39 +0000)]
When we start the definition of a class template, set the
InjectedClassNameType's Decl to point at the definition. It's a little
messy, but we do the same thing with classes and their record types,
since much of Clang expects that the TagDecl* one gets out of a type
is the definition. Fixes several Boost.Proto failures.
Refactor the AnalysisConsumer to analyze functions after the whole
translation unit is parsed. This enables us to inline some calls when still
analyzing one function at a time.
Actions are classified into Function, CXXMethod, ObjCMethod,
ObjCImplementation.
This does not hurt performance much. The analysis time for sqlite3.c:
before:
real 17m52.440s
user 17m49.460s
sys 0m2.010s
after:
real 18m0.500s
user 17m56.900s
sys 0m2.330s
DisplayProgress option is broken now. -inine-call action is removed. It
will be reenabled in another form, perhaps as an indenpendant option.
John McCall [Thu, 29 Apr 2010 23:50:39 +0000 (23:50 +0000)]
Rebuild the nested name specifiers in member-pointer declarator chunks when
entering the current instantiation. Set up a little to preserve type location
information for typename types while we're in there.
Do not enable '-analyze-check-security-syntactic' by default when using '--analyze'. There
are several known issues to address for it should be turned on by default.
Douglas Gregor [Thu, 29 Apr 2010 18:24:40 +0000 (18:24 +0000)]
When determining a standard conversion sequence involves resolving the
address of an overloaded function (or function template), perform that
resolution prior to determining the implicit conversion
sequence. This resolution is not part of the implicit conversion
sequence itself.
Previously, we would always consider this resolution to be a
function pointer decay, which was a lie: there might be an explicit &
in the expression, in which case decay should not occur. This caused
the CodeGen assertion in PR6973 (where we created a
pointer to a pointer to a function when we should have had a pointer
to a function), but it's likely that there are corner cases of
overload resolution where this would have failed.
Cleaned up the code involved in determining the type that will
produced afer resolving the overloaded function reference, and added
an assertion to make sure the result is correct. Fixes PR6973.
Use clang::VarDecl name instead of llvm::GlobalVariable name.
llvm::GLobalVariable name may not match user visibile name for function static variables.
Add USR support for 'static inline' functions (which can be declared in header files).
Add USR support for 'static' functions and local variables, which can be handy for resolving named variables within a translation unit.