Douglas Gregor [Thu, 5 May 2011 16:13:52 +0000 (16:13 +0000)]
Scoped enumerations should not be treated as integer types (in the C
sense). Fixes <rdar://problem/9366066> by eliminating an inconsistency
between C++ overloading (which handled scoped enumerations correctly)
and C binary operator type-checking (which didn't).
Douglas Gregor [Thu, 5 May 2011 15:50:42 +0000 (15:50 +0000)]
When providing code completions for an Objective-C property access,
also include methods with zero-argument selectors. Implements
<rdar://problem/9048332>.
Douglas Gregor [Thu, 5 May 2011 00:13:13 +0000 (00:13 +0000)]
With invalid overloaded operators, we can get into funny cases where
the overloading of member and non-member functions results in arity
mismatches that don't fit well into our overload-printing scheme. This
only happens for invalid code (which breaks the arity invariants for
these cases), so just suppress the diagnostic rather than inventing
anything new. Fixes <rdar://problem/9222009>.
Douglas Gregor [Wed, 4 May 2011 23:50:46 +0000 (23:50 +0000)]
When adding KVC code completions, keep track of all of the selectors
that we've previously seen, both in declared methods and from previous
KVC completions, to eliminate duplicates. Fixes <rdar://problem/9162207>.
Sean Hunt [Wed, 4 May 2011 23:29:54 +0000 (23:29 +0000)]
there i fixed it
Increase robustness of the delegating constructor cycle detection
mechanism. No more infinite loops on invalid or logic errors leading to
false results. Ensure that this is maintained correctly accross
serialization.
Douglas Gregor [Wed, 4 May 2011 23:05:40 +0000 (23:05 +0000)]
Clean up Sema::BuildCXXNestedNameSpecifier()'s creation of TypeLoc
information. Rather than looking at the declaration kind to figure out
what TypeLoc to build, look at the type; it makes so much more
sense. Fixes <rdar://problem/9086649>.
We can use this to produce nice diagnostics (and try to fixit-and-recover) in
various cases where we might see "MyFunction" instead of "MyFunction()". The
changes in SemaExpr are an example of how to use isExprCallable.
Douglas Gregor [Wed, 4 May 2011 21:55:00 +0000 (21:55 +0000)]
When converting an integral template argument value to a non-type
template parameter of type 'bool', force the value to be zero or
one. Fixes <rdar://problem/9169404>.
Bill Wendling [Wed, 4 May 2011 21:37:25 +0000 (21:37 +0000)]
Pack ivar offsets together.
Ivar offsets for synthesized ivars are wrong, which could end up with a large
number of dirty pages because of ivar fixups at runtime. When we pack all of the
synthesized ivars into the same section, it limits the number of dirty pages
created. Place them in the "__DATA,__objc_ivar" section.
<rdar://problem/9374905>
More ms_struct bitfield stuff:
Adjacent bit fields are packed into the same 1-, 2-, or
4-byte allocation unit if the integral types are the same
size. // rdar://8823265.
Axel Naumann [Wed, 4 May 2011 12:59:24 +0000 (12:59 +0000)]
From Vassil Vassilev:
Like in r126648, provide (empty) default implementation for pure virtual getMemoryBufferSizes(). Not all use cases have meaningful implementations.
Axel Naumann [Wed, 4 May 2011 09:25:56 +0000 (09:25 +0000)]
Add C++ include paths for libstdc++ with Ubuntu 11.04 and Debian's libstdc++6-4.5, as collected from http://packages.ubuntu.com/search?mode=exactfilename&suite=natty§ion=all&arch=any&searchon=contents&keywords=c%2B%2Blocale.h and http://packages.debian.org/wheezy/armel/libstdc++6-4.5-dev/filelist
Fixes compilation with clang++ on Ubuntu 11.04.
Sean Hunt [Wed, 4 May 2011 05:57:24 +0000 (05:57 +0000)]
Implement a better version of delegating constructor cycle detection.
This is more efficient as it's all done at once at the end of the TU.
This could still get expensive, so a flag is provided to disable it. As
an added bonus, the diagnostics will now print out a cycle.
The PCH test is XFAILed because we currently can't deal with a note
emitted in the header and I, being tired, see no other way to verify the
serialization of delegating constructors. We should probably address
this problem /somehow/ but no good solution comes to mind.
John McCall [Wed, 4 May 2011 01:45:19 +0000 (01:45 +0000)]
Type prefixes of unresolved-names should only be mangled as unresolved-types
if they match that production, i.e. if they're template type parameters
or decltypes (or, as an obvious case not yet described in the ABI document,
if they're template template parameters applied to template arguments).
Ted Kremenek [Wed, 4 May 2011 01:38:46 +0000 (01:38 +0000)]
Enhance clang_getCXTUResourceUsage() to return the amount of memory used by the Preprocessor's bump allocator as well as those from the PreprocessingRecord.
Douglas Gregor [Wed, 4 May 2011 00:25:33 +0000 (00:25 +0000)]
When tag lookup finds something ambiguous, and we're defining a new
tag, filter out those ambiguous names that we found if they aren't
within the declaration context where this newly-defined tag will be
visible.
This is basically a hack, because we really need to fix the lookup of
tag declarations in this case to not find things it
shouldn't. However, it's better than what we had before, and it fixes
<rdar://problem/9168556>.
Douglas Gregor [Wed, 4 May 2011 00:14:37 +0000 (00:14 +0000)]
Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),
which determines whether a particular file is actually a header that
is intended to be guarded from multiple inclusions within the same
translation unit.
Introduce ASTUnit::LoadFromCompilerInvocationAction that allows one to create an ASTUnit
from a CompilerInvocation along with an ASTFrontendAction to invoke, and without all the goo
about the precompiled preamble.
Sean Hunt [Tue, 3 May 2011 23:05:34 +0000 (23:05 +0000)]
Ensure that destructors are properly inovked when an exception leaves
the body of a delegating constructor call.
This means that the delegating constructor implementation should be
complete and correct, though there are some rough edges (diagnostic
quality with the cycle detection and using a deleted destructor).
Sean Hunt [Tue, 3 May 2011 20:43:02 +0000 (20:43 +0000)]
Move the AST modifications to after the cycle detection in
lib/Sema/SemaDeclCXX.cpp to avoid getting stuck in an infinite loop. See
the comment for more explanation.
Douglas Gregor [Tue, 3 May 2011 20:37:33 +0000 (20:37 +0000)]
Extend -Wnon-pod-memset to also encompass memcpy() and memmove(),
checking both the source and the destination operands, renaming the
warning group to -Wnon-pod-memaccess and tweaking the diagnostic text
in the process.
Douglas Gregor [Tue, 3 May 2011 20:05:22 +0000 (20:05 +0000)]
Separate the -Wnon-pod-memset warnings into two separate warnings:
- a default-on warning for pointers to dynamic classes (= classes with vtables)
- a default-off warning for other non-POD types
When parsing a template friend declaration we dropped the template
parameters on the floor in certain cases:
class X {
template <typename T> friend typename A<T>::Foo;
};
This was parsed as a *non* template friend declaration some how, and
received an ExtWarn. Fixing the parser to actually provide the template
parameters to the freestanding declaration parse triggers the code which
specifically looks for such constructs and hard errors on them.
Along the way, this prevents us from trying to instantiate constructs
like the above inside of a outer template. This is important as loosing
the template parameters means we don't have a well formed declaration
and template instantiation will be unable to rebuild the AST. That fixes
a crash in the GCC test suite.
Lenny Maiorani [Tue, 3 May 2011 16:34:26 +0000 (16:34 +0000)]
Removing strncpy() checking in CString checker for now. Some significant changes need to be made to properly support modeling of it since it potentially leaves strings non-null terminated.
Richard Trieu [Mon, 2 May 2011 23:00:27 +0000 (23:00 +0000)]
Added an assert to IntegerLiteral to ensure that the integer type passed in has the same size as the APInt passed in. Also, updated the comments around IntegerLiteral.
Changed the integer type that range-based for-loops used. Switched to pointer difference type, which satisfies the new assert in IntegerLiteral.
Ted Kremenek [Mon, 2 May 2011 21:21:42 +0000 (21:21 +0000)]
Tweak the retain/release checker to not stop tracking retained objects when calling C++ methods. This is a temporary solution to prune false positives until we have a general story using annotations.
Eli Friedman [Mon, 2 May 2011 20:24:29 +0000 (20:24 +0000)]
Skip extra copy from aggregate where it isn't necessary; rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0.
Ted Kremenek [Mon, 2 May 2011 19:42:42 +0000 (19:42 +0000)]
Augment retain/release checker to not warn about tracked objects passed as arguments to C++ constructors. This is a stop-gap measure for Objective-C++ code that uses smart pointers to manage reference counts.
Lenny Maiorani [Mon, 2 May 2011 19:05:49 +0000 (19:05 +0000)]
Implements strncasecmp() checker and simplifies some of the logic around creating substrings if necessary and calling the appropriate StringRef::compare/compare_lower().
Don't abuse reinterpret cast to do something the API of PointerUnion
provides proper support for. This was caught by
-Wundefined-reinterpret-cast, and I think a reasonable case for it to
warn on.
Also use is<...> instead of dyn_cast<...> when the result isn't needed.
This whole thing should probably switch to using UsuallyTinyPtrVector.
Eli Friedman [Mon, 2 May 2011 18:05:27 +0000 (18:05 +0000)]
Switch CallArgList from an std::pair to a new CallArg struct (which will eventually gain more members). Working towards modifying call emission to avoid unnecessary copies.
Nick Lewycky [Mon, 2 May 2011 01:48:46 +0000 (01:48 +0000)]
Remove redeclaration of Invalid. The code that set this to true was updating an
Invalid that was never read from again, causing non-type-template-parms to be
marked valid when in fact they weren't.
This was caught by GCC 4.6's -Wunused-but-set-variable warning.
Nick Lewycky [Mon, 2 May 2011 01:41:48 +0000 (01:41 +0000)]
Remove unused variable spotted by GCC.
Devang, can we remove this call entirely? If I try that, "make check" passes
but the call has a side-effect of ensuring that the block's context exists in
the debug info. getContextDescriptor() is used in a void context for that side-
effect elsewhere in this file. Please take a look!
John McCall [Mon, 2 May 2011 00:30:12 +0000 (00:30 +0000)]
Revise the representation of parameter scope data so that the
scope depth overlaps with the ObjCDeclQualifier, dropping
memory usage back to previous levels.
Add an optional field attached to a DeclRefExpr which points back to the
Decl actually found via name lookup & overload resolution when that Decl
is different from the ValueDecl which is actually referenced by the
expression.
This can be used by AST consumers to correctly attribute references to
the spelling location of a using declaration, and otherwise gain insight
into the name resolution performed by Clang.
The public interface to DRE is kept as narrow as possible: we provide
a getFoundDecl() which always returns a NamedDecl, either the ValueDecl
referenced or the new, more precise NamedDecl if present. This way AST
clients can code against getFoundDecl without know when exactly the AST
has a split representation.
For an example of the data this provides consider:
% cat x.cc
namespace N1 {
struct S {};
void f(const S&);
}
void test(N1::S s) {
f(s);
using N1::f;
f(s);
}
Now we can tell that the second call is 'using' (no pun intended) the using
declaration, and *which* using declaration it sees. Without this, we can
mistake calls that go through using declarations for ADL calls, and have no way
to attribute names looked up with using declarations to the appropriate
UsingDecl.
John McCall [Sun, 1 May 2011 22:35:37 +0000 (22:35 +0000)]
Store a parameter index and function prototype depth in every
parameter node and use this to correctly mangle parameter
references in function template signatures.
A follow-up patch will improve the storage usage of these
fields; here I've just done the lazy thing.
Move the state bits in DeclRefExpr out of the pointer union and into
a bitfield in the base class. DREs weren't using any bits here past the
normal Expr bits, so we have plenty of room. This makes the common case
of getting a Decl out of a DRE no longer need to do any masking etc.
Also, while here, clean up code to use the accessor methods rather than
directly poking these bits, and provide a nice comment for DREs that
includes the information previously attached to the bits going into the
pointer union.
No functionality changed here, but DREs should be a tad faster now.
Based on the new information in the AST provided by r130628, write
3 lines of code and improve a bunch of information in the libclang view
of the code.
Updates the two tests that exercise this with the new data, checking
that each new source location actually points back to the declared
template parameter.