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.
Douglas Gregor [Thu, 6 May 2010 17:25:47 +0000 (17:25 +0000)]
Rework our handling of temporary objects within the conditions of
if/switch/while/do/for statements. Previously, we would end up either:
(1) Forgetting to destroy temporaries created in the condition (!),
(2) Destroying the temporaries created in the condition *before*
converting the condition to a boolean value (or, in the case of a
switch statement, to an integral or enumeral value), or
(3) In a for statement, destroying the condition's temporaries at
the end of the increment expression (!).
We now destroy temporaries in conditions at the right times. This
required some tweaking of the Parse/Sema interaction, since the parser
was building full expressions too early in many places.
mike-m [Thu, 6 May 2010 14:11:13 +0000 (14:11 +0000)]
Reposition clang-builtin include/ to immediately precede /usr/include/,
matching gcc compiler. Fixes #include_next <...> shenanigans that lead to
file-not-found failures with <cstddef> on libstdc++ 4.3.[012].
Updated C++ include header search paths for various Debian/Ubuntu and Fedora
linux distros.
John McCall [Thu, 6 May 2010 09:25:57 +0000 (09:25 +0000)]
Push TypeSourceInfo::getTypeLoc() into a header file so that it's
inlineable. That header file has to be TypeLoc.h, which means that
TypeLoc.h needs to depend on Decl.h because TypeSourceInfo doesn't
have its own header. That could be remedied, though.
John McCall [Thu, 6 May 2010 08:58:33 +0000 (08:58 +0000)]
Rearchitect -Wconversion and -Wsign-compare. Instead of computing them
"bottom-up" when implicit casts and comparisons are inserted, compute them
"top-down" when the full expression is finished. Makes it easier to
coordinate warnings and thus implement -Wconversion for signedness
conversions without double-warning with -Wsign-compare. Also makes it possible
to realize that a signedness conversion is okay because the context is
performing the inverse conversion. Also simplifies some logic that was
trying to calculate the ultimate comparison/result type and getting it wrong.
Also fixes a problem with the C++ explicit casts which are often "implemented"
in the AST with a series of implicit cast expressions.
John McCall [Thu, 6 May 2010 08:49:23 +0000 (08:49 +0000)]
Remember the number of positive and negative bits used by the enumerators of
an enum in the enum decl itself. Use some spare bits from TagDecl for this
purpose.
Chris Lattner [Thu, 6 May 2010 05:50:07 +0000 (05:50 +0000)]
optimize builtin_isnan/isinf to not do an extraneous extension from
float -> double (which happens because they are modelled as int(...)
functions), and add a testcase for isinf.
Chris Lattner [Thu, 6 May 2010 05:35:16 +0000 (05:35 +0000)]
implement part of PR6083: codegen support for isinf. Like isnan,
this is generating correct but suboptimal (extra extend to double)
code for the float case. Will investigate next.
Remove a dependency on Frontend headers in the Driver library. Also saves
building and passing arguments to cc1 layer when setting values to their
defaults.
Zhongxing Xu [Thu, 6 May 2010 02:59:29 +0000 (02:59 +0000)]
Make -analyzer-inline-call not a separate analysis. Instead it's a boolean
flag now, and can be used with other analyses. Only turned it on for C++
methods for now.
Douglas Gregor [Thu, 6 May 2010 00:28:52 +0000 (00:28 +0000)]
Partial and full specializations of a class template may have a
different tag kind ("struct" vs. "class") than the primary template,
which has an affect on access control.
Should fix the last remaining Boost.Accumulors failure.
Ted Kremenek [Thu, 6 May 2010 00:22:25 +0000 (00:22 +0000)]
Workaround a really serious caching bug in SourceManager::isBeforeInTranslationUnit() where the
method will sometimes return different results for the same input SourceLocations. I haven't
unraveled this method completely yet, so this truly is a workaround until a better fix comes
along.
John McCall [Wed, 5 May 2010 22:59:52 +0000 (22:59 +0000)]
Add IgnoreParenImpCasts() to Expr, which is basically like IgnoreParenCasts
except it only skips implicit casts.
Also fix ObjCImplicitGetterSetterRefExpr's child_begin to skip the base expression
if it's actually a type reference (which you get with static property references).
Chris Lattner [Wed, 5 May 2010 22:55:13 +0000 (22:55 +0000)]
Pass the globaldecl into GetOrCreateLLVMFunction so that llvm
function attributes like byval get applied to the function
definition. This fixes PR7058 and makes i386 llvm/clang bootstrap
pass all the same tests as x86-64 bootstrap for me (the llvmc
tests still fail in both).
Douglas Gregor [Wed, 5 May 2010 22:38:15 +0000 (22:38 +0000)]
When implicit definition of the copy-assignment operator fails,
provide a note that shows where the copy-assignment operator was
needed. We used to have this, but I broke it during refactoring.
Douglas Gregor [Wed, 5 May 2010 20:15:55 +0000 (20:15 +0000)]
When we emit a non-constant initializer for a global variable of
reference type, make sure that the initializer we build is the
of the appropriate type for the *reference*, not for the thing that it
refers to. Fixes PR7050.
Douglas Gregor [Wed, 5 May 2010 15:38:32 +0000 (15:38 +0000)]
For thread-safe static initialization of local statics with
destructors, place the __cxa_atexit call after the __cxa_guard_release
call, mimicking GCC/LLVM-GCC behavior. Noticed while debugging
something related.
Sean Hunt [Wed, 5 May 2010 15:24:00 +0000 (15:24 +0000)]
Reapplying patch to change StmtNodes.def to StmtNodes.td, this time
with no whitespace. This will allow statements to be referred to in
attribute TableGen files.
Sean Hunt [Wed, 5 May 2010 15:23:54 +0000 (15:23 +0000)]
Revert r103072; I accidentally ended up deleting a bunch of trailing
whitespace which makes this patch unreadable. Will recommit without the
whitespace.
Douglas Gregor [Wed, 5 May 2010 05:58:24 +0000 (05:58 +0000)]
Support for 'template' as a disambiguator (PR7030)
ParseOptionalCXXScopeSpecifier() only annotates the subset of
template-ids which are not subject to lexical ambiguity. Add support
for the more general case in ParseUnqualifiedId() to handle cases
such as A::template B().
Chris Lattner [Wed, 5 May 2010 05:53:24 +0000 (05:53 +0000)]
add a new --print-diagnostic-categories option, which causes the driver to
print out all of the category numbers with their description. This is useful
for clients that want to map the numbers produced by
--fdiagnostics-show-category=id to their human readable string form. The
output is simple but utilitarian:
Douglas Gregor [Wed, 5 May 2010 05:51:00 +0000 (05:51 +0000)]
Reimplement code generation for copying fields in the
implicitly-generated copy constructor. Previously, Sema would perform
some checking and instantiation to determine which copy constructors,
etc., would be called, then CodeGen would attempt to figure out which
copy constructor to call... but would get it wrong, or poke at an
uninstantiated default argument, or fail in other ways.
The new scheme is similar to what we now do for the implicit
copy-assignment operator, where Sema performs all of the semantic
analysis and builds specific ASTs that look similar to the ASTs we'd
get from explicitly writing the copy constructor, so that CodeGen need
only do a direct translation.
However, it's not quite that simple because one cannot explicit write
elementwise copy-construction of an array. So, I've extended
CXXBaseOrMemberInitializer to contain a list of indexing variables
used to copy-construct the elements. For example, if we have:
struct A { A(const A&); };
struct B {
A array[2][3];
};
then we generate an implicit copy assignment operator for B that looks
something like this:
B::B(const B &other) : array[i0][i1](other.array[i0][i1]) { }
CodeGen will loop over the invented variables i0 and i1 to visit all
elements in the array, so that each element in the destination array
will be copy-constructed from the corresponding element in the source
array. Of course, if we're dealing with arrays of scalars or class
types with trivial copy-assignment operators, we just generate a
memcpy rather than a loop.
Fixes PR6928, PR5989, and PR6887. Boost.Regex now compiles and passes
all of its regression tests.
Conspicuously missing from this patch is handling for the exceptional
case, where we need to destruct those objects that we have
constructed. I'll address that case separately.
Ted Kremenek [Wed, 5 May 2010 00:55:23 +0000 (00:55 +0000)]
Rework clang_annotateTokens() to annotate tokens with information that more closely matches
clang_getCursor(). Tokens are now annotated with the cursor (for the matching AST element)
that most closely encompasses that token.
Chris Lattner [Tue, 4 May 2010 21:55:25 +0000 (21:55 +0000)]
add a new -fdiagnostics-show-category=none/id/name option, giving control
over choice of:
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,Format String]
John McCall [Tue, 4 May 2010 20:45:42 +0000 (20:45 +0000)]
Emit the globals, metadata, etc. associated with static variables even when
they're unreachable. This matters because (if they're POD, or if this is C)
the scope containing the variable might be reachable even if the variable
isn't. Fixes PR7044.
Chris Lattner [Tue, 4 May 2010 20:44:26 +0000 (20:44 +0000)]
add the ability to associate 'category' names with diagnostics
and diagnostic groups. This allows the compiler to group
diagnostics together (e.g. "Logic Warning",
"Format String Warning", etc) like the static analyzer does.
This is not exposed through anything in the compiler yet.
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).