Commit Graph

5179 Commits

Author SHA1 Message Date
Steve Naroff a326bae77a Fix <rdar://problem/5965704> clang: bad receiver type 'id const'
llvm-svn: 51809
2008-05-31 02:19:15 +00:00
Ted Kremenek a3774667d3 Correctly preserve the order between -F and -I options.
llvm-svn: 51803
2008-05-31 00:27:00 +00:00
Steve Naroff 66002283e6 Teach Expr::isLvalue() about ObjC properties. For now, all properties are writable. Added a FIXME for another day.
llvm-svn: 51800
2008-05-30 23:23:16 +00:00
Eli Friedman 6859a1b961 PR1893: Fix up the type of tentative definitions of incomplete array
types so that they end up the correct size.

llvm-svn: 51787
2008-05-30 20:39:54 +00:00
Eli Friedman 34994cbcbf Fix and enable generating general union initializers. Essentially, what
this does is reconstruct the type for structs and arrays if the type 
wouldn't be compatible otherwise.

The assertion about packing in the struct type reconstruction code 
sucks, but I don't see any obvious way to fix it.  Maybe we need a general
utility method to take a list of types and alignments and try to construct an
unpacked type if possible?

llvm-svn: 51785
2008-05-30 19:58:50 +00:00
Eli Friedman c18d9d53bb Allow the type of a global to be different from the type of its
associated declaration. This is a prerequisite to handling
general union initializations; for example, an array of unions involving 
pointers has to be turned into a struct because the elements can have 
incompatible types.

I refactored the code a bit to make it more readable; now, the logic for 
definitions is all in EmitGlobalVarInit.

The second parameter for GetAddrOfGlobalVar is now dead; I'll remove it 
separately.

By itself, this patch should not cause any visible changes.

llvm-svn: 51783
2008-05-30 19:50:47 +00:00
Eli Friedman 66572afde4 Allow a pointer implicitly cast to a bool as a constant expression, as
required by the standard (the standard doesn't know anything about 
implicit casts).

Disallow pointers cast to non-integral arithmetic types as constant 
expressions.  This was previously allowed by accident. 

llvm-svn: 51779
2008-05-30 18:14:48 +00:00
Eli Friedman 3360d898ec Make sure to allow assigning a pointer to a bool.
llvm-svn: 51778
2008-05-30 18:07:22 +00:00
Ted Kremenek 6bb6d9f197 Use llvm:🆑:desc for description of the -Wimplicit-function-declaration option.
Patch by Holger Schurig!

llvm-svn: 51774
2008-05-30 16:42:02 +00:00
Ted Kremenek 8595668eca Fix some strict-aliasing warnings by using Stmt* instead of Expr* in VariableArrayType, EnumConstantDecl, and VarDecl.
llvm-svn: 51772
2008-05-30 16:14:41 +00:00
Eli Friedman f7fe41656c Fix constant vector init for initializer lists with an incomplete list
of elements.

llvm-svn: 51769
2008-05-30 12:02:14 +00:00
Eli Friedman 35c01c6f2d Fix crash with -serialize (reported to cfe-dev). The issue was
essentially that we were destroying the declarations twice.

(Note that we don't use -serialize directly in the testsuite, only 
SerializeTest.)

llvm-svn: 51768
2008-05-30 11:28:30 +00:00
Eli Friedman 617ba48fd5 Always check that the definition of a function has the correct type.
This fixes a crash on the included testcase (found in NetHack).

llvm-svn: 51767
2008-05-30 11:13:18 +00:00
Sanjiv Gupta 18de624ca0 Emit parameter and local variable debug information with -g.
llvm-svn: 51765
2008-05-30 10:30:31 +00:00
Eli Friedman 711665c309 Add FIXME to CodeGen struct layout.
llvm-svn: 51764
2008-05-30 10:29:32 +00:00
Eli Friedman a2eaffc747 Some additions to constant initializer generation code. Adds
bit-field initialization; ugly code, X86-only, but it works, at least 
for basic stuff.  Separates/adds union initialization; currently disabled,
though, because the struct/array code needs modifications to support 
elements of the wrong type.

Fixes PR2381 and PR2309 with the bit-field initialization.  And NetHack 
compiles and appears to work with a few tweaks (to work around the lack 
of transparent_union support, and clang being a bit strict about
conflicting declarations).

llvm-svn: 51763
2008-05-30 10:24:46 +00:00
Eli Friedman 3df5efe83e Cleanup/refactoring of Sema struct layout. This patch unifies the struct
and union codepaths and fixes some minor bugs.

I'm reasonably confident this is accurate, at least for X86.  I'll 
correct any bugs as I find them; I haven't found any for a while, 
though.

llvm-svn: 51762
2008-05-30 09:31:38 +00:00
Steve Naroff ec94403018 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

llvm-svn: 51719
2008-05-30 00:40:33 +00:00
Ted Kremenek 5fc6dc070c Fix one strict-aliasing warning.
llvm-svn: 51707
2008-05-29 21:52:26 +00:00
Steve Naroff 021ca18bb5 - Move ObjC Expresssion AST's from Expr.h => ExprObjC.h
- #include ExprObjC.h in many places

llvm-svn: 51703
2008-05-29 21:12:08 +00:00
Anton Korobeynikov e1a9c26b89 Update to follow recent LLVM changes
llvm-svn: 51689
2008-05-29 17:42:01 +00:00
Chris Lattner 8c80070de2 Implement support for -w, which silences all warnings. PR2384.
llvm-svn: 51683
2008-05-29 15:36:45 +00:00
Eli Friedman 43a6d51494 More complete/correct implementation of the comparison operators for
constant expressions.

llvm-svn: 51682
2008-05-29 15:17:49 +00:00
Eli Friedman 3c28524632 Fix an extremely subtle bug with pointer comparisons: they have to be
unsigned because it's possible (at least in theory) to have
have both positive and negative pointers pointing to the same object.

llvm-svn: 51681
2008-05-29 15:09:15 +00:00
Eli Friedman 133e8040ca Rearrange EmitLValueForField a bit to work properly for _Bool bitfields
in unions (we don't want to do the union-specific bitcast for 
bit-fields).

llvm-svn: 51678
2008-05-29 11:33:25 +00:00
Eli Friedman 045bf4ff82 Add codegen support for a few more kinds of initializer constant
expressions.

llvm-svn: 51677
2008-05-29 11:22:45 +00:00
Eli Friedman 174d9c26f1 Add CodeGen support for alignment on globals, both for unusual natural
alignment and alignment attributes.

llvm-svn: 51676
2008-05-29 11:10:27 +00:00
Eli Friedman b65ff27f53 A couple minor fixes to make debug info usable for arbitrary code: don't
emit incomplete types, because they crash llc, and always use the 
logical location as the current location so we don't crash doing invalid 
queries on CurLoc.

llvm-svn: 51675
2008-05-29 11:08:17 +00:00
Eli Friedman d72a9624a1 Tentative declarations are supposed to have common linkage, not weak.
This change makes clang generate the same thing as llvm-gcc.

llvm-svn: 51674
2008-05-29 11:03:17 +00:00
Eli Friedman 5a6d0ede91 Always use packed structs. This isn't really very nice, but there's
nothing fundamentally wrong with it. Emitting unpacked structs where 
possible is more work for almost no practical benefit.  We'll probably 
want to fix it at some point anyway, but it's low priority.

The issue with long double in particular is that LLVM thinks an X86 long
double is 10 bytes, while clang considers it for all purposes to be
either 12 or 16 bytes, depending on the platform, even in a packed
struct.

llvm-svn: 51673
2008-05-29 10:58:49 +00:00
Eli Friedman bb936ce207 Implementation of stdarg.h.
llvm-svn: 51672
2008-05-29 10:40:55 +00:00
Chris Lattner ae2c57fbbe Fix rewrite rope to keep the leaf list up-to-date as it erases leaves
from the rope.  rdar://5952468

llvm-svn: 51651
2008-05-28 18:45:56 +00:00
Chris Lattner 34873d2134 give location info to another paren expr.
llvm-svn: 51646
2008-05-28 16:38:23 +00:00
Chris Lattner c5c27f7bfe add an assertion
llvm-svn: 51645
2008-05-28 16:35:02 +00:00
Chris Lattner a120a521a5 Fix a couple crashes on invalid input.
llvm-svn: 51622
2008-05-27 23:32:43 +00:00
Ted Kremenek ffdbeefc54 When the build command is xcodebuild, set the magical environment variable LDPLUSPLUS to g++ to ensure that C++ object files are linked with g++ instead of gcc.
llvm-svn: 51621
2008-05-27 23:18:07 +00:00
Ted Kremenek f9671ecbfd Correctly check to see if we are analyzing C++ files (skip).
llvm-svn: 51620
2008-05-27 23:17:16 +00:00
Devang Patel 1c56ace4df Check first member alignment and uses packed struct if required.
llvm-svn: 51619
2008-05-27 22:45:40 +00:00
Devang Patel d608074e09 Fix test case
llvm-svn: 51618
2008-05-27 22:44:22 +00:00
Eli Friedman 203cdd5aae Add the copysign builtins; I ran into a program that wanted
__builtin_copysign.

llvm-svn: 51597
2008-05-27 15:59:57 +00:00
Eli Friedman 21911e89d5 A few more cases for aggregate values.
llvm-svn: 51596
2008-05-27 15:51:49 +00:00
Eli Friedman 5e2281ede8 Implementation of __builtin_ctlz.
llvm-svn: 51595
2008-05-27 15:32:46 +00:00
Eli Friedman 824f8c12fd Assume statement expressions have side effects; this gets rid of a lot
of extra warnings in the Python source.

llvm-svn: 51594
2008-05-27 15:24:04 +00:00
Eli Friedman 70f5a921b7 The cache is working again; re-enable it.
llvm-svn: 51587
2008-05-27 08:43:22 +00:00
Eli Friedman a904087b0d Get the type right for wide string literals; it's wchar_t, not char.
llvm-svn: 51586
2008-05-27 07:57:14 +00:00
Eli Friedman 6f024557ea Add FIXME.
llvm-svn: 51585
2008-05-27 05:09:49 +00:00
Eli Friedman aee9e54dca Don't swap function decls, and add them to the scope as they are
encountered.  Mixing up the decls is unintuitive, and confuses the AST 
destruction code. Fixes PR2360.

Note that there is a need to look up the characteristics and 
declarations of a function associated with a particular name or decl, 
but the original swapping code doesn't solve it properly. 
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001644.html is one 
suggestion for how to fix that.

llvm-svn: 51584
2008-05-27 05:07:37 +00:00
Eli Friedman 078c963a31 Add a more reliable check for whether a static declaration has already
been used.  In preparation for the fix to PR2360, but also a minor bug 
in its own right.

llvm-svn: 51583
2008-05-27 04:58:01 +00:00
Eli Friedman ac0285a683 Stop leaking the main Sema object. (Leak found using valgrind.)
llvm-svn: 51580
2008-05-27 04:23:47 +00:00
Eli Friedman 3e1d35b92d Stop leaking the target data. (Leak found with valgrind.)
llvm-svn: 51579
2008-05-27 04:22:24 +00:00
Eli Friedman bdef5df44e Generalize the float type generation code, and specifically fix the
codegen of X86 long double.

llvm-svn: 51578
2008-05-27 04:20:05 +00:00
Eli Friedman 3e113409cb Implementation of gcc mode attribute; this is significant because
it fixes PR2204.  Not too much to say about the implementation; it works 
in a similar way to the vector size attribute.

At some point, we need to modify the targets to provide information 
about the appropriate types.

llvm-svn: 51577
2008-05-27 03:33:27 +00:00
Eli Friedman 42ed07e10e Rewrite struct/union layout. This is mostly cleanup; this might also fix
a few bugs, but I don't know of any in particular. This has good effects 
besides cleanup, though: it also should make it easier to implement the 
aligned and packed attributes, and also target-specific struct layouts, 
because the code won't have to be duplicated in codegen.

llvm-svn: 51576
2008-05-27 03:14:44 +00:00
Eli Friedman e2bbfe22c7 Stop leaking the TUDecl.
llvm-svn: 51575
2008-05-27 03:08:09 +00:00
Eli Friedman 1c2d5f56f8 Change diagnostic per suggestion, to make it a bit clearer what is
happening.

llvm-svn: 51574
2008-05-27 02:01:50 +00:00
Eli Friedman df649f3da5 Emit memmove, not memcpy, for structure copies; this is unfortunately
required for correctness in cases of copying a struct to itself or to 
an overlapping struct (itself for cases like *a = *a, and overlapping 
is possible with unions).

Hopefully, this won't end up being a perf issue; LLVM *should* be able 
to optimize memmove to memcpy in a lot of cases, and for small copies 
the generated code *should* be mostly comparable. (In reality, LLVM 
is currently horrible at optimizing memmove, but that's a bug, not a 
fundamental issue.)

gcc currently generates wrong code; that's 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667.

llvm-svn: 51566
2008-05-26 12:59:39 +00:00
Eli Friedman 292e98cc18 Fix for PR2001. I'm not really fond of it, but it is correct (unless
someone tries to make a bitfield volatile?).

Not sure how to write a test; any suggestions?

llvm-svn: 51558
2008-05-25 14:13:57 +00:00
Eli Friedman 0e56c82e4a Count the number of initializable members correctly in structs/unions
with unnamed members.

llvm-svn: 51557
2008-05-25 14:03:31 +00:00
Eli Friedman e0f832bd4f Diagnose implicit init list for empty aggregate, like struct {}. Fixes
PR2151 (by not creating the empty implicit init list).

llvm-svn: 51556
2008-05-25 13:49:22 +00:00
Eli Friedman 85f5497c4a Move the error checking for variable-sized objects so we don't
double-report errors; fixes PR2362.

llvm-svn: 51555
2008-05-25 13:22:35 +00:00
Eli Friedman b2bef7c1c2 Make sure to define __sparc__ on Solaris; this should "fix"
test/Codegen/mandel.c on Solaris. :-)

llvm-svn: 51554
2008-05-25 05:26:09 +00:00
Sanjiv Gupta 98070578bf Generate subprogram debug info with -g.
Also take care of freeing memory at the right places.

llvm-svn: 51553
2008-05-25 05:15:42 +00:00
Eli Friedman d042a969c9 Fix this test on non-X86 platforms.
llvm-svn: 51552
2008-05-25 04:43:38 +00:00
Eli Friedman 1f97e5798f Always initialize NEXT_CATCH; fixes a Valgrind uninitialized read error
(originally reported in PR1682).

llvm-svn: 51551
2008-05-25 04:34:57 +00:00
Ted Kremenek e37e612e7a Fix variable misspelling.
llvm-svn: 51548
2008-05-24 16:16:30 +00:00
Ted Kremenek 37d6f58018 Don't use inferlanguage to override the default language for all files.
llvm-svn: 51547
2008-05-24 16:14:34 +00:00
Ted Kremenek 55842bd269 Don't analyze .o files.
llvm-svn: 51546
2008-05-24 16:09:00 +00:00
Ted Kremenek f18f460716 Cleanup indentation and remove some dead code.
Analyze files not compiled using "-c".  This fixes:

<rdar://problem/5961638> invoke checker when gcc is not called with "-c"

llvm-svn: 51545
2008-05-24 15:58:54 +00:00
Ted Kremenek a08154d85f Call the correct destructor.
llvm-svn: 51544
2008-05-24 15:09:56 +00:00
Steve Naroff 04c3299652 This fixes a VC++ build failure.
llvm-svn: 51528
2008-05-24 00:16:40 +00:00
Chris Lattner 10a7bd6341 fix a nasty off-by-one error.
llvm-svn: 51519
2008-05-23 23:29:33 +00:00
Chris Lattner 78f37e6d28 add some assertions to catch bad things before they die
somewhere deep in rewrite rope.

llvm-svn: 51515
2008-05-23 23:10:58 +00:00
Chris Lattner 17c2476d0b fix an inconsistency computing offsets that caused a crash on rewrite-nest.m
llvm-svn: 51514
2008-05-23 23:06:56 +00:00
Ted Kremenek 567f333f23 Disable the use of PCH files when using xcodebuild.
llvm-svn: 51509
2008-05-23 22:18:16 +00:00
Steve Naroff b3424a9ab6 Minor tweak to -ast-dump for ivars.
llvm-svn: 51508
2008-05-23 22:01:24 +00:00
Steve Naroff 59fefb56b1 Fix range info for explicit ivar refs.
llvm-svn: 51507
2008-05-23 22:00:37 +00:00
Ted Kremenek 20ccc4c3ed Revert r51498: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=51498&r1=51497&r2=51498&view=diff
Turns out that there are multiple places where a redefinition diagnostic can be emitted.  A cleaner solution (without touching Sema) is to have
the Driver turn off these diagnostics.  (will submit this patch soon)

llvm-svn: 51502
2008-05-23 21:28:18 +00:00
Steve Naroff c11802a521 Remove a diagnostic (temporary hack that will be removed next week).
llvm-svn: 51498
2008-05-23 20:57:38 +00:00
Chris Lattner 37f5b7d39c minor changes, collect the range of an expr before rewriting the subexprs
no functionality change.

llvm-svn: 51497
2008-05-23 20:40:52 +00:00
Steve Naroff fd16687b9a Make sure method definitions get output with -ast-dump.
llvm-svn: 51494
2008-05-23 18:50:58 +00:00
Ted Kremenek a4951b7796 When known, include the analyzer build in the output of scan-build.
llvm-svn: 51492
2008-05-23 18:17:05 +00:00
Ted Kremenek 6849601f69 More test cases for retain/release checker. These cases handle not flagging leaks for static variables.
llvm-svn: 51486
2008-05-23 17:25:17 +00:00
Gabor Greif f61cb42ab5 fix typo
llvm-svn: 51479
2008-05-23 11:19:39 +00:00
Ted Kremenek d6795749a6 Unbreak build. Forget to check in this header file change with a previous commit.
llvm-svn: 51470
2008-05-23 02:53:24 +00:00
Ted Kremenek 47c96d011e Fix typo.
llvm-svn: 51466
2008-05-23 01:40:41 +00:00
Steve Naroff e3fa7136b0 Tweak AST dumper for ObjC ivars.
llvm-svn: 51463
2008-05-23 00:59:14 +00:00
Ted Kremenek db622628e8 Additional retain/release checker regression tests.
llvm-svn: 51454
2008-05-22 23:46:11 +00:00
Ted Kremenek b91ef1b62b Prototyped support in the BugReporter to emit diagnostics of the form "p now aliases q".
llvm-svn: 51453
2008-05-22 23:45:19 +00:00
Steve Naroff 4c290c7c0b Make sure the source location for @property points the the @-sign (not the decl spec).
Also added a FIXME related to how we represent @properties in the ObjCInterfaceDecl AST.

llvm-svn: 51450
2008-05-22 23:24:08 +00:00
Dan Gohman 5d30975e5e Change uses of llvm::Type::isFirstClassType to use the new
llvm::Type::isSingleValueType. Currently these two functions have
the same behavior, but soon isFirstClassType will return true for
struct and array types.

Clang may some day want to use of isFirstClassType for some of
these some day as an optimization, but it'll require some
consideration.

llvm-svn: 51446
2008-05-22 22:12:56 +00:00
Ted Kremenek 1df2f3a1f5 Expand retain/release checker to consider methods/function calls that cause a
tracked object to "escape": it's reference count might be incremented by the
called function, thus causing an object's lifetime to extend beyond when the
local reference count is decremented to 0.

This addresses: <rdar://problem/5933215>

llvm-svn: 51433
2008-05-22 17:31:13 +00:00
Ted Kremenek a4010c698c Don't use ostringstream (pulling in <sstream>) when creating the dead store diagnostic (simply not needed).
llvm-svn: 51432
2008-05-22 16:28:24 +00:00
Ted Kremenek 0954b4564e Update driver include paths to work on darwin10.
llvm-svn: 51431
2008-05-22 15:26:22 +00:00
Eli Friedman bb5de96bc8 Patch for PR2350; the issue was tnat we were allowing (with an error)
void f(const void) in one place and rejecting it in another.

llvm-svn: 51424
2008-05-22 08:54:03 +00:00
Eli Friedman 1763075b9c Make debugging information usable. This is barebones, but it makes -g
actually work (instead of crashing llc), and there's enough info emitted 
to get line number information in gdb. This should hopefully be helpful 
for debugging non-working programs.

I got rid of the begin/endregion calls because the implementation wasn't 
working; someone who knows the debugging info a bit better might try to 
add it. I really have no clue how a compiler is supposed to emit them.

This commit shouldn't have any effect without -g.

llvm-svn: 51404
2008-05-22 01:40:10 +00:00
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
Dan Gohman 1627ae7c48 Explicitly #include Support/Streams.h when using llvm::cout and friends.
llvm-svn: 51391
2008-05-21 20:19:16 +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 43f6b67135 A small testcase; no patch, since it was a bug in a patch I never
committed.

llvm-svn: 51370
2008-05-21 13:21:01 +00:00
Eli Friedman 0ceef458b6 Fix this test so that it's valid; the point is to test for the crash,
not the missing diagnostic.

llvm-svn: 51365
2008-05-21 05:37:55 +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
Steve Naroff 52ef6f5231 Add SemaInit.cpp to VC++ proj.
llvm-svn: 51330
2008-05-20 20:39:37 +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 4b44e2ee8c Test from PR2332; bug already fixed by r51311.
llvm-svn: 51316
2008-05-20 12:55:29 +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 f77daf5e58 Fix test (it was incorrectly succeeding).
llvm-svn: 51310
2008-05-20 09:04:19 +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 503731aa22 Fix typo in test.
llvm-svn: 51308
2008-05-20 08:27:04 +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 3b965e1d01 Updated Xcode project.
llvm-svn: 51281
2008-05-19 23:19:04 +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 541268086a Remove illegal test.
llvm-svn: 51267
2008-05-19 20:17:34 +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