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.
Have the array type traits build an expression with type 'size_t'
instead of 'int'.
The Embarcadero spec says 'unsigned int', not 'int'. That's what
'size_t' is on Windows, but for Clang using a 'size_t' that can be
larger than int seems more appropriate.
Remove more dead code for emitting diagnostics. The callers of these
functions already precluded dependent types from reaching them.
Also change one of the callers to not error when a trait is applied to
a dependent type. This is a perfectly reasonable pattern, and both Unary
and Binary type traits already support dependent types (by populating
the AST with a nonce value).
Remove the actual diagnostic, since these aren't errors.
Convert the expression trait evaluation to a static function and
a switch with any default case. This both warns when an enumerator is
missing and asserts if a value sneaks through despite the warning.
While in there fix a bunch of coding style issues with this code.
Remove the default case from the unary type trait evaluation function,
adding an unreachable annotation. Remarkably this one was already
enumarting every trait.
Remove the type traits UTT_IsLvalueExpr and UTT_IsRvalueExpr.
As might be surmised from their names, these aren't type traits, they're
expression traits. Amazingly enough, they're expression traits that we
have, and fully implement. These "type" traits are even parsed from the
same tokens as the expression traits. Luckily, the parser only tried the
expression trait parsing for these tokens, so this was all just a pile
of dead code.
More cleanup of the type traits implementation.
1) Moved the completeness checking routine above the evaluation routine
so the reader sees that we do in fact check for complete types when
necessary.
2) Remove the FIXME comment about not doing this.
3) Make the arguments to the evaluate function agree in order with those
to the completeness checking function.
4) Completely specify the enumerators for the completeness checking
function rather than relying on a default.
5) Remove a check for the Borland language to only require complete
types in a few places. Borland's own documentation doesn't agree with
this: some of the previously unspecified traits *do* require
a complete type, some don't.
6) Correctly split the traits which do not require complete types from
those that do, clarifying comments and citations to the standard or
other documentation where relevant.
Order the type traits according to the standard's listing of unary type
traits where possible. For the rest, group them and add some
documentation regarding their origins.
Switch the interface name for both TemplateTypeParmType and
SubstTemplateTypeParmType to be 'getIdentifier' instead of 'getName' as
it returns an identifier. This makes them more consistent with the
NamedDecl interface.
Also, switch back to using this interface to acquire the indentifier in
TypePrinter.cpp. I missed this in r130628.
Re-applies the patch first applied way back in r106099, with
accompanying fixes to make it work today.
The core of this patch is to provide a link from a TemplateTypeParmType
back to the TemplateTypeParmDecl node which declared it. This in turn
provides much more precise information about the type, where it came
from, and how it functions for AST consumers.
To make the patch work almost a year after its first attempt, it needed
serialization support, and it now retains the old getName() interface.
Finally, it requires us to not attempt to instantiate the type in an
unsupported friend decl -- specifically those coming from template
friend decls but which refer to a specific type through a dependent
name.
A cleaner representation of the last item would be to build
FriendTemplateDecl nodes for these, storing their template parameters
etc, and to perform proper instantation of them like any other template
declaration. They can still be flagged as unsupported for the purpose of
access checking, etc.
This passed an asserts-enabled bootstrap for me, and the reduced test
case mentioned in the original review thread no longer causes issues,
likely fixed at somewhere amidst the 24k revisions that have elapsed.