Commit Graph

2818 Commits

Author SHA1 Message Date
Chris Lattner d8d18d561e add codegen support for global inits that require array decay.
llvm-svn: 44511
2007-12-02 07:30:13 +00:00
Chris Lattner d45aa2a03b warn about unhandled initializers instead of crashing on them.
llvm-svn: 44510
2007-12-02 07:19:18 +00:00
Chris Lattner 5bcdf24a50 Handle global variable definitions which change the type of a definition, such as:
extern int x[];
void foo() { x[0] = 1; }
int x[10];
void bar() { x[0] = 1; }

llvm-svn: 44509
2007-12-02 07:09:19 +00:00
Chris Lattner c48023bd5b remove the alloca insertion point inst, which is an internal helper.
llvm-svn: 44508
2007-12-02 06:32:24 +00:00
Chris Lattner 6d27513f6e merge the llvm global variable when there are multiple C decls.
llvm-svn: 44507
2007-12-02 06:30:46 +00:00
Chris Lattner 41af8182d8 implement codegen for functions whose function body type don't match
their prototype.

llvm-svn: 44506
2007-12-02 06:27:33 +00:00
Chris Lattner c5b3aab66b merge functions with multiple function decls if they have the same name.
llvm-svn: 44505
2007-12-02 05:56:05 +00:00
Chris Lattner e15d0dd63f Teach clang the prototype for __builtin_alloca.
llvm-svn: 44504
2007-12-02 05:42:36 +00:00
Chris Lattner f0780fae43 convert the rest of the stderr users in codegen to use diagnostics.
llvm-svn: 44503
2007-12-02 01:49:16 +00:00
Chris Lattner fc94434faf move unsupported warning into a centralized place.
llvm-svn: 44502
2007-12-02 01:43:38 +00:00
Chris Lattner c8dbe1e5d6 Warn about unsupported codegen with the diags machinery, giving us:
t.c:3322:5: warning: cannot codegen this yet
    __asm__ ("bswap   %0" : "+r" (_data));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

instead of:

Unimplemented stmt!
(AsmStmt 0x80eaa0 <t.c:3331:5, line:3334:28>)

llvm-svn: 44501
2007-12-02 01:40:18 +00:00
Chris Lattner 963540dc28 register clz and ctz builtins.
llvm-svn: 44500
2007-12-02 01:20:23 +00:00
Chris Lattner f3a59a1fb8 fix a crash when the rewriter would scan off the beginning of the file.
llvm-svn: 44499
2007-12-02 01:13:47 +00:00
Chris Lattner e6535cfdd2 add support for custom client-specific diagnostics. As a testcase, make the
rewriter emit this error if it fails to rewrite an @encode:

t.m:17:9: error: rewriter could not replace sub-expression due to macros
    c = ENC(char *)[2] + 4;
        ^~~~~~~~~~~

... where ENC is: #define ENC @encode

llvm-svn: 44498
2007-12-02 01:09:57 +00:00
Oliver Hunt a96fe8d5c5 Add support for __builtin_expect which is needed for assert,
among other things.

Also change a codegen warning to dump to stderr so it doesn't
mess with -emit-llvm output

llvm-svn: 44497
2007-12-02 01:03:24 +00:00
Chris Lattner 9724ce12f9 improve VC++ compatibility, patch by Cédric Venet.
llvm-svn: 44496
2007-12-02 00:47:03 +00:00
Oliver Hunt aefc8fd415 Support initalisers for more than just int-typed static variables.
We now use the CodeGenModule logic for generating the constant 
initialiser expression, so happily further initialiser fixes should 
automatically work for statics as well.

llvm-svn: 44495
2007-12-02 00:11:25 +00:00
Fariborz Jahanian 9fac54d881 Compute side-effect for conditional expression.
llvm-svn: 44492
2007-12-01 19:58:28 +00:00
Chris Lattner 53efb14795 Add #include, patch by Cédric Venet
llvm-svn: 44491
2007-12-01 18:59:50 +00:00
Christopher Lamb 7d303b2a20 Better match llvm-gcc's behavior for CodeGen naming of anonymous structs and unions.
llvm-svn: 44490
2007-12-01 09:20:34 +00:00
Christopher Lamb b0e6094a22 When generating the CodeGen type name of a struct, union, enum use the typedef
name if a tag type name is not available for the type. This matches how llvm-gcc 
chooses CodeGen type names.

This means that "typedef struct {...} foo" now results in a CodeGen name of 
"struct.foo" rather than "struct."

llvm-svn: 44489
2007-12-01 09:08:41 +00:00
Seo Sanghyeon 34f92ace1f Test commit
llvm-svn: 44488
2007-12-01 08:06:07 +00:00
Chris Lattner ae7a834e74 make the unused expression warning less noisy by not warning about comma exprs whose
LHS and RHS both have side effects.

llvm-svn: 44486
2007-12-01 06:07:34 +00:00
Chris Lattner e69d662bae simplify some code, add support for functions without a proto
llvm-svn: 44485
2007-12-01 05:58:21 +00:00
Chris Lattner 9e137aad78 fix a couple switch codegen problems Oliver reported.
llvm-svn: 44484
2007-12-01 05:27:33 +00:00
Ted Kremenek 3e14c152c6 Fixed bug in the serialization of SelectorTable where we did not register the
pointer of MultiKeywordSelectors.

Added optimization to the serialization of SelectorTable where we only serialize
out MultiKeywordSelectors that are ever referenced by an object other than the
SelectorTable.

llvm-svn: 44483
2007-12-01 04:43:17 +00:00
Chris Lattner 4431a1b19b start partitioning the diagnostics into two classes: those
that are builtin and those that are aren't.  This is a bunch
of API refactoring that will make this possible, but there is
no functionality change yet.

llvm-svn: 44473
2007-11-30 22:53:43 +00:00
Anders Carlsson 7a9a38abe0 String literals are always valid LValues.
llvm-svn: 44472
2007-11-30 22:47:59 +00:00
Ted Kremenek c9bcda94ae Implemented serialization of SelectorTable and Selectors.
Modified serialization of IdentifierTable to self-register itself with
the Deserializer.

llvm-svn: 44471
2007-11-30 22:46:56 +00:00
Chris Lattner e9c810c87c pass diagnostics into the rewrite test client.
llvm-svn: 44468
2007-11-30 22:25:36 +00:00
Anders Carlsson 3b754452eb Initialize CurMethodDecl to 0.
llvm-svn: 44463
2007-11-30 20:01:38 +00:00
Anders Carlsson 801c5c7467 GCC has an extension where the left hand side of the ? : operator can be omitted. Handle this in a few more places.
llvm-svn: 44462
2007-11-30 19:04:31 +00:00
Anders Carlsson 452815a6b2 Initialize LaxVectorConversions.
llvm-svn: 44459
2007-11-30 18:29:41 +00:00
Chris Lattner 1386de8757 fix a bug handling typedefs in member expr codegen. Patch
by Seo Sanghyeon

llvm-svn: 44455
2007-11-30 18:02:19 +00:00
Chris Lattner b6a7b582ee Fix a codegen crash on void ?: reported by Oliver
llvm-svn: 44454
2007-11-30 17:56:23 +00:00
Chris Lattner aa0b570dfb Support fully general case expressions, patch by Sanghyeon Seo!
llvm-svn: 44453
2007-11-30 17:44:57 +00:00
Christopher Lamb 0112f62bb9 Doh! Check in this long overdue test fix.
llvm-svn: 44450
2007-11-30 06:35:48 +00:00
Anders Carlsson e1af1d20ef Support lax vector conversions.
llvm-svn: 44449
2007-11-30 04:21:22 +00:00
Steve Naroff 205ec3d07a Yesterday, I simplified how we stream top-level decls.
After a discussion with Ted, we both came to the conclusion that adding a "HandleTopLevelDeclaration" hook to ASConsumer is far more elegant. The default implementation of HandleTopLevelDeclaration will be responsible for iterating over the ScopedDecl (which has a chain of the decls:-).

TODO: Once Ted adds HandleTopLevelDeclaration, make sure TagDecls are chainged appropriately...
llvm-svn: 44445
2007-11-29 23:05:20 +00:00
Ted Kremenek bfcf8cdbd7 Added method "HandleTopLevelDeclaration" to ASTConsumer. This will eventually
be the new hook that ASTStreamer calls to feed top-level Decls to
ASTConsumers.

The difference between "HandleTopLevelDeclaration" and "HandleTopLevelDecl" is
that "HandleTopLevelDecl" is currently called by ASTStreamer for every
top-level declaration, including those that appear within a Decl chain. Using
the new interface, ASTStreamer would only call HandleTopLevelDeclaration for
Decls that appear that the beginning of a Decl chain (i.e., a group of related
decls).

To preserve the behavior that all subclasses of ASTConsumer currently expect,
the default implementation of HandleTopLevelDeclaration simply calls
HandleTopLevelDecl, and for decl chains it calls HandleTopLevelDecl for each
Decl* in a chain of Decls.

The advantage of this interface is that some subclasses of ASTConsumer only
really want the Decl chain, and not each individual Decl passed to them. This
extra level of indirection allows subclasses to override the default behavior
if they so desire.

llvm-svn: 44444
2007-11-29 23:05:17 +00:00
Christopher Lamb 2ed9afd777 Update the initializer's type, in addition to the decl, if we've changed the type of the decl based on it.
llvm-svn: 44440
2007-11-29 19:09:19 +00:00
Ted Kremenek 22a0d616f6 Added "complex.c" (a copy of test/Codegen/complex.) to the serialization
test suite.

llvm-svn: 44439
2007-11-29 19:05:51 +00:00
Ted Kremenek 870600d625 Only serialize top-level decls that appear at the head of a decl chain.
llvm-svn: 44438
2007-11-29 19:04:54 +00:00
Christopher Lamb 42e69f219d Support floating point literals of the form "1e-16f" which specify an exponent but no decimal point.
llvm-svn: 44431
2007-11-29 06:06:27 +00:00
Ted Kremenek 1150e25901 Enhanced serialization testing by also pretty-printing CFGs constructed from ASTs
both before and after serialization/deserialization. If the CFGs between the pre-
and post- serialized/deserialized ASTs differ, the serialization has failed.

llvm-svn: 44429
2007-11-29 01:24:25 +00:00
Ted Kremenek 2501c8294f Fixed test case to not expect a warning when one should not be emitted.
Removed redundant test case.

llvm-svn: 44426
2007-11-29 01:03:21 +00:00
Ted Kremenek 0865d8a5d0 Added test cases for -Wfloat-equal to test comparisons against literals that can be
represented exactly and inexactly by APFloats. For the former, we do not emit a
warning.

llvm-svn: 44425
2007-11-29 01:00:11 +00:00
Ted Kremenek eda40e273e Enhanced implementation of -Wfloat-equal to check for comparisons against
floating-point literals that are represented exactly by the APFloat in
FloatingLiteral. For such literals, we do not emit a warning since such checks are
often performed in real code to see if a variable has changed from its original
value. This heuristic clearly can lead to false negatives, but the hope is it will
significantly reduce false positives to help make the compiler flag more useful.

llvm-svn: 44424
2007-11-29 00:59:04 +00:00
Ted Kremenek 3a2c950401 Added "isExact" field to FloatingLiteral. This flag indicates whether or not
the APFloat representing the parsed literal can represent the literal value
exactly.  This is useful when performing various semantic checks on the code,
and issuing appropriate warnings to users.

llvm-svn: 44423
2007-11-29 00:56:49 +00:00
Ted Kremenek 9924ca2e14 Removed potential buffer overrun (spotted by Neil Booth) when NumericLiteralParser
converts a parsed literal into an APFloat. We are still performing a copy of the
string, which hopefully will be removed eventually for performance reasons. This
version now is at least safe.

Changed rounding in APFloat construction in NumericLiteralParser from rmTowardsZero
to rmNearestTiesToEven.

llvm-svn: 44422
2007-11-29 00:54:29 +00:00
Steve Naroff 197616c3a8 Several fixes/simplifications surrounding how we stream top-level decl AST's.
The following code...

typedef struct cssm_data {} CSSM_DATA, *CSSM_DATA_PTR;

struct Y { int A; };

struct X { int A; } D; 

struct X E, F;

...now produces the following output...

> ../../Debug/bin/clang xx.c -ast-print
Read top-level tag decl: 'cssm_data'
typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data *CSSM_DATA_PTR;
Read top-level tag decl: 'Y'
Read top-level tag decl: 'X'
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'F'

...which is much more accurate than the previous -ast-print output...

typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data CSSM_DATA;
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'E'

llvm-svn: 44421
2007-11-28 22:54:11 +00:00
Ted Kremenek 5933768bec Converted AST Pretty-Printer to use iostreams instead of FILE*. This fixes
a bug where the statement pretty-printer used iostreams but the AST printer
did not.  This was an issue when dumping ASTs to something other than stderr.

Updated SerializationTest to use the new iostreams interface for the AST printer.

llvm-svn: 44417
2007-11-28 21:32:21 +00:00
Ted Kremenek 5d169cf285 Inlined test case to make it independent of the stmt_exprs test case in test/Sema.
llvm-svn: 44416
2007-11-28 21:29:54 +00:00
Ted Kremenek 31540ed8fe Added the "Serialization" test directory to the set of tests executed.
Introduced a few line breaks to make the Makefile easier to read.

llvm-svn: 44413
2007-11-28 19:24:15 +00:00
Ted Kremenek 46cfdb9625 Added initial test case for testing serialization of ASTs. This test
case simply performs --test-pickling on the code found in Sema/stmt_exprs.c.

llvm-svn: 44412
2007-11-28 19:23:15 +00:00
Ted Kremenek ac76a41717 Modified --test-pickling to perform an actual cross-check of serialized ASTs:
(1) Parsed ASTs are pretty-printed to a text file.
(2) The ASTs are serialized to disk.
(3) The ASTs are deserialized from disk.
(4) The deserialized ASTs are pretty-printed to a text file.
(5) The two pretty-printed files are compared. If they are different, the test
    fails.

llvm-svn: 44411
2007-11-28 19:21:47 +00:00
Ted Kremenek 44d5166cdb Changed TestRunner.sh to dump the output and generated script files in
subdirectories mirroring where the test case file is located

For example, for the test case "Sema/stmt_exprs.c", instead of the files
"Output/stmt_exprs.c.out" and "Output/stmt_exprs.c.out.script" being created, the
files "Output/Sema/stmt_exprs.c.out" and "Output/Sema/stmt_exprs.c.out.script" are
created. This prevents any collisions from different test directories that have the
same file name for a test case, and also makes it clear where the test case was
drawn from.

llvm-svn: 44410
2007-11-28 19:16:54 +00:00
Ted Kremenek ab18e6d7fd Added missing "RUN:" to comment for test case file. This fixed a bug where the test
case testing the frontend's support of statement expressions was not being
executed.

llvm-svn: 44409
2007-11-28 19:05:11 +00:00
Chris Lattner db2a6ef881 Fix a bug checking for 'int foo(void)' that didn't look through typedefs of void.
Bug pointed out by Michael Zolda, thanks!

llvm-svn: 44408
2007-11-28 18:51:29 +00:00
Oliver Hunt 93c4ce650c Fix typo in writable string test
llvm-svn: 44398
2007-11-28 06:52:03 +00:00
Oliver Hunt a951571941 Adding code gen tests for writable and shared string literals.
llvm-svn: 44397
2007-11-28 06:27:12 +00:00
Anders Carlsson 0e136ec1d3 Add correct types for the last remaining intrinsics.
llvm-svn: 44396
2007-11-28 06:09:44 +00:00
Chris Lattner fb30009465 Implement support for -fwritable-strings and make the code generator
merge string literals when it is not provided.

llvm-svn: 44394
2007-11-28 05:34:05 +00:00
Anders Carlsson 299f2fc648 Add more intrinsics. We can now correctly parse both Carbon.h and Cocoa.h without having to do -arch ppc.
llvm-svn: 44392
2007-11-28 05:19:59 +00:00
Chris Lattner d0d8d4e3b9 fix compilation error noticed by Nuno Lopes
llvm-svn: 44388
2007-11-28 04:30:09 +00:00
Ted Kremenek 7c81bdd4e7 Migrated static functions that print decls into a DeclPrinter class,
which is now used (or subclasssed) by the ASTConsumers.  This new class
stores a FILE* that is used for writing, instead of just hardwiring output
to stderr (it defaults to stderr if no FILE* is provided).

Modified CreateASTPrinter() to accept a FILE* for printing.

llvm-svn: 44377
2007-11-27 21:46:50 +00:00
Chris Lattner da22eeca44 add several cases that Expr::hasStaticStorage missed, pointed out by Oliver Hunt
llvm-svn: 44376
2007-11-27 21:35:27 +00:00
Chris Lattner 1a6bb70ad0 Set loc earlier in CheckSingleInitializer to avoid emitting a
diagnostic without a location.  This produces:

simpleTest.c:2:18: error: initializer element is not constant
int *myPointer = &(myArray[2]);
                 ^~~~~~~~~~~~~

instead of:

error: initializer element is not constant
llvm-svn: 44375
2007-11-27 21:21:35 +00:00
Chris Lattner a7944d86de sizeof is defined by bitsin(char) not by units of 8 bits.
llvm-svn: 44369
2007-11-27 18:22:04 +00:00
Chris Lattner 1cfe02c38b update to match change in mainline llvm.
llvm-svn: 44367
2007-11-27 18:20:52 +00:00
Steve Naroff 0ee0b0ab8c Move the null pointer constant check from Sema::CheckSingleInitializer/ActOnCallExpr/CheckMessageArgumentTypes/ActOnReturnStmt to Sema::CheckSingleAssignmentConstraints. This makes sure all null pointer assignments are considered compatible.
Thanks to Seo Sanghyeon for the bug, follow-through, and patch!

llvm-svn: 44366
2007-11-27 17:58:44 +00:00
Chris Lattner db3467f8d4 handle __vector_size__ like vector_size
llvm-svn: 44358
2007-11-27 07:28:18 +00:00
Anders Carlsson 61d6f8d6c3 Add builtin type signature support for vector types. Add correct type signatures for a bunch of MMX builtins. We now parse all the intrinsics in mmintrin.h
llvm-svn: 44357
2007-11-27 07:22:09 +00:00
Anders Carlsson 24c59958f4 Add comment to CheckVectorCast.h
llvm-svn: 44356
2007-11-27 07:16:40 +00:00
Chris Lattner f04b69b26c take an initial stab at setting function linkage right. Handle
static and inline at least.

llvm-svn: 44355
2007-11-27 06:46:51 +00:00
Anders Carlsson de71adff60 Report errors for invalid casts from/to vectors.
llvm-svn: 44350
2007-11-27 05:51:55 +00:00
Anders Carlsson f511f646a4 Add more semantic analysis for inline asm statements.
llvm-svn: 44349
2007-11-27 04:11:28 +00:00
Ted Kremenek fbb08bc2e2 Added optional pass-by-reference argument "isExact" to
NumericLiteralParser::GetFloatValue(). Upon method return, this flag has the value
true if the returned APFloat can exactly represent the number in the parsed text,
and false otherwise.

Modified the implementation of GetFloatValue() to parse literals using APFloat's
convertFromString method (which allows us to set the value of isExact).

llvm-svn: 44339
2007-11-26 23:12:30 +00:00
Ted Kremenek 871422eca9 Removed dependence on #including iostream.
llvm-svn: 44338
2007-11-26 22:50:46 +00:00
Ted Kremenek 6eefb85ef5 Fixed #include of objc/objc.h so that it works on case-sensitive filesystems.
llvm-svn: 44337
2007-11-26 22:49:09 +00:00
Ted Kremenek 2b0ce11952 Reverted changed to getTagDeclType() introduced in patch 44089:
http://llvm.org/viewvc/llvm-project?view=rev&revision=44089

"Decl" once again can no longer be NULL, so the NULL checks are not needed.

llvm-svn: 44336
2007-11-26 21:16:01 +00:00
Fariborz Jahanian 96502afb6f Fixed a rewrite bug in class synthesis (which I first thought was a rewrite API bug).
llvm-svn: 44335
2007-11-26 20:59:57 +00:00
Kevin e01743a3a3 Removes link to status page till the info gets added. Someone put us on Reddit; Don't want it to look bad on the project. :)
http://programming.reddit.com/info/61f8g/comments/

llvm-svn: 44334
2007-11-26 20:47:14 +00:00
Fariborz Jahanian a883d6ed89 Patch to fix a regression caused by recent rewrite changes.
A potential API bug in ReplaceText pending (A FIXME is added).

llvm-svn: 44333
2007-11-26 19:52:57 +00:00
Ted Kremenek ebb1c0ca74 Fixed StmtPrinter to handle GCC extension to the ternary operator "?:" where
the LHS subexpression can be NULL.  Patch provided by Nuno Lopes!

llvm-svn: 44328
2007-11-26 18:27:54 +00:00
Ted Kremenek 138988765c Fixed bug in CFG construction where we did not properly handle the GCC
extension "?:" for the ternary operator, e.g.: x ?: y; This expression is
represented in the clang ASTs as a ConditionalOperator whose LHS expression is
NULL. Now we handle this special case, causing the block containing the
condition to be a predecessor to the block that "merges" the values of the
ternary operator.

Thanks to Nuno Lopes for identifying and diagnosing this bug!

llvm-svn: 44327
2007-11-26 18:20:26 +00:00
Bill Wendling 8da1db4f34 The checking for the delimiters of expected error/warning messages was
looking only for { and } instead of {{ and }}. Changed it to check for
this explicitly.

llvm-svn: 44326
2007-11-26 08:26:20 +00:00
Chris Lattner 2ab40a6207 Fix sema support for the gnu ?: expression with a
missing middle expression, and fix a codegen bug where
we didn't correctly promote the condition to the right 
result type.  This fixes PR1824.

llvm-svn: 44322
2007-11-26 01:40:58 +00:00
Chris Lattner a3ee6fa84f this works.
llvm-svn: 44321
2007-11-26 01:39:17 +00:00
Chris Lattner 852ed06d60 sizeof() return size in bytes, not bits, patch by Nuno Lopes!
llvm-svn: 44316
2007-11-25 17:48:21 +00:00
Ted Kremenek 43fb8b0799 Moved logic for -Wfloat-equal to SemaChecking.cpp.
Moved utility functions IgnoreParen and friends to be static inline functions
defined in SemaUtil.h.

Added SemaUtil.h to Xcode project.

llvm-svn: 44312
2007-11-25 00:58:00 +00:00
Anders Carlsson 290aa8560b Check that the clobber registers are valid.
llvm-svn: 44311
2007-11-25 00:25:21 +00:00
Anders Carlsson c163657f2f Forgot some X86 registers
llvm-svn: 44309
2007-11-25 00:23:10 +00:00
Anders Carlsson 5fa3f348f7 Add tables for GCC register names and aliases. This will be used for inline asm
llvm-svn: 44308
2007-11-24 23:38:12 +00:00
Ted Kremenek 0d20033c6a Added more test cases for uninitialized values checker.
llvm-svn: 44307
2007-11-24 23:06:58 +00:00
Ted Kremenek 2e04d73d83 Fixed bogus culling of uninitialized-values "taint" propagation during assignments.
We accidentally were throttling the propagation of uninitialized state across
assignments (e.g. x = y).  Thanks to Anders Carlsson for spotting this problem.

Added test cases to test suite to provide regression testing for the
uninitialized values analysis.

llvm-svn: 44306
2007-11-24 20:07:36 +00:00
Ted Kremenek 33407b3338 Moved dead-stores test cast to a new test suite subdirectory: Analysis.
llvm-svn: 44305
2007-11-24 19:49:35 +00:00
Anders Carlsson 660bdd1c87 Keep track of whether the asm is volatile or not.
llvm-svn: 44297
2007-11-23 23:12:25 +00:00
Chris Lattner 136449a6d7 improve codegen for global variable initializers, implementing
test/CodeGen/global-with-initialiser.c

Patch by Oliver Hunt!

llvm-svn: 44290
2007-11-23 22:07:55 +00:00
Anders Carlsson 80a5ea3552 Check asm input and output expressions.
llvm-svn: 44289
2007-11-23 19:43:50 +00:00