Commit Graph

65 Commits

Author SHA1 Message Date
Chris Lattner b1537ebdd4 rewrite some of the type refinement code to eliminate dangling pointers
simplify the code and generally make it more robust.

llvm-svn: 46745
2008-02-05 08:06:13 +00:00
Chris Lattner b977b6a59b Relax an assertion, fixing PR1968
llvm-svn: 46742
2008-02-05 06:37:34 +00:00
Christopher Lamb 025b5fb883 Add experimental support for address space qualified types. Address space
qualifiers use the __attribute__((address_space(id))) syntax.

llvm-svn: 46691
2008-02-04 02:31:56 +00:00
Chris Lattner ce6ae5cb06 fix codegen on static variables which have multiple decl nodes. These
should be merged just like normal globals.  This fixes this testcase
that Anders provided:

static struct s a;
static struct s *ap1 = &a;
static struct s a =  { 10 };

llvm-svn: 46661
2008-02-02 04:43:11 +00:00
Anders Carlsson 610ee7134e Factor out the constant generation into its own file.
llvm-svn: 46386
2008-01-26 01:36:00 +00:00
Steve Naroff fda820970a Add more support for Apple's "private extern" extension...
llvm-svn: 46371
2008-01-25 22:14:40 +00:00
Nate Begeman 43eec490fb Support checking and codegen of constant vector globals
llvm-svn: 46343
2008-01-25 05:34:48 +00:00
Chris Lattner 38376f1595 Add first pieces of support for parsing and representing
extern "C" in C++ mode.  Patch by Mike Stump!

llvm-svn: 45904
2008-01-12 07:05:38 +00:00
Chris Lattner 41a1ef0dfe implement proper support for _Bool in memory, which is usually i8, not i1.
This fixes a crash reported by Seo Sanghyeon

llvm-svn: 45778
2008-01-09 18:47:25 +00:00
Chris Lattner a77acbdcae implement codegen support for most unary operators when
initializing a global.  This handles important cases like:
float foo3 = -0.01f;

llvm-svn: 45427
2007-12-29 23:43:37 +00:00
Chris Lattner 5b12ab8c93 Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.

llvm-svn: 45410
2007-12-29 19:59:25 +00:00
Chris Lattner 37bd2ecb11 local static vars are globals also. This fixes a testcase
reported by Seo.

llvm-svn: 45156
2007-12-18 08:16:44 +00:00
Chris Lattner b8be97e239 introduce a new CodeGenModule::getIntrinsic method, which wraps
Intrinsic::getDeclaration, allowing much more terse code.

llvm-svn: 45136
2007-12-18 00:25:38 +00:00
Chris Lattner 28c91c5f35 add a hack so that codegen doesn't abort on missing sema of initializers, now
we emit stuff like this:

abort on missing sema of initializers, now
we emit stuff like this:

t3.c:1:24: warning: cannot codegen this initializer yet
const char x[2][4] = { { 'a', 'b', '\0', '\0' }, { 'c', 'd', 'e', '\0' } };
                       ^~~~~~~~~~~~~~~~~~~~~~~~

This should be removed when sema is finished.

llvm-svn: 45086
2007-12-17 05:17:42 +00:00
Christopher Lamb 77560fbde7 Update to use new PointerType::getUnqual() api.
llvm-svn: 45081
2007-12-17 01:11:20 +00:00
Chris Lattner 70efff25be builtin id 0 is invalid, don't use a slot for it.
llvm-svn: 44968
2007-12-13 00:38:03 +00:00
Chris Lattner b8bd2db8b3 fix off-by-one error.
llvm-svn: 44963
2007-12-12 23:46:36 +00:00
Ted Kremenek 1daa3cfbae TargetInfo no longer includes a reference to SourceManager.
Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation.
Added many utility methods to FullSourceLoc to provide shorthand for:

    FullLoc.getManager().someMethod(FullLoc.getLocation());
    
instead we have:

    FullLoc.someMethod();
    
Modified TextDiagnostics (and related classes) to use this short-hand.

llvm-svn: 44957
2007-12-12 22:39:36 +00:00
Ted Kremenek d4e5fbacab Mega-patch: ripped SourceManager out of Diagnostic/DiagnosticClient. Now
SourceManager is passed by reference, allowing the SourceManager to be
associated with a specific translation unit, and not the entire execution
of the driver.

Modified all users of Diagnostics to comply with this new interface.

Integrated SourceManager as a member variable of TargetInfo. TargetInfo will
eventually be associated with a single translation unit (just like
SourceManager).

Made the SourceManager reference in ASTContext private. Provided accessor
getSourceManager() for clients to use instead. Modified clients to comply with
new interface.

llvm-svn: 44878
2007-12-11 21:27:55 +00:00
Chris Lattner 11fbda2b5a Reimplement support for strings that initialize global inits now that
the types are right in sema.  Thanks Steve.

llvm-svn: 44834
2007-12-11 01:38:45 +00:00
Chris Lattner 433fb26707 add support for implicit cast from array to pointer that is not the element
type.

llvm-svn: 44809
2007-12-10 19:50:32 +00:00
Chris Lattner cb04ac9599 abort when we lower an initializer to the wrong type, as we currently do for:
char text[] = "string";

llvm-svn: 44752
2007-12-10 00:05:55 +00:00
Chris Lattner 686628e052 extend or truncate the initializer for a string initializer to match its type.
llvm-svn: 44751
2007-12-10 00:00:56 +00:00
Chris Lattner c25c42f3ca Implement codegen support for:
char text[8] = "string";

Big fixme remains.

llvm-svn: 44750
2007-12-09 23:49:42 +00:00
Chris Lattner 283d094b75 implement support for functions that initialize globals.
llvm-svn: 44730
2007-12-09 00:36:01 +00:00
Christopher Lamb 0cbd8723f3 Treat discarding array initializer elements as an extwarn (so -pedantic-errors flags it). Allow CodeGen to truncate the initializer if needed.
llvm-svn: 44518
2007-12-02 08:49:54 +00:00
Chris Lattner 0475c8178f globals can't be vla's
llvm-svn: 44512
2007-12-02 07:32:25 +00:00
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 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 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
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
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
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 41b7c6b250 Put constant CFStrings in the __DATA,__cfstring section.
llvm-svn: 43593
2007-11-01 00:41:52 +00:00
Devang Patel 75ef2f0b45 Take 2.
Make target info available to clang code generator.  This is far from complete but this helps clang codegen module make progress.

At the moment target triplet and target description strings are hard coded in clang::TargetInfo

llvm-svn: 43572
2007-10-31 20:01:01 +00:00
Devang Patel 7abb7acafd Initialize MemCpyFn
llvm-svn: 43569
2007-10-31 19:54:57 +00:00
Chris Lattner 5087e267c2 temporarily revert devang's patch to link in the llvm codegen etc.
llvm-svn: 43544
2007-10-31 04:53:03 +00:00
Devang Patel 46c7003052 Make target info available to clang code generator.
This is far from complete but this helps clang codegen module
make progress.

llvm-svn: 43536
2007-10-31 00:59:29 +00:00
Devang Patel 73721a12ca Refactor code into a separate method.
llvm-svn: 43519
2007-10-30 21:27:20 +00:00
Devang Patel ffe1e218f2 Fix 80 col violations.
llvm-svn: 43516
2007-10-30 20:59:40 +00:00
Devang Patel 19c2b9a66f Codegen global array initializers.
llvm-svn: 43383
2007-10-26 16:31:40 +00:00
Hartmut Kaiser 7078da8e58 Updated VC++ build system.
Silenced some VC++ warnings.
Had to rephrase a partial specialization of the IntrospectionTrait struct in SerializationTest.cpp, please review.
Added a compiler specific workaround in IdentifierTable.h. Is that the way to fix this kind of issues?

llvm-svn: 43074
2007-10-17 15:00:17 +00:00
Steve Naroff 9def2b15c1 Phase 2 of making the Decl class more lightweight...
Move Identifier/Loc instance variables (and associated getters/setters) down from Decl to ScopedDecl/FieldDecl.

Objc AST's can now inherit from Decl without getting instance variables and types that are C specific. For now, I am keeping NextDeclarator, since I believe it may be useful to ObjC. If not, it can be moved later.

llvm-svn: 41934
2007-09-13 21:41:19 +00:00
Chris Lattner fb2eb6941a eliminate some VC++ warnings, patch contributed by Hartmut Kaiser
llvm-svn: 41692
2007-09-04 02:34:27 +00:00
Chris Lattner 9e47ead594 Implement codegen support for lowering "library builtins" like __builtin_isinf
to their corresponding library routines (e.g. isinf).  This allows us to handle
all the stuff in macos math.h, and other stuff as it's added to *Builtins.def.

llvm-svn: 41634
2007-08-31 04:44:06 +00:00
Chris Lattner 1eec6601d9 add the ability to get the llvm function corresponding to a library builtin.
llvm-svn: 41633
2007-08-31 04:31:45 +00:00