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

455 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner a50089ec68 This is an attempt to improve loc info for 'unused result' expression
warnings, but it fails because we don't have the location of the .
and I don't understand ObjCKVCRefExpr.  I'll revisit this later.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79190 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 16:45:18 +00:00
Anders Carlsson 2d46eb21eb Call MaybeBindToTemporary for overloaded binary and unary operators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79173 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 04:11:06 +00:00
Anders Carlsson 6f68027af2 Add MaybeBindToTemporary calls for member call expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79171 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 03:42:12 +00:00
Nate Begeman 888376a2bb Transition the PCH support for ShuffleVectorExpr over to ASTContext allocation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78783 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 02:28:50 +00:00
Fariborz Jahanian 6cc670e2eb Warn on use of property dot syntax when unused.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78760 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 00:45:33 +00:00
Chris Lattner ab0e8873c3 Fix rdar://7126285: don't warn on unused ObjC property access
that uses "dot syntax" since it might have a side effect.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78704 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 20:08:03 +00:00
Nate Begeman 2ef13e5abe Take 2 on AltiVec-style vector initializers.
Fixes PR4704 problems

Addresses Eli's patch feedback re: ugly cast code

Updates all postfix operators to remove ParenListExprs.  While this is awful,
no better solution (say, in the parser) is obvious to me.  Better solutions
welcome.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78621 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-10 23:49:36 +00:00
Daniel Dunbar 1df5109f47 Revert r78535, it is causing a number of failures to build projects.
--- Reverse-merging r78535 into '.':
D    test/Sema/altivec-init.c
U    include/clang/Basic/DiagnosticSemaKinds.td
U    include/clang/AST/Expr.h
U    include/clang/AST/StmtNodes.def
U    include/clang/Parse/Parser.h
U    include/clang/Parse/Action.h
U    tools/clang-cc/clang-cc.cpp
U    lib/Frontend/PrintParserCallbacks.cpp
U    lib/CodeGen/CGExprScalar.cpp
U    lib/Sema/SemaInit.cpp
U    lib/Sema/Sema.h
U    lib/Sema/SemaExpr.cpp
U    lib/Sema/SemaTemplateInstantiateExpr.cpp
U    lib/AST/StmtProfile.cpp
U    lib/AST/Expr.cpp
U    lib/AST/StmtPrinter.cpp
U    lib/Parse/ParseExpr.cpp
U    lib/Parse/ParseExprCXX.cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78551 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-10 03:01:36 +00:00
Nate Begeman 25b4fdb9d6 AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);
In addition to being defined by the AltiVec PIM, this is also the vector
initializer syntax used by OpenCL, so that vector literals are compatible
with macro arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78535 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-09 17:55:44 +00:00
Anders Carlsson d497206844 Get rid of Stmt::Clone now that we can reference count statements instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78452 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-08 02:50:17 +00:00
Douglas Gregor 42602bb40a Separate Stmt::Destroy into the entrypoint for destroying a statement
or expression (Destroy) from the virtual function used to actually
destroy a given expression (DoDestroy). 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78375 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-07 06:08:38 +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
Chris Lattner fb84664349 fix PR4633: cast to void should silence the 'unused expression' warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77344 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 18:25:28 +00:00
Daniel Dunbar 68a049cab6 CallExpr's SubExprs sometimes were allocated in the wrong place.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77302 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 06:29:46 +00:00
Steve Naroff f242b1b0c4 Allow front-end 'isa' access on object's of type 'id'.
Enhance test case to cover 'isa' access on interface types (clang produces an error, GCC produces a warning).

Still need back-end CodeGen for ObjCIsaExpr.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76979 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-24 17:54:45 +00:00
Anders Carlsson 19cc4abea0 Revert r75641.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76327 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 19:43:29 +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
Chris Lattner 6346f96314 objc methods can't be an operand to callexpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76179 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 15:46:27 +00:00
Zhongxing Xu a00425414e Refactor code into a new CallExpr::getDirectCallee() method. Simplify some
code with the new method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 07:29:51 +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 f495456020 Remove ASTContext::isObjCObjectPointerType().
Convert all clients to use the new predicate on Type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76076 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 15:41:00 +00:00
Anders Carlsson 3d598a5ab3 Rename RecordLayout.h to ASTRecordLayout.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75641 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 17:29:11 +00:00
Argyrios Kyrtzidis ba0a9006db Read/write a CXXOperatorCallExpr from/to PCH files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 03:19:21 +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
Douglas Gregor 83314aa1cf Implement template argument deduction when taking the address of a
function template. Most of the change here is in factoring out the
common bits used for template argument deduction from a function call
and when taking the address of a function template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 20:55:45 +00:00
Douglas Gregor 6f4a69a310 Fix bitfield promotion in the presence of explicit casts, from Abrama Bagnara.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74830 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 15:38:40 +00:00
Argyrios Kyrtzidis 40b598eea1 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:34:44 +00:00
Chris Lattner 001d64dd29 Fix the FloatingLiteral API to take the isexact flag by value instead of
by pointer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74432 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-29 17:34:55 +00:00
Nate Begeman 131f465824 OpenCL 1.0 Support, patch 1/N: upper case swizzle operator and hex element index.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74202 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 21:06:09 +00:00
Fariborz Jahanian 262f9cf852 Renamed Protocol as TheProtocol so people can use clang header for
building obj-c++ clients. "Protocol" is a class name in Cocoa.h


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73854 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 18:26:03 +00:00
Douglas Gregor 68584ed35a Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:11:24 +00:00
Chris Lattner 1b63e4f732 Sink the BuiltinInfo object from ASTContext into the
preprocessor and initialize it early in clang-cc.  This
ensures that __has_builtin works in all modes, not just
when ASTContext is around.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73319 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 01:54:56 +00:00
Anders Carlsson 02d95baf23 Instantiation support for more Obj-C expressions, string literals, @selector and @protocol expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73036 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-07 19:51:47 +00:00
Fariborz Jahanian 102e390bcb A corner case of objc2 gc's write-barrier generation
for the Next runtime.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72703 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-01 21:29:32 +00:00
Douglas Gregor 78d1583d0b When evaluating a VarDecl as a constant or determining whether it is
an integral constant expression, maintain a cache of the value and the
is-an-ICE flag within the VarDecl itself. This eliminates
exponential-time behavior of the Fibonacci template metaprogram.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72428 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26 18:54:04 +00:00
Anders Carlsson 6dde78f744 Add a new CallExpr::getCallReturnType and use it in Expr::isLvalueInternal. No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72410 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26 04:57:27 +00:00
Anders Carlsson 5e5783180a A block that returns a reference is an lvalue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72409 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26 02:03:20 +00:00
Douglas Gregor 9ea62768fc Template instantiation for C99 designated initializers, because we
can. Also, delay semantic analysis of initialization for
value-dependent as well as type-dependent expressions, since we can't
always properly type-check a value-dependent expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72233 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 23:17:49 +00:00
Douglas Gregor d5f3a0fde4 Fix handling of the GNU "t ? : f" extension to the conditional
operator in C++, and verify that template instantiation for the
condition operator does the right thing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72127 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 20:13:50 +00:00
Douglas Gregor d8ac436c8c Template instantiation for imaginary literals, because they were next in Expr.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72058 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 22:38:38 +00:00
Anders Carlsson 6b1d283fe8 Make ActOnExprStmt take a FullExprArg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71989 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 21:11:30 +00:00
Sebastian Redl 8b0b475b34 Implement instantiation of a few boring, simple expressions. I don't think these are testable yet, though.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71953 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 18:50:46 +00:00
Anders Carlsson ffce2df6ae Basic support for member exprs where the base expr type is dependent.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71907 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 23:10:19 +00:00
Sebastian Redl 6e8ed16ffe Implement C++0x nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-10 18:38:11 +00:00
Fariborz Jahanian 06b89124a9 Fixes a bug for objc2's gc in the presense of type-casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71041 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 23:28:21 +00:00
Eli Friedman 53202857c6 PR2524: downgrade taking address of expression of type 'void' to an
extension warning.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70805 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 22:36:05 +00:00
Douglas Gregor 33bbbc5ec8 When determining whether an expression refers to a bit-field, look
into the left-hand side of an assignment expression. This completes
most of PR3500; the only remaining part is to deal with the
GCC-specific implementation-defined behavior for "unsigned long" (and
other) bit-fields.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-02 02:18:30 +00:00
Eli Friedman 852871abbf PR4103: Silence bogus unused expression warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70384 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 16:35:53 +00:00
Eli Friedman 9a901bb639 Remove getIntegerConstantExprValue in favor of using EvaluateAsInt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70145 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 19:19:15 +00:00
Chris Lattner 0389e6bd01 implement PCH support for the rest of ExprObjC.h, including
the missing bits of ObjCMessageExpr.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70100 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 00:44:05 +00:00
Eli Friedman 09de176799 Change isNullPointerConstant to be strict; hopefully this won't cause
any issues now that we have our own tgmath.h.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70090 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 22:37:12 +00:00
Chris Lattner 81045d8dcd Fix PR4027 + rdar://6808859, we were rejecting implicit casts of
aggregates even though we already accept explicit ones.  Easy fix.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 05:19:11 +00:00
Douglas Gregor 7297134f12 FunctionDecl::getBody() is getting an ASTContext argument for use in
lazy PCH deserialization. Propagate that argument wherever it needs to
be. No functionality change, except that I've tightened up a few PCH
tests in preparation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69406 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 00:02:19 +00:00
Douglas Gregor 88c9a46f0b Fix two embarrassing PCH bugs:
1) Accidentally used delete [] on an array of statements that was allocated with ASTContext's allocator
  2) Deserialization of names with multiple declarations (e.g., a struct and a function) used the wrong mangling constant, causing it to view declaration IDs as Decl*s.

403.gcc builds and links properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69390 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 21:46:47 +00:00
Sebastian Redl 76458501a8 Implement lvalue test for conditional expressions.
Add a few commented lines to the test case that point out things that don't work yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69354 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 16:30:52 +00:00
Steve Naroff 3aaa482ea5 Fix <rdar://problem/6765383> clang-6: clang does not appear to support declaring a static Block 'const'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69306 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 19:02:57 +00:00
Douglas Gregor d077d759d0 PCH support for InitListExpr, DesignatedInitExpr, and ImplicitValueInitExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69251 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 00:55:48 +00:00
Douglas Gregor 94cd5d1397 PCH support for ShuffleVectorExpr and BlockDeclRefExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69244 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 00:01:45 +00:00
Douglas Gregor d3c98a02c7 PCH support for ExtVectorElementExpr and VAArgExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69240 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 23:02:49 +00:00
Douglas Gregor 1f0d0133b0 PCH support for MemberExpr and CallExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69186 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 17:43:59 +00:00
Douglas Gregor 673ecd6a4a PCH support for string literals
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69172 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 16:35:07 +00:00
Douglas Gregor ffb4b6e299 Implement support for designated initializers that refer to members of
anonymous structs or unions. Fixes PR3778.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69153 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 06:41:24 +00:00
Daniel Dunbar 44e35f7b2b Improve "assignment to cast" diagnostic.
- Strip off extra parens when looking for casts.
 - Change the location info to point at the cast (instead of the
   assignment).

For example, on
  
  int *b;
  #define a ((void*) b)
  void f0() {
    a = 10;
  }
  
we now emit:
  
  /tmp/t.c:4:3: error: assignment to cast is illegal, lvalue casts are not supported
    a = 10;
    ^ ~
  /tmp/t.c:2:12: note: instantiated from:
  #define a ((void*) b)
            ~^~~~~~~~~~
  
instead of:
  
  /tmp/t.c:4:5: error: expression is not assignable
    a = 10;
    ~ ^


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69114 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 00:08:05 +00:00
Daniel Dunbar 5717daef56 Strip paren expressions when trying to diagnose "cast as lvalue"
extension.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69100 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 23:26:44 +00:00
Douglas Gregor eeae8f0727 Make our diagnostics about the obsolete GNU designated-initializer
syntax into extension warnings, and provide code-modification hints
showing how to fix the problem.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-28 00:41:23 +00:00
Chris Lattner 7fd0995e99 use isa<>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67543 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 17:57:53 +00:00
Eli Friedman 04831aa327 Adjust isModifiableLvalue to give a slightly more useful diagnostic for
attempting to illegally modify a BlockDeclRefExpr.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67491 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-22 23:26:56 +00:00
Chris Lattner b7beee9f2b fix some warnings in release-assert mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67456 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-22 00:10:22 +00:00
Douglas Gregor fa2192042f When building the structured initializer list, pre-allocate storage in
its vectors based on the subobject type we're initializing and the
(unstructured) initializer list. This eliminates some malloc thrashing
when parsing initializers (from 117 vector reallocations down to 0
when parsing Cocoa.h). We can't always pre-allocate the right amount
of storage, since designated initializers can cause us to initialize
in non-predictable patterns.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67421 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20 23:58:33 +00:00
Douglas Gregor 0686368005 Destroy expressions properly when resizing an initializer list
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67417 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20 23:38:03 +00:00
Sebastian Redl 7c80bd6403 Almost complete implementation of rvalue references. One bug, and a few unclear areas. Maybe Doug can shed some light on some of the fixmes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67059 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 23:22:08 +00:00
Anders Carlsson a135fb43eb Add the ability to clone integer and string literals. Use it when instantiating template expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67030 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-15 18:34:13 +00:00
Anders Carlsson c3082413e4 Handle dependent types/exprs in static_assert expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66997 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-14 00:33:21 +00:00
Douglas Gregor bc736fceca Implement template instantiation for the prefix unary operators. As
always, refactored the existing logic to tease apart the parser action
and the semantic analysis shared by the parser and template
instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 23:49:33 +00:00
Douglas Gregor 063daf6e19 Refactor the way we handle operator overloading and template
instantiation for binary operators. This change moves most of the
operator-overloading code from the parser action ActOnBinOp to a new,
parser-independent semantic checking routine CreateOverloadedBinOp. 

Of particular importance is the fact that CreateOverloadedBinOp does
*not* perform any name lookup based on the current parsing context (it
doesn't take a Scope*), since it has to be usable during template
instantiation, when there is no scope information. Rather, it takes a
pre-computed set of functions that are visible from the context or via
argument-dependent lookup, and adds to that set any member operators
and built-in operator candidates. The set of functions is computed in
the parser action ActOnBinOp based on the current context (both
operator name lookup and argument-dependent lookup). Within a
template, the set computed by ActOnBinOp is saved within the
type-dependent AST node and is augmented with the results of
argument-dependent name lookup at instantiation time (see
TemplateExprInstantiator::VisitCXXOperatorCallExpr).

Sadly, we can't fully test this yet. I'll follow up with template
instantiation for sizeof so that the real fun can begin.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66923 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 18:40:31 +00:00
Chris Lattner ecdd84147c add a helper function to strip noop casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66909 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 17:28:01 +00:00
Douglas Gregor baf534875e Eliminate some unused default cases in switches on the binary operator kind
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66837 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-12 22:51:37 +00:00
Douglas Gregor 2d2e9cfdc1 Eliminate CXXClassVarDecl. It doesn't add anything
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66696 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 20:22:50 +00:00
Eli Friedman 7976932a1c Minor cleanup for choose expressions: add a helper that returns the
chosen sub-expression, rather than just evaluating the condition.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66018 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 05:52:32 +00:00
Eli Friedman 35183aca18 Change the AST generated for offsetof a bit so that it looks like a
normal expression, and change Evaluate and IRGen to evaluate it like a 
normal expression.  This simplifies the code significantly, and fixes 
PR3396.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65622 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-27 06:44:11 +00:00
Eli Friedman 60ce9635b9 Make isICE assert when Evaluate can't evaluate an ICE, as suggested by
Daniel.  Some minor fixes/cleanup.  Allow __builtin_choose_expr, 
__real__, and __imag__ in ICEs, following gcc's example.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65610 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-27 04:07:58 +00:00
Mike Stump befbcf4e02 The middle operand in ?: is optional, really.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65609 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-27 03:16:57 +00:00
Eli Friedman e28d7195aa Rewrite of isIntegerConstantExpr to be centered around Evaluate. This
is a rather big change, but I think this is the direction we want to go; 
the code is significantly shorter now, and it doesn't duplicate Evaluate 
code.  There shouldn't be any visible changes as far as I know.

There has been some movement towards putting ICE handling into 
Evaluate (for example, VerifyIntegerConstantExpression uses Evaluate 
instead of isICE).  This patch is sort of the opposite of the approach, 
making ICE handling work without Evaluate being aware of it. I think 
this approach is better because it separates the code that does the 
constant evaluation from code that's calculating a rather 
arbitrary predicate.

The one thing I don't really like about this patch is that 
the handling of commas in C99 complicates it signficantly. (Seriously, 
what was the standards committee thinking when they wrote that 
part?) I think I've come up with a decent approach, but it doesn't feel
ideal.  I might add some way to check for evaluated commas from Evaluate 
in a subsequent patch; that said, it might not be worth bothering.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65524 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 09:29:13 +00:00
Chris Lattner eaf2bb89eb first wave of fixes for @encode sema support. This is part of PR3648.
The big difference here is that (like string literal) @encode has 
array type, not pointer type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 22:18:39 +00:00
Fariborz Jahanian 207c5210eb We should not generate __weak write barrier on indirect reference
of a pointer to object; This patch does this odd behavior according to
gcc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65334 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 18:59:50 +00:00
Fariborz Jahanian 44baa8abba More objc gc work. Match gcc's treatment of ivar access
true a local pointer to objective-c object in generating
write barriers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65290 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22 18:40:18 +00:00
Eli Friedman dcdafb6a70 Improvements to ASTContext::getDeclAlignInBytes; fixes the testcase in
PR3254 and part of PR3433.

The isICE changes are necessary to keep the computed results 
consistent with Evaluate.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65258 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22 02:56:25 +00:00
Eli Friedman 1f4a6db271 A few small tweaks to isConstantInitializer. (No test because this
isn't getting used by Sema or CodeGen at the moment...)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65107 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 02:36:22 +00:00
Chris Lattner 1e4db7c468 rip out __builtin_overload
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64961 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 22:14:55 +00:00
Chris Lattner c6c16af963 teach child iterators to walk into the child string of an ObjCStringLiteral,
so it shows up in -ast-dump.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64901 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 06:53:08 +00:00
Chris Lattner 2085fd6cd2 privatize all of the string literal memory allocation/creation
stuff behind a private static function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64898 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 06:40:38 +00:00
Chris Lattner 726e168dc0 change the StringLiteral AST node to track all of the SourceLocations of
the various PPTokens that are pasted together to make it.  In the course
of working on this, I discovered ParseObjCStringLiteral which needs some
work.  I'll tackle it next.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64892 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 05:49:11 +00:00
Daniel Dunbar 2d6744ff04 isICE was evaluating ?: incorrectly with missing-gcc-LHS extension.
Add assert to isICE that, on success, result must be the same as
EvaluateAsInt()... this enforces a minimum level of sanity.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64865 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 00:47:45 +00:00
Daniel Dunbar a135975d42 Convert isIntegerConstantExpr to use ASTContext::MakeIntValue.
- This idiom ensures that the result will have the right width and
   type.

 - Tested on most of x86_64/llvm-test to satisfy my paranoia.

 - This fixes at least the following bugs:
   o UnaryTypeTraitExpr wasn't setting the width correctly.
   o Arithmetic on _Bool wasn't setting the width correctly.

   And probably a number more.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64864 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 00:32:53 +00:00
Daniel Dunbar c87a282e7b Rename UnaryTypeTraitExpr::Evaluate to EvaluateTrait to not collide
with Expr::Evaluate().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64850 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 23:20:26 +00:00
Daniel Dunbar f592c929bd Unbreak clang.
Doug: please verify that it is expected that LastIdx can be less that
NumInits. And perhaps add a comment so that Chris doesn't break your
code. :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64688 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 22:42:44 +00:00
Chris Lattner d603eaa682 fix long lines.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64684 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 22:33:34 +00:00
Chris Lattner 2140e904db introduce and use a new ExtVectorElementExpr::isArrow method, at Eli's suggestion
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64681 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 22:14:05 +00:00
Douglas Gregor 3c385e5f8d Add hook to add attributes to function declarations that we know
about, whether they are builtins or not. Use this to add the
appropriate "format" attribute to NSLog, NSLogv, asprintf, and
vasprintf, and to translate builtin attributes (from Builtins.def)
into actual attributes on the function declaration.

Use the "printf" format attribute on function declarations to
determine whether we should do format string checking, rather than
looking at an ad hoc list of builtins and "known" function names.

Be a bit more careful about when we consider a function a "builtin" in
C++.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64561 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 18:57:46 +00:00
Chris Lattner 026dc96ac6 Several related changes:
1) implement parser and sema support for reading and verifying attribute(warnunusedresult).
2) rename hasLocalSideEffect to isUnusedResultAWarning, inverting the sense
   of its result.
3) extend isUnusedResultAWarning to directly return the loc and range 
   info that should be reported to the user.  Make it substantially more
   precise in some cases than what was previously reported.
4) teach isUnusedResultAWarning about CallExpr to decls that are 
   pure/const/warnunusedresult, fixing a fixme.
5) change warn_attribute_wrong_decl_type to not pass in english strings, instead,
   pass in integers and use %select.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64543 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 07:37:35 +00:00
Douglas Gregor 3e41d60eb6 Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:

  1) When we're supporting the "implicit function declaration" feature
  of C99, these functions will be implicitly declared with the right
  signature rather than as a function returning "int" with no
  prototype. See PR3541 for the reason why this is important (hint:
  GCC always predeclares these functions).
 
  2) If users attempt to redeclare one of these library functions with
  an incompatible signature, we produce a hard error.

This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:

  'strcpy' was implicitly declared here with type 'char *(char *, char
  const *)'

but we should really print out a fake code line showing the
declaration, like this:

  'strcpy' was implicitly declared here as:

    char *strcpy(char *, char const *)

This would also be good for printing built-in candidates with C++
operator overloading.

The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64504 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 23:20:09 +00:00
Daniel Dunbar adadd8db2a Fix va_arg bug noticed by Eli, __builtin_va_arg is not an l-value
designating an object.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64371 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 09:21:08 +00:00
Ted Kremenek 668bf91d31 CallExpr now uses ASTContext's allocate to allocate/delete its array of subexpressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64162 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-09 20:51:47 +00:00
Ted Kremenek 353ffceafc Deallocate the StringLiteral itself in StringLiteral::Destroy() and deallocate the string data before running StringLiteral's destructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64146 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-09 17:10:09 +00:00
Ted Kremenek fb7413f126 Allocate the subexpression array for OberloadExpr from ASTContext's allocator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64145 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-09 17:08:14 +00:00
Sebastian Redl 4a4251b9e7 Make const-initialized const integral variables I-C-Es in C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64015 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 13:06:23 +00:00
Ted Kremenek 8189cde56b Overhaul of Stmt allocation:
- Made allocation of Stmt objects using vanilla new/delete a *compiler
  error* by making this new/delete "protected" within class Stmt.
- Now the only way to allocate Stmt objects is by using the new
  operator that takes ASTContext& as an argument.  This ensures that
  all Stmt nodes are allocated from the same (pool) allocator.
- Naturally, these two changes required that *all* creation sites for
  AST nodes use new (ASTContext&).  This is a large patch, but the
  majority of the changes are just this mechanical adjustment.
- The above changes also mean that AST nodes can no longer be
  deallocated using 'delete'.  Instead, one most do
  StmtObject->Destroy(ASTContext&) or do
  ASTContextObject.Deallocate(StmtObject) (the latter not running the
  'Destroy' method).

Along the way I also...
- Made CompoundStmt allocate its array of Stmt* using the allocator in
  ASTContext (previously it used std::vector).  There are a whole
  bunch of other Stmt classes that need to be similarly changed to
  ensure that all memory allocated for ASTs comes from the allocator
  in ASTContext.
- Added a new smart pointer ExprOwningPtr to Sema.h.  This replaces
  the uses of llvm::OwningPtr within Sema, as llvm::OwningPtr used
  'delete' to free memory instead of a Stmt's 'Destroy' method.

Big thanks to Doug Gregor for helping with the acrobatics of making
'new/delete' private and the new smart pointer ExprOwningPtr!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63997 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 01:47:29 +00:00
Sebastian Redl 224605064a Implement dereferencing of pointers-to-member.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63983 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 00:15:38 +00:00
Ted Kremenek 6e94ef5696 Move StringLiteral to allocate its internal string data using the allocator in
ASTContext. This required changing all clients to pass in the ASTContext& to the
constructor of StringLiteral. I also changed all allocations of StringLiteral to
use new(ASTContext&).

Along the way, I updated a bunch of new()'s in StmtSerialization.cpp to use the
allocator from ASTContext& (not complete).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63958 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 19:55:15 +00:00
Douglas Gregor aaba5e346d Basic representation of C++ class templates, from Andrew Sutton.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63750 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04 19:02:06 +00:00
Douglas Gregor a9c8780860 Make CodeGen produce an error if we come across a non-constant initializer list that involves the GNU array-range designator extension
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63327 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29 19:42:23 +00:00
Douglas Gregor 3498bdb9e9 Introduce a new expression node, ImplicitValueInitExpr, that
represents an implicit value-initialization of a subobject of a
particular type. This replaces the (ab)use of CXXZeroValueInitExpr
within initializer lists for the "holes" that occur due to the use of
C99 designated initializers.

The new test case is currently XFAIL'd, because CodeGen's
ConstExprEmitter (in lib/CodeGen/CGExprConstant.cpp) needs to be
taught to value-initialize when it sees ImplicitValueInitExprs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63317 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29 17:44:32 +00:00
Douglas Gregor 0bb76897be Clean up designated initialization of unions, so that CodeGen doesn't
have to try to guess which member is being initialized.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63315 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29 16:53:55 +00:00
Douglas Gregor 54f0728c2a Remove Expr::hasSideEffects. It doesn't work anyway
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63254 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 23:43:32 +00:00
Douglas Gregor 4c67834407 Code generation support for C99 designated initializers.
The approach I've taken in this patch is relatively straightforward,
although the code itself is non-trivial. Essentially, as we process
an initializer list we build up a fully-explicit representation of the
initializer list, where each of the subobject initializations occurs
in order. Designators serve to "fill in" subobject initializations in
a non-linear way. The fully-explicit representation makes initializer
lists (both with and without designators) easy to grok for codegen and
later semantic analyses. We keep the syntactic form of the initializer
list linked into the AST for those clients interested in exactly what
the user wrote.

Known limitations:
  - Designating a member of a union that isn't the first member may
    result in bogus initialization (we warn about this)
  - GNU array-range designators are not supported (we warn about this)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63242 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 21:54:33 +00:00
Steve Naroff c0ac4923f0 Finish making AST BumpPtrAllocation runtime configurable (based on -disable-free).
snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m
0.179u 0.051s 0:00.23 95.6%	0+0k 0+0io 0pf+0w
snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m -disable-free
0.169u 0.052s 0:00.22 95.4%	0+0k 0+0io 0pf+0w


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63153 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 23:20:32 +00:00
Sebastian Redl 4e716e07d9 Fix compile error from r62953.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62959 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-25 13:34:47 +00:00
Eli Friedman 32a311e276 One more case for Expr::isConstantInitializer; I think this covers
everything that we aren't intending to implement in Expr::Evaluate.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62953 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-25 03:27:40 +00:00
Eli Friedman c39dc9a25a Enhancements to Expr::isConstantInitializer to deal with a few
cases it couldn't deal with before.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-25 03:12:18 +00:00
Eli Friedman c9e8f60678 Rename Expr::isConstantExpr to Expr::isConstantInitializer; this more
accurately states what the function is trying to do and how it is 
different from Expr::isEvaluatable.  Also get rid of a parameter that is both 
unused and inaccurate.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62951 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-25 02:32:41 +00:00
Douglas Gregor 05c13a3411 Initial implementation of semantic analysis and ASTs for C99
designated initializers. This implementation should cover all of the
constraints in C99 6.7.8, including long, complex designations and
computing the size of incomplete array types initialized with a
designated initializer. Please see the new test-case and holler if you
find cases where this doesn't work.

There are still some wrinkles with GNU's anonymous structs and
anonymous unions (it isn't clear how these should work; we'll just
follow GCC's lead) and with designated initializers for the members of a
union. I'll tackle those very soon.

CodeGen is still nonexistent, and there's some leftover code in the
parser's representation of designators that I'll also need to clean up.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62737 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-22 00:58:24 +00:00
Nate Begeman 59b5da6d85 Support evaluation of vector constant expressions, and codegen of same.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62455 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 03:20:47 +00:00
Nate Begeman 190d6a2539 A couple more vector component access fixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62443 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 02:01:21 +00:00
Nate Begeman 353417af9d Update support for vector component access on ExtVectors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62440 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 01:47:54 +00:00
Fariborz Jahanian d1fa6449e9 Patch to supprt case of readonly property being
assigned to when it has user declared setter method
defined in the class implementation (but no declaration in
the class itself).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62098 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 19:55:42 +00:00
Douglas Gregor 1a49af9681 Add QualifiedDeclRefExpr, which retains additional source-location
information for declarations that were referenced via a qualified-id,
e.g., N::C::value. We keep track of the location of the start of the
nested-name-specifier. Note that the difference between
QualifiedDeclRefExpr and DeclRefExpr does have an effect on the
semantics of function calls in two ways:
  1) The use of a qualified-id instead of an unqualified-id suppresses
     argument-dependent lookup
  2) If the name refers to a virtual function, the qualified-id
  version will call the function determined statically while the
  unqualified-id version will call the function determined dynamically
  (by looking up the appropriate function in the vtable).

Neither of these features is implemented yet, but we do print out
qualified names for QualifiedDeclRefExprs as part of the AST printing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61789 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-06 05:10:23 +00:00
Sebastian Redl 64b45f7e0d PODness and Type Traits
Make C++ classes track the POD property (C++ [class]p4)
Track the existence of a copy assignment operator.
Implicitly declare the copy assignment operator if none is provided.
Implement most of the parsing job for the G++ type traits extension.
Fully implement the low-hanging fruit of the type traits:
__is_pod: Whether a type is a POD.
__is_class: Whether a type is a (non-union) class.
__is_union: Whether a type is a union.
__is_enum: Whether a type is an enum.
__is_polymorphic: Whether a type is polymorphic (C++ [class.virtual]p1).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61746 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 20:52:13 +00:00
Douglas Gregor 88a3514f36 Add support for calls to overloaded member functions. Things to note:
- Overloading has to cope with having both static and non-static
    member functions in the overload set.
  - The call may or may not have an implicit object argument,
    depending on the syntax (x.f() vs. f()) and the context (static
    vs. non-static member function).
  - We now generate MemberExprs for implicit member access expression.
  - We now cope with mutable whenever we're building MemberExprs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61329 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 05:46:06 +00:00
Douglas Gregor 86f1940835 Add support for member references (E1.E2, E1->E2) with C++ semantics,
which can refer to static data members, enumerators, and member
functions as well as to non-static data members.

Implement correct lvalue computation for member references in C++. 
Compute the result type of non-static data members of reference type properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61294 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-20 23:49:58 +00:00
Anders Carlsson 1c0cfd4599 Get rid of the old Expr::Evaluate variant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61260 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-19 20:58:05 +00:00
Chris Lattner 42b83dde7c Implement the final (hopefully) wrinkle to i-c-e + builtin_constant_p
processing: it allows arbitrary foldable constants as the operand of ?: when
builtin_constant_p is the condition.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60954 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 18:00:51 +00:00
Chris Lattner 1f64805512 add a fixme.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60935 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 06:57:03 +00:00
Chris Lattner 28daa53db7 implement rdar://6091492 - ?: with __builtin_constant_p as the operand is an i-c-e.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60934 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 06:55:44 +00:00
Chris Lattner 670a62cd1d Fix rdar://6095061 - gcc allows __builtin_choose_expr as an lvalue
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60924 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 05:35:08 +00:00
Douglas Gregor 44b4321fea Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60878 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11 16:49:14 +00:00
Douglas Gregor 898574e749 Introduce basic support for dependent types, type-dependent
expressions, and value-dependent expressions. This permits us to parse
some template definitions.

This is not a complete solution; we're missing type- and
value-dependent computations for most of the expression types, and
we're missing checks for dependent types and type-dependent
expressions throughout Sema.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60615 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 23:32:09 +00:00
Douglas Gregor 72c3f314d9 Representation of template type parameters and non-type template
parameters, with some semantic analysis:
  - Template parameters are introduced into template parameter scope
  - Complain about template parameter shadowing (except in Microsoft mode)

Note that we leak template parameter declarations like crazy, a
problem we'll remedy once we actually create proper declarations for
templates. 

Next up: dependent types and value-dependent/type-dependent
expressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60597 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 18:15:24 +00:00
Sebastian Redl d457589fc6 Fix some type punning errors in SizeOfAlignOf and Typeid AST nodes. This should satisfy compilers and language lawyers alike.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60511 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 23:17:54 +00:00
Anders Carlsson d26527708b Revert change that made isNullPointerConstant start emitting warnings. We don't want that :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60333 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 06:28:23 +00:00
Anders Carlsson 07b5cc0f40 Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60320 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 02:25:52 +00:00
Anders Carlsson efa9b3877e Add a new variant of isNullConstantExpr that returns an EvalResult.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60318 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 02:13:57 +00:00
Douglas Gregor 2d8b273470 Implement the GNU __null extension
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60235 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 04:51:27 +00:00
Fariborz Jahanian 31afbf02a3 Refactored checking on readonly property into a method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60050 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 21:48:26 +00:00
Fariborz Jahanian 6669db9d80 Patch to allow over-riding of readonly property to
a writable property in one of its category.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60035 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 17:56:43 +00:00
Anders Carlsson c9ad94e12a Remove more #ifdeffed code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60033 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 17:16:39 +00:00
Anders Carlsson e8a32b855c Reimplement Expr::isConstantExpr in terms of Expr::Evaluate. This fixes PR2832.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59946 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 05:23:59 +00:00
Fariborz Jahanian ba8d2d684e Support for implicit property assignment. Error assigning to
'implicit' property with no 'setter'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59878 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 20:25:50 +00:00
Fariborz Jahanian 5daf570d0c New AST node to access "implicit" setter/getter using property dor syntax.
Issuing diagnostics when assigning to read-only properties.
This is work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59874 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 18:39:36 +00:00
Sebastian Redl 4c5d320a75 Implementation of new and delete parsing and sema.
This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59835 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 19:14:01 +00:00
Douglas Gregor 4fcd399a52 Enable some more operator overloading tests, and don't look into an identifier for functions that might not have one
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59818 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 15:30:19 +00:00
Chris Lattner 92e62b0222 Rename IdentifierInfo::isName to ::isStr. Use a nifty trick
from Sebastian to enforce that a literal string is passed in,
and use this to avoid having to call strlen on it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59706 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-20 04:42:34 +00:00
Douglas Gregor 337c6b9f5d Support overloading of the subscript operator[], including support for
built-in operator candidates. Test overloading of '&' and ','.

In C++, a comma expression is an lvalue if its right-hand
subexpression is an lvalue. Update Expr::isLvalue accordingly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59643 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 17:17:41 +00:00
Douglas Gregor 7425373618 Added operator overloading for unary operators, post-increment, and
post-decrement, including support for generating all of the built-in
operator candidates for these operators. 

C++ and C have different rules for the arguments to the builtin unary
'+' and '-'. Implemented both variants in Sema::ActOnUnaryOp.

In C++, pre-increment and pre-decrement return lvalues. Update
Expr::isLvalue accordingly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59638 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 15:42:04 +00:00
Chris Lattner 7e3e9b152e simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 07:55:04 +00:00
Chris Lattner ca354faa7e Implement rdar://6319320: give a good diagnostic for cases where people
are trying to use the old GCC "casts as lvalue" extension.  We don't and
will hopefully never support this.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59460 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 19:51:54 +00:00
Chris Lattner 6ee7aa154e rename Expr::tryEvaluate to Expr::Evaluate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59426 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 21:24:15 +00:00
Douglas Gregor b4609806e9 Add a new expression node, CXXOperatorCallExpr, which expresses a
function call created in response to the use of operator syntax that
resolves to an overloaded operator in C++, e.g., "str1 +
str2" that resolves to std::operator+(str1, str2)". We now build a
CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But
only for binary operators, where we actually implement overloading)

I decided *not* to refactor the current CallExpr to make it abstract
(with FunctionCallExpr and CXXOperatorCallExpr as derived
classes). Doing so would allow us to make CXXOperatorCallExpr a little
bit smaller, at the cost of making the argument and callee accessors
virtual. We won't know if this is going to be a win until we can parse
lots of C++ code to determine how much memory we'll save by making
this change vs. the performance penalty due to the extra virtual
calls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 16:09:21 +00:00
Douglas Gregor bf3af05628 Some cleanup for the implementation of built-in operator
candidates. Thanks to Chris for the review!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59260 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 20:12:29 +00:00
Eli Friedman a6afa768aa Fix for crash issues with comma operators with a void first operand, and
some more bullet-proofing/enhancements for tryEvaluate.  This shouldn't 
cause any behavior changes except for handling cases where we were 
crashing before and being able to evaluate a few more cases in tryEvaluate.
 
This should settle the minor mess surrounding r59196.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 06:09:17 +00:00
Eli Friedman b11e77836d Backout of r59196, plus a new ICE test. Sorry if this is a
little rude; I figure it's cleaner to just back this out now so 
it doesn't get forgotten or mixed up with other checkins.

The modification to isICE is simply wrong; I've added a test that the 
change to isICE breaks.

I'm pretty sure the modification to tryEvaluate is also wrong.  
At the very least, there's some serious miscommunication going on here, 
as this is going in exactly the opposite direction of r59105.  My 
understanding is that tryEvaluate is not supposed to care about side 
effects.  That said, a lot of the clients to tryEvaluate are 
expecting it to enforce a no-side-effects policy, so we probably need 
another method that provides that guarantee.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59212 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 02:13:11 +00:00
Daniel Dunbar dd2b12a032 Fix bug in constant evaluation exposed by 176.gcc.
- Evaluation of , operator used bogus assumption that LHS could be
   evaluated as an integral expression even though its type is
   unspecified.

This change is making isICE very permissive of the LHS in non-evaluated 
contexts because it is not clear what predicate we would use to reject 
code here. The standard didn't offer me any guidance; opinions?


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59196 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 00:03:19 +00:00
Douglas Gregor eb8f306325 Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin

  bool operator==(int const*, int const*)

can be used for the expression "x1 == x2" given:

  struct X {
    operator int const*();
  } x1, x2;

The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it. 

There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.

Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.

As part of this change, ImplicitCastExpr can now be an lvalue.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59148 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 17:17:38 +00:00
Sebastian Redl 0518999d3a Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof expressions, both of values and types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59057 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 17:56:53 +00:00
Sebastian Redl c42e118384 Implement C++ 'typeid' parsing and sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59042 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 11:37:55 +00:00
Douglas Gregor cd9b46e544 Add a new expression class, ObjCSuperExpr, to handle the Objective-C 'super'. Remove ObjCThis from PredefinedExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58698 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-04 14:56:14 +00:00
Douglas Gregor 796da18402 Create a new expression class, CXXThisExpr, to handle the C++ 'this' primary expression. Remove CXXThis from PredefinedExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-04 14:32:21 +00:00
Sebastian Redl 6215dee86c Trivial style fix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58689 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-04 11:45:54 +00:00
Sebastian Redl 0777972d38 Implement semantic checking of static_cast and dynamic_cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58509 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 14:43:28 +00:00
Douglas Gregor 27c8dc06f6 Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:

  - Try/Perform-ImplicitConversion now handles implicit conversions
    that don't involve references.
  - Try/Perform-CopyInitialization uses
    CheckSingleAssignmentConstraints for C. PerformCopyInitialization
    is now used for all argument passing and returning values from a
    function.
  - Diagnose errors with declaring references and const values without
    an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
  
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58353 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29 00:13:59 +00:00
Douglas Gregor 6eec8e883d Rename ExplicitCCastExpr to CStyleCastExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58331 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 15:36:24 +00:00
Douglas Gregor 3c3281742d Replace a dyn_cast with a cast when we know the exact type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58330 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 15:29:51 +00:00
Douglas Gregor 9d293dfc0a Improve our handling of (C++) references within Clang. Specifically:
- Do not allow expressions to ever have reference type
  - Extend Expr::isLvalue to handle more cases where having written a
    reference into the source implies that the expression is an lvalue
    (e.g., function calls, C++ casts).
  - Make GRExprEngine::VisitCall treat the call arguments as lvalues when
    they are being bound to a reference parameter.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 00:22:11 +00:00
Douglas Gregor 49badde06e Refactor the expression class hierarchy for casts. Most importantly:
- CastExpr is the root of all casts
  - ImplicitCastExpr is (still) used for all explicit casts
  - ExplicitCastExpr is now the root of all *explicit* casts
  - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++
  - CXXFunctionalCastExpr inherits from ExplicitCastExpr
  - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all
    of the C++ named cast expression types (static_cast, dynamic_cast, etc.)
  - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, 
    CXXReinterpretCastExpr, and CXXConstCastExpr to 

Also, fixed returned-stack-addr.cpp, which broke once when we fixed
reinterpret_cast to diagnose double->int* conversions and again when
we eliminated implicit conversions to reference types. The fix is in
both testcase and SemaChecking.cpp.

Most of this patch is simply support for the renaming. There's very
little actual change in semantics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58264 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27 19:41:14 +00:00
Ted Kremenek ce2fc3a343 - Move ExprIterator to Stmt.h so that it can be used by classes defined in Stmt.h
- Implement child_begin() and child_end() for AsmStmt.  Previously these had stub implementations that did not iterate over the input/output operands of an inline assembly statement.
- Use ExprIterator for performing iteration over input/output operands.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58261 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27 18:40:21 +00:00
Chris Lattner 418f6c7d14 Remember whether an initlist had a designator in the AST.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58218 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-26 23:43:26 +00:00
Daniel Dunbar ac620decb6 PR2919: __builtin_types_compatible_p strips CRV qualifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58079 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24 08:07:57 +00:00
Argyrios Kyrtzidis 90b7bc6751 Now that DeclRefExpr accepts a NamedDecl, use a DeclRefExpr for when a CXXFieldDecl is referenced inside a method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58000 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 21:00:29 +00:00
Douglas Gregor ba7e210a99 QualType::isMoreQualifiedThan and isAtLeastAsQualifiedAs assert that we
aren't trying to compare with address-space qualifiers (for now).

Clean up handing of DeclRefExprs in Expr::isLvalue and refactor part
of the check into a static DeclCanBeLvalue.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57980 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 15:04:37 +00:00
Douglas Gregor ae8d467e75 Functions can be lvalues in C++, but not modifiable lvalues
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57941 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 00:03:08 +00:00
Douglas Gregor 98cd599ee8 Initial step toward supporting qualification conversions (C++ 4.4).
Changes:
  - Sema::IsQualificationConversion determines whether we have a qualification
    conversion.
  - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++,
    performing an implicit conversion from the right-hand side to the type of
    the left-hand side rather than checking based on the C notion of 
    "compatibility". We now rely on the implicit-conversion code to
    determine whether the conversion can happen or
    not. Sema::TryCopyInitialization has an ugly reference-related
    hack to cope with the initialization of references, for now.
  - When building DeclRefExprs, strip away the reference type, since
    there are no expressions whose type is a reference. We'll need to
    do this throughout Sema.
  - Expr::isLvalue now permits functions to be lvalues in C++ (but not
  in C).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57935 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21 23:43:52 +00:00
Dale Johannesen ee5a700af3 Adjust calls to APFloat conversion for new interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57332 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-09 23:02:32 +00:00
Steve Naroff 56ee6896f2 - Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.

This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?).

Still some follow-up work to finish this (forthcoming).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57298 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-08 17:01:13 +00:00
Ted Kremenek 8a213de1a8 A little more tweaking with StmtIterator and SizeOfAlignofExpr. A recent commit actually introduced a regression, not fixed a bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57282 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 23:35:42 +00:00
Ted Kremenek b84887d99d Fixed a masked bug when iterating over the child expressions of SizeOfAlignOfTypeExpr. This bug was unmasked by recent changes to StmtIterator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57273 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 23:07:10 +00:00
Chris Lattner 45b6b9d080 Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExpr
which is checking for something that can be inconsistent with
what we can constant fold.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57159 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 06:49:02 +00:00
Chris Lattner a4d55d89c8 Move folding of __builtin_classify_type out of the CallExpr
interface into the constant folding interface.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57158 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 06:40:35 +00:00
Chris Lattner 019f4e858e Add a comment that describes tryEvaluate. Make tryEvaluate fold
__builtin_constant_p properly, and add some scaffolding for
FloatExprEvaluator to eventually handle huge_val and inf.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57152 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:28:25 +00:00
Chris Lattner cb88896740 add a new CallExpr::isBuiltinCall() method, and use it to simplify some existing
code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57151 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:00:53 +00:00
Chris Lattner a62a03b282 a more efficient test for __builtin_classify_type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57149 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 04:48:17 +00:00
Daniel Dunbar ae3f4919e4 Add Builtins.def attribute for "can be a constant expression".
- Enabled for builtins which are always constant expressions
   (__builtin_huge_val*, __builtin_inf*, __builtin_constant_p,
   __builtin_classify_type, __builtin___CFStringMakeConstantString).

Added Builtin::Context::isConstantExpr.
 - Currently overly simply interface which only works for builtins
   whose constantexprness does not depend on their arguments.

CallExpr::isBuiltinConstantExpr now takes an ASTContext argument.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56983 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-02 23:30:31 +00:00
Ted Kremenek 9da13f9ddb Internally store the body of a BlockExpr using a Stmt* instead of a CompoundStmt*, and use the getBody() method to do the appropriate checking. This both removes the type-punning warnings in Expr.cpp and also makes BlockExpr have more consistency checks against modifications to its body (via StmtIterator).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 23:24:14 +00:00
Steve Naroff 4f6a7d7ead Tweak Expr::isModifiableLvalue() and Expr::isLvalue() to better deal with BlockDeclRef exprs.
This fixes <rdar://problem/6248392> clang: Error when using address of stack variable inside block.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56652 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 14:41:28 +00:00
Daniel Dunbar e1226d24d2 Bug fix, result of isIntegerConstantExpr could be of incorrect width
for type.
  - PR2817


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56482 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-22 23:53:24 +00:00
Steve Naroff 9c3c902835 Remove BlockStmtExpr.
Block literals are now represented by the concrete BlockExpr class.
This is cleanup (removes a FIXME).
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56288 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-17 18:37:59 +00:00
Steve Naroff 17dab4f616 Remove support for BlockExprExpr. For example...
^(expression) or ^(int arg1, float arg2)(expression)
...is no longer supported. 
All block literals now require a compound statement.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56257 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-16 23:11:46 +00:00
Argyrios Kyrtzidis 24b41fa823 CXXConditionDeclExpr expression node is an lvalue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56093 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 04:22:26 +00:00
Steve Naroff dd972f20dc More type checking for blocks. Still incomplete (will hopefully finish up this weekend).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55862 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 22:11:13 +00:00
Steve Naroff bfdcae678d Fix a handful of typos (closure->block) to avoid confusion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55768 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04 15:31:07 +00:00
Steve Naroff 4eb206bebc Add semantic analysis for "blocks".
Highlights...

- 4 new AST nodes, BlockExpr, BlockStmtExpr, BlockExprExpr, BlockDeclRefExpr.
- Sema::ActOnBlockStart(), ActOnBlockError(), ActOnBlockStmtExpr(), ActOnBlockExprExpr(), ActOnBlockReturnStmt().

Next steps...

- hack Sema::ActOnIdentifierExpr() to deal with block decl refs.
- add attribute handler for byref decls.
- add test cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 18:15:37 +00:00
Daniel Dunbar aa1f9f1d50 Fix isIntegerConstantExpr eval of __builtin_offsetof to return result
with correct width.
 - PR2728.

Also, fix PR2727 test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55493 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-28 18:42:20 +00:00
Daniel Dunbar 9048891ff9 Fix double-free error with sizeof applied to VLA types.
- PR2727.

Also, fix warning in CodeGenTypes for new BlockPointer type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55479 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-28 18:02:04 +00:00
Anders Carlsson 2ea2b5e2b0 Handle emitting __builtin_huge_valf as a constant expr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55299 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-25 03:27:15 +00:00
Anders Carlsson b88d45ea7e treat bool literals as constatnt expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55255 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 21:12:35 +00:00
Argyrios Kyrtzidis 7267f7832e Add CodeGen support for CXXZeroInitValueExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55249 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 19:35:47 +00:00
Anders Carlsson 15425f9d2d Handle AddrLabelExprs in Expr::isConstantExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55245 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 18:49:32 +00:00
Argyrios Kyrtzidis 987a14bf58 Add support for C++'s "type-specifier ( expression-list )" expression:
-The Parser calls a new "ActOnCXXTypeConstructExpr" action.
-Sema, depending on the type and expressions number:
   -If the type is a class, it will treat it as a class constructor. [TODO]
   -If there's only one expression (i.e. "int(0.5)" ), creates a new "CXXFunctionalCastExpr" Expr node
   -If there are no expressions (i.e "int()" ), creates a new "CXXZeroInitValueExpr" Expr node.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55177 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 15:38:55 +00:00
Argyrios Kyrtzidis 0835a3cdee Add ExplicitCastExpr to replace the current CastExpr, and have ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr):
Expr
  -> CastExpr
     -> ExplicitCastExpr
     -> ImplicitCastExpr 

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54955 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-18 23:01:59 +00:00
Daniel Dunbar 32442bbc98 Update some isIntegerConstantExpr uses to use
getIntegerConstantExprValue where appropriate.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54771 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13 23:47:13 +00:00
Daniel Dunbar acc5f3e423 More #include cleaning
- Kill unnecessary #includes in .cpp files. This is an automatic
   sweep so some things removed are actually used, but happen to be
   included by a previous header. I tried to get rid of the obvious
   examples and this was the easiest way to trim the #includes in one
   fell swoop.
 - We now return to regularly scheduled development.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 06:23:49 +00:00
Daniel Dunbar c4a1dea2dc More #include cleaning
- Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h
 - Moved Sema::getCurMethodDecl() out of line (dependent on
   ObjCMethodDecl via dyn_cast).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54629 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 05:35:13 +00:00
Daniel Dunbar e91593ef08 More #include cleaning
- Drop Expr.h,RecordLayout.h from ASTContext.h (for DeclBase.h and
   SourceLocation.h)
 - Move ASTContext constructor into implementation


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54627 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 04:54:23 +00:00
Steve Naroff 76de9d7a32 Cleanup ObjCSuperRefExpr (remove last usage and AST node:-).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54617 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 19:10:41 +00:00
Chris Lattner d9f6910f4e rename PreDefinedExpr -> PredefinedExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54605 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 01:53:14 +00:00
Eli Friedman 355aba8d7c Remove the ICE pointer cast hack; the issue this was working around is
now fixed in an alternate way.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54598 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-09 22:24:21 +00:00
Chris Lattner c63a1f276f Finally fix PR2189. This makes a fairly invasive but important change to
move getAsArrayType into ASTContext instead of being a method on type.
This is required because getAsArrayType(const AT), where AT is a typedef
for "int[10]" needs to return ArrayType(const int, 10).

Fixing this greatly simplifies getArrayDecayedType, which is a good sign.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54317 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-04 07:31:14 +00:00
Chris Lattner 28be73f74c convert more code to use ASTContext to get canonical types instead
of doing it directly.  This is required for PR2189.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54102 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 21:30:36 +00:00
Chris Lattner 611b2eccaf fix some problems handling stmtexprs with labels (PR2374), and
improve 'expression unused' diagnostics for stmtexprs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54098 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 19:51:01 +00:00
Chris Lattner 7c4a191d8b fix 80 col violation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54075 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-25 23:30:42 +00:00
Chris Lattner baf0d66784 Add support for __extension__ as an lvalue. rdar://6097308
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54033 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-25 18:07:19 +00:00
Ted Kremenek 5a56ac30d0 Added UnaryOperator::isPrefix().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53963 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-23 22:18:43 +00:00
Nuno Lopes 5f6b632391 revert my bogus attempt to fix the comment. sorry for the noise.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53248 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-08 21:13:06 +00:00
Nuno Lopes 9a979c327c fix CheckForConstantInitializer() for Compound Literals
also fix the correspondent test (it was expecting more errors than it should. please confirm my fix is correct (at least gcc agrees with me)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53174 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 16:46:50 +00:00
Anders Carlsson c44eec6dd2 Shuffle things around in preparation for integrating Eli's constant evaluator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53074 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 04:20:39 +00:00
Argyrios Kyrtzidis 07952324dd Add Sema support for C++ classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52956 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-01 10:37:29 +00:00
Ted Kremenek 4df728e368 ObjCMessageExpr objects that represent messages to class methods now can contain the ObjCInterfaceDecl* of the target class if it was available when the ObjCMessageExpr object was constructed. The original interfaces of the class has been preserved (requiring no functionality changes from clients), but now a "getClasSInfo" method returns both the ObjCInterfaceDecl* and IdentifierInfo* of the target class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52676 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 15:50:53 +00:00
Chris Lattner 4111024be8 Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.
Patch by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52422 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 18:05:57 +00:00
Ted Kremenek 5549976193 This patch is motivated by numerous strict-aliasing warnings when compiling
clang as a Release build.

The big change is that all AST nodes (subclasses of Stmt) whose children are
Expr* store their children as Stmt* or arrays of Stmt*. This is to remove
strict-aliasing warnings when using StmtIterator. None of the interfaces of any
of the classes have changed (except those with arg_iterators, see below), as the
accessor methods introduce the needed casts (via cast<>). While this extra
casting may seem cumbersome, it actually adds some important sanity checks
throughout the codebase, as clients using StmtIterator can potentially overwrite
children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts
provide extra sanity checks that are operational in debug builds to catch
invariant violations such as these.

For classes that have arg_iterators (e.g., CallExpr), the definition of
arg_iterator has been replaced. Instead of it being Expr**, it is an actual
class (called ExprIterator) that wraps a Stmt**, and provides the necessary
operators for iteration. The nice thing about this class is that it also uses
cast<> to type-checking, which introduces extra sanity checks throughout the
codebase that are useful for debugging.

A few of the CodeGen functions that use arg_iterator (especially from
OverloadExpr) have been modified to take begin and end iterators instead of a
base Expr** and the number of arguments. This matches more with the abstraction
of iteration. This still needs to be cleaned up a little bit, as clients expect
that ExprIterator is a RandomAccessIterator (which we may or may not wish to
allow for efficiency of representation).

This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c,
which was already broken) on both a Debug and Release build, but it should
obviously be reviewed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52378 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 02:43:46 +00:00
Chris Lattner da8249e57f Fix ast dumping to work with long double literals, e.g. we dump:
long double X() { return 1.0L; }

as:

long double X()
(CompoundStmt 0xb06a00 <t.c:2:17, col:32>
  (ReturnStmt 0xb068d0 <col:19, col:26>
    (FloatingLiteral 0xb02cf0 <col:26> 'long double' 1.000000)))




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52080 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-07 22:13:43 +00:00
Steve Naroff c793808539 Put back my temporary hack until Eli addresses this in a more complete fashion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51920 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 22:06:04 +00:00
Eli Friedman 1b76ada683 Re-fix r51907 in a way which doesn't affect valid code. This essentially
moves the check for the invalid construct to a point where it doesn't 
affect other uses of isIntegerConstantExpr, and we can warn properly 
when the extension is used.  This makes it a bit more complicated, but 
it's a lot cleaner.

Steve, please tell me if this check is sufficient to handle the 
relevant system header.  I know it's enough to handle the testcase, but 
I don't know what exactly the original looks like.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51918 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 21:01:11 +00:00
Steve Naroff a2ac06e964 Change Expr::isIntegerConstantExpr() to allow for pointer types (for GCC compatibility). Note FIXME.
Fix <rdar://problem/5977870> clang on xcode: error: arrays with static storage duration must have constant integer length


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51907 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 17:15:29 +00:00
Steve Naroff e3e9add4fd Fix <rdar://problem/5979875> clang on xcode: error: use of undeclared identifier 'super'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51888 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-02 23:03:37 +00:00
Steve Naroff 799a6a6850 Teach Expr::isLvalue() about ObjC properties. For now, all properties are writable. Added a FIXME for another day.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51800 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 23:23:16 +00:00
Steve Naroff ae7840776d Add basic support for properties references (a missing feature).
While it is far from complete, it does fix the following <rdar://problem/5967199> clang on xcode: error: member reference is not to a structure or union



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51719 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 00:40:33 +00:00
Steve Naroff f494b579b2 - Move ObjC Expresssion AST's from Expr.h => ExprObjC.h
- #include ExprObjC.h in many places


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51703 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 21:12:08 +00:00
Eli Friedman 211f6adf13 Assume statement expressions have side effects; this gets rid of a lot
of extra warnings in the Python source.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51594 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 15:24:04 +00:00
Dan Gohman 4f8d123e3e Move getAccessedFieldNo out of lib/AST/Expr.cpp into
lib/CodeGen/CGExpr.cpp and to change include/clang/AST/Attr.h to
use its own enum for visibility types instead of using
llvm::GlobalValue::VisibilityTypes. These changes eliminate
dependencies in the AST library on LLVM's VMCore library.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-22 00:50:06 +00:00
Dan Gohman e1b6d5084e Remove the unneeded #include of VMCore header "llvm/DerivedTypes.h".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51392 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-21 20:26:42 +00:00
Eli Friedman 4be1f47de2 Make the unused expression warning a bit less aggressive (found in PHP
code).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51276 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 21:24:43 +00:00
Eli Friedman 861dc46e3c Minor cleanup to isBuiltinConstantExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51188 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16 13:28:37 +00:00
Ted Kremenek 774e4af13a Removed bogus "return true" in Expr::isConstantExpr that returned true for all
expressions. This appears to be a regression introduced in r51113 that caused
many test cases to fail (there is still a test case in the Analysis directory
that is failing):

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080512/005706.html


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51164 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-15 21:49:04 +00:00
Eli Friedman d38617c8a5 Implementation of __builtin_shufflevector, a portable builtin capable of
expressing the full flexibility of the LLVM shufflevector instruction.  
The expected immediate usage is in *mmintrin.h, so that they don't 
depend on the mess of gcc-inherited (and not completely implemented)
shuffle builtins.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51113 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-14 19:38:39 +00:00
Nate Begeman 3b8d116703 Remove AST dependency on VMCore by switching ExtVectorElementExpr off Constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51068 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-13 21:03:02 +00:00
Nate Begeman 8a99764f9b Extend vector member references to include {.hi, .lo, .e, .o} which return a
vector of the same element type and half the width, with the high, low, even,
and odd elements respectively.

Allow member references to member references, so that .hi.hi gives you the high
quarter of a vector.  This is fairly convenient syntax for some insert/extract
operations.

Remove some unnecessary methods/types in the ExtVectorElementExpr class.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50892 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 06:41:27 +00:00
Steve Naroff 1a42a2550a Fixup InitListExpr::child_begin/end. Thanks to Ted for catching the regression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50816 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-07 17:35:03 +00:00
Steve Naroff 81e72e4c23 Fix off-by-one error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50815 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-07 16:50:14 +00:00
Ted Kremenek 9226197183 Fixed bug in ObjCIVarExpr: the child iterator now iterates over the Base expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50585 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-02 18:40:22 +00:00
Ted Kremenek ea958e57a3 Use pointer swizziling to unify in ObjCMessageExpr the receiver and classname "fields". This saves us a pointer.
Implemented serialization for ObjCMessageExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50528 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 17:26:20 +00:00
Steve Naroff c5ae899b4b Extend InitListExpr API/IMPL to support arbitrary add/remove (in support of the initializer rewrite I am doing).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50511 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 02:04:18 +00:00