Steve Naroff [Sun, 1 Jun 2008 02:43:50 +0000 (02:43 +0000)]
Tweak Sema::ObjCQualifiedIdTypesAreCompatible() to handle qualified interface types on the RHS.
This eliminates a bogus warning identified in the test below.
This fixes <rdar://problem/5968256> clang on xcode: error: incompatible type initializing 'NSObject<XCSelectionSource> *', expected 'id<NSObject,XCSelectionSource>'
Ted Kremenek [Sat, 31 May 2008 20:11:04 +0000 (20:11 +0000)]
Added "InitializeTU" to ASTConsumer. This is used by Sema::ParseAST to pass a
TranslationUnit object instead of an ASTContext. By default it calls
Initialize(ASTConstext& Context) (to match with the current interface used by
most ASTConsumers).
Modified the ObjC-Rewriter to use InitializeTU, and to tell the TranslationUnit
to not free its Decls. This is a workaround for: <rdar://problem/5966749>
Steve Naroff [Sat, 31 May 2008 05:02:17 +0000 (05:02 +0000)]
Fix <rdar://problem/5969777> clang ObjC rewriter: #imported file name mysteriously commented out
This fix involved tightening up needToScanForQualifiers(), which predated ObjCQualifiedIdType.
It also includes a minor tweak to the code that searches for the beginning of the qualified type. If the AST contained the correct beginning of the declaration (i.e. the beginning of the declaration specifiers), this code would be more robust. Since it doesn't, we apply an adhoc heuristic. Note that DeclSpec contains this info...we just don't propagate it to the AST (at present).
Steve Naroff [Sat, 31 May 2008 03:35:42 +0000 (03:35 +0000)]
Hack RewriteObjC::RewriteObjCStringLiteral() to include the filename in the generated code (replacing any non-alphanumeric characters with "_"). This allows header files to contain ObjCStringLiterals.
Eli Friedman [Fri, 30 May 2008 19:58:50 +0000 (19:58 +0000)]
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?
Eli Friedman [Fri, 30 May 2008 19:50:47 +0000 (19:50 +0000)]
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.
Eli Friedman [Fri, 30 May 2008 18:14:48 +0000 (18:14 +0000)]
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.
Eli Friedman [Fri, 30 May 2008 10:24:46 +0000 (10:24 +0000)]
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).
Steve Naroff [Fri, 30 May 2008 00:40:33 +0000 (00:40 +0000)]
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
Eli Friedman [Thu, 29 May 2008 15:09:15 +0000 (15:09 +0000)]
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.
Eli Friedman [Thu, 29 May 2008 11:08:17 +0000 (11:08 +0000)]
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.
Eli Friedman [Thu, 29 May 2008 10:58:49 +0000 (10:58 +0000)]
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.
Ted Kremenek [Tue, 27 May 2008 23:18:07 +0000 (23:18 +0000)]
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.
Eli Friedman [Tue, 27 May 2008 05:07:37 +0000 (05:07 +0000)]
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.
Eli Friedman [Tue, 27 May 2008 04:58:01 +0000 (04:58 +0000)]
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.
Eli Friedman [Tue, 27 May 2008 03:33:27 +0000 (03:33 +0000)]
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.
Eli Friedman [Tue, 27 May 2008 03:14:44 +0000 (03:14 +0000)]
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.
Eli Friedman [Mon, 26 May 2008 12:59:39 +0000 (12:59 +0000)]
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.
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)
Steve Naroff [Thu, 22 May 2008 23:24:08 +0000 (23:24 +0000)]
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.
Dan Gohman [Thu, 22 May 2008 22:12:56 +0000 (22:12 +0000)]
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.