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

190 Коммитов

Автор SHA1 Сообщение Дата
Sean Hunt 7381d5cfbd Switch over the tablegen to use much prettier range technology
Also rename ABSTRACT to ABSTRACT_STMT, in keeping with the other .def
files

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104017 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18 06:22:21 +00:00
John McCall c12c5bba6c Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of
  one of {primitive-id, primitive-Class, user-defined @class}
with
  a list of protocols.
An ObjCObjectPointerType is therefore just a pointer which always points to
one of these types (possibly sugared).  ObjCInterfaceType is now just a kind
of ObjCObjectType which happens to not carry any protocols.

Alter a rather large number of use sites to use ObjCObjectType instead of
ObjCInterfaceType.  Store an ObjCInterfaceType as a pointer on the decl rather
than hashing them in a FoldingSet.  Remove some number of methods that are no
longer used, at least after this patch.

By simplifying ObjCObjectPointerType, we are now able to easily remove and apply
pointers to Objective-C types, which is crucial for a certain kind of ObjC++
metaprogramming common in WebKit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103870 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-15 11:32:37 +00:00
Daniel Dunbar a63db84b16 Revert r103770, "Added basic source locations to Elaborated and DependentName
types.", it is breaking Clang bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103775 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-14 16:34:09 +00:00
Abramo Bagnara 5431299f6e Added basic source locations to Elaborated and DependentName types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103770 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-14 14:14:23 +00:00
John McCall 5d7c29a278 Rebuild builtin_id * as an ObjCObjectPointerType, where builtin_id is the
magic type that 'id' is a pointer to.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103708 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-13 08:39:13 +00:00
Abramo Bagnara 465d41b92b Merged Elaborated and QualifiedName types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103517 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 21:36:43 +00:00
Douglas Gregor afa0fefb57 Fix a silly bootstrap-breaking thinko, where we were trying to convert
non-existent condition expressions to boolean values during template
instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103364 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-08 23:34:38 +00:00
Douglas Gregor eaa18e449b When instantiating statements that involve conditions (if, while, do,
for, and switch), be careful to construct the full expressions as soon
as we perform template instantation, so we don't either forget to call
temporary destructors or destroy temporaries at the wrong time. This
is the template-instantiation analogue to r103187, during which I
hadn't realized that the issue would affect the handling of these
constructs differently inside and outside of templates.

Fixes a regression in Boost.Function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103357 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-08 22:20:28 +00:00
Douglas Gregor eecf38f821 Fixed DISABLE_SMART_POINTERS breakage
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103198 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06 21:39:56 +00:00
Douglas Gregor 586596fd7f Rework our handling of temporary objects within the conditions of
if/switch/while/do/for statements. Previously, we would end up either:

  (1) Forgetting to destroy temporaries created in the condition (!),
  (2) Destroying the temporaries created in the condition *before*
  converting the condition to a boolean value (or, in the case of a
  switch statement, to an integral or enumeral value), or
  (3) In a for statement, destroying the condition's temporaries at
  the end of the increment expression (!).

We now destroy temporaries in conditions at the right times. This
required some tweaking of the Parse/Sema interaction, since the parser
was building full expressions too early in many places.

Fixes PR7067.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103187 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06 17:25:47 +00:00
Sean Hunt 4bfe196841 Reapplying patch to change StmtNodes.def to StmtNodes.td, this time
with no whitespace. This will allow statements to be referred to in
attribute TableGen files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103087 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-05 15:24:00 +00:00
Sean Hunt c302113179 Revert r103072; I accidentally ended up deleting a bunch of trailing
whitespace which makes this patch unreadable. Will recommit without the
whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103086 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-05 15:23:54 +00:00
Sean Hunt 9d90d62e16 Change StmtNodes.def to StmtNodes.td in anticipation of a rewrite of attributes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103072 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-05 04:13:52 +00:00
Douglas Gregor 72be24f39c Fix a thinko that caused us not to compute __builtin_offset as a
constant expression in C. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102762 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30 20:35:01 +00:00
Douglas Gregor 895162da2d Clean up our handling of local instantiation scopes, which keep track
of the mapping from local declarations to their instantiated
counterparts during template instantiation. Previously, we tried to do
some unholy merging of local instantiation scopes that involved
storing a single hash table along with an "undo" list on the
side... which was ugly, and never handled function parameters
properly.

Now, we just keep separate hash tables for each local instantiation
scope, and "combining" two scopes means that we'll look in each of the
combined hash tables. The combined scope stack is rarely deep, and
this makes it easy to avoid the "undo" issues we were hitting. Also,
I've simplified the logic for function parameters: if we're declaring
a function and we need the function parameters to live longer, we just
push them back into the local instantiation scope where we need them. 

Fixes PR6990.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102732 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30 18:55:50 +00:00
Douglas Gregor cc8a5d5f90 Teach __builtin_offsetof to compute the offsets of members of base
classes, since we only warn (not error) on offsetof() for non-POD
types. We store the base path within the OffsetOfExpr itself, then
evaluate the offsets within the constant evaluator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102571 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 00:18:15 +00:00
Douglas Gregor 29d2fd56b5 Fix template instantiation for __builtin_offfsetof expressions that refer to members of anonymous structs/unions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102551 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-28 22:43:14 +00:00
Douglas Gregor 8ecdb65716 Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.

This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.

OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.

There are two major caveats to this patch:

  1) CodeGen cannot handle the case where __builtin_offsetof is not a
  constant expression, so it produces an error. So, to avoid
  regressing in C, we retain the old UnaryOperator-based
  __builtin_offsetof implementation in C while using the shiny new
  OffsetOfExpr implementation in C++. The old implementation can go
  away once we have proper CodeGen support for this case, which we
  expect won't cause much trouble in C++.

  2) __builtin_offsetof doesn't work well with non-POD class types,
  particularly when the designated field is found within a base
  class. I will address this in a subsequent patch.

Fixes PR5880 and a bunch of assertions when building Boost.Python
tests. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-28 22:16:22 +00:00
Douglas Gregor c96be1ea33 During template instantiation, set the naming class of
UnresolvedLookupExpr and UnresolvedMemberExpr by substituting the
naming class we computed when building the expression in the
template...

... which we didn't always do correctly. Teach
UnresolvedMemberExpr::getNamingClass() all about the new 
representation of injected-class-names in templates, so	that it	can
return a naming	class that is the current instantiation.

Also, when decomposing a template-id into its template name and its
arguments, be sure to set the naming class on the LookupResult
structure. 

Fixes PR6947 the right way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102448 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-27 18:19:34 +00:00
Douglas Gregor 66c4515418 When instantiating UnresolvedLookupExpr and UnresolvedMemberExpr
expressions, be sure to set the naming class of the LookupResult
structure. Fixes PR6947.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102434 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-27 16:10:10 +00:00
Douglas Gregor 57fdc8a438 Improve source-location information in a C++ typeid (type) expression
by using TypeSourceInfo, cleaning up the representation
somewhat. Teach getTypeOperand() to strip references and
cv-qualifiers, providing the semantic view of the type without
requiring any extra storage (the unmodified type remains within the
TypeSourceInfo). This fixes a bug found by Boost's call_traits test.

Finally, clean up semantic analysis, by splitting the ActOnCXXTypeid
routine into ActOnCXXTypeId (the parser action) and two BuildCXXTypeId
functions, which perform the semantic analysis for typeid(type) and
typeid(expression), respectively. We now perform less work at template
instantiation time (we don't look for std::type_info again) and can
give better diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102393 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26 22:37:10 +00:00
Douglas Gregor 9cbfdd212e Implement template instantiation for implicit property references in
Objective-C++. This is the last bit of (non-blocks-related) template
instantiation logic for Objective-C++. Yay! 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102382 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26 21:04:54 +00:00
Douglas Gregor e330354c6b Implement template instantiation for ObjCPropertyRefExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102379 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26 20:47:02 +00:00
Douglas Gregor f9b9eab747 Implement template instantiation for value-dependent Objective-C ivar
references and isa expressions. Also, test template instantiation of
unresolved member references to Objective-C ivar references and isa
expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102374 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26 20:11:03 +00:00
Douglas Gregor be270a0fae Implement template instantiation for Objective-C @catch
statements. This is the last of the Objective-C statements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102356 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26 17:57:08 +00:00
Douglas Gregor 107de90451 Keep track of when DependentNameTypes have no associated keyword
(e.g., no typename, enum, class, etc.), e.g., because the context is
one that is known to refer to a type. Patch from Enea Zaffanella!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102243 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 15:35:55 +00:00
Douglas Gregor 8f5e3dd32e Improve the AST representation of Objective-C @try/@catch/@finally
statements. Instead of the @try having a single @catch, where all of
the @catch's were chained (using an O(n^2) algorithm nonetheless),
@try just holds an array of its @catch blocks. The resulting AST is
slightly more compact (not important) and better represents the actual
language semantics (good).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102221 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 22:50:49 +00:00
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