Douglas Gregor [Tue, 12 Jan 2010 21:28:44 +0000 (21:28 +0000)]
Improve recovery for template-ids whose template-name doesn't actually
name a template, when they occur in a base-specifier. This is one of
the (few) places where we know for sure that an identifier followed by
a '<' must be a template name, so we can diagnose and recover well:
Chandler Carruth [Tue, 12 Jan 2010 20:32:25 +0000 (20:32 +0000)]
Fix the CodeGen half of PR5911 by changing reference initialization to
correctly look through arrays to see cv-qualifiers. Also enhances the routine
for doing this to preserve more type sugaring for diagnostics.
Douglas Gregor [Tue, 12 Jan 2010 17:52:59 +0000 (17:52 +0000)]
Parse dependent template-ids in base clauses and member
initializers. This isn't actually in the C++ grammar (in any version),
but that's clearly an oversight: both GCC and EDG support this syntax,
and it's used within Boost code. I'll file a core issue proposing
precisely the change made here. Fixes PR6008.
Douglas Gregor [Tue, 12 Jan 2010 17:06:20 +0000 (17:06 +0000)]
When determining whether a given name is a template in a dependent
context, do not attempt typo correction. This harms performance (as
Abramo noted) and can cause some amusing errors, as in this new
testcase.
John McCall [Tue, 12 Jan 2010 07:18:19 +0000 (07:18 +0000)]
So I was sitting around, trying vainly to think of something to commit, and then
I said to myself, self, why don't you go add a couple of parameters to a method
and then fail to use them, and I thought that sounded like a pretty good idea,
so I did it.
John McCall [Tue, 12 Jan 2010 02:15:36 +0000 (02:15 +0000)]
Reorganize some of the code to note overload candidates. Improves the
fidelity with which we note them as functions/constructors and templates
thereof. Also will be helpful when reporting bad conversions (next).
John McCall [Tue, 12 Jan 2010 00:44:57 +0000 (00:44 +0000)]
Introduce a specific representation for the ambiguous implicit conversion
sequence. Lots of small relevant changes. Fixes some serious problems with
ambiguous conversions; also possibly improves associated diagnostics.
Ted Kremenek [Mon, 11 Jan 2010 23:56:39 +0000 (23:56 +0000)]
CIndex:
- Remove unused (and unimplemented) clang_getDeclarationName().
- Remove unused (and unimplemented) clang_getEntity().
- Add clang_getEntityFromDecl(): maps from a CXDecl to a CXEntity)
- Add clang_getDeclaration(): maps from a (CXEntity, CXTranslationUnit) to a CXDecl).
Douglas Gregor [Mon, 11 Jan 2010 23:29:10 +0000 (23:29 +0000)]
Eliminate an embarrassing performance regression in C/ObjC, where we
were performing name lookup for template names in C/ObjC and always
finding nothing. Turn off such lookup unless we're in C++ mode, along
with the check that determines whether the given identifier is a
"current class name", and assert that we don't make this mistake
again.
David Chisnall [Mon, 11 Jan 2010 22:33:19 +0000 (22:33 +0000)]
Allow VLAs in C++ if in GNU mode (GNU C++ permits them). Clang can now compile LanguageKit, although the resulting code crashes (although not in any of the functions that use VLAs).
Douglas Gregor [Mon, 11 Jan 2010 22:30:10 +0000 (22:30 +0000)]
C++0x [dcl.typedef]p4, take 3, where we actually figure out what "that
is not also a typedef-name" actually means. For anyone keeping score,
that's John: 2, Doug: 0.
Douglas Gregor [Mon, 11 Jan 2010 22:04:54 +0000 (22:04 +0000)]
Use isa<ElaboratedType> rather than getAs<ElaboratedType>, since the
latter may (eventually) perform multiple levels of desugaring (thus
breaking the newly-added tests) and the former is faster. Thanks, John!
Douglas Gregor [Mon, 11 Jan 2010 21:54:40 +0000 (21:54 +0000)]
Allow redefinitions of typedef-names within class scope when the type
they redefine is a class-name but not a typedef-name, per C++0x
[dcl.typedef]p4. The code in the test was valid C++98 and is valid
C++0x, but an unintended consequence of DR56 made it ill-formed in
C++03 (which we were luck enough to implement). Fixes PR5455.
Douglas Gregor [Mon, 11 Jan 2010 19:55:36 +0000 (19:55 +0000)]
When resolving a single function template specialization to a
function, be sure to adjust the resulting argument type to a pointer
(if necessary). Fixes PR5910 and PR5949.
Douglas Gregor [Mon, 11 Jan 2010 18:53:25 +0000 (18:53 +0000)]
Add support for out-of-line definitions of conversion function
templates. Previously, a little thinko in the code that replaced a
conversion function template with its redeclaration was causing some
very weird lookup behavior.
Douglas Gregor [Mon, 11 Jan 2010 18:46:21 +0000 (18:46 +0000)]
Tighten up the "cannot return array or function type" diagnostic to
say either "array type" or "function type", whichever it is. No reason
to make the user guess.
Douglas Gregor [Mon, 11 Jan 2010 18:40:55 +0000 (18:40 +0000)]
Implement name lookup for conversion function template specializations
(C++ [temp.mem]p5-6), which involves template argument deduction based
on the type named, e.g., given
struct X { template<typename T> operator T*(); } x;
when we call
x.operator int*();
we perform template argument deduction to determine that T=int. This
template argument deduction is needed for template specialization and
explicit instantiation, e.g.,
template<> X::operator float*() { /* ... */ }
and when calling or otherwise naming a conversion function (as in the
first example).
This fixes PR5742 and PR5762, although there's some remaining ugliness
that's causing out-of-line definitions of conversion function
templates to fail. I'll look into that separately.
Ken Dyck [Mon, 11 Jan 2010 17:06:35 +0000 (17:06 +0000)]
Roll out ASTContext::getTypeSizeInChars(), replacing instances of
"ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits
ones as appropriate.
Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType,
fromQuantity(), and getQuantity() for clarity.
Ted Kremenek [Mon, 11 Jan 2010 02:33:26 +0000 (02:33 +0000)]
Switch RegionStore over to using <BaseRegion+raw offset> to store
value bindings. Along with a small change to OSAtomicChecker, this
resolves <rdar://problem/7527292> and resolves some long-standing
issues with how values can be bound to the same physical address by
not have the same "key". This change is only a beginning; logically
RegionStore needs to better handle loads from addresses where the
stored value is larger/smaller/different type than the loaded value.
We handle these cases in an approximate fashion now (via
CastRetrievedVal and help in SimpleSValuator), but it could be made
much smarter.
Ted Kremenek [Mon, 11 Jan 2010 00:07:44 +0000 (00:07 +0000)]
Preliminary reworking of value-binding logic in RegionStore:
(1) Introduce a new 'BindingKey' class to match 'BindingValue'. This
gives us the flexibility to change the current key value from 'const
MemRegion*' to something more interesting.
(2) Rework additions/removals/lookups from the store to use new
'Remove', 'Add', 'Lookup' utility methods.
No "real" functionality change; just prep work and abstraction.
Sean Hunt [Sun, 10 Jan 2010 23:37:56 +0000 (23:37 +0000)]
Do not parse hexadecimal floating point literals in C++0x mode because they are
incompatible with user-defined literals, specifically with the following form:
0x1p+1
The preprocessing-number token extends only as far as the 'p'; the '+' is not
included. Previously we could get away with this extension as p was an invalid
suffix, but now with user-defined literals, 'p' might well be a valid suffix
and we are forced to consider it as such.
This patch also adds a warning in non-0x C++ modes telling the user that
this extension is incompatible with C++0x that is enabled by default
(previously and with other languages, we warn only with a compliance
option such as -pedantic).
Douglas Gregor [Sun, 10 Jan 2010 23:08:15 +0000 (23:08 +0000)]
Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for
static_cast<type>(expr)
when we can have an expression, or
using namespace identifier;
when we can have a using directive.
Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.
Generalize target weirdness handling having proper layering in mind:
1. Add helper class for sema checks for target attributes
2. Add helper class for codegen of target attributes
As a proof-of-concept - implement msp430's 'interrupt' attribute.
Chris Lattner [Sun, 10 Jan 2010 00:24:58 +0000 (00:24 +0000)]
implement rdar://7520940: published framework headers should
import other headers within the same framework with the full
framework path, not with a relative include.
Ted Kremenek [Sat, 9 Jan 2010 22:58:54 +0000 (22:58 +0000)]
Fix overzealous assertion in GRExprEngine::VisitLValue(). A
CallExpr/ObjCMessageExpr can be visited in an "lvalue" context if it
returns a struct temporary. Currently the analyzer doesn't reason
about struct temporary returned by function calls, but we shouldn't
crash here either.
Benjamin Kramer [Sat, 9 Jan 2010 16:17:37 +0000 (16:17 +0000)]
Rework InitPreprocessor to use a MacroBuilder class instead of pushing around
std::vectors.
- MacroBuilder wraps a raw_ostream so it can easily write to any buffer
supported by raw_ostream.
- MacroBuilder's method take Twines for easy string concatenation (this was done
with sprintf and temporary buffers before).
- Targets still use std::vector as they don't have access to the builder.
Ted Kremenek [Fri, 8 Jan 2010 18:54:04 +0000 (18:54 +0000)]
Fix handling in GRExprEngine of 'default' branch in switch statements
when the default case is winnowed down to be infeasible. When all
cases were ruled out (and the analysis state for the default case
would be infeasible) we would still consider the default case
possible. This fixes PR 5969.