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

163 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 4dfdd1b5eb Template instantiation for @try and @finally (but not @catch, yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102147 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 23:59:56 +00:00
Douglas Gregor c3203e7ee1 Template instantiation for the Objective-C "fast enumeration"
statement, i.e., 

  for (element in collection) {
    // do something
  }



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102138 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 23:10:45 +00:00
Douglas Gregor 8fdc13a78a Template instantiation for Objective-C++ @synchronized statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 22:01:21 +00:00
Douglas Gregor d1377b25a3 Implement template instantiation for Objective-C++ @throw statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 21:44:01 +00:00
Douglas Gregor ef57c61ec3 Some Objective-C++ types and expressions will never change during
template instantiation, since they cannot be dependent or have
dependent parts. Handle them the simple way.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102094 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 17:28:13 +00:00
Douglas Gregor f49bb082eb When a dependent Objective-C++ message send was able to resolve the
method being called at template definition time, retain that method
and pass it through to type-checking. We will not perform any lookup
for the method during template instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102081 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 17:01:48 +00:00
Douglas Gregor 39968adc66 Remove the SelectorLoc argument to Sema::BuildInstanceMesssage and
Sema::BuildClassMessage; we weren't using it, and template
instantiation was faking it anyway.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102074 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 16:50:51 +00:00
Douglas Gregor db93c4a8f8 Expand the one use of TransformPointerLikeType and eliminate this macro. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102073 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 16:46:21 +00:00
Douglas Gregor 92e986e0ad Implement template instantiation for Objective-C++ message sends. We
support dependent receivers for class and instance messages, along
with dependent message arguments (of course), and check as much as we
can at template definition time.

This commit also deals with a subtle aspect of template instantiation
in Objective-C++, where the type 'T *' can morph from a dependent
PointerType into a non-dependent ObjCObjectPointer type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102071 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 16:44:27 +00:00
Zhongxing Xu d8383d45e4 CXXNamedCastExpr is actually an abstract expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101994 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-21 06:32:25 +00:00
Douglas Gregor 81d3466d03 Keep proper source location information for the type in an Objective-C
@encode expression. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101907 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 15:39:42 +00:00
Douglas Gregor 16573fa970 Keep track of the actual storage specifier written on a variable or
function declaration, since it may end up being changed (e.g.,
"extern" can become "static" if a prior declaration was static). Patch
by Enea Zaffanella and Paolo Bolzoni.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101826 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 22:54:31 +00:00
Douglas Gregor 1eabb7d0c3 Improve diagnostics when an elaborated-type-specifer containing a
nested-name-specifier (e.g., "class T::foo") fails to find a tag
member in the scope nominated by the
nested-name-specifier. Previously, we gave a bland

  error: 'Nested' does not name a tag member in the specified scope

which didn't actually say where we were looking, which was rather
horrible when the nested-name-specifier was instantiated. Now, we give
something a bit better:

  error: no class named 'Nested' in 'NoDepBase<T>'




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100060 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 23:17:41 +00:00
Douglas Gregor 4033642464 Change the representation of dependent elaborated-type-specifiers
(such as "class T::foo") from an ElaboratedType of a TypenameType to a
DependentNameType, which more accurately models the underlying
concept.

Improve template instantiation for DependentNameType nodes that
represent nested-name-specifiers, by performing tag name lookup and
checking the resulting tag appropriately. Fixes PR5681.

There is still much testing and cleanup to do in this area.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100054 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 22:19:08 +00:00
Douglas Gregor 4a2023f501 Extend DependentNameType with a keyword enum that specifies whether
this was parsed as a typename-specifier, elaborated-type-specifier
(including the kind), or just a dependent qualified type name.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100039 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 20:19:30 +00:00
Chandler Carruth a3ce8ae361 Re-bind non-dependent CXXTemporaryObjectExpr nodes as temporaries when
instantiating a template, which ensures the destructor is called. This fixes
PR6671.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100029 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 18:34:58 +00:00
Douglas Gregor 4714c12a1a Rename TypenameType to DependentNameType in anticipation of some
refactoring work in this area.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100019 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 17:34:00 +00:00
John McCall 6bb8017bb9 Propagate the "found declaration" (i.e. the using declaration instead of
the underlying/instantiated decl) through a lot of API, including "intermediate"
MemberExprs required for (e.g.) template instantiation.  This is necessary
because of the access semantics of member accesses to using declarations:
only the base class *containing the using decl* need be accessible from the
naming class.

This allows us to complete an access-controlled selfhost, if there are no
recent regressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99936 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 21:47:33 +00:00
John McCall 069ace5adc Fix a self-host problem caused by this over-eager assertion. I'm not sure
there's a good equivalent that's actually true, unfortunately.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98253 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 09:33:17 +00:00
John McCall 21ef0fa27b Maintain type source information for functions through template
instantiation.  Based on a patch by Enea Zaffanella!  I found a way to
reduce some of the redundancy between TreeTransform's "standard"
FunctionProtoType transformation and TemplateInstantiator's override,
and I killed off the old SubstFunctionType by adding type source info
for the last cases where we were creating FunctionDecls without TSI
(at least that get passed through template instantiation).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98252 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 09:03:00 +00:00
John McCall 3cb0ebd5f7 Create a new InjectedClassNameType to represent bare-word references to the
injected class name of a class template or class template partial specialization.
This is a non-canonical type;  the canonical type is still a template 
specialization type.  This becomes the TypeForDecl of the pattern declaration,
which cleans up some amount of code (and complicates some other parts, but
whatever).

Fixes PR6326 and probably a few others, primarily by re-establishing a few
invariants about TypeLoc sizes.     



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 03:28:59 +00:00
Douglas Gregor 5fccd36204 Reinstate r97674 with a fix for the assertion that was firing in <list>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97686 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 23:55:11 +00:00
Douglas Gregor a7cb22d27f Revert r97674; it's causing failures
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97677 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 23:26:56 +00:00
Douglas Gregor b29b37d7e5 Implement disambiguation of base class members via a
nested-name-specifier. For example, this allows member access in
diamond-shaped hierarchies like:

  struct Base {
    void Foo();
    int Member;
  };

  struct D1 : public Base {};
  struct D2 : public Base {};

  struct Derived : public D1, public D2 { }

  void Test(Derived d) {
    d.Member = 17; // error: ambiguous cast from Derived to Base
    d.D1::Member = 17; // error: okay, modify D1's Base's Member
  }

Fixes PR5820 and <rdar://problem/7535045>. Also, eliminate some
redundancy between Sema::PerformObjectMemberConversion() and
Sema::PerformObjectArgumentInitialization() -- the latter now calls
the former.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97674 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 22:53:40 +00:00
Douglas Gregor 91be6f5ccb Use CXXTemporaryObjectExpr for explicitly-constructed temporaries. We
used to do this, but it got lost when we switched functional-style
cast syntax over to using the new initialization code. Fixes PR6457.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97568 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02 17:18:33 +00:00
Douglas Gregor aac571c68d Finish pushing source-location information though TreeTransform's
TransformDefinition.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97445 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 17:25:41 +00:00
Douglas Gregor 7c1e98f1cb When looking for the instantiated declaration that corresponds to a
given declaration in a template, make sure that the context we're
searching through is complete. Fixes PR6376.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97444 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 15:56:25 +00:00
Douglas Gregor 1af745143e Make sure to mark constructors, operator new, and operator delete as
used when we instantiate C++ new expressions, delete expressions, and
object-construction expressions. Fixes PR6424, although we can't test
all of it until we finish implementing lookup of "operator delete" for
new expressions (!).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97195 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26 00:38:10 +00:00
Douglas Gregor c845aad6f7 When we decide to re-use an existing CXXConstructExpr node, make sure
to mark the constructor as referenced. Fixes the narrow issue reported
in PR6424, but there are a few other places that I'll fix before
closing out that PR.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97185 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26 00:01:57 +00:00
Gabor Greif bf2ca2f87f Add "template" keyword at strategic position to fix
compilation using g++ v3.4.

I'll watch the buildbots and back out if necessary.
Feel free to do the same if something breaks.

Without this patch I get (on g++ 3.4.6) following error:

In file included from clang/lib/Sema/SemaTemplate.cpp:14:
clang/lib/Sema/TreeTransform.h: In member function `clang::ASTOwningResult<&clang::ActionBase::DeleteExpr> clang::TreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(clang::ASTOwningResult<&clang::ActionBase::DeleteExpr>, clang::SourceLocation, bool, clang::NestedNameSpecifier*, clang::SourceRange, clang::TypeSourceInfo*, clang::SourceLocation, clang::SourceLocation, clang::PseudoDestructorTypeStorage)':
clang/lib/Sema/TreeTransform.h:5784: error: expected primary-expression before '>' token
clang/lib/Sema/TreeTransform.h:5784: error: expected primary-expression before ')' token
make[4]: *** [clang/lib/Sema/Release/SemaTemplate.o] Error 1


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97136 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 13:04:33 +00:00
Douglas Gregor edc90500b1 Restore the invariant that a nested-name-specifier can only contain
class types, dependent types, and namespaces. I had previously
weakened this invariant while working on parsing pseudo-destructor
expressions, but recent work in that area has made these changes
unnecessary.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97112 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 04:46:04 +00:00
Douglas Gregor a2e7dd2f4a Use CXXPseudoDestructorExpr as the stored representation for dependent
expressions that look like pseudo-destructors, e.g.,

  p->T::~T()

where p has dependent type.

At template instantiate time, we determine whether we actually have a
pseudo-destructor or a member access, and funnel down to the
appropriate routine in Sema.

Fixes PR6380.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97092 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 01:56:36 +00:00
Douglas Gregor fce46ee68f Keep track of the location of the '~' in a pseudo-destructor expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97080 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 23:50:37 +00:00
Douglas Gregor 26d4ac97fb Retain complete source information for the type after the '~' in a
CXXPseudoDestructorExpr. 

Update template instantiation for pseudo-destructor expressions to use
this source information and to make use of
Sema::BuildPseudoDestructorExpr when the base expression is dependent
or refers to a scalar type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97079 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 23:40:28 +00:00
Douglas Gregor d4dca08d6b Rework parsing of pseudo-destructor expressions and explicit
destructor calls, e.g., 

  p->T::~T

We now detect when the member access that we've parsed, e.g.,

  p-> or x.

may be a pseudo-destructor expression, either because the type of p or
x is a scalar or because it is dependent (and, therefore, may become a
scalar at template instantiation time). 

We then parse the pseudo-destructor grammar specifically:

  ::[opt] nested-name-specifier[opt] type-name :: ∼ type-name

and hand those results to a new action, ActOnPseudoDestructorExpr,
which will cope with both dependent member accesses of destructors and
with pseudo-destructor expressions.

This commit affects the parsing of pseudo-destructors, only; the
semantic actions still go through the semantic actions for member
access expressions. That will change soon.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97045 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 18:44:31 +00:00
Douglas Gregor b10cd04880 Implement support for parsing pseudo-destructor expression with a nested-name-specifier, e.g.,
typedef int Int;
  int *p;
  p->Int::~Int();

This weakens the invariant that the only types in nested-name-specifiers are tag types (restricted to class types in C++98/03). However, we weaken this invariant as little as possible, accepting arbitrary types in nested-name-specifiers only when we're in a member access expression that looks like a pseudo-destructor expression.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96743 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 18:36:56 +00:00
Douglas Gregor 124b878dba Improve parsing and instantiation of destructor names, so that we can
now cope with the destruction of types named as dependent templates,
e.g.,

  y->template Y<T>::~Y()

Nominally, we implement C++0x [basic.lookup.qual]p6. However, we don't
follow the letter of the standard here because that would fail to
parse

  template<typename T, typename U>
  X0<T, U>::~X0() { }

properly. The problem is captured in core issue 339, which gives some
(but not enough!) guidance. I expect to revisit this code when the
resolution of 339 is clear, and/or we start capturing better source
information for DeclarationNames.

Fixes PR6152.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96367 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 19:09:40 +00:00
Douglas Gregor ae6288981b Fix a fiendinshly fun little type-canonicalization bug, where we were
rebuilding a typename type terminating in a template-id (with
dependent template name, naturally) as a TypenameType when, because
its context could be fully resolved, we should have been building it
as a QualifiedNameType. Fixes PR6268.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96084 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 06:05:33 +00:00
Chandler Carruth 53cb6f82c4 This doesn't seem to be used code as it didn't break any tests, but fix the
glaring logic bug anyways. =D


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95533 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08 06:42:49 +00:00
John Thompson 82287d19de First stage of adding AltiVec support
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95335 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 00:12:22 +00:00
Douglas Gregor 321725d95d Provide a real fix for PR6199, reverting the old workaround. Here, we
realize that CXXConstructExpr is always implicit, so we should just
return its argument (if there is only one) rather than directly
invoking the constructor.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95192 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 03:01:57 +00:00
John McCall 09cc141c89 Remove abstract expression kinds from the StmtClass enum. Update a few users
appropriately.  Call out a few missing cases in the expression mangler.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95176 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 00:55:45 +00:00
Anders Carlsson ff93dbd887 Use IdentifierInfo * instead of std::string for the AsmStmt names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94925 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 22:25:16 +00:00
Anders Carlsson a5a79f7d16 More asm cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 20:05:21 +00:00
Anders Carlsson eb60edffa1 Add an CXXBindReferenceExpr (not used just yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94791 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 02:39:32 +00:00
John McCall 6e26689f5d Preserve access bits through overload resolution much better. Some
general refactoring in operator resolution.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 03:27:55 +00:00
Anders Carlsson 703e394866 Implement instantiation of AsmStmts (Crazy, I know)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-24 05:50:09 +00:00
John McCall 1d7d8d66ef The type of a compound literal expression is not necessarily the same as the
type which was syntactically written.  Fixes PR 6080.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93933 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:33:45 +00:00
John McCall 42f56b5006 Preserve type source information in compound literal expressions.
Patch by Enea Zaffanella!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93752 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 19:35:47 +00:00
Douglas Gregor ddf889a2ad Improve source-location information for builtin TypeLocs, from Enea
Zaffanella (with a couple of my tweaks).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93733 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 18:04:31 +00:00