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

282 Коммитов

Автор SHA1 Сообщение Дата
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