Douglas Gregor [Wed, 4 Apr 2012 05:10:53 +0000 (05:10 +0000)]
When performing template argument deduction for an initializer list,
be sure to perform the argument type adjustments in
[temp.deduct.call]p2, e.g., array decay.
And, when performing these deductions in the context of 'auto', make
sure that we're deducing the P' in std::initializer_list<P'> rather
than the whole initializer list.
Together, this makes code like
for( auto s : {"Deferred", "New", "Open", "Review"}) { }
[preprocessor] In Preprocessor::CachingLex() check whether there were more tokens
cached during the non-cached lex, otherwise we are going to drop them.
Fixes a bogus "_Pragma takes a parenthesized string literal" error when
expanding consecutive _Pragmas in a macro argument.
John McCall [Wed, 4 Apr 2012 02:40:27 +0000 (02:40 +0000)]
When computing the conversion sequence in overload resolution
for converting an empty list to a scalar, be sure to initialize
the source and destination types so that comparison of conversion
sequences will work in case there are multiple viable candidates.
John McCall [Wed, 4 Apr 2012 01:27:53 +0000 (01:27 +0000)]
Enter an expression evaluation context when parsing
statement-expressions. Prevents cleanups and such from being
claimed by the first full-expression in the block.
Change BugReporter's usage of IsCachedDiagnostic to only impact pruning diagnostics emitted to the
console, and leave it up to PathDiagnosticConsumer to unique reports with the shortest path.
Nick Lewycky [Tue, 3 Apr 2012 21:44:08 +0000 (21:44 +0000)]
Remove more redundant lookups. Add a new "all_lookups_iterator" which provides
a view over the contents of a DeclContext without exposing the implementation
details of the StoredDeclsMap. Use this in LookupVisibleDecls to find the
visible declarations. Fixes PR12339!
Replace the workaround from r153445 with a proper fix.
Infinite recursion was happening when DiagnoseInvalidRedeclaration
called ActOnFunctionDeclarator to check if a typo correction works when
the correction was just to the nested-name-specifier because the wrong
DeclContext was being passed in. Unlike a number of functions
surrounding typo correction, the DeclContext passed in for a function is
the context of the function name after applying any nested name
specifiers, not the lexical DeclContext where the
function+nested-name-specifier appears.
Correct handling of _Pragma macro inside a macro argument.
If we are pre-expanding a macro argument don't actually "activate"
the pragma at that point, activate the pragma whenever we encounter
it again in the token stream.
This ensures that we will activate it in the correct location
or that we will ignore it if it never enters the token stream, e.g:
Rework ProgramPoint to bit-mangle the 'Kind' into both Data pointers and the LocationContext. After switching to PointerIntPair, it didn't look like a safe assumption to use the lower 3 bits of the LocationContext* field. Thanks to Jordy Rose and Benjamin Kramer for their feedback.
Anna Zaks [Tue, 3 Apr 2012 02:05:47 +0000 (02:05 +0000)]
[analyzer] Record the basic blocks covered by the analyzes run.
Store this info inside the function summary generated for all analyzed
functions. This is useful for coverage stats and can be helpful for
analyzer state space search strategies.
Change location information for synthesized properties to be at the
property file/line rather than the @synthesize file/line. Avoids
some nasty confusing-ness with conflating the file from the scope
and the line from the original declaration. Use the current scope
location as a separate parameter so that we can match it up
better in the line table with the beginning of the scope.
Update a couple of testcases accordingly since I had to change
that we actually use the passed in location in EmitFunctionStart
and for the new metadata parameter and add a new testcase to
make sure we've got the right line numbers for synthesized
properties.
Fix another false positive in RegionStore involving doing loads from symbolic offsets. We still don't
properly reason about such accesses, but we shouldn't emit bogus "uninitialized value" warnings
either. Fixes <rdar://problem/11127008>.
David Blaikie [Mon, 2 Apr 2012 19:15:28 +0000 (19:15 +0000)]
Correct error recovery when missing 'class' in a template template parameter.
The diagnostic message correctly informs the user that they have omitted the
'class' keyword, but neither suggests this insertion as a fixit, nor attempts
to recover as if they had provided the keyword.
This fixes the recovery, adds the fixit, and adds a separate diagnostic and
corresponding replacement fixit for cases where the user wrote 'struct' or
'typename' instead of 'class' (suggested by Richard Smith as a possible common
mistake).
I'm not sure the diagnostic message for either the original or new cases feel
very Clang-esque, so I'm open to suggestions there. The fixit hints make it
fairly easy to see what's required, though.
Richard Smith [Mon, 2 Apr 2012 18:53:24 +0000 (18:53 +0000)]
PR12438: Profile a reference to a type template parameter by depth and index,
not by canonical decl. This only matters for sizeof...(Pack) expressions; in
all other cases, we'd profile it as a type instead.
Richard Smith [Mon, 2 Apr 2012 18:40:40 +0000 (18:40 +0000)]
Implement DR1402: if a field or base class is not movable, the derived class's
move constructor/move assignment operator are not declared, rather than being
defined as deleted, so move operations on the derived class fall back to
copying rather than moving.
If a move operation on the derived class is explicitly defaulted, the
unmovable subobject will be copied instead of being moved.
Use -rewrite-legacy-objc as clang argument for translating
objective-c's fragile abi, Use -rewrite-objc for translating
objective-c's modern abi. // rdar://11143173
Bob Wilson [Sun, 1 Apr 2012 23:03:29 +0000 (23:03 +0000)]
Ignore unused --serialize-diagnostics option when using llvm-gcc.
llvm-gcc doesn't handle --serialize-diagnostics so when compiling i386
kernel/kext code with -Werror, you get an error about that option being
unused. Claim the argument to prevent this from breaking builds.
<rdar://problem/11161933>
After getting a cursor with clang_getCursor for a particular source location,
allows querying the cursor in order to find out if the location points to a
selector identifier in an objc method or message expression, and which selector index it is.
John McCall [Fri, 30 Mar 2012 21:29:05 +0000 (21:29 +0000)]
Fix a pair of invalidation bugs when emitting protocol definitions
in the fragile and non-fragile Mac ObjC runtimes. No useful test
case. Fixes rdar://problem/11072576.
John McCall [Fri, 30 Mar 2012 21:00:39 +0000 (21:00 +0000)]
Make sure we unique static-local decls across multiple emissions of
the function body, but do so in a way that doesn't make any assumptions
about the static local actually having a proper, unique mangling,
since apparently we don't do that correctly at all.
It retrieves a source range for a piece that forms the cursors spelling name.
Most of the times there is only one range for the complete spelling but for
objc methods and objc message expressions, there are multiple pieces for each
selector identifier.
Chandler Carruth [Fri, 30 Mar 2012 19:44:53 +0000 (19:44 +0000)]
Revert r153723, and its follow-ups r153728 and r153733.
These patches cause us to miscompile and/or reject code with static
function-local variables in an extern-C context. Previously, we were
papering over this as long as the variables are within the same
translation unit, and had not seen any failures in the wild. We still
need a proper fix, which involves mangling static locals inside of an
extern-C block (as GCC already does), but this patch causes pretty
widespread regressions. Firefox, and many other applications no longer
build.
Lots of test cases have been posted to the list in response to this
commit, so there should be no problem reproducing the issues.
Chad Rosier [Fri, 30 Mar 2012 17:33:35 +0000 (17:33 +0000)]
[driver] Create a new L_Group for language options and add the -std= option to
said group. Also classify the group as a CompileOnly_Group so that this option
does not cause an unused argument warning when used with a link command.
rdar://11153013
Douglas Gregor [Fri, 30 Mar 2012 16:20:47 +0000 (16:20 +0000)]
If we encounter a friend class template for which we cannot resolve
the nested-name-specifier (e.g., because it is dependent), do not
error even though we can't represent it in the AST at this point.
This is a horrible, horrible hack. The actual feature we still need to
implement (for C++98!) is covered by PR12292. However, we used to
silently accept this code, so when we recently started rejecting it we
caused some regressions (e.g., <rdar://problem/11147355>). This hack
brings us back to the passable-but-not-good state we had previously.
Anna Zaks [Fri, 30 Mar 2012 05:48:16 +0000 (05:48 +0000)]
[analyzer]Malloc,RetainRelease: Allow pointer to escape via NSMapInsert.
Fixes a false positive (radar://11152419). The current solution of
adding the info into 3 places is quite ugly. Pending a generic pointer
escapes callback.
Anna Zaks [Fri, 30 Mar 2012 05:48:10 +0000 (05:48 +0000)]
[analyzer] Do not inline functions which previously reached max block
count.
This is an optimization for "retry without inlining" option. Here, if we
failed to inline a function due to reaching the basic block max count,
we are going to store this information and not try to inline it
again in the translation unit. This can be viewed as a function summary.
On sqlite, with this optimization, we are 30% faster then before and
cover 10% more basic blocks (partially because the number of times we
reach timeout is decreased by 20%).
John McCall [Fri, 30 Mar 2012 05:43:39 +0000 (05:43 +0000)]
Handle placeholder expressions in an ObjC for-collection loop.
The way we handle this implicitly removes the ability to use
property l-values in this position, but that's really okay.
John McCall [Fri, 30 Mar 2012 04:25:14 +0000 (04:25 +0000)]
When emitting a static local variable in C++, handle
the case that the variable already exists. Partly this is just
protection against people making crazy declarations with custom
asm labels or extern "C" names that intentionally collide with
the manglings of such variables, but the main reason is that we
can actually emit a static local variable twice with the
requirement that it match up. There may be other cases with
(e.g.) the various nested functions, but the main exemplar is
with constructor variants, where we can be forced into
double-emitting the function body under certain circumstances
like (currently) the presence of virtual bases.
Eric Christopher [Fri, 30 Mar 2012 01:07:48 +0000 (01:07 +0000)]
Change location information for synthesized properties to be at the
property file/line rather than the @synthesize file/line. Avoids
some nasty confusing-ness with conflating the file from the scope
and the line from the original declaration.
Update a couple of testcases accordingly since I had to change
that we actually use the passed in location in EmitFunctionStart.
Bill Wendling [Fri, 30 Mar 2012 00:26:17 +0000 (00:26 +0000)]
The UTF16 string referenced by a CFString should go into the __TEXT,__ustring
section. A 'normal' string will go into the __TEXT,__const section, but this
isn't good for UTF16 strings. The __ustring section allows for coalescing, among
other niceties (such as allowing the linker to easily split up strings).
Instead of outputting the UTF16 string as a series of bytes, output it as a
series of shorts. The back-end will then nicely place the UTF16 string into the
correct section, because it's a mensch.
<rdar://problem/10655949>
Add info to ObjCPropertyRefExpr to indicate whether the dot syntax property
reference is going to message the setter, the getter, or both.
Having this info on the ObjCPropertyRefExpr node makes it easier for AST
clients (like libclang) to reason about the meaning of the property reference.
[AST/Sema]
-Use 2 bits (with a PointerIntPair) in ObjCPropertyRefExpr to record the above info
-Have ObjCPropertyOpBuilder set the info appropriately.
[libclang]
-When there is an implicit property reference (property syntax using methods)
have clang_getCursorReferenced return a cursor for the method. If the property
reference is going to result in messaging both the getter and the setter choose
to return a cursor for the setter because it is less obvious from source inspection
that the setter is getting called.
The general idea has the seal of approval by John.
Richard Smith [Thu, 29 Mar 2012 01:16:42 +0000 (01:16 +0000)]
Reject 'template<typename...Ts> void f(Ts ...(x));'. Add a special-case
diagnostic and a fix-it to explain to the user where the ellipsis is
supposed to go.
[arcmt] Fix a bug where a property in a class extension, that did not exist
in the interface, got its attribute rewritten twice, resulting in
'weakweak' or 'strongstrong'.
John McCall [Wed, 28 Mar 2012 23:30:44 +0000 (23:30 +0000)]
When we can't prove that the target of an aggregate copy is
a complete object, the memcpy needs to use the data size of
the structure instead of its sizeof() value. Fixes PR12204.