Douglas Gregor [Fri, 22 Oct 2010 15:24:46 +0000 (15:24 +0000)]
When performing name lookup for a namespace definition, only look into
the current context's redeclaration context, ignoring using
directives. Fixes PR8430.
Ted Kremenek [Thu, 21 Oct 2010 18:49:42 +0000 (18:49 +0000)]
Tweak diagnostics for redeclaration of a @property in a class extension where the redelcaration and original
declaration have the 'readwrite' attribute. This is a common case, and we can issue a more lucid diagnostic.
Douglas Gregor [Thu, 21 Oct 2010 18:04:08 +0000 (18:04 +0000)]
Implement the integral promotion rules for the C++0x char16_t and
char32_t character types and enable built-in overloaded operator
candidates for these types. Fixes PR8432.
Douglas Gregor [Thu, 21 Oct 2010 17:26:49 +0000 (17:26 +0000)]
Diagnose the declaration of template template parameters that
themselves have no template parameters. This is actually a restriction
due to the grammar of template template parameters, but we choose to
diagnose it in Sema to provide better recovery.
Douglas Gregor [Thu, 21 Oct 2010 16:57:46 +0000 (16:57 +0000)]
Always treat 'main' as an extern "C" function, so that we detect
redeclarations of main appropriately rather than allowing it to be
overloaded. Also, disallowing declaring main as a template.
Douglas Gregor [Thu, 21 Oct 2010 16:21:08 +0000 (16:21 +0000)]
When checking whether a return statement returns a stack-local
variable, handle conditional operators involving a
throw-expression. Fixes GCC DejaGNU's g++.dg/template/cond4.C.
Ted Kremenek [Thu, 21 Oct 2010 15:38:55 +0000 (15:38 +0000)]
Tweak the ObjCAtSyncChecker to assume that a mutex is non-nil after checking that it is
nil. Otherwise we can get false paths where a second @synchronized using the mutex
can have a bogus warning. Fixes <rdar://problem/8578650>.
Douglas Gregor [Thu, 21 Oct 2010 06:10:04 +0000 (06:10 +0000)]
Improve the implementation of libclang's token-annotation logic for
entities in the preprocessing record. Previously, we would only end up
getting the first token of a preprocessing record annotated
correctly. For example, given
#include "foo.h"
we would only get the '#' annotated as an inclusion directive; the
'include' and '"foo.h"' tokens would be given the general 'processing
directive' annotation.
Now, we get proper annotations for entities in the preprocessing
record.
Reorganize predefined macros for all Windows targets.
This adds an option to set the _MSC_VER macro without
recompiling. This is very useful when testing compatibility
with the Windows SDK and c++stdlib headers.
-fmsc-version=<version> (defaults to VS2003 (1300))
Ted Kremenek [Thu, 21 Oct 2010 04:00:58 +0000 (04:00 +0000)]
Previously, the printf warnings would say your arguments type was 'int' when it was really a 'char'
or a 'short'. This fixes that and allows the hints to suggest 'h' modifiers for small ints.
Modify the assumptions of an assert; the updated latest redeclaration can have the same location
if it's a template specialization pointing at the template.
Douglas Gregor [Wed, 20 Oct 2010 22:00:55 +0000 (22:00 +0000)]
Extend the preprocessing record and libclang with support for
inclusion directives, keeping track of every #include, #import,
etc. in the translation unit. We keep track of the source location and
kind of the inclusion, how the file name was spelled, and the
underlying file to which the inclusion resolved.
Get FunctionDecl to recurse on FunctionTypeLoc rather than
FunctionType! I didn't realize it was available, until rjmccall
pointed out that DeclaratorDecl made the typeloc available. This
makes FunctionDecl recursion *much* easier, because the typeloc can
take care of default parameters, so we no longer have to do that
separately, which means we can just do a normal type traversal instead
of this special-case WalkUp stuff we did before.
The only downside -- and it's minor -- is that because the TypeLoc
handles both the return type and the argument types, we can't recurse
on the explicit template args in the right place (which would be
between them). I do it beforehand instead. So for
int MyFunc<float>(char x);
we get callbacks in the order: float, int, char.
Duncan Sands [Wed, 20 Oct 2010 08:21:16 +0000 (08:21 +0000)]
GCC 4.4 warns that Receiver may be used uninitialized in this function.
As far as I can see, gcc is right to think this! The following change
will cause a nice segfault rather than undefined behaviour if this case
occurs. Someone who understands what this code is supposed to do should
probably take a proper look.
John McCall [Wed, 20 Oct 2010 05:44:58 +0000 (05:44 +0000)]
When matching template parameter lists to template-ids in a scope specifier
on a friend declaration, skip template-ids which do not depend on the
current parameter list.
Douglas Gregor [Wed, 20 Oct 2010 03:06:34 +0000 (03:06 +0000)]
Fix handling of property and ivar lookup in typo correction; the two
kinds of lookup into Objective-C classes were tangled together, a
situation that was compounded by automatically synthesized ivars.
Douglas Gregor [Wed, 20 Oct 2010 01:32:02 +0000 (01:32 +0000)]
Introduce a simple cache for unqualified typo corrections, so that we
don't repeatedly loop through identifiers, correcting the same typo'd
identifier over and over again.
We still bail out after 20 typo corrections, but this should help
improve performance in the common case where we're typo-correcting
because the user forgot to include a header.
The type-to-delete may not be a pointer if it's a dependent type.
Here's example code:
---
template<class T> class MyClass {
struct S { };
S* NewS() { return new S; }
void DeleteS() { delete NewS(); }
};
---
CXXDeleteExpr::getDestroyedType() on the 'delete NewS()' expression
would crash before this change. Now it returns a dependent type
object. Solution suggested by dgregor.
Ted Kremenek [Tue, 19 Oct 2010 22:15:20 +0000 (22:15 +0000)]
Really^2 fix <rdar://problem/8361834>, this time without crashing.
Now MICache is a linked list (per the FIXME), where we tradeoff between MacroInfo objects being in MICache
and MIChainHead. MacroInfo objects in the MICache chain are already "Destroy()'ed", so they can be reused. When
inserting into MICache, we need to remove them from the regular linked list so that they aren't destroyed more than
once.
The problem was not the management of MacroInfo objects, but that when we recycle them
via the MICache the memory of the underlying SmallVector (within MacroInfo) was not getting
released. This is because objects stashed into MICache simply are reused with a placement
new, and never have their destructor called.
Bill Wendling [Tue, 19 Oct 2010 20:08:12 +0000 (20:08 +0000)]
Now that mm_malloc.h was rewritten to *not* include errno.h (see
http://llvm.org/viewvc/llvm-project?rev=116771&view=rev) we can get rid of these
hacks.
Douglas Gregor [Tue, 19 Oct 2010 19:39:10 +0000 (19:39 +0000)]
Improve the performance of typo correction, by using a simple
computation to compute the lower bound of the edit distance, so that
we can avoid computing the edit distance for names that will clearly
be rejected later. Since edit distance is such an expensive algorithm
(M x N), this leads to a 7.5x speedup when correcting NSstring ->
NSString in the presence of a Cocoa PCH.
Ted Kremenek [Tue, 19 Oct 2010 18:16:54 +0000 (18:16 +0000)]
Simplify lifetime management of MacroInfo objects in Preprocessor by having the Preprocessor maintain them in a linked
list of allocated MacroInfos. This requires only 1 extra pointer per MacroInfo object, and allows us to blow them
away in one place. This fixes an elusive memory leak with MacroInfos (whose exact location I couldn't still figure
out despite substantial digging).
Douglas Gregor [Tue, 19 Oct 2010 17:17:35 +0000 (17:17 +0000)]
When marking declarations referenced within an expression (e.g.,
within a default argument), recurse into default arguments. Fixes
PR8401, a regression I introduced in r113700 while refactoring our
handling of "used" declarations in default arguments.
Chandler Carruth [Tue, 19 Oct 2010 08:47:51 +0000 (08:47 +0000)]
Use CLANG_RESOURCE_DIR define if one is provided, otherwise use the default of
'../lib/clang/<version>'. Actually use '..' rather than removing the trailing
component to correctly handle paths containing '.' or symlinks in the presence
of -no-canonical-prefixes, etc. This shouldn't change any existing behavior.
John McCall [Tue, 19 Oct 2010 01:40:49 +0000 (01:40 +0000)]
Redirect templated friend class decls to a new Sema callback and
construct an unsupported friend when there's a friend with a templated
scope specifier. Fixes a consistency crash, rdar://problem/8540527
Douglas Gregor [Tue, 19 Oct 2010 00:03:23 +0000 (00:03 +0000)]
Tweak code-completion result priorities, so that exact and similar
type matches have a bigger impact. The impetus for this change was
that, when initializing an enumeration value, we want enumerators of
that enumeration type to have a higher priority than, e.g., unrelated
local variables.
Ted Kremenek [Mon, 18 Oct 2010 23:36:05 +0000 (23:36 +0000)]
"Fix" bogus idempotent operations warning due to loop unrolling not unrolling enough loops to show that an invariant
doesn't hold. This fix is to increase the loop unrolling count to 4, which experiments show doesn't typically impact
analysis time. The real fix is to modify the IdempotentOperationsChecker to suppress warnings where an analysis point
could be preceded by a point where we gave up due to loop unrolling.
Daniel Dunbar [Mon, 18 Oct 2010 22:36:15 +0000 (22:36 +0000)]
Driver/IA: Accept and ignore -force_cpusubtype_ALL, as in 'clang -c
-Wa,-force_cpusubtype_ALL t.c'.
- Tweaks -Wa, and -Xassembler handling to only accept an explicit short list of
arguments and give an obvious unsupported error on others.
Douglas Gregor [Mon, 18 Oct 2010 22:01:46 +0000 (22:01 +0000)]
Fix the translation of the PCC_ForInit code-completion context for
C++/C99/Objective-C, so that we properly include types. This fix
affects global caching of code-completion results; without caching,
the behavior was already correct.