Граф коммитов

3304 Коммитов

Автор SHA1 Сообщение Дата
John McCall 7d384dd5ac Split LookupResult into its own header.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 07:57:50 +00:00
Douglas Gregor 083128f6b1 Code completion after @property, providing the names of forward-declared properties
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 04:49:41 +00:00
Douglas Gregor 55385fe3e7 Code completion for Objective-C properly lists
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89194 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 04:19:12 +00:00
Eli Friedman 4c3b896229 Make CreateOverloadedUnaryOp build the correct node for postinc/dec operators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89192 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 03:58:17 +00:00
Eli Friedman e4216e9d76 Simplify ActOnPostfixUnaryOp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89188 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 03:38:04 +00:00
John McCall 7ba107a186 Incremental progress on using declarations. Split UnresolvedUsingDecl into
two classes, one for typenames and one for values;  this seems to have some
support from Doug if not necessarily from the extremely-vague-on-this-point
standard.  Track the location of the 'typename' keyword in a using-typename
decl.  Make a new lookup result for unresolved values and deal with it in
most places.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89184 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 02:36:19 +00:00
Douglas Gregor 95ac6556a5 Code completion for member accesses that involve Objective-C properties and instance variables
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89182 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 01:29:26 +00:00
Douglas Gregor a14cd1111f Eliminate some completely-redundant lookups
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 01:29:02 +00:00
Eli Friedman f43fb722f6 PR5520: Make sure to check whether the base type is complete before looking for
operator->.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89180 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 01:28:03 +00:00
Ted Kremenek 321c22f1c4 Add SourceLocations to ObjCClassDecl for the class identifiers referenced by @class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89170 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 00:28:11 +00:00
Douglas Gregor f74a419b72 Finish code completion for Objective-C message sends
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89168 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 00:06:18 +00:00
Douglas Gregor 60b01cc448 Rename Objective-C message send completion functions to indicate that we're referring to message sends
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 23:31:36 +00:00
Douglas Gregor 36ecb04619 Refactor code-completion support for message sends, collecting the
code to find and add Objective-C methods (starting at an
ObjCContainerDecl) into a single, static function. Also, make sure
that we search into the implementations of classes and categories to
find even more methods.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 23:22:23 +00:00
Ted Kremenek c09cba67d0 Pass source locations of identifiers referenced by @class through Action::ActOnForwardClassDeclaration().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89162 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 23:12:20 +00:00
Ted Kremenek c32b1d82c1 Do not register ObjCInterfaceDecls implicitly created by @class in the
current DeclContext.  These "imaginary" declarations pose issues for
clients searching DeclContext for actual declarations.  Instead,
register them for name lookup, and add the ObjCInterfaceDecl later to
the DeclContext when we hit an actual @interface declaration.

This also fixes a bug where the invariant that the Decls in a
DeclContext are sorted in order of their appearance is no longer
violated.  What could happen is that an @class causes an
ObjCInterfaceDecl to get added first to the DeclContext, then the
ObjCClassDecl itself is added, and then later the SourceLocation of
the ObjCInterfaceDecl is updated with the correct location (which is
later in the file).  This breaks an assumed invariant in
ResolveLocation.cpp (and possibly other clients).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89160 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 22:58:30 +00:00
Douglas Gregor 0a0d1ac3bd Improve location information when adding conversion candidates
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89141 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 21:16:22 +00:00
Fariborz Jahanian 5f8f8571c5 Start support of weak_import objective-c classes.
(Radar 6815425).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89124 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 19:08:08 +00:00
Sebastian Redl 4a2614e946 Adjust format attribute index for implicit object arguments. Fixes PR5521.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89113 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 18:02:24 +00:00
Douglas Gregor 24a069f5eb Implement code completion for Objective-C message sends to "super".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89112 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 17:59:40 +00:00
Fariborz Jahanian 1ac7104947 Fixes a typo, reported by Doug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89107 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 17:15:16 +00:00
Douglas Gregor 9630eb6e37 Augment code-completion results to provide argument names and
placeholder arguments for Objective-C message sends. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89103 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 16:44:22 +00:00
Douglas Gregor 92eff46686 StringRef'ify CodeCompletionString
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 16:43:05 +00:00
John McCall 5b47faf354 Temporarily unbreak the clang-on-llvm tests. :) Not going to fix unresolved
lookup all in a night.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89089 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 10:36:41 +00:00
John McCall 314be4e7d8 Store "sugared" decls in LookupResults (i.e. decl aliases like using declarations);
strip the sugar off in getFoundDecl() and getAsSingleDecl(), but leave it on for
clients like overload resolution who want to use the iterators.

Refactor a few pieces of overload resolution to strip off using declarations in
a single place.  Don't do anything useful with the extra context knowledge yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89061 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 07:50:12 +00:00
Douglas Gregor 6490ae5003 Silence some warnings produced by Clang, and add a missing header
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89051 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 06:14:37 +00:00
Douglas Gregor 48c32a7e7c Implement template instantiation for using directives, which is dead simple.
Also, make the "don't know how to instantiate a particular kind of
declaration" diagnostic nicer, so we don't have to trap Clang in a
debugger to figure out what went wrong.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89050 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 06:07:40 +00:00
John McCall 9488ea120e Instead of hanging a using declaration's target decls directly off the using
decl, create shadow declarations and put them in scope like normal.
Work in progress.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89048 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 05:59:44 +00:00
Douglas Gregor 03c5705a99 Require the object type of a member access expression ("." or "->") to
be complete.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89042 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 05:17:33 +00:00
Anders Carlsson 9f853df0d3 Unify the way destructor epilogues are generated for synthesized and regular destructors. Also fix PR5529.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89034 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 04:44:12 +00:00
John McCall a24dc2e38c Carry lookup configuration throughout lookup on the LookupResult. Give
LookupResult RAII powers to diagnose ambiguity in the results.  Other diagnostics
(e.g. access control and deprecation) will be moved to automatically trigger
during lookup as part of this same mechanism.

This abstraction makes it much easier to encapsulate aliasing declarations
(e.g. using declarations) inside the lookup system:  eventually, lookup will
just produce the aliases in the LookupResult, and the standard access methods
will naturally strip the aliases off.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 02:14:36 +00:00
Eli Friedman 16fea9b2e5 PR5526: Make sure to set the right cast kinds for the inserted implicit casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89023 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 01:22:05 +00:00
Eli Friedman e73d3bc991 Simplify the AST a bit by skipping creating member initializers for members
with a trivial constructor.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88990 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 23:07:59 +00:00
Douglas Gregor a4923eb7c4 First part of changes to eliminate problems with cv-qualifiers and
sugared types. The basic problem is that our qualifier accessors
(getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
the current QualType and not at any qualifiers that come from sugared
types, meaning that we won't see these qualifiers through, e.g.,
typedefs:

  typedef const int CInt;
  typedef CInt Self;

Self.isConstQualified() currently returns false!

Various bugs (e.g., PR5383) have cropped up all over the front end due
to such problems. I'm addressing this problem by splitting each
qualifier accessor into two versions: 

  - the "local" version only returns qualifiers on this particular
    QualType instance
  - the "normal" version that will eventually combine qualifiers from this
    QualType instance with the qualifiers on the canonical type to
    produce the full set of qualifiers.

This commit adds the local versions and switches a few callers from
the "normal" version (e.g., isConstQualified) over to the "local"
version (e.g., isLocalConstQualified) when that is the right thing to
do, e.g., because we're printing or serializing the qualifiers. Also,
switch a bunch of
  
  Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()

expressions over to 

  Context.hasSameUnqualifiedType(T1, T2)




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 21:35:15 +00:00
Sebastian Redl a439e6f8f5 Repair broken FindCompositePointerType. Correct early termination condition. Get CVR qualifiers from canonical types. Traverse collected qualifiers in reverse order on rebuilding the pointer, so that we don't swap inner and outer qualifiers. That last one fixes PR5509.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88960 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 21:03:45 +00:00
Eli Friedman 1a3c75f32f Fix PR5488: special-case the overloaded arrow operator so that we don't try to
treat it as a unary operator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88938 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 19:13:03 +00:00
Fariborz Jahanian 63e963cdff Handle case of missing '@end' in implementation context
gracefully, on par with gcc, by: Issuing a warning,
doing final sematinc check of its definitions and generating
its meta-data.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88934 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 18:57:01 +00:00
Eli Friedman 05d9d7aa2d Set the cast kind for a few more code paths.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88893 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 05:44:20 +00:00
Anders Carlsson 6d7013940a Make sure that virtual destructors have delete operators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88877 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 22:49:34 +00:00
Anders Carlsson 1f126bd18c Deallocation functions must also be static.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88859 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 19:08:46 +00:00
Anders Carlsson 67bf2e7706 allocation functions are always static.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88858 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 18:59:32 +00:00
Anders Carlsson 78f7455181 Factor finding a deallocation function for a record type out into a separate function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88857 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 18:45:20 +00:00
Anders Carlsson 50724302e2 If we find a deallocation function in the class scope, but it is a placement function we should not look for a deallocation function in the global scope.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88851 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 16:43:15 +00:00
Douglas Gregor ab15d0e5af When performing a static downcast as part of a static_cast, make sure
that we're dealing with canonical types like the documentation say
(yay, CanQualType). Alas, this is another instance where using
getQualifiers() on a non-canonical QualType got us in trouble.

Good news: with this fix, Clang can now parse all of its own headers!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88848 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 09:20:52 +00:00
Douglas Gregor c07a494b37 Don't gratuitously mark the default constructors of base or member initializers as used
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 08:51:10 +00:00
Douglas Gregor 891fdae811 When adding the underlying declaration of a decl to a lookup-results
set, expand overloaded function declarations. Long-term, this should
actually be done by the name-lookup code rather than here, but this
part of the code (involving using declarations) is getting a makeover
now and the test-case is useful.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88846 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 08:11:13 +00:00
Douglas Gregor 593564ba94 When looking for operator() to type-check a call to an object of class
type, use full qualified name lookup rather than the poking the
declaration context directly. This makes sure that we see operator()'s
in superclasses. Also, move the complete-type check before this name
lookup.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88842 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 07:48:03 +00:00
Douglas Gregor d5b57281cc If any errors have occurred by the time we hit the end of a function body, clear out any remaining temporaries so they aren't seen later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88834 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 07:07:58 +00:00
Anders Carlsson a8a1e3da7c Always build a builtin operator expression for the __extension__ unary operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88811 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 21:26:41 +00:00
Sebastian Redl a82e4ae149 - Have TryStaticImplicitCast set the cast kind to NoOp when binding a reference. CheckReferenceInit already inserts implicit casts to the necessary types. This fixes an assertion in CodeGen for some casts and brings a fix for PR5453 close, if I understand that bug correctly.
- Also, perform calculated implicit cast sequences if they're determined to work. This finally diagnoses static_cast to ambiguous or implicit bases and fixes two long-standing fixmes in the test case. For the C-style cast, this requires propagating the access check suppression pretty deep into other functions.
- Pass the expressions for TryStaticCast and TryStaticImplicitCast by reference. This should lead to a better AST being emitted for such casts, and also fixes a memory leak, because CheckReferenceInit and PerformImplicitConversion wrap the node passed to them. These wrappers were previously lost.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88809 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 21:15:49 +00:00
Eli Friedman 3e42ffd3a8 PR5462: Don't run off the edge of the argument array for vararg handling
when there are more parameters in the prototype than arguments to the call.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88759 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 04:43:10 +00:00
Eli Friedman 49e2b8e2e5 Fix for PR5489: don't skip the complete type requrirement for variable
definitions just because the type happens to be an array type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88752 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 03:40:14 +00:00
Douglas Gregor 19aeac6ea4 When type-checking a static cast (or the static_cast part of a C-style
cast) that is converting to a class type, enumerate its constructors
as in any other direct initialization. This ensures that we get the
proper conversion sequence.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88751 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 03:27:21 +00:00
Anders Carlsson 0ba63ea5be Diagnose ambiguity of operator delete and operator delete[]. Sebastian, please review.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88747 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 03:17:38 +00:00
Douglas Gregor 66724ea67d If we attempt to add a constructor template specialization that looks
like a copy constructor to the overload set, just ignore it. This
ensures that we don't try to use such a constructor as a copy
constructor *without* triggering diagnostics at the point of
declaration.

Note that we *do* diagnose such copy constructors when explicitly
written by the user (e.g., as an explicit specialization).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88733 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 01:20:54 +00:00
Douglas Gregor fd47648b5d Revert r88718, which does NOT solve the constructor-template-as-copy-constructor issue. Big thanks to John for finding this
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88724 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 23:59:09 +00:00
Douglas Gregor 15755cb839 Template argument deduction of a non-type template parameter from a
template argument.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88722 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 23:45:44 +00:00
Douglas Gregor cad84b7c12 A constructor template cannot be instantiated to a copy
constructor. Make sure that such declarations can never be formed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88718 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 23:14:53 +00:00
Anders Carlsson 8db68da430 Clear temporaries in more places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88687 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 20:11:49 +00:00
Anders Carlsson f8a9a797a4 Fix bug Doug noticed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88679 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 19:21:49 +00:00
Douglas Gregor 79b680ea86 When performing copy initialization (= "implicit conversion", here) to
a class type from itself or a derived class thereof, enumerate
constructors and permit user-defined conversions to the arguments of
those constructors. This fixes the wacky implicit conversion sequence
used in std::auto_ptr's lame emulation of move semantics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88670 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 18:44:21 +00:00
Douglas Gregor afe7ec28b1 When transforming an expression statement (e.g., for template
instantiation), be sure to finish the expression statement by
providing a FullExprArg, making sure that temporaries get
destroyed. Fixes an obscure failure when parsing
llvm/LinkAllPasses.h.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88668 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 18:34:26 +00:00
Anders Carlsson 4b3cbeaea6 Don't bind arguments to temporaries if the argument has a reference type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88662 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 17:04:35 +00:00
Daniel Dunbar 3a2838d142 Rework Sema code completion interface.
- Provide Sema in callbacks, instead of requiring it in constructor. This
   eliminates the need for a factory function. Clients now just pass the object
   to consume the results in directly.

 - CodeCompleteConsumer is cheap to construct, so building it whenever we are
   doing code completion is reasonable.

Doug, please review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 08:58:20 +00:00
Anders Carlsson 03d8ed439f Fix two bugs with temporaries:
1. For 

A f() {
	return A();
}

we were incorrectly calling the A destructor on the returned object.

2. For

void f(A);
void g() {
	A a;
	f(a);
}

we were incorrectly not calling the copy constructor.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87082 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 04:34:45 +00:00
Daniel Dunbar ad5757f798 Spell empty StringRef correctly (0 is a null StringRef, which is not the same).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87011 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 18:40:12 +00:00
Douglas Gregor caddba07f8 Recognize (and check) pointer-to-member template arguments that are
non-type template parameters or constants of pointer-to-member
type. Once checked, be sure to retain those pointer-to-member
constants as expressions if they are dependent, or as declarations if
they are not dependent.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87010 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 18:38:13 +00:00
Douglas Gregor 231edff790 When instantiating a reference to a non-type template parameter of pointer to
member type (e.g., T Class::*Member), build a pointer-to-member
constant expression. Previously, we we just building a simple
declaration reference expression, which meant that the expression was
not treated as a pointer to member.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 17:40:13 +00:00
Anders Carlsson 95c5d8ac29 Set CK_BaseToDerived in TryStaticDowncast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86996 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 16:53:16 +00:00
Douglas Gregor cffecd08f1 Give CanQual<T> an implicit conversion to bool, so that it can be used
in "if" statements like:

  if (CanQual<ReferenceType> RefType = T.getAs<ReferenceType>())

Thanks to Clang for pointing out this mistake :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86995 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 16:49:45 +00:00
Douglas Gregor fb898e17cf When comparing template parameter lists, distinguish between three cases:
- Comparing template parameter lists to determine if we have a redeclaration
  - Comparing template parameter lists to determine if we have equivalent
    template template parameters
  - Comparing template parameter lists to determine whether a template 
    template argument is valid for a given template template parameter.

Previously, we did not distinguish between the last two cases, which
got us into trouble when we were looking for exact type matches
between the types of non-type template parameters that were dependent
types. Now we do, so we properly delay checking of template template
arguments until instantiation time.

Also, fix an accidental fall-through in a case statement that was
causing crashes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86992 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 16:20:59 +00:00
Douglas Gregor 00b98c229e Improve source-location information for implicitly-generated member call expressions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86989 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 15:31:47 +00:00
John McCall af8e6ed61b Random const correctness, and incidentally use computeDeclContext when building
a using declaration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86942 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 03:15:40 +00:00
John McCall a29e6b87bd Note to self: don't leave debugging statements in the code for four hours.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86931 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 02:10:34 +00:00
Douglas Gregor 8b13c08b1a Improve recovery in a wonky case where one tries to specialize a
template template parameter.

When building a template-id type, check whether the template-name
itself is dependent (even if the template arguments are not!) and
handle it as a template-id type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 00:46:20 +00:00
John McCall c8d8ac5f45 Add <foo> = [<bar> nextObject] to the -Widiomatic-parentheses category,
and give that category an explicit test.  Generalize the internal diagnostic
name.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86905 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 00:06:05 +00:00
Douglas Gregor db0d4b751e Template argument deduction for template template parameters. This
permits, among other things, ripping apart and reconstructing
templates via partial specialization:

  template<typename T> 
  struct DeepRemoveConst { typedef T type; };

  template<typename T>
  struct DeepRemoveConst<const T> {
    typedef typename DeepRemoveConst<T>::type type;
  };

  template<template<typename> class TT, typename T>
  struct DeepRemoveConst<TT<T> > {
    typedef TT<typename DeepRemoveConst<T>::type> type;
  };

Also, fix a longstanding thinko in the code handling partial ordering
of class template partial specializations. We were performing the
second deduction without clearing out the results of the first
deduction. It's amazing we got through so much code with such a
horrendous error :(



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86893 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 23:06:43 +00:00
John McCall 8406aedf47 Fix PR 5422: handle lvalue results when evaluating 'based' ptrtoints as part of
the -Wconversion check.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86891 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 22:52:37 +00:00
Fariborz Jahanian 7ca8b06948 writable atomic property's setter/getter must be in 'lock' step of
either both synthesized or bith user defined. 
Implements radar 6557233.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86887 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 22:40:11 +00:00
Douglas Gregor f35f828f98 Improve diagnostics when a default template argument does not match
with its corresponding template parameter. This can happen when we
performed some substitution into the default template argument and
what we had doesn't match any more, e.g.,

  template<int> struct A;
  template<typename T, template<T> class X = A> class B;

  B<long> b;

Previously, we'd emit a pretty but disembodied diagnostic showing how
the default argument didn't match the template parameter. The
diagnostic was good, but nothing tied it to the *use* of the default
argument in "B<long>". This commit fixes that.

Also, tweak the counting of active template instantiations to avoid
counting non-instantiation records, such as those we create for
(surprise!) checking default arguments, instantiating default
arguments, and performing substitutions as part of template argument
deduction.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86884 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 21:54:23 +00:00
Douglas Gregor d9e1530ef3 Move handling of template parameter packs out of the
template-type-parameter specific template argument checking code and
up to the template argument checking loop. In theory, this should make
variadic templates work better; in practice, they don't well enough
for us to care anyway (YET!), so this is mostly a re-organization to
simplify CheckTemplateArgument.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86868 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 19:41:09 +00:00
Douglas Gregor e7526419a6 Refactoring of template-argument checking code to reduce nesting,
increase sanity. No intended functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86866 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 19:31:23 +00:00
Douglas Gregor 9148c3f582 Before checking a template template argument against its corresponding
template template parameter, substitute any prior template arguments
into the template template parameter. This, for example, allows us to
properly check the template template argument for a class such as:

  template<typename T, template<T Value> class X> struct Foo;

The actual implementation of this feature was trivial; most of the
change is dedicated to giving decent diagnostics when this
substitution goes horribly wrong. We now get a note like:

  note: while substituting prior template arguments into template
      template parameter 'X' [with T = float]

As part of this change, enabled some very pedantic checking when
comparing template template parameter lists, which shook out a bug in
our overly-eager checking of default arguments of template template
parameters. We now perform only minimal checking of such default
arguments when they are initially parsed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86864 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 19:13:48 +00:00
Douglas Gregor 9106ef78f8 Instantiation of template template parameters for nested templates, e.g.,
template<typename T>
  struct X {
    template<template<T Value> class Y> struct Inner;
  };



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86844 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 16:58:32 +00:00
John McCall 09b6d0e793 Preserve source locations when building offsetof expressions featuring
anonymous members.  Partial fix for PR 5390.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 03:23:23 +00:00
John McCall a52ef08b26 Apparently the following idiom is specifically encouraged:
if (self = [super init])
Recognize it and only warn if -Wparentheses is explicitly enabled.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86790 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 02:41:58 +00:00
Douglas Gregor 788cd06cf8 Introduce a new representation for template template
parameters. Rather than storing them as either declarations (for the
non-dependent case) or expressions (for the dependent case), we now
(always) store them as TemplateNames. 

The primary change here is to add a new kind of TemplateArgument,
which stores a TemplateName. However, making that change ripples to
every switch on a TemplateArgument's kind, also affecting
TemplateArgumentLocInfo/TemplateArgumentLoc, default template
arguments for template template parameters, type-checking of template
template arguments, etc.

This change is light on testing. It should fix several pre-existing
problems with template template parameters, such as:
  - the inability to use dependent template names as template template
  arguments
  - template template parameter default arguments cannot be
  instantiation

However, there are enough pieces missing that more implementation is
required before we can adequately test template template parameters. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86777 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 01:00:40 +00:00
John McCall f7f3d0db75 Create a new Scope when parsing a declaration with a C++ scope specifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86764 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 00:21:18 +00:00
Fariborz Jahanian b03bfa55d0 Diagnose illegally typed operator new/new[].
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86755 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 23:47:18 +00:00
Douglas Gregor 314b97f8c5 Improve parsing of template arguments to lay the foundation for
handling template template parameters properly. This refactoring:

  - Parses template template arguments as id-expressions, representing
    the result of the parse as a template name (Action::TemplateTy)
    rather than as an expression (lame!).

  - Represents all parsed template arguments via a new parser-specific
    type, ParsedTemplateArgument, which stores the kind of template
    argument (type, non-type, template) along with all of the source
    information about the template argument. This replaces an ad hoc
    set of 3 vectors (one for a void*, which was either a type or an
    expression; one for a bit telling whether the first was a type or
    an expression; and one for a single source location pointing at
    the template argument).

  - Moves TemplateIdAnnotation into the new Parse/Template.h. It never
    belonged in the Basic library anyway.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86708 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 19:49:08 +00:00
Fariborz Jahanian 4770a4a3d4 Changed a variable name to match what it represents
(Ted's feedback).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 19:31:09 +00:00
John McCall d9f01d47db Fix a similar problem with qualified lookup through using directives,
although in this case we probably just run a risk of duplicating work;
I can't think of how this could cause a bug.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86680 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 09:25:37 +00:00
John McCall 12ea5780e7 Make a somewhat more convincing test case for unqualified lookup through
using directives, and fix a bug thereby exposed:  since we're playing
tricks with pointers, we need to make certain we're always using the same 
pointers for things.
Also tweak an existing error message.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86679 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 09:20:04 +00:00
John McCall d7be78a052 Fix unqualified lookup through using directives.
This is a pretty minimal test case;  I'll make a better one later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86669 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 07:01:13 +00:00
Anders Carlsson b76cd3d0c1 When trying to assign a regular string literal to an Objective-C 'id' type or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example:
@class NSString;

@interface Test
+ (void)test:(NSString *)string;
@end

void g(NSString *a);

void f() {
  NSString *a = "Foo";
  g("Foo");
  [Test test:"Foo"];
}

will produce

t.m:10:17: warning: incompatible pointer types initializing 'char [4]', expected 'NSString *'
  NSString *a = "Foo";
                ^~~~~
                @
t.m:11:5: warning: incompatible pointer types passing 'char [4]', expected 'NSString *'
  g("Foo");
    ^~~~~
    @
t.m:12:14: warning: incompatible pointer types sending 'char [4]', expected 'NSString *'
  [Test test:"Foo"];
             ^~~~~
             @
3 diagnostics generated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86665 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 04:46:30 +00:00
Anders Carlsson 4881b99bc8 Use PP.getLocForEndOfToken as suggested by John.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 03:32:44 +00:00
Anders Carlsson ad26b7376b If a function with a default argument is redefined and the new function also has a defualt argument then add a fixit hint that removes the default argument. Fixes PR5444.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86659 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 03:24:44 +00:00
Fariborz Jahanian d288bafe2d Further change in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86599 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 22:28:08 +00:00
Fariborz Jahanian 9aea0ce248 Removed a FIXME on nested type specifier warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 22:25:11 +00:00
Fariborz Jahanian 3451e9282a Changed error for nested type qualifier mismatch to
warning, to match gcc. It used to be warning, so
better keep it a warning (it broke a certain project).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86597 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 22:16:37 +00:00
Douglas Gregor 89c49f09b0 Make sure that Type::getAs<ArrayType>() (or Type::getAs<subclass of
ArrayType>()) does not instantiate. Update all callers that used this
unsafe feature to use the appropriate ASTContext::getAs*ArrayType method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86596 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 22:08:55 +00:00
Douglas Gregor ff4393c1ce Make sure that we look into nested, transparent declaration contexts
when looking for a name within a given DeclContext. Now enumerators
will show up in code-completion results.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86591 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 21:35:27 +00:00
Fariborz Jahanian d411b3f746 For array pointee type, get its cvr qualifier from
its element type. Fixes pr5432.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86587 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 21:02:05 +00:00
Benjamin Kramer 3f17a37357 Fix build after r86579.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 20:14:44 +00:00
Douglas Gregor d47c47d65e Make sure that we instantiate default function arguments for an
overloaded operator(). 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86581 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 19:27:57 +00:00
Eli Friedman 80c30dad6c Add additional note to mark the cause of synthesized constructors. Mark
declaration invalid if the constructor can't be properly built.  Addresses
remaining review comments from Fariborz for r86500.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86579 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 19:20:36 +00:00
Douglas Gregor 0f8716b7bb Improve instantiation of default template arguments for nested
templates. The instantiation of these default arguments must be (and
now, is) delayed until the template argument is actually used, at
which point we substitute all levels of template arguments
concurrently.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86578 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 19:17:50 +00:00
Eli Friedman 8f4c59e912 Add support for cdecl attribute. (As far as I know, it doesn't affect CodeGen
unless we start implementing command-line switches which override the default
calling convention, so the effect is mostly to silence unknown attribute
warnings.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86571 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 18:38:53 +00:00
Douglas Gregor e48319a8a9 When transforming an InitListExpr, if we already computed a non-dependent type for the InitListExpr, keep it
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 17:16:50 +00:00
Eli Friedman bb4a33cdf6 Add hack to make the given testcase work. As far as I can tell, this change is
reasonably safe, but it doesn't seem like the right solution.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86508 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 03:59:26 +00:00
Eli Friedman f8db4771d4 Remove a useless variable that got left behind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 01:11:03 +00:00
Eli Friedman 49c16da71b Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors.  This has a number of benefits:

1. Less code.

2. Explicit and implicit constructors get the same diagnostics.

3. The AST explicitly contains constructor calls from implicit default
constructors.  This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 01:05:47 +00:00
Eli Friedman a8ce9ecae8 Fix use-after-free bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86485 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 22:15:39 +00:00
Sebastian Redl a29e51bb98 Special-case default argument expression in instantiation. This should fix PR4301. Doug, please double-check my assumptions. Read the PR for more details.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86465 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 13:56:19 +00:00
Sebastian Redl 9770ef0eea When checking the namespace of a redeclaration or definition, look through linkage specs. Fixes PR5430.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86461 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 11:36:54 +00:00
Sebastian Redl 42dddbeadb Don't reprocess non-dependent initializers of non-dependent VarDecls. Fixes PR5426.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86460 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 10:16:43 +00:00
Sean Hunt c9132b697c Test commit - minor terminology change to my recent patch suggested by John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86442 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 07:46:34 +00:00
Douglas Gregor 3eaa9ffa17 Always make sure we're using an unqualified type when building a
constructor name.  Fixes PR5418.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86441 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 07:12:55 +00:00
Fariborz Jahanian 36a862f1d6 Patch to gives an error that at least points users in the direction of the error, rather
than an error about incompatible types. Patch by Sean Hunt.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86402 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 20:20:40 +00:00
Douglas Gregor 3734c21b60 Cope with calls to operator() templates. Fixes PR5419.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86387 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 17:23:56 +00:00
John McCall dc767a1f56 Support -Wshorten-64-to-32 for integer types only, which seems to satisfy the
core requirements.  Fixes rdar://problem/6389954



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86364 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 09:03:53 +00:00
John McCall e8babd198c Improve -Wconversion by permitting binary operations on values of the target
type (or smaller) to stay "closed" within the type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86356 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 08:15:46 +00:00
Anders Carlsson f7613d5361 Don't treat variables with non-trivial ctors or dtors as unused. Fixes PR5407.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86352 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 07:26:56 +00:00
Anders Carlsson 99a000e3ca Cleanup, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86351 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 07:18:14 +00:00
Anders Carlsson d8fe2d56fb When instantiating a field decl, make sure to clone its attributes. With this change FileCheck no longer crashes when it's run without any arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86344 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 06:07:58 +00:00
John McCall 680523a91d Implement -Wconversion. Off by default, in the non-gcc group. There's
significant work left to be done to reduce the false-positive rate here.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86326 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 03:30:10 +00:00
Steve Naroff c4df6d2c05 Add basic code completion support for ObjC messages.
Still a work in progress...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86323 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 02:08:14 +00:00
Eli Friedman 88fad6310d Make sure isCopyAssignment is only true for actual copy assignment operators,
instead of all assignment operators.  The mistake messes up IRGen because
it ends up assuming that the assignment operator is actually the implicit
copy assignment operator, and therefore tries to emit the RHS as an lvalue.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 00:02:45 +00:00
Douglas Gregor 0c8296dfb4 Various improvements to Clang's code-completion infrastructure:
- Introduce more code-completion string "chunk" kinds that describe
  symbols, the actual text that the user is expected to type, etc.
  - Make the generation of macro results optional, since it can be
  slow
  - Make code-completion accessible through the C API, marshalling the
  code-completion results through a temporary file (ick) to maintain
  process separation.

The last doesn't have tests yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86306 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 00:00:49 +00:00
Fariborz Jahanian d669be595a Since default writable attribute is 'assign', allow
specification of 'assign' (no warning to be issued),
when a continuation class makes a 'readonly' attribute
'readwrite' but also specifies the 'assign' attribute.
(this matches gcc's behavior and prevents exessive 
 warnings)/


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86297 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 22:59:12 +00:00
John McCall 7d62a8f81f Don't warn -Wsign-compare if we're in an unevaluated context, and fixed
a typo pointed out by Fariborz.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 18:16:06 +00:00
John McCall 48f5e63aec compare.c also needs a target triple now, and improve some comments while we're
at it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86243 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 08:53:51 +00:00
John McCall 5dbad3d46c Improve the -Wsign-compare heuristics:
* If the unsigned type is smaller than the signed type, never warn, because
    its value will not change when zero-extended to the larger type.
  * If we're testing for (in)equality, and the unsigned value is an integer
    constant whose sign bit is not set, never warn, because even though the
    signed value might change, it can't affect the result of the equality.

Also make the comparison test cases much more rigorous, and have them expose
the subtle differences between C and C++ here.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86242 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 08:49:08 +00:00
Douglas Gregor 3f0b5fd3a5 Rework the fix-it hint for code like
get_origin->x

where get_origin is actually a function and the user has forgotten the
parentheses. Instead of giving a lame note for the fix-it, give a
full-fledge error, early, then build the call expression to try to
recover. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86238 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 06:30:47 +00:00
Douglas Gregor b653c52d91 If we have a C-style cast, functional cast, or a static_cast to a
class type, don't perform the array-to-pointer or function-to-pointer
conversions, because we may end up binding a reference to a function
or array.

With this change, FileCheck now passes -fsyntax-only!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86211 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 01:14:41 +00:00
Douglas Gregor b7a86f5c5f When we encounter a derived-to-base conversion when performing an
implicit conversion sequence, check the validity of this conversion
and then perform it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 01:02:41 +00:00
Fariborz Jahanian 4c0cea2d9e Minor cleanup of my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86209 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 00:55:14 +00:00
Fariborz Jahanian 966256afd4 This patch implements Sema for clause 13.3.3.1p4.
It has to do with vararg constructors used as conversion
functions. Code gen needs work. This is WIP.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86207 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 00:23:08 +00:00
Douglas Gregor 4912c347ce Make sure that EnumConstantDecls always get a type, even when they have type-dependent initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86197 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 00:03:12 +00:00
Sebastian Redl 732429cfb1 The signed/unsigned checker should not warn for value-dependent expressions, and should especially not try to evaluate them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86173 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 21:09:23 +00:00
Douglas Gregor c7621a6471 Be a little more careful when trying to extract a TypeDecl from a enum/class/struct/union specifier; in invalid code, we may also see ClassTemplateDecls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86171 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 20:54:04 +00:00
Sebastian Redl 6e82475568 Don't allow definitions of array variables without some size information in C++. Fixed PR5401
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86165 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 19:47:47 +00:00
Douglas Gregor 9c4b838782 Eliminate some false positives due to a thinko in the "'blah' is
always zero in this context" warning logic. Also, make the diagnostic
itself more precise when referring to pointer values ("NULL" vs. "zero").


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86143 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 17:49:26 +00:00
Sebastian Redl a65b55142b When collecting types for built-in candidates, make arrays decay to pointers. Otherwise, subscripting an array leads to no candidates at all. Fixes PR5360.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86140 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 16:36:20 +00:00
Sebastian Redl 923d56d436 Allow the element type of arrays to be incomplete in C++.
This fixes PR5048. Also fix a bug where zero-sized arrays weren't warned about when the size was unsigned.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86136 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 15:52:31 +00:00
Douglas Gregor 393896f49d Fixed two places where we needed to force completion of a type
(without complaining if it fails) to get proper semantics: reference
binding with a derived-to-base conversion and the enumeration of
constructors for user-defined conversions. There are probably more
cases to fix, but my prior attempt at statically ensuring that
complete-type checking always happens failed. Perhaps I'll try again.

With this change, Clang can parse include/llvm/*.h!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86129 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 13:06:35 +00:00
John McCall b13c87f0c9 Implement the conditional-operator part of -Wsign-compare. Turn
DiagnoseSignCompare into Sema::CheckSignCompare and call it from more places.

Add some enumerator tests.  These seem to expose some oddities in the
types we're converting C++ enumerators to;  in particular, they're converting
to unsigned before int, which seems to contradict 4.5 [conv.prom] p2.

Note to self: stop baiting Doug in my commit messages.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86128 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 09:23:39 +00:00
Douglas Gregor 6ca7cfb3fb When instantiating a UnaryOperator, allow the resulting expression to
still be dependent or invoke an overloaded operator. Previously, we
only supported builtin operators.

BinaryOperator/CompoundAssignOperator didn't have this issue because
we always built a CXXOperatorCallExpr node, even when name lookup
didn't find any functions to save until instantiation time. Now, that
code builds a BinaryOperator or CompoundAssignOperator rather than a
CXXOperatorCallExpr, to save some space.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86087 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 00:51:44 +00:00
John McCall 45aa4557fe Implement -Wsign-compare, or at least the actual comparison part of it.
Conditional operands are next.

Fixes part of rdar://problem/7289584.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86083 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 00:40:04 +00:00
Douglas Gregor b1c2ea5ddd Make sure to grab CVR qualifiers from the canonical type. ARGH!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86079 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 00:07:36 +00:00
Douglas Gregor 8a4386b363 When instantiating a MemberExpr, be sure to instantiate the
explicitly-specified template arguments, too!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86066 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 23:20:05 +00:00
John McCall 6aee621291 Comments, formatting. Based on patch by Brandon Pearcy!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86065 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 23:13:52 +00:00
John McCall b41900410f Diagnose using a field to initialize itself. Patch by Brandon Pearcy!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86061 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 23:02:40 +00:00
Douglas Gregor 43d8863df9 When starting a C++ member access expression, make sure to compute the
type of the object even when it is dependent. Specifically, this makes
sure that we get the right type for "this->", which is important when
performing name lookup into this scope to determine whether an
identifier or operator-function-id is a template name.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86060 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 22:49:18 +00:00
Douglas Gregor ff5243981e Fix a little canonical-types issue with non-type template arguments.
Fixes PR5349. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86052 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 21:50:46 +00:00
Douglas Gregor 1fe6b919f7 Don't try to check the initialization of fields with dependent
types. Fixes PR5352.

Fariborz, please review.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86031 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 17:16:11 +00:00
Douglas Gregor 87c12c4a46 Store the unresolved class type in MemberPointerType's Class field,
from Peter Collingbourne!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86030 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 16:49:01 +00:00
Douglas Gregor 12c118a8ff Switch parsing of using declarations over to ParseUnqualifiedId.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 16:30:06 +00:00
John McCall 5ab7517205 Preserve type source information in sizeof/alignof expressions, and pass it
through to indexing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86018 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 07:28:41 +00:00
Douglas Gregor c86a6e9881 When performing template instantiation (transformation) of
expressions, keep track of whether we are immediately taking the
address of the expression. Pass this flag when building a declaration
name expression so that we handle pointer-to-member constants
properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86017 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 07:01:15 +00:00
John McCall 9112b93829 Diagnose the use of 'fastcall' on functions without prototypes or with
varargs prototypes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86001 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 03:36:09 +00:00
John McCall d00f200f64 Diagnose __builtin_offsetof on incomplete types. Fixes
rdar://problem/7222956



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85999 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 03:03:43 +00:00
John McCall 54abf7d4fa Change our basic strategy for avoiding deprecation warnings when the decl use
appears in a deprecated context.  In the new strategy, we emit the warnings
as usual unless we're currently parsing a declaration, where "declaration" is
restricted to mean a decl group or a few special cases in Objective C.  If
we *are* parsing a declaration, we queue up the deprecation warnings until
the declaration has been completely parsed, and then emit them only if the
decl is not deprecated.
We also standardize the bookkeeping for deprecation so as to avoid special cases.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85998 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 02:18:39 +00:00
Douglas Gregor ca1bdd7c26 Implement support for parsing dependent template-ids that refer to
overloaded operators, e.g.,

  p->template operator+<T>()




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85989 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 00:56:37 +00:00
Mike Stump df317bf716 Refine volatile handling, specifically, we must have the canonical
type to look at the volatile specifier.  I found these all from just
hand auditing the code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85967 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 23:25:48 +00:00
Douglas Gregor 014e88d94f Parsing and semantic analysis for template-ids that name overloaded
operators, e.g., 

  operator+<int>

which now works in declarators, id-expressions, and member access
expressions. This commit only implements the non-dependent case, where
we can resolve the template-id to an actual declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85966 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 23:16:33 +00:00
Mike Stump fbf6870f59 We have to ensure we have the canonical type to do this. This is but
one instance of a large problem.  assert for non-canoical types would
help track down these things.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85956 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 22:20:01 +00:00
Fariborz Jahanian 6f26920dfa Remove previous patch for pr5296 due to further clarification
of value-initialization and trivial constructors.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85935 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 20:38:53 +00:00
Douglas Gregor 2d1c214141 Replace the code that parses member access expressions after "." or
"->" with a use of ParseUnqualifiedId. Collapse
ActOnMemberReferenceExpr, ActOnDestructorReferenceExpr (both of them),
ActOnOverloadedOperatorReferenceExpr,
ActOnConversionOperatorReferenceExpr, and
ActOnMemberTemplateIdReferenceExpr into a single, new action
ActOnMemberAccessExpr that does the same thing more cleanly (and can
keep more source-location information).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85930 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 19:44:04 +00:00
Douglas Gregor 02a24ee67c Use ParseUnqualifiedId when parsing id-expressions. This eliminates
yet another copy of the unqualified-id parsing code.

Also, use UnqualifiedId to simplify the Action interface for building
id-expressions. ActOnIdentifierExpr, ActOnCXXOperatorFunctionIdExpr,
ActOnCXXConversionFunctionExpr, and ActOnTemplateIdExpr have all been
removed in favor of the new ActOnIdExpression action.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85904 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 16:56:39 +00:00
Douglas Gregor 3f9a0566e6 Introduce a new class, UnqualifiedId, that provides a parsed
representation of a C++ unqualified-id, along with a single parsing
function (Parser::ParseUnqualifiedId) that will parse all of the
various forms of unqualified-id in C++.

Replace the representation of the declarator name in Declarator with
the new UnqualifiedId class, simplifying declarator-id parsing
considerably and providing more source-location information to
Sema. In the future, I hope to migrate all of the other
unqualified-id-parsing code over to this single representation, then
begin to merge actions that are currently only different because we
didn't have a unqualified notion of the name in the parser.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85851 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 01:35:08 +00:00
Fariborz Jahanian cc667e2bd2 Assortment of property attributes declared in continuation
class must match those of same property declared
in its primary class. (Fixes radar 7352425)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85843 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 00:01:38 +00:00
Fariborz Jahanian a6f14e1a7e Property declared in continuation class can only be used to
change a readonly property declared in the class (and its inherited protocols)
to writable property. (Fixes radar 7350645).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85836 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 22:45:15 +00:00
Fariborz Jahanian 3684bd4c95 Diagnose implementation of a property declared in a category
in its class implementation instead of crashing. Fixes radar 7350345.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85813 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 18:45:36 +00:00
Douglas Gregor cf3293eaeb When determining whether a reference to a static data member is an
integral constant expression, make sure to find where the initializer
was provided---inside or outside the class definition---since that can
affect whether we have an integral constant expression (and, we need
to see the initializer itself).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85741 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 20:32:48 +00:00
Douglas Gregor 7a34314290 Within a template, qualified name lookup can refer to a non-dependent type
that is not known to be a base class at template definition time due
to some dependent base class. Treat qualified name lookup that refers
to a non-static data member or function as implicit class member
access when the "this" type would be dependent.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85718 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 17:08:18 +00:00
Douglas Gregor 550d9b28fd Implement "incremental" template instantiation for non-type template
parameters and template type parameters, which occurs when
substituting into the declarations of member templates inside class
templates. This eliminates errors about our inability to "reduce
non-type template parameter depth", fixing PR5311.

Also fixes a bug when instantiating a template type parameter
declaration in a member template, where we weren't properly reducing
the template parameter's depth.

LLVM's StringSwitch header now parses.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85669 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-31 17:21:17 +00:00
Douglas Gregor 259571e27e When a friend is declared in a dependent context, don't even try to
match it up with a declaration in the outer scope.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85628 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 22:42:42 +00:00
Douglas Gregor e8c01bdb56 Instantiate class template friends better; fixes PR5332.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85612 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 21:07:27 +00:00
Douglas Gregor 3f7c7f4865 Include macros in code-completion results
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85594 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 16:50:04 +00:00
Chris Lattner 9e6b37a9f1 warn about returning the address of a label.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85576 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 04:01:58 +00:00
Anders Carlsson 1a31a18db9 Add a CK_DerivedToBaseMemberPointer cast kind and use it in Sema (Still no codegen).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85552 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 00:46:35 +00:00
John McCall ac406052f7 Include pointee type information in the diagnostic for creating bad pointers or
arrays.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 00:37:20 +00:00
John McCall 85737a71fe Report accurate source-location information when rebuilding types during
template instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85545 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 00:06:24 +00:00
Douglas Gregor 2685eab9d3 We may need to instantiate a class template specialization as part of a derived-to-base pointer case
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85532 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 23:08:22 +00:00
Douglas Gregor fbf2c945f8 Slightly improve source-location information during template instantiation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85529 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 22:21:39 +00:00
Sebastian Redl f322ed6d39 Properly instantiate usage of overloaded operator []. Fixes PR5345.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85524 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 20:17:01 +00:00
John McCall 828bff2079 A few TemplateArgumentLoc clean-ups. Try to remember the Expr for a declaration.
Provide an API for getting the SourceRange of a TAL and use it judiciously.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85520 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 18:45:58 +00:00
Douglas Gregor fd2300e1ee Yet more instantiation-location information. Fixes PR5336.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85516 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 17:56:10 +00:00
Anders Carlsson 0ebb6d391d Make sure to call CompleteConstructorCall for bases and members that are initialized implicitly in constructors so that default arguments etc are set correctly. Fixes PR5283.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 15:46:07 +00:00
John McCall 833ca991c1 Track source information for template arguments and template specialization
types.  Preserve it through template instantiation.  Preserve it through PCH,
although TSTs themselves aren't serializable, so that's pretty much meaningless.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 08:12:44 +00:00
Douglas Gregor ed9c0f90b7 Implement support for semantic checking and template instantiation of
class template partial specializations of member templates. Also,
fixes a silly little bug in the marking of "used" template parameters
in member templates. Fixes PR5236.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85447 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 00:04:11 +00:00
Fariborz Jahanian 680a3f3581 Use array's base element type in getting to its
constructor. WIP.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85420 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 19:04:36 +00:00
Fariborz Jahanian c0fcce4614 Removed an unnecessary arguement passed to InitializeVarWithConstructor
which should come from the variable and wasn't correct for arrays in any case.
No change in functionality.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 18:41:06 +00:00
Fariborz Jahanian 5de245058d Diagnose use of data pointer member in a function call
expression instead of crashing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85401 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 16:49:46 +00:00
Douglas Gregor 5557b25bdb Slightly improve source location information during template instantiation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85353 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 00:29:27 +00:00
Fariborz Jahanian db07b3f7cd Type of a conditional expression with two distinct objective-c
class pointer is the most derived common class of the two.
This is <rdar://problem/7334235>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85337 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 23:02:38 +00:00
Douglas Gregor 7ced9c8529 Introduce FunctionDecl::isInlined() to tell whether a function should
be inlined.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 21:11:48 +00:00
Douglas Gregor 0130f3cc4c Rename FunctionDecl::isInline/setInline to
FunctionDecl::isInlineSpecified/setInlineSpecified.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85305 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 21:01:01 +00:00
Douglas Gregor 3b846b6c25 Explicit instantiation suppresses the instantiation of non-inline
function template specializations and member functions of class
template specializations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85300 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 20:53:28 +00:00
Douglas Gregor 0d03514da0 An explicit instantiation definition only instantiations those class
members that have a definition. Also, use
CheckSpecializationInstantiationRedecl as part of this instantiation
to make sure that we diagnose the various kinds of problems that can
occur with explicit instantiations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85270 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 18:42:08 +00:00
Fariborz Jahanian 6c813e1cb7 Generate constructor for value-initialization cases, even if the
implementation technique doesn't call the constructor at that point.
DR302. Fixes pr5296.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85249 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 16:51:19 +00:00
Sebastian Redl aee3c9375f Implement Chris's suggestions for the precendence warnings. Reformat the code a bit. Test the fixits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 12:10:02 +00:00
Douglas Gregor 972e6ce33c Only set the point of instantiation for an implicit or explicit
instantiation once we have committed to performing the
instantiation. As part of this, make our makeshift
template-instantiation location information suck slightly less.

Fixes PR5264.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85209 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 06:26:26 +00:00
Mike Stump cf57d61525 Almost missed this one... Doc update for last change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 02:07:23 +00:00
Mike Stump 1d7e767dc8 Refine noreturn handling. Fixes -Wmissing-noreturn so that it doesn't
complain that functions that have a return statement should be
declared noreturn.  Fixed PR5286.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85195 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 01:59:05 +00:00
Ted Kremenek 7762291803 Use a pred_iterator instead of a succ_iterator (wrong typedef).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 01:07:53 +00:00
Fariborz Jahanian ef78ac6013 Add 'fixit' hint on mis-use of pointer-to-member
binary operators.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85153 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 20:45:27 +00:00
Sebastian Redl 6b169accbb Add fixit hint to bitwise precedence warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85129 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 17:01:32 +00:00
Sebastian Redl 9e1d29bb36 Implement a warning for mixing bitwise logical with comparison ops. Fixes PR5297.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85117 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 15:24:15 +00:00
Chris Lattner 7a128e8400 Fix PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
declared noreturn.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85075 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:43:07 +00:00
Chris Lattner 523382640e Implement rdar://6756623 - use of deprecated type in deprecated typedef should not warn
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85073 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:31:57 +00:00
Sebastian Redl 38fd4d0011 Make sure we actually have a definition before asking if it is implicit. Fixes PR4674.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:31:45 +00:00
Chris Lattner d451f836be When parsing a top level struct declaration, make sure to
process decl attributes instead of dropping them on the floor.
This allows us to diagnose cases like the testcase.  Also don't
diagnose deprecated stuff in ActOnTag: not all uses of tags
may be 'uses', and SemaType does this now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:21:57 +00:00
Chris Lattner a64ef0ab5c move calls to DiagnoseUseOfDecl (which warns about deprecated/unavailable
types) out of Sema::getTypeName into ConvertDeclSpecToType.  getTypeName
is sometimes used as a predicate in the parser, so it could cause redundant
diags to be emitted.  This is also needed by two upcoming enhancements.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:09:09 +00:00
Sebastian Redl 8ce35b095e Remove the Skip parameter from GetTypeForDeclarator and dependents. Take the opportunity to improve an error message and fix PR4498.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85068 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 21:45:37 +00:00
Chris Lattner 5a597a9d1c remove a nonsensical todo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85067 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 21:19:07 +00:00
Chris Lattner 311157fa6b move the extwarn about using long long out of the entry of
GetTypeForDeclarator and into the code that handles long long 
already.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85063 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 18:25:04 +00:00
Chris Lattner 5db2bb1cb0 simplify interface to ConvertDeclSpecToType, check for inferred
block return types only when a TST isn't specified, not every time
through GetTypeForDeclarator.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85062 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 18:21:37 +00:00
Chris Lattner 1564e3906c change ConvertDeclSpecToType to be a static function in SemaType.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85061 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 18:07:27 +00:00
Chris Lattner c7f1904474 change Sema::ActOnFriendTypeDecl to use GetTypeForDeclarator instead
of ConvertDeclSpecToType, which I'd like to keep private to SemaType.cpp.
We do this by cons'ing up a trivial Declarator for the type.

John, please review.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85060 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:47:27 +00:00
Chris Lattner 778ed741de various cleanups for SemaType.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85059 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:36:50 +00:00
Chris Lattner ffb9368015 minor reorg: check both attributes before decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85058 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:21:40 +00:00
Chris Lattner 10ca337b1e simplify Sema::getTypeName a bit: if control gets out of the switch,
IIDecl cannot be null.  There is no need to check for both C++ mode and
presence of CXXRecordDecl.  ObjC interfaces can't have ScopeSpecs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85057 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:16:46 +00:00
Chris Lattner b7c3fd7b49 In objc mode, every identifier in a cast expression was using doing a
type looking using getTypeName() and every property access was using
NextToken() to do lookahead to see if the identifier is followed by
a '.'.  Rearrange this code to not need lookahead and only do the
type lookup if we have "identifier." in the token stream.  Also
improve a diagnostic a bit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85056 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:04:48 +00:00
Sebastian Redl 9994a34f6c Audit the code for places where it is assumed that every base specifier refers to a RecordType. Add assertions or conditions as appropriate. This fixes another crash in the Apache stdlib vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85055 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:03:50 +00:00
Sebastian Redl bbc1cc5757 Ignore dependent bases in ADL. Fixes PR5271.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85054 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 09:35:33 +00:00
Nate Begeman 2207d79204 Add support for vector shifts, pretty straight forward.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85033 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 02:26:48 +00:00
John McCall ba6a9bd384 Preserve type source information in TypedefDecls. Preserve it across
template instantiation.  Preserve it through PCH.  Show it off to the indexer.

I'm healthily ignoring the vector type cases because we don't have a sensible
TypeLoc implementation for them anyway.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84994 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 08:00:42 +00:00
Douglas Gregor 3eefb1c4bd Fix overload resolution when calling a member template or taking the
address of a member template when explicit template arguments are
provided.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 04:59:53 +00:00
Douglas Gregor 33642df300 Implement template instantiation for non-type template
parameters. Fixes PR5103.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84979 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 23:25:44 +00:00
John McCall e27ec8ad56 Store the builtin types as CanQualTypes. Expand a bit on the CanQual API,
but also remove some methods that cause ambiguities, and generally
make CanQual<blah> more analogous to QualType.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 23:03:21 +00:00
Douglas Gregor 097bfb1175 Migrate Sema::ActOnCallExpr to Sema::FixOverloadedFunctionReference,
so that we maintain better source information after template argument
deduction and overloading resolves down to a specific
declaration. Found and dealt with a few more cases that 
FixOverloadedFunctionReference didn't cope with.

(Finally) added a test case that puts together this change with the
DeclRefExpr change to (optionally) include nested-name-specifiers and
explicit template argument lists.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84974 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 22:18:25 +00:00
John McCall 58e4677a94 Remove OriginalTypeParmDecl; the original type is the one specified
in the DeclaratorInfo, if one is present.

Preserve source information through template instantiation.  This is made
more complicated by the possibility that ParmVarDecls don't have DIs, which
is possibly worth fixing in the future.

Also preserve source information for function parameters in ObjC method
declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84971 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 21:48:59 +00:00
Fariborz Jahanian f071e9b173 Diagnose misuse of '.*' and '->*' operators during parse
instead of crashing in code gen.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84968 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 21:01:39 +00:00
Sebastian Redl 644be853b8 Apply the special enum restrictions from [over.match.oper]p3b2 in argument-dependent lookup too. This fixes PR5244.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84963 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 19:23:15 +00:00
Douglas Gregor a2813cec26 Eliminate QualifiedDeclRefExpr, which captured the notion of a
qualified reference to a declaration that is not a non-static data
member or non-static member function, e.g., 

  namespace N { int i; }
  int j = N::i;

Instead, extend DeclRefExpr to optionally store the qualifier. Most
clients won't see or care about the difference (since
QualifierDeclRefExpr inherited DeclRefExpr). However, this reduces the
number of top-level expression types that clients need to cope with,
brings the implementation of DeclRefExpr into line with MemberExpr,
and simplifies and unifies our handling of declaration references.

Extended DeclRefExpr to (optionally) store explicitly-specified
template arguments. This occurs when naming a declaration via a
template-id (which will be stored in a TemplateIdRefExpr) that,
following template argument deduction and (possibly) overload
resolution, is replaced with a DeclRefExpr that refers to a template
specialization but maintains the template arguments as written.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84962 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 18:54:35 +00:00
Fariborz Jahanian 7a1f4cc8d5 Fixed a code gen bug (by fixing the AST) involving user-defined
pointer-to-member type conversion follwed by a pointer-to-member
standard conversion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84955 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 18:08:22 +00:00
John McCall eee91c3efb Rebuild dependently-sized ext vectors if either the element type or the size
changed under the transform.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84953 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 17:55:45 +00:00
Benjamin Kramer 38caf910aa Silence GCC 4.3 warning.
TreeTransform.h:2333: warning: suggest parentheses around && within ||


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84949 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 10:48:09 +00:00
John McCall 07fb6bef62 Preserve type source information when substituting into FieldDecls.
Just r84734 now that some fundamental work has been completed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84914 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 23:33:21 +00:00
John McCall eb692e07c7 Preserve source information for anonymous struct/union declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 23:31:08 +00:00
John McCall 54e14c4db7 When building types from declarators, instead of building two types (one for
the DeclaratorInfo, one for semantic analysis), just build a single type whose
canonical type will reflect the semantic analysis (assuming the type is
well-formed, of course).

To make that work, make a few changes to the type system:
* allow the nominal pointee type of a reference type to be a (possibly sugared)
  reference type.  Also, preserve the original spelling of the reference type.
  Both of these can be ignored on canonical reference types.
* Remove ObjCProtocolListType and preserve the associated source information on
  the various ObjC TypeLocs.  Preserve the spelling of protocol lists except in
  the canonical form.
* Preserve some level of source type structure on parameter types, but
  canonicalize on the canonical function type.  This is still a WIP.

Drops code size, makes strides towards accurate source location representation,
slight (~1.7%) progression on Cocoa.h because of complexity drop.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84907 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 22:37:11 +00:00
John McCall 467b27b9a2 Canonicality is a property of qualified types, not unqualified types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84891 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 20:10:53 +00:00
Douglas Gregor 423a4e0c85 When replacing a template-id expression with a declaration reference expression after overloading completes, make sure to keep the qualifier. Still not ready with that test-case...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84880 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 18:02:20 +00:00
Douglas Gregor f17bb74e74 When building and instantiating a template-id reference expression, such as
N::f<int>

keep track of the full nested-name-specifier. This is mainly QoI and
relatively hard to test; will try to come up with a printing-based
test once we also retain the explicit template arguments past overload
resolution.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84869 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 17:20:55 +00:00
Sebastian Redl 5ed66f7091 Try to instantiate templates before doing hierarchy checks in static_cast. Fixes PR5261.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84860 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 15:07:22 +00:00
Douglas Gregor a9e29aa4b1 When a template-id expression refers to a member function template, turn it into an (implicit) member access expression. Fixes PR5220
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84848 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 07:19:14 +00:00
Douglas Gregor e961afbf3f Refactor our handling of implicit member reference expressions to get most of the logic out of BuildDeclarationNameExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 07:08:30 +00:00
Douglas Gregor 573d9c3252 Don't (directly) call RequireCompleteType with an invalid source location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 23:19:44 +00:00
Douglas Gregor 652371ad04 Don't generate pointer types for void or base classes when finding
conversion types for builtin overloaded operator candidates; I misread
this section in the standard the first time around.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84788 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 22:01:30 +00:00