Douglas Gregor [Wed, 13 Jan 2010 23:24:38 +0000 (23:24 +0000)]
Improve the sorting of code-completion results. We now always sort by
the "typed" text, first, then take into account
nested-name-specifiers, name hiding, etc. This means that the
resulting sort is actually alphabetical :)
John McCall [Wed, 13 Jan 2010 22:30:33 +0000 (22:30 +0000)]
Don't report ambiguities in the user-defined conversion if we weren't supposed
to be considering user-defined conversions in the first place.
Doug, please review; I'm not sure what we should be doing if we see a real
ambiguity in selecting a copy constructor when otherwise suppressing
user-defined conversions.
Ted Kremenek [Wed, 13 Jan 2010 21:46:36 +0000 (21:46 +0000)]
Reorganize CIndex.cpp into clearer sections of functions, and add a utility function 'MakeCXCursor' to centralize the logic for creating CXCursor objects.
Douglas Gregor [Wed, 13 Jan 2010 21:24:21 +0000 (21:24 +0000)]
Whenever completing ordinary names for an Objective-C source, also
provide completions for @ keywords. Previously, we only provided
@-completions after an @ was actually typed, which is useful but
probably not the common case.
Also, make sure a few Objective-C 2.0 completions only show up when
Objective-C 2.0 support is enabled (the default).
Douglas Gregor [Wed, 13 Jan 2010 17:31:36 +0000 (17:31 +0000)]
Reimplement constructor declarator parsing to cope with template-ids
that name constructors, the endless joys of out-of-line constructor
definitions, and various other corner cases that the previous hack
never imagined. Fixes PR5688 and tightens up semantic analysis for
constructor names.
Additionally, fixed a problem where we wouldn't properly enter the
declarator scope of a parenthesized declarator. We were entering the
scope, then leaving it when we saw the ")"; now, we re-enter the
declarator scope before parsing the parameter list.
Note that we are forced to perform some tentative parsing within a
class (call it C) to tell the difference between
C(int); // constructor
and
C (f)(int); // member function
which is rather unfortunate. And, although it isn't necessary for
correctness, we use the same tentative-parsing mechanism for
out-of-line constructors to improve diagnostics in icky cases like:
C::C C::f(int); // error: C::C refers to the constructor name, but
// we complain nicely and recover by treating it as
// a type.
John McCall [Wed, 13 Jan 2010 09:16:55 +0000 (09:16 +0000)]
Record some basic information about bad conversion sequences. Use that
information to feed diagnostics instead of regenerating it. Much room for
improvement here, but fixes some unfortunate problems reporting on method calls.
Sean Hunt [Wed, 13 Jan 2010 09:01:02 +0000 (09:01 +0000)]
Implement semantic checking for C++ literal operators.
This now rejects literal operators that don't meet the requirements.
Templates are not yet checked for.
Sean Hunt [Wed, 13 Jan 2010 08:31:49 +0000 (08:31 +0000)]
Add a bunch more feature-checking macros for C++0x features. Some of these are
disabled with the intent that users can start with them now and not have to change
a thing to have them work when we implement the features.
John McCall [Wed, 13 Jan 2010 06:44:51 +0000 (06:44 +0000)]
Insert clang-flags into the clang command. Currently it needs to be a list;
future work should permit strings (by splitting them into a list o' strings).
Daniel Dunbar [Wed, 13 Jan 2010 00:48:06 +0000 (00:48 +0000)]
cc1: Factor out CompilerInstance::ExecuteAction which has the majority of the
clang -cc1 logic for running an action against a set of options.
- This should make it easier to build tools that have a clang -cc1 like
interface, but aren't actually part of clang -cc1.
John McCall [Wed, 13 Jan 2010 00:25:19 +0000 (00:25 +0000)]
Improve the reporting of non-viable overload candidates by noting the reason
why the candidate is non-viable. There's a lot we can do to improve this, but
it's a good start. Further improvements should probably be integrated with the
bad-initialization reporting routines.
Ted Kremenek [Wed, 13 Jan 2010 00:13:47 +0000 (00:13 +0000)]
Make method definitions in TUVisitor out-of-line, making it easy to tell what visitor methods are defined.
Generalize TUVisitor to take a general "root" and "iterator" callback; this is prep. work to merging TUVisitor and CDeclVisitor.
Douglas Gregor [Wed, 13 Jan 2010 00:12:48 +0000 (00:12 +0000)]
Remove broken fix-it when a default function argument has been
redefined. There's a FIXME with an apology about why we don't try to
do better here. Fixes <rdar://problem/7513023>.
Douglas Gregor [Tue, 12 Jan 2010 23:18:54 +0000 (23:18 +0000)]
Don't emit string-comparison or self-comparison warnings in
unevaluated contexts, because they only matter for code that will
actually be evaluated at runtime.
As part of this, I had to extend PartialDiagnostic to support fix-it
hints.
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.