Steve Naroff [Thu, 5 Jun 2008 14:49:39 +0000 (14:49 +0000)]
Fix <rdar://problem/5986833> clang on xcode: incompatible type returning 'void', expected 'int'.
- Changed Sema::ObjCActOnStartOfMethodDef() to more accurately type "self" in factory methods.
- Changed Sema::ActOnInstanceMessage() to use the new type to restrict the lookup.
Steve Naroff [Thu, 5 Jun 2008 13:55:23 +0000 (13:55 +0000)]
Fix <rdar://problem/5987482> clang on xcode: null dereference in Sema::ActOnMemberReferenceExpr.
In addition to fixing the crasher, this commit fixes further improves property lookup (by searching protocols of qualified interfaces..."NSObject <prot>").
Ted Kremenek [Wed, 4 Jun 2008 20:49:03 +0000 (20:49 +0000)]
ccc-analyzer now properly eats the -install_name, -exported_symbols_list, -current_version, -compatibility_version, and -sectorder command line arguments.
Eli Friedman [Wed, 4 Jun 2008 19:41:28 +0000 (19:41 +0000)]
For setting attributes, don't assume there are ParamVarDecls available,
because trying to access non-existent ParamVarDecls can crash.
Testcase from the original source for PR2414.
Eli Friedman [Tue, 3 Jun 2008 21:01:11 +0000 (21:01 +0000)]
Re-fix r51907 in a way which doesn't affect valid code. This essentially
moves the check for the invalid construct to a point where it doesn't
affect other uses of isIntegerConstantExpr, and we can warn properly
when the extension is used. This makes it a bit more complicated, but
it's a lot cleaner.
Steve, please tell me if this check is sufficient to handle the
relevant system header. I know it's enough to handle the testcase, but
I don't know what exactly the original looks like.
Steve Naroff [Tue, 3 Jun 2008 12:56:35 +0000 (12:56 +0000)]
Allow for a GCC cast extension.
Fixes part of <rdar://problem/5980829> clang on xcode: used type 'NSRange' where arithmetic or pointer type is required.
Eli Friedman [Sun, 1 Jun 2008 15:54:49 +0000 (15:54 +0000)]
First cut at setting attributes for functions and calls; this puts us
much closer to passing the gcc struct layout tests.
It might be possible to refactor this a bit, but I'm not sure there's
actually enough common code for that to be useful.
To get the calling convention completely correct, a bit of
platform-specific code is necessary even for x86-Linux. On x86-Linux, the
alignment of function parameters is extremely strange; as far as I can tell,
it's always 4 except for SSE vectors or structs containing SSE vectors. I'm
continuing to investigate this.
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.