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

157 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 20b3e9918c Implement support for equality comparisons (!=, ==) of member
pointers, by extending the "composite pointer type" logic to include
member pointer types.

Introduce test cases for member pointer comparisons, including those
that involve the builtin operator candidates implemented earlier. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79925 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-24 17:42:35 +00:00
Anders Carlsson 27a5b9b9ba Add CK_NullToMemberPointer and CK_BaseToDerivedMemberPointer cast kinds. Make -ast-dump print out the cast kinds of cast expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79787 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-22 23:33:40 +00:00
Argyrios Kyrtzidis a5d82000f7 Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use DeclaratorInfo to get this information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 00:31:54 +00:00
Argyrios Kyrtzidis e8661906d4 Use Sema's LocInfoType to pass and preserve type source info through the Parser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79395 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 01:28:28 +00:00
Argyrios Kyrtzidis a1d5662d96 Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema interfaces.
DeclaratorDecl contains a DeclaratorInfo* to keep type source info.
Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl.
EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo.

Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79392 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 01:27:57 +00:00
Anders Carlsson d67c4c31a8 Store the delete operator for delete expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79200 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 20:29:29 +00:00
Anders Carlsson 9abf2aedae AddInitializerToDecl can't take a FullExprArg. Make it take an ExprArg, and create the CXXExprWithTemporaries before setting the initializer on the VarDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 05:13:48 +00:00
Anders Carlsson 089c2602eb BuildCXXConstructExpr doesn't need to take an ASTContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79149 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 23:41:35 +00:00
Argyrios Kyrtzidis e955e7221a Check whether a tag was defined in a C++ condition declaration using GetTypeForDeclarator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78644 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 05:20:41 +00:00
Anders Carlsson 8249576432 Use CastExpr::CK_ArrayToPointerDecay and fix an assert.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78502 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-08 21:04:35 +00:00
Anders Carlsson cdb6197975 More CastKind work.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-07 22:21:05 +00:00
Fariborz Jahanian 1cf9ff87ee Set and use Elidable in elimination of copy ctors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78331 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 19:12:38 +00:00
Fariborz Jahanian b2c352ed55 Patch to improve ir-gen for constructors with default argument
expressions and a test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78213 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 17:03:54 +00:00
Douglas Gregor 50d62d1b4a Introduce the canonical type smart pointers, and use them in a few places to
tighten up the static type system.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 05:36:45 +00:00
Mike Stump ac5fc7c6bc Canonicalize else.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-04 21:02:39 +00:00
Fariborz Jahanian a83f7ed3de Minor renaming/refactoring. No change in functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77985 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-03 19:13:25 +00:00
Anders Carlsson 3503d041ca Add CK_DerivedToBase and use it PerformObjectMemberConversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77652 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 01:23:52 +00:00
Anders Carlsson cdef2b75aa Add a CastKind enum to CastExpr. Right now it's not used for much but it will be :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77650 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 00:48:10 +00:00
Ted Kremenek 6217b80b7a Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 21:53:49 +00:00
Sebastian Redl ef0cb8e62d Make functional-style casts emit correct messages, and fix a crash-on-invalid.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77451 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 13:50:23 +00:00
Ted Kremenek 35366a67ba Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 17:50:17 +00:00
Ted Kremenek 5cad1f7446 Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76139 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 01:20:38 +00:00
Ted Kremenek 1a1a6e2bd4 Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.

The motivation behind this change is twofold:

1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.

2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.

Along with this patch:

a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76098 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 19:58:26 +00:00
Steve Naroff 58f9f2c884 Introduce Type::isAnyPointerType() and convert all clients (suggested by Chris).
I don't love the name, however it simplifies the code and is a worthwhile change. If/when we come up with a better name, we can do a search/replace.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75650 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 18:25:06 +00:00
Anders Carlsson 771d7c3743 Remove some unused code from an experiment that I didn't like.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75315 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 23:48:10 +00:00
Steve Naroff 14108da7f7 This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 23:34:53 +00:00
Anders Carlsson 3292d5ce51 Some (most) type trait expressions require that the argument passed in is a complete type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74937 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 19:06:02 +00:00
Argyrios Kyrtzidis 17945a0f64 De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:36:12 +00:00
Fariborz Jahanian f8d736ca54 Renamed MarcDestructorReferenced -> MarkDestructorReferenced
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 15:05:11 +00:00
Fariborz Jahanian 8d2b35630d Patch to mark destructors when they are used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74359 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 23:49:16 +00:00
Douglas Gregor 2e01cdacc5 Eliminate DeclPtrTy() arguments to ActOnDeclarator that are just a very, very weird way to pass "false". No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74007 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 21:43:56 +00:00
Douglas Gregor ac7610dad6 Rework the way we track which declarations are "used" during
compilation, and (hopefully) introduce RAII objects for changing the
"potentially evaluated" state at all of the necessary places within
Sema and Parser. Other changes:

  - Set the unevaluated/potentially-evaluated context appropriately
    during template instantiation.
  - We now recognize three different states while parsing or
    instantiating expressions: unevaluated, potentially evaluated, and
    potentially potentially evaluated (for C++'s typeid).
  - When we're in a potentially potentially-evaluated context, queue
    up MarkDeclarationReferenced calls in a stack. For C++ typeid
    expressions that are potentially evaluated, we will play back
    these MarkDeclarationReferenced calls when we exit the
    corresponding potentially potentially-evaluated context.
  - Non-type template arguments are now parsed as constant
    expressions, so they are not potentially-evaluated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73899 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 20:57:11 +00:00
Douglas Gregor e0762c9211 Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.

This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73797 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:52:42 +00:00
Anders Carlsson f54741e646 Handle temporaries in default arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73462 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 03:37:31 +00:00
Anders Carlsson 99ba36de0d Improvements to CXXExprWithTemporaries in preparation for fixing a bug with default arguments that have temporaries.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72944 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 15:38:08 +00:00
Anders Carlsson d958389d52 Make sure to copy back arguments that can be changed by FindAllocationOverload. This fixes placement new. (Sebastian, please review).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72673 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 20:26:12 +00:00
Anders Carlsson fc27d268cb Fix an off by one error when trying to perform copy initialization of operator new and operator delete arguments. Sebastian, please review.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72670 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 19:49:47 +00:00
Anders Carlsson 75bbb97f6e Forgot the implementation. Thanks Eli.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72647 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 22:51:20 +00:00
Anders Carlsson 88eaf075c5 Clean up the newly added C++ AST nodes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72643 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 22:38:53 +00:00
Anders Carlsson a19e66d448 It's OK for a full expr to be null. This fixes the failing test cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72642 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 22:24:16 +00:00
Anders Carlsson f5dcd38858 AddInitializerToDecl needs to take a full expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:37:25 +00:00
Anders Carlsson 860306ee30 Add the newly created temporary to the ExprTemporaries stack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72638 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:21:49 +00:00
Anders Carlsson ff6b3d64c9 Stop using CXXTempVarDecl and use CXXTemporary instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72634 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:05:25 +00:00
Anders Carlsson 8e587a15da Remove VarDecl from CXXConstructExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72633 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 20:56:46 +00:00
Anders Carlsson def11996fb Add Sema::MaybeBindToTemporary which takes an expression and (if needed) wraps it in a CXXBindTemporaryExpr. Use this when creating CXXTemporaryObjectExprs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72629 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 20:36:53 +00:00
Douglas Gregor 3433cf7dfd Template instantiation for C++ "new" expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 00:00:09 +00:00
Douglas Gregor d81e6ca6e3 Introduce a new expression type, CXXUnresolvedConstructExpr, to
describe the construction of a value of a given type using function
syntax, e.g.,
  
  T(a1, a2, ..., aN)

when the type or any of its arguments are type-dependent. In this
case, we don't know what kind of type-construction this will be: it
might construct a temporary of type 'T' (which might be a class or
non-class type) or might perform a conversion to type 'T'. Also,
implement printing of and template instantiation for this new
expression type. Due to the change in Sema::ActOnCXXTypeConstructExpr,
our existing tests cover template instantiation of this new expression
node.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 18:46:25 +00:00
Anders Carlsson 7c3e8a1ddb Create CXXConstructExpr calls for arguments passed to functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 04:45:15 +00:00
Anders Carlsson bde2008586 Fix instantiate-function-1.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71988 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 19:43:12 +00:00
Anders Carlsson 165a0a07c0 Implement Sema::ActOnFinishFullExpr and create a CXXExprWithTemporaries node if necessary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71983 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 18:41:29 +00:00