Commit Graph

628 Commits

Author SHA1 Message Date
Eli Friedman c7460b1011 Minor refactoring: compute the return value separately from emitting the
ret.

llvm-svn: 51403
2008-05-22 01:22:33 +00:00
Eli Friedman e53d15386f Make CurFuncDecl more specific; I have some code I'm going to land in a
bit that wants to use CurFuncDecl as a FunctionDecl.

llvm-svn: 51402
2008-05-22 01:16:59 +00:00
Dan Gohman 75d69da5ab 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.

llvm-svn: 51398
2008-05-22 00:50:06 +00:00
Ted Kremenek 91f035cda7 Improve dead stores diagnostics to include the variable name.
llvm-svn: 51395
2008-05-21 22:59:16 +00:00
Dan Gohman dac7fe424f Remove the unneeded #include of VMCore header "llvm/DerivedTypes.h".
llvm-svn: 51392
2008-05-21 20:26:42 +00:00
Ted Kremenek a2157719be Add Destroy method to Types, making there destruction more harmonious with
the destruction of Decls and Stmts.

llvm-svn: 51385
2008-05-21 16:38:54 +00:00
Ted Kremenek f025a8bc1c Fix potential double-free.
llvm-svn: 51381
2008-05-21 16:00:02 +00:00
Steve Naroff e181c13593 Fixup ASTContext::PrintStats()...it was causing several test failures.
llvm-svn: 51380
2008-05-21 15:59:22 +00:00
Ted Kremenek 512d9412ec When destroying DeclStmts, also destroy the associated Decl (reclaim its memory).
llvm-svn: 51379
2008-05-21 15:53:55 +00:00
Ted Kremenek b120ff1b95 Fixed bug in the transfer function for dereferences: the loaded value from EvalLoad should bind to the UnaryOperator*, not its subexpression.
Added test case to exercise this fix when checking for uses of uninitialized values.

Patch by Zhongxing Xu!

llvm-svn: 51377
2008-05-21 15:48:33 +00:00
Eli Friedman 9a5ffcb14e Remove an unnecessary/buggy if check. Ran into this with some other
changes in my tree, so I don't have a testcase which affects trunk.

llvm-svn: 51371
2008-05-21 13:24:44 +00:00
Eli Friedman b158b4a47b Fix the destruction "properly" in the sense that we actually destroy the
ASTs.  This is a hack, but I haven't considered how we really 
want to do this.

llvm-svn: 51364
2008-05-21 05:33:10 +00:00
Eli Friedman 0883bfb541 PR2347: Fix crash iterating over VLAs; this started triggering because
we now iterate over the whole AST when we destroy it.

llvm-svn: 51363
2008-05-21 05:06:46 +00:00
Eli Friedman 14b2993484 Don't kill the declarations if the translation unit doesn't own them
(specifically, for TranslationUnits created from SerializationTest.cpp).  
Fixes a double-free bug in the serialization tests.

llvm-svn: 51362
2008-05-21 05:01:55 +00:00
Eli Friedman 86346ede95 Fix a couple of bugs found by Neil Booth in the const-ness checking.
llvm-svn: 51361
2008-05-21 03:39:11 +00:00
Eli Friedman bcfa2d75d7 Protect iso646.h from C++ (although I can't imagine why someone would
need it...).  Patch by Mike Stump.

llvm-svn: 51360
2008-05-21 03:11:31 +00:00
Nuno Lopes 27f8407406 initialize variable and fix a bunch of test failures
llvm-svn: 51326
2008-05-20 18:03:51 +00:00
Nuno Lopes 652eaab03c fix warning with gcc 4.1 (ptr to bool convertion)
llvm-svn: 51324
2008-05-20 17:33:56 +00:00
Eli Friedman cc6b071c1e Remove hacks from ASTContext now that alignment gets reported correctly.
llvm-svn: 51322
2008-05-20 15:17:39 +00:00
Eli Friedman 7cef49e2d8 Missed an include.
llvm-svn: 51321
2008-05-20 14:27:34 +00:00
Eli Friedman 1ca6476ac5 Minor correction for PPC targets.
llvm-svn: 51320
2008-05-20 14:25:01 +00:00
Eli Friedman b53660698a Some small changes to make the target info a bit more accurate.
llvm-svn: 51319
2008-05-20 14:21:01 +00:00
Eli Friedman d5a55bd466 Perform stricter/more accurate checking for C99 constant expressions
in Sema, per discussion on mailing list.  This doesn't cause any changes 
in the test results.  I'll probably add some more tests at some point, 
but it's an open question what we need to accept to be compatible with 
real code.

This doesn't touch the existing isConstantExpr method on Expr; that 
should be addressed somehow eventually (either removed or refined to 
whatever is appropriate).

llvm-svn: 51318
2008-05-20 13:48:25 +00:00
Eli Friedman 9e9b046ac9 Add a couple more headers. stddef was discussed on cfe-dev, and
consensus was that it was fine; iso646 is trivial.

We actually don't need that many headers overall... on Ubuntu, at least, 
all we need are stdint.h, stdarg.h, limits.h, and float.h to stop 
depending on having gcc's headers around for normal code.

On a side note, the path searching needs some improvement; I had to 
hardcode the path to my header directory into clang.cpp to get the 
driver to use it consistently.

llvm-svn: 51317
2008-05-20 13:34:26 +00:00
Eli Friedman 3ed1d5f496 Disable the function address cache; this doesn't have any ill effects,
as far as I can tell, and it fixes code like test/CodeGen/functions.c.

(Whatever performance effect it might have, crashing on a 
construct like this isn't really acceptable; I've run into this 
multiple times.)

llvm-svn: 51312
2008-05-20 09:21:07 +00:00
Eli Friedman 2460b0c941 Fix the scope of K&R-style argument declarations so that they don't
extend beyond the end of the function.

I'm not completely sure this is the right way to fix this bug, so 
someone familiar with the parser should double-check.

llvm-svn: 51311
2008-05-20 09:10:20 +00:00
Eli Friedman 53e38bd6b6 Add codegen support for stack address intrinsics.
llvm-svn: 51309
2008-05-20 08:59:34 +00:00
Eli Friedman f8353034eb Add __builtin_frame_address and __builtin_return_address gcc builtins to
Sema. No codegen yet.

llvm-svn: 51307
2008-05-20 08:23:37 +00:00
Eli Friedman 4b0e2a30e0 Implement codegen for comma operator for structs.
llvm-svn: 51304
2008-05-20 07:56:31 +00:00
Eli Friedman d0e48ea682 Be a bit more defensive in SemaInit.
llvm-svn: 51301
2008-05-20 05:25:56 +00:00
Eli Friedman 37a186d765 Add some more checking for compound literals.
llvm-svn: 51300
2008-05-20 05:22:08 +00:00
Ted Kremenek 78aa98f7b8 Reclaim memory from chains of ScopedDecls, and reclaim memory for the initializers of EnumConstantDecls.
llvm-svn: 51299
2008-05-20 04:49:55 +00:00
Ted Kremenek 40e489dfd8 Delete AST nodes, not just Decls.
llvm-svn: 51298
2008-05-20 04:10:52 +00:00
Ted Kremenek fa8a09e0bc Reclaim memory allocated for ParmVarDecl's in FunctionDecl::Destroy.
Fixed a bug in ParmVarDecl::param_end(): Handle the case where there are no
ParmVarDecls for a FunctionDecl, but its function prototype has formal arguments
(can happen with typedefs).

llvm-svn: 51297
2008-05-20 03:56:00 +00:00
Ted Kremenek 878ff6c04d When serializing FunctionDecl, serialize out a reference to the previous declaration.
llvm-svn: 51294
2008-05-20 03:33:58 +00:00
Ted Kremenek b865b38eda Remove unnecessary #include (introduced by a recent patch of mine).
llvm-svn: 51288
2008-05-20 00:47:23 +00:00
Ted Kremenek ce20e8fe8d Try to plug some memory leaks...
1) Sema::ParseAST now constructs a TranslationUnit object to own the top-level Decls, which releases the top-level Decls upon exiting ParseAST.

2) Bug fix: TranslationUnit::~TranslationUnit handles the case where a Decl is added more than once as a top-level Decl.

3) Decl::Destroy is now a virtual method, obviating the need for a special dispatch based on DeclKind.

3) FunctionDecl::Destroy now releases its Body using its Destroy method.

4) Added Stmt::Destroy and Stmt::DestroyChildren, which recursively delete the child ASTs of a Stmt and call their dstors.  We may need to special case dstor/Destroy methods for particular Stmt subclasses that own other dynamically allocated objects besides AST nodes.

5) REGRESSION: We temporarily are not deallocating attributes; a FIXME is provided.

llvm-svn: 51286
2008-05-20 00:43:19 +00:00
Eli Friedman 247ee87e26 Restructure constant structure init codegen so that it's possible to
implement bitfield codegen (although I don't envy the person who 
implements it).  This also prevents a crash on code like that from PR2309
(it's still broken, but it fails more gracefully).

llvm-svn: 51285
2008-05-20 00:11:07 +00:00
Eli Friedman 8d0b976e7c Remove code that shouldn't have any effect anymore.
llvm-svn: 51284
2008-05-20 00:04:21 +00:00
Eli Friedman a3a4068949 Implement CodeGen for __builtin_memcpy.
llvm-svn: 51282
2008-05-19 23:27:48 +00:00
Ted Kremenek ee5794265a Added Stmt::DestroyChildren, which will be used by the dstors of the subclasses of Stmt to recursively delete their child AST nodes.
llvm-svn: 51278
2008-05-19 22:02:12 +00:00
Eli Friedman ca8da1d89d Make the unused expression warning a bit less aggressive (found in PHP
code).

llvm-svn: 51276
2008-05-19 21:24:43 +00:00
Eli Friedman a68c3006f4 Switch on SemaInit; this makes some code in SemaDecl dead, but I'll give
it a few days to make sure there aren't any significant regressions.

llvm-svn: 51273
2008-05-19 20:29:35 +00:00
Eli Friedman 6fcdec280b Adjust warning so that it doesn't fire when there is an error.
llvm-svn: 51269
2008-05-19 20:20:43 +00:00
Eli Friedman feb4cc1c6a Add errors for some illegal constructs (specifically, "int a = {{3}};"
and "int a = {};").  I'll adjust the tests in a bit.

llvm-svn: 51265
2008-05-19 20:12:18 +00:00
Eli Friedman 5a36d3fffb Some more SemaInit cleanup.
llvm-svn: 51262
2008-05-19 20:00:43 +00:00
Eli Friedman 23a9e3176c Various fixes; solves (almost) all of the test regressions that would be
caused by enabling SemaInit.

llvm-svn: 51261
2008-05-19 19:16:24 +00:00
Eli Friedman f23b6fa41f Fix the emission of expressions like char a[10] = "asdf"; previously,
they were causing bad code to be emitted.  There are two fixes here: one 
makes sure we emit a string that is long enough, and one makes sure we 
properly handle string initialization in init lists.

llvm-svn: 51259
2008-05-19 17:51:16 +00:00
Eli Friedman 8e12298192 Add proper type-checking for pointer additiion; before, we were accepting
addition with a pointer and an integer even when it didn't make sense.

llvm-svn: 51228
2008-05-18 18:08:51 +00:00
Eli Friedman f2442dcc8d Fix support for _Bool bitfields. The issue is that the bitfield width
used for _Bool is not the same as the primitive width (which for _Bool 
is 1 bit).  The load and store changes add some casts to make the 
types consistent.  The EmitLValue changes make sure that the pointer is 
of an appropriate type for loading the bitfield.

This isn't perfect, but it's an improvement, and getting everything 
right depends on actually laying out structs in an ABI-compliant way.

llvm-svn: 51224
2008-05-17 20:03:47 +00:00