John McCall [Wed, 6 Jul 2011 00:26:06 +0000 (00:26 +0000)]
Change the driver's logic about Objective-C runtimes: abstract out a
structure to hold inferred information, then propagate each invididual
bit down to -cc1. Separate the bits of "supports weak" and "has a native
ARC runtime"; make the latter a CodeGenOption.
The tool chain is still driving this decision, because it's the place that
has the required deployment target information on Darwin, but at least it's
better-factored now.
Douglas Gregor [Tue, 5 Jul 2011 18:30:26 +0000 (18:30 +0000)]
Look through parenthesized declarators when determining whether an
instantiated function template was written with a prototype or via
some kind of typedef. Fixes PR10273 / <rdar://problem/9723679>.
Switch the Decl and Stmt stats printing to use llvm::errs() instead of
fprintf, and to be more consistent in formatting with the other stats
printing routines.
Eli Friedman [Sat, 2 Jul 2011 00:34:19 +0000 (00:34 +0000)]
Make clang behave in a gcc-compatible way in the presence of multiple flags for the same x86 target feature (e.g. -mno-sse -msse). gcc uses a somewhat unintuitive algorithm here in that the enabled SSE instructions is based on the order of the *last* flag for *each* feature-level, so that "-mno-sse -msse2" only enables SSE2, but "-mno-sse -msse2 -msse" enables all SSE levels.
Move the Sema argument to all of the Sema-using helper functions in
SemaDeclAttr to the first argument. This makes them follow the very
consistent policy elsewhere in Sema for helper functions.
Original patch by Caitlin Sadowski, with some tweaking by me.
Mechanical rename of 'd' Decl pointer parameters to 'D'. This is more
conventional in the rest of Clang's codebase, and closer to the current
style recommendations. It also makes the code more internally consistent
as FD, VD, etc are used frequently for particular decl variables.
-Fix mistake in ASTContext::getInnerObjCOwnership noticed by Doug
-Remove unnecessary 'return'.
-Remove unnecessary 'if' check (llvm_unreachable make sure attrStr will be non-null)
-Add a test of transferring ownership to a reference cast type.
[ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:
id x;
(NSString**)&x; // Casting as (__strong NSString**).
-Remove Sema::ActOnCastOfParenListExpr and move most of its functionality to
newly introduced Sema::BuildVectorLiteral.
-Make Sema::ActOnCastExpr handle a vector initializer both when the cast'ed expression
is a ParenListExpr and when it is a ParenExpr.
-Ultimately make Sema::ActOnParenOrParenListExpr independent of what the cast type was.
[ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:
id x;
static_cast<NSString**>(&x); // Casting as (__strong NSString**).
This currently only works for C++ named casts, C casts to follow.
Douglas Gregor [Fri, 1 Jul 2011 21:54:36 +0000 (21:54 +0000)]
Emit guard variables for any weak global that has a run-time
initializer. Previously, we only used guard variables for weak static
data members. Fixes <rdar://problem/9692249>.
Douglas Gregor [Fri, 1 Jul 2011 21:27:45 +0000 (21:27 +0000)]
When adding boolean keywords for typo correction, add either "bool" or
"_Bool" (depending on dialect), but not both, since they have the same
edit distance from "Bool".
Douglas Gregor [Fri, 1 Jul 2011 21:08:19 +0000 (21:08 +0000)]
Don't zero-initialize default-initialized local variables that have
trivial default constructors. This generated-code regression was
caused by r131796, which had simplified the handling of default
initialization in Sema. Fixes <rdar://problem/9694300>.
Richard Trieu [Fri, 1 Jul 2011 20:54:02 +0000 (20:54 +0000)]
For code such as:
int f(int x) {
if (int foo = f(bar)) {}
return 0;
}
Clang produces the following error messages:
paren_imbalance.cc:2:19: error: use of undeclared identifier 'bar'
if (int foo = f(bar)) {}
^
paren_imbalance.cc:2:26: error: expected ')'
if (int foo = f(bar)) {}
^
paren_imbalance.cc:2:6: note: to match this '('
if (int foo = f(bar)) {}
^
The second error is incorrect. This patch will stop Clang from producing an error on parenthesis imbalance during error recovery when there isn't one.
Richard Trieu [Fri, 1 Jul 2011 20:02:53 +0000 (20:02 +0000)]
Fix for PR7410. Allow functions in a derived class that improperly overwrite a virtual function in the base class to be inserted into the derived class function list to prevent extra errors every time the derived class is used.
Richard Smith [Fri, 1 Jul 2011 19:46:12 +0000 (19:46 +0000)]
Fix AST representations of alias-declarations which define tag types. Inside classes, the tag types need to have an associated access specifier, and inside function definitions, they need to be included in the declarations of the DeclStmt. These issues manifested as assertions during template instantiation, and also in a WIP constexpr patch.
Douglas Gregor [Fri, 1 Jul 2011 18:22:13 +0000 (18:22 +0000)]
When we create a precompiled preamble, don't copy the
CompilerInvocation on the stack, because other objects (e.g., the
CompilerInstance) maintain an intrusive reference-counted pointer to
the CompilerInvocation. This doesn't matter in the normal case,
because we take back the CompilerInvocation. However, during crash
recovery, this leads to us trying to free an object on the stack, and
hilarity ensues. Fixes <rdar://problem/9652540>.
John McCall [Fri, 1 Jul 2011 02:19:08 +0000 (02:19 +0000)]
Just mangle substituted template parameter types as unresolved types.
This is kindof questionable but seems to do more-or-less the right thing.
This is not a particularly friendly part of the ABI.
Douglas Gregor [Fri, 1 Jul 2011 01:22:09 +0000 (01:22 +0000)]
Introduce the notion of instantiation dependence into Clang's AST. A
type/expression/template argument/etc. is instantiation-dependent if
it somehow involves a template parameter, even if it doesn't meet the
requirements for the more common kinds of dependence (dependent type,
type-dependent expression, value-dependent expression).
When we see an instantiation-dependent type, we know we always need to
perform substitution into that instantiation-dependent type. This
keeps us from short-circuiting evaluation in places where we
shouldn't, and lets us properly implement C++0x [temp.type]p2.
In theory, this would also allow us to properly mangle
instantiation-dependent-but-not-dependent decltype types per the
Itanium C++ ABI, but we aren't quite there because we still mangle
based on the canonical type in cases like, e.g.,
John McCall [Fri, 1 Jul 2011 00:04:39 +0000 (00:04 +0000)]
Change the mangling of enclosing template template parameters
that serve as the base template name of an unresolved-name to
be mangled as a substitution.
Replace an unreachable error path with an assert
(SourceManager::createFileID cannot return an invalid file ID).
Also update a comment to reflect this.
Chandler Carruth [Thu, 30 Jun 2011 08:14:54 +0000 (08:14 +0000)]
Fix an obvious typo in an attribute's diagnostics.
Patch by Caitlin Sadowski.
Unfortunately, this attribute doesn't seem to have a single test. It is
only mentioned in comments in one test, and as a string literal in
a copy of some Clang code checked in as a test for the Indexer. =[ It
dates from 2009 r74280 as part of OpenCL 1.0.
Introduce a caching mechanism for macro expanded tokens.
Previously macro expanded tokens were added to Preprocessor's bump allocator and never released,
even after the TokenLexer that were lexing them was finished, thus they were wasting memory.
A very "useful" boost library was causing clang to eat 1 GB just for the expanded macro tokens.
Introduce a special cache that works like a stack; a TokenLexer can add the macro expanded tokens
in the cache, and when it finishes, the tokens are removed from the end of the cache.
Now consumed memory by expanded tokens for that library is ~ 1.5 MB.
Douglas Gregor [Wed, 29 Jun 2011 21:22:02 +0000 (21:22 +0000)]
When redeclaring a local extern in the same scope, make sure that we
replace the existing declaration appropriately. Patch by Jordy Rose,
fixes PR10013 / <rdar://problem/9584157>.
David Chisnall [Wed, 29 Jun 2011 13:17:23 +0000 (13:17 +0000)]
Make ARC support default to true. Please can we stop making Objective-C runtime features part of the platform description? This only makes sense for Darwin.
Eli Friedman [Wed, 29 Jun 2011 07:04:55 +0000 (07:04 +0000)]
We don't pass classes with a copy-constructor or destructor byval, so the address takes up an integer register (if one is available). Make sure the x86-64 ABI implementation takes that into account properly.
The fixed implementation is compatible with the implementation both gcc and llvm-gcc use.
rdar://9686430 . (This is the issue that was reported in the thread "[LLVMdev] Segfault calling LLVM libs from a clang-compiled executable".)
Daniel Dunbar [Tue, 28 Jun 2011 23:33:55 +0000 (23:33 +0000)]
Revert r133024, "[format strings] correctly suggest correct type for '%@'
specifiers. Fixes <rdar://problem/9607158>." because it causes false positives
on some code that uses CF toll free bridging.
- I'll let Doug or Ted figure out the right fix here, possibly just to accept
any pointer type.
Chandler Carruth [Tue, 28 Jun 2011 22:48:40 +0000 (22:48 +0000)]
Fix non-determinism in selecting between equal-length names which refer
to the same declaration when correcting typos. This is done by
essentially sorting the corrections as they're added.
Original patch by Kaelyn Uhrain, but modified for style and correctness
by accounting for more than just the textual spelling.
This still is a bit of a WIP hack to make this deterministic. Kaelyn
(and myself) are working on a more principled solution going forward.
Chad Rosier [Tue, 28 Jun 2011 22:29:53 +0000 (22:29 +0000)]
Modify test case to allow buildbots to make forward progress. This test should
now (incorrectly) pass. Once the appropriate fixes have been made this test
should be reverted.