Douglas Gregor [Wed, 1 Apr 2009 15:47:24 +0000 (15:47 +0000)]
Give Type::getDesugaredType a "for-display" mode that can apply more
heuristics to determine when it's useful to desugar a type for display
to the user. Introduce two C++-specific heuristics:
- For a qualified type (like "foo::bar"), only produce a new
desugred type if desugaring the qualified type ("bar", in this
case) produces something interesting. For example, if "foo::bar"
refers to a class named "bar", don't desugar. However, if
"foo::bar" refers to a typedef of something else, desugar to that
something else. This gives some useful desugaring such as
"foo::bar (aka 'int')".
- Don't desugar class template specialization types like
"basic_string<char>" down to their underlying "class
basic_string<char, char_traits<char>, allocator<char>>, etc.";
it's better just to leave such types alone.
Update diagnostics.html with some discussion and examples of type
preservation in C++, showing qualified names and class template
specialization types.
Re-enable PTH testing for cocoa.h and carbon.h. This tests that PTH works on
real-world header files and these tests have caught serious bugs in the past.
Daniel Dunbar [Wed, 1 Apr 2009 07:45:00 +0000 (07:45 +0000)]
x86-32 Darwin ABI: Handle small structures correctly.
- Small structures are returned in a register if:
1. They fit nicely in a register.
2. All fields fit nicely in a register.
(more or less)
- We now pass the first 5000 ABITests if unions are disabled.
- <rdar://problem/6497882> [irgen] x86-32 ABI compatibility with
small structs
Daniel Dunbar [Wed, 1 Apr 2009 07:08:38 +0000 (07:08 +0000)]
x86-32 Darwin ABI: Single element arrays can be part of "single
element structures", which have different ABI rules.
- Current return-arguments-32 status is: 1 out of 1000 failures (-7)
- Also, vectors inside "single element structs" require special
handling.
Fix: <rdar://problem/6740387>. Sending nil to an object that returns a struct
should only be an error if that value is consumed. This fix was largely
accomplished by moving 'isConsumedExpr' back to ParentMap.
Chris Lattner [Wed, 1 Apr 2009 06:23:52 +0000 (06:23 +0000)]
remove ASTContext::buildObjCInterfaceType, which breaks canonical
types. It is no longer needed now that the code generator
re-lays-out interfaces if they are defines after being laid out
from a forward decl.
- Changed PathDiagnosticPiece::getLocation() to return a PathDiagnosticLocation
instead of a FullSourceLoc. This resulted in a bunch of small edits in various
clients.
- Updated BugReporter to include an alternate PathDiagnostic generation
algorithm for PathDiagnosticClients desiring more control-flow pieces.
Daniel Dunbar [Wed, 1 Apr 2009 05:09:09 +0000 (05:09 +0000)]
Pull clang-cc code for generating PTH files based on the input type.
- <rdar://problem/6741594> [pth] don't abuse -x to drive pth
generation
- Simpler, and fixes PR3915.
Cleanup test cases for PTH:
- Update to use -emit-pth
- Removed PTH test of carbon.c and cocoa.mm; these didn't actually
verify anything, and since PTH is token based the extra coverage
(over cocoa.m) isn't particularly helpful.
- Split PTH tests in cocoa.m to cocoa-pth.m, solely to increase
available parallelism when running tests.
Ted, could you update the PTH test cases (include-pth.c and
cocoa-pth.m) to have some sort of positive check that the PTH is
getting used? "# of PTH cache hits" or "tokens read from PTH cache"
statistics would work great. :)
Daniel Dunbar [Wed, 1 Apr 2009 04:37:47 +0000 (04:37 +0000)]
Fix a subtle bug where the cleanup scope entries had a dangling block reference
- <rdar://problem/6732143> Crash when generating @synchronize for
zero-cost exception
- Thanks to Anders for helping track down the problem.
CFG: For 'if(...) {}' (empty body) construct an empty CFGBlock so that we can
distinguish between the true and false branches for path-sensitive analyses.
Chris Lattner [Wed, 1 Apr 2009 02:36:43 +0000 (02:36 +0000)]
fix the two xfails I added with a previous patch by making ObjC interface
types get completed when their definition is seen if previously laid out by
the code generator.
Add '-emit-pth' option to clang-cc as an alternate API for the high-level driver
to generate PTH files. Soon we will remove from clang-cc the GCC-style '-x
c-header' interface for generating PTH files and push this logic to 'clang'.
Daniel Dunbar [Tue, 31 Mar 2009 23:42:16 +0000 (23:42 +0000)]
Add Target hooks for IRgen of [cf]string literals.
- Notably, set section on cfstring literal string data (for now, this
is done everywhere because it matches what we were already doing
for the CFString data itself)
- <rdar://problem/6599098> [irgen] linker requires objc string data
to go into cstring
Daniel Dunbar [Tue, 31 Mar 2009 20:53:55 +0000 (20:53 +0000)]
Driver: Forward -Wp, and -Xpreprocessor arguments to clang when using
the preprocessor.
- PR3602.
- As is inherent in the blanket forwarding options, this will only
work if clang-cc happens to accept what the user passed. Users by
and large should use driver options to interact with the
preprocessor, if at all possible.
Douglas Gregor [Tue, 31 Mar 2009 18:38:02 +0000 (18:38 +0000)]
Implement template instantiation for template names, including both
template template parameters and dependent template names. For
example, the oft-mentioned
typename MetaFun::template apply<T1, T2>::type
can now be instantiated, with the appropriate name lookup for "apply".
Steve Naroff [Tue, 31 Mar 2009 16:53:37 +0000 (16:53 +0000)]
Some "prep" work for handling ObjC @-string constants that contain UTF-8. No functionality change.
Changed GenerateConstantString() to take an ObjCStringLiteral (instead of a std::string). While this isn't strictly necessary, it seems cleaner and allows us to cache to "containsNonAscii" if necessary (to avoid checking in both Sema and CodeGen).
Chris Lattner [Tue, 31 Mar 2009 09:24:30 +0000 (09:24 +0000)]
Fix a problem in ASTContext::addRecordToClass handling forward declarations.
In a case like:
@class foo;
foo *P;
addRecordToClass was making an empty shadow struct for the foo interface and
completing it. Later when an:
@interface foo
...
@endif
foo *Q;
was seen, ASTContext::addRecordToClass would think that foo was already laid
out and not lay out the definition. This fixes it to create a forward declared
struct the first time around, then complete it when the definition is seen.
Note that this causes two tests to regress, because something is trying to get
the size of the forward declared structs returned by this. Previously, this
would end up getting a size of zero but now it properly dies. I'm not sure
what the right solution is for this, so I xfailed the tests.
Fariborz, please take a look at this. The testcase in rdar://6676794 now gets
farther, but dies later because the objc ivar is not assigned a field number.
As an aside, I really don't like the fact that the objc front-end is creating
shadow C structs for ObjC types. This seems like an implementation detail of
the code generator that could be fixed by better factoring of the extant code.
Chris Lattner [Tue, 31 Mar 2009 09:04:50 +0000 (09:04 +0000)]
remove the warning. We don't control what users do, and this code
is run for perfectly reasonable things like NSString* because type
layout is recursive.
Chris Lattner [Tue, 31 Mar 2009 07:46:52 +0000 (07:46 +0000)]
Codegen sometimes crashes on comparisons that aren't legal, just
disable this feature for now, to err on the side of rejecting instead
of sometimes crashing. rdar://6326239
Steve Naroff [Mon, 30 Mar 2009 23:46:03 +0000 (23:46 +0000)]
Implement UCN support for C string literals (C99 6.4.3) and add some very basic tests. Chris Goller has graciously offered to write some test to help validate UCN support.
From a front-end perspective, I believe this code should work for ObjC @-strings. At the moment, I believe we need to tweak the code generation for @-strings (which doesn't appear to handle them). Will be investigating.
Douglas Gregor [Mon, 30 Mar 2009 22:58:21 +0000 (22:58 +0000)]
Improve the representation of template names in the AST. This
representation handles the various ways in which one can name a
template, including unqualified references ("vector"), qualified
references ("std::vector"), and dependent template names
("MetaFun::template apply").
One immediate effect of this change is that the representation of
nested-name-specifiers in type names for class template
specializations (e.g., std::vector<int>) is more accurate. Rather than
representing std::vector<int> as
std::(vector<int>)
we represent it as
(std::vector)<int>
which more closely follows the C++ grammar.
Additionally, templates are no longer represented as declarations
(DeclPtrTy) in Parse-Sema interactions. Instead, I've introduced a new
OpaquePtr type (TemplateTy) that holds the representation of a
TemplateName. This will simplify the handling of dependent
template-names, once we get there.
Ted Kremenek [Mon, 30 Mar 2009 22:20:54 +0000 (22:20 +0000)]
Re-apply 68028. The code had drifted enough that the tests would fail without
it. Will discuss offline whether symbolic regions should by typed or typeless.
Ted Kremenek [Mon, 30 Mar 2009 18:39:15 +0000 (18:39 +0000)]
Convert use of loc::SymbolVal and nonloc::SymbolVal to V.getAsSymbol(). This
also makes this code more correct as it transparently handles SVals that wrapped
TypedViewRegions(SymbolicRegions).