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

283 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor be230c36e3 Implement support for pack expansions whose pattern is a non-type
template argument (described by an expression, of course). For
example:

  template<int...> struct int_tuple { };

  template<int ...Values>
  struct square {
    typedef int_tuple<(Values*Values)...> type;
  };

It also lays the foundation for pack expansions in an initializer-list.
  



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122751 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 17:17:50 +00:00
Douglas Gregor f7dd69969a Add some const qualifiers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122365 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 21:51:48 +00:00
Douglas Gregor b99268b308 Implement instantiation of pack expansions whose pattern is a type-id
in an exception specification.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122297 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 00:52:54 +00:00
Douglas Gregor 7ca7ac40ad Further refactoring of the tree transformation for template argument
lists, so that all such transformations go through a single,
iterator-based transformation function. This is the only place where
we need to implement the logic for transforming pack expansions whose
pattern is a template argument.

Unfortunately, the new cases this refactoring brings into the fold
can't be meaningfully tested yet. We need template argument deduction
to work well enough for variadic function templates first.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122289 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 23:36:19 +00:00
Douglas Gregor 8491ffe86c Implement basic support for template instantiation of pack expansions
whose patterns are template arguments. We can now instantiate, e.g.,

  typedef tuple<pair<OuterTypes, InnerTypes>...> type;

where OuterTypes and InnerTypes are template type parameter packs.

There is a horrible inefficiency in
TemplateArgumentLoc::getPackExpansionPattern(), where we need to
create copies of TypeLoc data because our interfaces traffic in
TypeSourceInfo pointers where they should traffic in TypeLocs
instead. I've isolated in efficiency in this one routine; once we
refactor our interfaces to traffic in TypeLocs, we can eliminate it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122278 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 22:05:00 +00:00
Matt Beaumont-Gay 21a288f2ee Remove unused variable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122257 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 19:38:37 +00:00
Douglas Gregor 7f61f2fc1a Finish refactoring the transformation of template argument lists,
centralizing the transformation into two routines. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122253 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 17:42:22 +00:00
Douglas Gregor fcc1253ba2 Refactor the transformation of template argument lists to centralize
the list traversal. Part 1, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122252 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 17:31:10 +00:00
Douglas Gregor 7536dd5e6c Introduce a new type, PackExpansionType, to capture types that are
pack expansions, e.g. given

  template<typename... Types> struct tuple;

  template<typename... Types>
  struct tuple_of_refs {
    typedef tuple<Types&...> types;
  };

the type of the "types" typedef is a PackExpansionType whose pattern
is Types&. 

This commit introduces support for creating pack expansions for
template type arguments, as above, but not for any other kind of pack
expansion, nor for any form of instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122223 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 02:24:11 +00:00
Argyrios Kyrtzidis f40f0d5a38 Keep the source location of the selector in ObjCMessageExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121516 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 20:08:27 +00:00
Abramo Bagnara 075f8f1b6b Added ParenType type node.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121488 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 16:29:40 +00:00
Francois Pichet f187237d91 Remove the TypesCompatibleExprClass AST node. Merge its functionality into BinaryTypeTraitExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121298 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-08 22:35:30 +00:00
Francois Pichet 6ad6f2848d Type traits intrinsic implementation: __is_base_of(T, U)
New AST node introduced: BinaryTypeTraitExpr; to be reused for more intrinsics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121074 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 00:08:36 +00:00
John McCall 4765fa05b5 Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoretical
reason this is limited to C++, and it's certainly not limited to temporaries.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120996 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 08:20:24 +00:00
John McCall 12f78a6741 Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ObjCPropertyRefExpr
into the latter.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120643 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 01:19:52 +00:00
Douglas Gregor 7e44e3fcd7 Make TypeLocBuilder an implementation detail of Sema. Nobody else should be using it
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120628 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 00:05:49 +00:00
Argyrios Kyrtzidis 44aa1f3978 Revert r119838 "Don't warn for empty 'if' body if there is a macro that expands to nothing"
and use a better and more general approach, where NullStmt has a flag to indicate whether it was preceded by an empty macro.

Thanks to Abramo Bagnara for the hint!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119887 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-20 02:04:01 +00:00
Argyrios Kyrtzidis a25b6a4b43 Don't warn for empty 'if' body if there is a macro that expands to nothing, e.g:
if (condition)
    CALL(0); // empty macro but don't warn for empty body.

Fixes rdar://8436021.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119838 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-19 20:54:25 +00:00
John McCall f89e55ab1b Calculate the value kind of an expression when it's created and
store it on the expression node.  Also store an "object kind",
which distinguishes ordinary "addressed" l-values (like
variable references and pointer dereferences) and bitfield,
@property, and vector-component l-values.

Currently we're not using these for much, but I aim to switch
pretty much everything calculating l-valueness over to them.
For now they shouldn't necessarily be trusted.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119685 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-18 06:31:45 +00:00
John McCall 7cd7d1ad33 Add a new expression kind, OpaqueValueExpr, which is useful for
certain internal type-checking procedures as well as for representing
certain implicitly-generated operations.  Uses to follow.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119289 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-15 23:31:06 +00:00
John McCall 43fed0de4f Replace one hack with a different hack: strip out the ObjectType
parameters to the Transform*Type functions and instead call out
the specific cases where an object type and the unqualified lookup
results are important.  Fixes an assert and failed compile on
a testcase from PR7248.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118887 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-12 08:19:04 +00:00
Bob Wilson e86d78cf47 Add a variant of GCC-style vector types for ARM NEON.
NEON vector types need to be mangled in a special way to comply with ARM's ABI,
similar to some of the AltiVec-specific vector types.  This patch is mostly
just renaming a bunch of "AltiVecSpecific" things, since they will no longer
be specific to AltiVec.  Besides that, it just adds the new "NeonVector" enum.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118724 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-10 21:56:12 +00:00
Douglas Gregor 910f8008fe Remove broken support for variadic templates, along with the various
abstractions (e.g., TemplateArgumentListBuilder) that were designed to
support variadic templates. Only a few remnants of variadic templates
remain, in the parser (parsing template type parameter packs), AST
(template type parameter pack bits and TemplateArgument::Pack), and
Sema; these are expected to be used in a future implementation of
variadic templates.

But don't get too excited about that happening now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118385 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-07 23:05:16 +00:00
John McCall 21e413fe63 Use the real keyword location when rebuilding an elaborated type instead of
making something up.  Fixes PR8129.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118258 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 19:04:38 +00:00
John McCall 3fa5cae9b3 No really, we don't have a retain/release system for statements/expressions
anymore.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117357 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-26 07:05:15 +00:00
Chandler Carruth 428edafa9e Improve the tracking of source locations for parentheses in constructor calls.
This adds them where missing, and traces them through PCH. We fix at least one
bug in the extents found by the Index library, and make a lot of refactoring
tools which care about the exact formulation of a constructor call easier to
write. Also some minor cleanups to more consistently follow the friend pattern
instead of the setter pattern when rebuilding a serialized AST.

Patch originally by Samuel Benzaquen.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117254 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-25 08:47:36 +00:00
Fariborz Jahanian 8ac2d44982 Eliminate usage of ObjCSuperExpr used for
'super' as receiver of property or a setter/getter
methods. //rdar: //8525788



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116483 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-14 16:04:05 +00:00
John McCall 2a984cad5a Add some infrastructure for dealing with expressions of 'placeholder' type,
i.e. expressions with an internally-convenient type which should not be
appearing in generally valid, complete ASTs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116281 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-12 00:20:44 +00:00
John McCall 63d5fb3a14 When instantiating a new-expression, force a rebuild if there were default
arguments in either the placement or constructor arguments.  This is
important if the default arguments refer to a declaration or create a
temporary.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115700 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 22:36:42 +00:00
Douglas Gregor dab60ad68a Implement the C++0x "trailing return type" feature, e.g.,
auto f(int) -> int

from Daniel Wallin!

(With a few minor bug fixes from me).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115322 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-01 18:44:50 +00:00
Argyrios Kyrtzidis 1a18600b85 Don't warn for an unused label if it has 'unused' attribute. Fixes rdar://8483139.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114954 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-28 14:54:07 +00:00
Douglas Gregor 5833b0b831 When marking the declarations in a default argument expression as
"used", at the time that the default argument itself is used, also
mark destructors that will be called by this expression. This fixes a
regression that I introduced in r113700, which broke WebKit, and fixes
<rdar://problem/8427926>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113883 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-14 22:55:20 +00:00
Sebastian Redl 2e156225a2 Define and implement CXXNoexceptExpr. Create it in Sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113623 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-10 20:55:43 +00:00
Douglas Gregor 83cb942690 Simplify template instantiation for C++ exception declarations,
eliminating an unnecessary use of TemporaryBase in the process.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113500 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09 17:09:21 +00:00
Douglas Gregor ba48d6aad1 Eliminate some unnecessary uses of TreeTransform::TemporaryBase. There
are still a few (legitimate, unfortunate) uses of this hack around,
but at least now there are fewer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09 16:55:46 +00:00
Douglas Gregor a1a04786ce Eliminate the comma locations from all of the Sema routines that deal
with comma-separated lists. We never actually used the comma
locations, nor did we store them in the AST, but we did manage to
waste time during template instantiation to produce fake locations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113495 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09 16:33:13 +00:00
Douglas Gregor 3d37c0ada0 Add proper type-source information to UnaryTypeTraitExpr, including
libclang visitation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113492 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09 16:14:44 +00:00
Douglas Gregor 1efb6c7163 Push the range associated with a nested-name-specifier further through
TreeTransform, since we were getting an empty source range where we
shouldn't. Sadly, the test case is Boost.Proto, and isn't worth
reducing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113446 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-08 23:56:00 +00:00
Francois Pichet 01b7c3028d Microsoft's __uuidof operator implementation part 1.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113356 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-08 12:20:18 +00:00
Douglas Gregor ab6677ec40 Provide proper type-source location information for
CXXTemporaryObjectExpr, CXXScalarValueInitExpr, and
CXXUnresolvedConstructExpr, getting rid of a bunch of FIXMEs in the
process.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113319 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-08 00:15:04 +00:00
Douglas Gregor 1bb2a93ab7 Improve source-location information for CXXNewExpr, by hanging on to
the TypeSourceInfo for the allocated type. Fixes PR7501.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113291 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-07 21:49:58 +00:00
Douglas Gregor e2ca6d4a2f Eliminate CXXBindReferenceExpr, which was used in a ton of
well-intentioned but completely unused code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112868 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-02 21:50:02 +00:00
Douglas Gregor 7e010a04fe When instantiating a function type, instantiate the return type before
instantiating the parameters. In a perfect world, this wouldn't
matter, and compilers are free to instantiate in any order they
want. However, every other compiler seems to instantiate the return
type first, and some code (in this case, Boost.Polygon) depends on
this and SFINAE to avoid instantiating something that shouldn't be
instantiated.

We could fight this battle, and insist that Clang is allowed to do
what it does, but it's not beneficial: it's more predictable to
instantiate this way, in source order. When we implement
late-specified return types, we'll need to instantiate the return type
last when it was late-specified, hence the FIXME.

We now compile Boost.Polygon properly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 00:26:14 +00:00
Sean Hunt 6cf750298d Revert my user-defined literal commits - r1124{58,60,67} pending
some issues being sorted out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112493 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-30 17:47:05 +00:00
Sean Hunt 0016d519b8 Implement C++0x user-defined string literals.
The extra data stored on user-defined literal Tokens is stored in extra
allocated memory, which is managed by the PreprocessorLexer because there isn't
a better place to put it that makes sure it gets deallocated, but only after
it's used up. My testing has shown no significant slowdown as a result, but
independent testing would be appreciated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 21:26:48 +00:00
Argyrios Kyrtzidis 9996a7f06a Fix the memory leak of FloatingLiteral/IntegerLiteral.
For large floats/integers, APFloat/APInt will allocate memory from the heap to represent these numbers.
Unfortunately, when we use a BumpPtrAllocator to allocate IntegerLiteral/FloatingLiteral nodes the memory associated with
the APFloat/APInt values will never get freed.
I introduce the class 'APNumericStorage' which uses ASTContext's allocator for memory allocation and is used internally by FloatingLiteral/IntegerLiteral.

Fixes rdar://7637185

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 09:06:06 +00:00
John McCall 7114cbab7e Continue to instantiate sub-statements in a CompoundStmt as long as
we don't see a DeclStmt (failure to instantiate which generally causes
panic).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112282 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 19:56:05 +00:00
John McCall f312b1ea17 One who seeks knowledge learns something new every day.
One who seeks the Tao unlearns something new every day.
Less and less remains until you arrive at non-action.
When you arrive at non-action,
nothing will be left undone.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112244 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 23:41:50 +00:00
John McCall 2d88708cbe Split out a header to hold APIs meant for the Sema implementation from Sema.h.
Clients of Sema don't need to know (for example) the list of diagnostics we
support.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112093 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 22:03:47 +00:00
John McCall 2de56d1d0c GCC didn't care for my attempt at API compatibility, so brute-force everything
to the new constants.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112047 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 11:45:40 +00:00