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

1107 Коммитов

Автор SHA1 Сообщение Дата
Argyrios Kyrtzidis 73a0d889ed Implement support for C++ direct initializers in declarations, e.g. "int x(1);".
This is how this kind of initializers appear in the AST:
-The Init expression of the VarDecl is a functional type construction (of the VarDecl's type).
-The new VarDecl::hasCXXDirectInitializer() returns true.

e.g, for "int x(1);":
-VarDecl 'x' has Init with expression "int(1)" (CXXFunctionalCastExpr).
-hasCXXDirectInitializer() of VarDecl 'x' returns true.

A major benefit is that clients that don't particularly care about which exactly form was the initializer can handle both cases without special case code.
Note that codegening works now for "int x(1);" without any changes to CodeGen.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 17:10:33 +00:00
Chris Lattner 4bf203c91f fix incorrect rdar number.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57165 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 07:43:28 +00:00
Chris Lattner eb52b44caf __CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
won't expand to the builtin.  This fixes rdar://6248329



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57164 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 07:43:09 +00:00
Chris Lattner 506ff88f44 Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue.  Implement this in codegen by moving the code out of CGBuiltin
into EmitConstantExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57163 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 07:26:43 +00:00
Chris Lattner 46cfefa8a4 "Enhance" CheckArithmeticConstantExpression to accept ?: with a constant
condition as a constant even if the unevaluated side is a not a constant.
We don't do this when extensions are off, and we emit a warning when this 
happens:

t.c:22:11: warning: expression is not a constant, but is accepted as one by GNU extensions
short t = __builtin_constant_p(5353) ? 42 : somefunc();
          ^                                 ~~~~~~~~~~

suggestions for improvement are welcome.  This is obviously horrible, but
is required for real-world code.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57153 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:42:39 +00:00
Argyrios Kyrtzidis e25d270b4d Allow variadic arguments without named ones for C++, e.g. "void(...);"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57143 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 00:07:55 +00:00
Argyrios Kyrtzidis d3dbbb68b1 Add some text from the C++ standard and additional ambiguity resolution tests.
No funcitonality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57136 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 21:10:08 +00:00
Argyrios Kyrtzidis 78c8d80f19 Handle ambiguities between expressions and type-ids that occur inside parentheses, e.g.:
sizeof(int()) -> "int()" is type-id
sizeof(int()+1) -> "int()+1" is expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57131 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 19:56:22 +00:00
Argyrios Kyrtzidis b9f341916e Found a subtle bug caused by an implicit enum-to-bool conversion (of the TentativeParsingResult enum).
This was the motivation of the following changes:

-'TentativeParsingResult' enum is replaced by a 'TPResult' class that basically encapsulates the enum.
-TPR_true, TPR_false, TPR_ambiguous, and TPR_error enum constants are replaced by TPResult::True(), TPResult::False(), etc. calls that return a TPResult object.
-Also fixed the subtle bug in Parser::isCXXFunctionDeclarator (caught by the above changes as a compilation error).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57125 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 18:52:21 +00:00
Anders Carlsson 770918281c Add parsing of the sentinel attribute. Still need to create the attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57121 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 18:05:59 +00:00
Argyrios Kyrtzidis bbc70c019f Disambiguate between a declaration or an expression, in the 'for-init-statement' part of a 'for' statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57112 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 15:50:46 +00:00
Argyrios Kyrtzidis ca35baa788 Fix Parser::isCXXConditionDeclaration to properly resolve declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57111 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 15:19:49 +00:00
Argyrios Kyrtzidis a8a4598b6f Disambiguate between a declaration or expression for the 'condition' part of a if/switch/while/for statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57109 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 15:03:47 +00:00
Argyrios Kyrtzidis 1ee2c43bc0 Consider GNU attributes when doing ambiguity resolution.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57108 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 14:27:18 +00:00
Daniel Dunbar eb15425409 Add X86 builtin code generation test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57104 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 06:38:36 +00:00
Daniel Dunbar ea7a31fe21 Improve C language testing coverage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57103 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 06:36:33 +00:00
Daniel Dunbar 1768a6242a Add some builtins to codegen test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57101 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 06:34:45 +00:00
Daniel Dunbar 5186906067 Add -rewrite-macros test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57094 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 01:39:04 +00:00
Daniel Dunbar a6f6c71cf7 Coverage test for targets.
- This pushes us over 80% coverage of executable LOC.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57092 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 01:04:25 +00:00
Daniel Dunbar 075e3c1c38 Improve codegen coverage tests.
- Hit debug info generation.
 - Hit both ObjC runtimes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57088 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 00:31:54 +00:00
Argyrios Kyrtzidis 9173e91787 Append the test runs with '&&'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57085 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 00:08:56 +00:00
Argyrios Kyrtzidis 5404a156be Resolve ambiguous C++ statements (C++ 6.8p1).
'ParseTentative.cpp' implements the functionality needed to resolve ambiguous C++ statements, to either a declaration or an expression, by "tentatively parsing" them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57084 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 00:06:24 +00:00
Daniel Dunbar 417dd179b2 Add coverage tests of C and Obj-C language features.
- AST printing, dumping, serialization, codegen.
 - HTML printing.
 - Parser callbacks.

Several of these are XFAIL because they trigger unimplemented code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57081 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 23:47:28 +00:00
Daniel Dunbar b7219f8238 Desensitize env-include-paths.c to the directory it is running in.
- It would probably be better if TestRunner.sh canonicalized this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57075 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 21:05:04 +00:00
Daniel Dunbar bb95255e08 Bug fix, CPATH="" does not add '.' to search path.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57072 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 20:58:18 +00:00
Daniel Dunbar ae3c16cc54 Add test/Driver.
- env-include-paths.c is XFAIL as it exposed a bug.

Add test/Coverage.
 - For tests which achieve code coverage but don't validate anything.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57070 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 20:46:41 +00:00
Daniel Dunbar f7a726b5f2 De-XFAIL test/Parser/pragma-pack.c
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57069 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 19:45:56 +00:00
Chris Lattner 7499cb59f0 switch to using -verify
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57068 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 19:43:25 +00:00
Chris Lattner 4f2670d827 Move the expected-warning lines to a place that clang -verify will pick them
up.  Speculatularly hacktastic, but strangely beautiful?
Daniel, lines 20/21 are rejected, please investigate.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57067 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 19:38:15 +00:00
Daniel Dunbar fcdd8fe26d Add Parser support for #pragma pack
- Uses Action::ActOnPragmaPack
 - Test case is XFAIL pending verifier fixes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57066 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 19:21:03 +00:00
Daniel Dunbar 7d076643e7 Merge postfix attributes on record decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57019 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 17:33:35 +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
Daniel Dunbar de45428f92 Add support for format string checking of object-size checking
versions of sprintf and friends.
 - Added FIXME that this mechanism should be generalized.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56962 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-02 18:44:07 +00:00
Steve Naroff 8af6a451ea Changed Sema::CheckForConstantInitializer to allow global block literals.
This commit also includes some name changes in the blocks rewriter (no functionality change).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56955 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-02 17:12:56 +00:00
Ted Kremenek cc9ac41ac0 Enhance NSError** checking with analogous checking for CFErrorRef*.
Expand checking to include functions, not just methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56938 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-01 23:24:09 +00:00
Ted Kremenek 9f67edeff2 Added test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56915 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-01 05:05:46 +00:00
Daniel Dunbar ad2dc71a6f NeXT: Update to use CreateRuntimeFunction for the routines it imports.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56902 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-01 01:06:06 +00:00
Steve Naroff 037cda5282 Fix <rdar://problem/6191148> [sema] Objective-C method lookup (at global scope) fails to handle overloaded selectors properly.
Long standing bug in Sema::ActOnInstanceMessage(). We now warn when messaging an "id" with multiple method signatures in scope. The diags are a little verbose, however they can be streamlined if necessary. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56843 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-30 14:38:43 +00:00
Nuno Lopes 33e2c5f8b5 fix test for latest changes in llvm asm representation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56842 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-30 14:37:33 +00:00
Chris Lattner f77d545fe9 Fix va_arg handling to do argument decaying at the correct place. This
fixes problems handling references of va_list, which happens on x86_64.
This fixes PR2841 and rdar://6252231


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56809 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 22:28:25 +00:00
Steve Naroff b440686eee Teach Sema::CheckAssignmentConstraints() to allow assignments between id and block pointer types (^{}).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56793 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 18:10:17 +00:00
Steve Naroff 6c4088e5fc Fix <rdar://problem/6251012> clang: Blocks are objects too.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56791 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 16:51:41 +00:00
Steve Naroff 5e0a74fbf4 Fix <rdar://problem/6253149> property declaration doesn't declare getter and setter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56785 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 14:20:56 +00:00
Steve Naroff e84a864a78 Fix <rdar://problem/6252129> implementation of method in category doesn't effectively declare it for methods below.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56771 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 14:55:53 +00:00
Steve Naroff ae530cfaf6 Fix <rdar://problem/6252108> assigning to argument passed to block should not require __block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56770 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 14:02:55 +00:00
Chris Lattner 891ed9aa87 Fix rdar://6252231 - cannot call vsnprintf with va_list on x86_64,
by decaying __builtin_va_list's type when forming builtins.  On
x86-64 (and other targets) __builtin_va_list is a typedef for
an array.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56768 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 06:05:35 +00:00
Chris Lattner f7037b1c3b Fix rdar://6251437, references to enum constant decls in a block
don't need a BlockDeclRefExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56766 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 05:30:26 +00:00
Steve Naroff 59f5394648 Fix <rdar://problem/6252216> compare block to NULL.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56764 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 01:11:11 +00:00
Steve Naroff 538afe30e4 Fix <rdar://problem/6252226> parser thinks block argument is undefined identifier in NSServices.m
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56761 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 00:13:36 +00:00
Daniel Dunbar 0cb45f6ea7 Remove automagic substitution of %llvmgcc
- Is unused and somewhat unreliable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56737 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-27 00:47:03 +00:00