Douglas Gregor [Mon, 26 Mar 2012 16:54:18 +0000 (16:54 +0000)]
When diagnosing an invalid out-of-line redeclaration, don't permit
typo correction to introduce a nested-name-specifier; we aren't
prepared to handle it here. Fixes PR12297 / <rdar://problem/11075219>.
Douglas Gregor [Mon, 26 Mar 2012 15:52:37 +0000 (15:52 +0000)]
Canonicalize the declaration we write to a PCH file for an
InjectedClassNameType; otherwise, it won't be properly wired to the
original (canonical) declaration when it is deserialized. Fixes
<rdar://problem/11112464>.
Benjamin Kramer [Mon, 26 Mar 2012 15:39:31 +0000 (15:39 +0000)]
Driver: Factor string vector push_back into a helper class and optimize it.
Due to lack of move semantics we would create a temporary std::string from the
string literal, copy it into the vector and discard the temporary. This leads
to massive code bloat, optimizing it saves 50k on i386-linux-Release+Asserts.
While there add a two-element overload for push_back, simplifying code a bit.
Richard Smith [Mon, 26 Mar 2012 04:58:10 +0000 (04:58 +0000)]
Handle instantiations of redeclarations of forward-declared enumerations within
templated functions. Build a redeclaration chain, and only instantiate the
definition of the enum when visiting the defining declaration.
Jordy Rose [Sat, 24 Mar 2012 03:03:29 +0000 (03:03 +0000)]
[analyzer] Restart path diagnostic generation if any of the visitors change the report configuration while walking the path.
This required adding a change count token to BugReport, but also allowed us to ditch ImmutableList as the BugReporterVisitor data type.
Also, remove the hack from MallocChecker, now that visitors appear in the opposite order. This is not exactly a fix, but the common case -- custom diagnostics after generic ones -- is now the default behavior.
[parser] If there are unmatched braces in a function definition, try to
recover by returning the statements that we parsed so far, instead of
dropping the whole function body.
Richard Smith [Fri, 23 Mar 2012 23:09:08 +0000 (23:09 +0000)]
When defining a forward-declared enum, don't try to attach the definition to
a previous declaration if the redeclaration is invalid. That way lies madness.
Fixes a crash-on-invalid reported by Abramo.
Ted Kremenek [Fri, 23 Mar 2012 06:26:56 +0000 (06:26 +0000)]
Avoid applying retain/release effects twice in RetainCountChecker when a function call was inlined (i.e., we do not need to apply summaries in such cases).
Richard Smith [Fri, 23 Mar 2012 03:33:32 +0000 (03:33 +0000)]
Support for definitions of member enumerations of class templates outside the
class template's definition, and for explicit specializations of such enum
members.
[libclang] For a CXCursor_ObjCInstanceMethodDecl/CXCursor_ObjCClassMethodDecl cursor,
return from clang_getCursorLocation the start location of the method name.
Bill Wendling [Thu, 22 Mar 2012 23:25:07 +0000 (23:25 +0000)]
When an MMX output variable is tied to the input variable, we have to implicitly
cast the value to x86_mmx. This gives the ASM string the correct call signature.
<rdar://problem/10919182>
Eli Friedman [Thu, 22 Mar 2012 22:36:39 +0000 (22:36 +0000)]
Make sure we correctly set the alignment for vector loads and stores associated with vector element lvalues. Patch by Kevin Schoedel (with some minor modifications by me).
[PCH] When we are replacing a decl in a chained PCH that is also a DeclContext,
make sure to fully load its external lexical and visible declarations before
re-writing it.
Chandler Carruth [Thu, 22 Mar 2012 06:22:13 +0000 (06:22 +0000)]
Relax the FileCheck assertions in this test a touch. Previously the test
relied on an artifact of how the inliner and subsequent passes in
clang's -O3 mode happen to treat basic blocks and the labels for the
basic blocks. In my work on the inliner, and changed this fundamental
assumption, and the label that was being checked on the entry basic
block will no longer appear in opt builds. There was no reason to expect
the label to always be present anyways, much to my regret.
I've changed the test to just ensure that we return an immediate
constant. If there are intervening instructions, that's bad, but not
really that relevant to the test.
I'd love it if others have a better way of checking that a function body
contains only a 'ret' instruction that isn't dependent on whether or not
the entry block receives a label...
Richard Smith [Thu, 22 Mar 2012 03:35:28 +0000 (03:35 +0000)]
During the instantiation of a class template specialization, that
specialization is known to be incomplete. If we're asked to try to
complete it, don't attempt to instantiate it again -- that can lead
to stack overflow, and to rejects-valids if the class being incomplete
is not an error.
Simplify DataRecursiveIntBinOpEvaluator::VisitBinOp() a bit and make sure we don't
evaluate RHS if LHS could not be evaluated and keepEvaluatingAfterFailure() is false.
Richard Trieu [Wed, 21 Mar 2012 23:30:30 +0000 (23:30 +0000)]
Change the binary operator data recursive evaluator to not stop at the first
non-constant value encountered. This allows the evaluator to deduce that
expressions like (x < 5 || true) is equal to true. Previously, it would visit
x and determined that the entire expression is could not evaluated to a
constant.
Anna Zaks [Wed, 21 Mar 2012 19:45:08 +0000 (19:45 +0000)]
[analyzer] Malloc: Utter the name of the leaked variable.
Specifically, we use the last store of the leaked symbol in the leak diagnostic.
(No support for struct fields since the malloc checker doesn't track those
yet.)
+ Infrastructure to track the regions used in store evaluations.
This approach is more precise than iterating the store to
obtain the region bound to the symbol, which is used in RetainCount
checker. The region corresponds to what is uttered in the code in the
last store and we do not rely on the store implementation to support
this functionality.
Bob Wilson [Wed, 21 Mar 2012 17:19:12 +0000 (17:19 +0000)]
Duplicated code is bad. At least make it consistent.
The getARMTargetCPU and getLLVMArchSuffixForARM functions exist in both
Toolchain.cpp and Tools.cpp. This stuff needs a thorough overhaul. In the
meantime, this patch at least makes them consistent. One version had been
converted to use StringSwitch, and the other version had new Cortex M-series
processors added.
Allow void blocks to return witn a void expression in
c-mode to match behavior with void functions in c. Issue
warning with -pedantic. // rdar://11069896
Bob Wilson [Wed, 21 Mar 2012 16:31:37 +0000 (16:31 +0000)]
For Darwin, do not let -mcpu override the -arch option. <rdar://11059238>
On Darwin the architecture and the corresponding Mach-O slice is typically
specified with -arch. If not, it defaults to the current host architecture.
Do not use -mcpu to override the -arch value. This is only an issue when
people need to use specialized code for a non-default CPU (hopefully guarded
by run-time checks to detect the current processor). The -mcpu option is
still used for the -target-cpu option to clang, but this patch causes it to
not be used to set the architecture in the target triple.
John McCall [Wed, 21 Mar 2012 06:57:19 +0000 (06:57 +0000)]
For the annals of subtle but terrible bugs: fix a longstanding bug
in vtable layout where virtual methods inherited from virtual bases
could be assigned the same vcall adjustment slot if they shared
a name and parameter signature but differed in their
cv-qualification. The code was already trying to handle this
case, but unfortunately used the ordinary type qualifiers
(which are always empty here) instead of the method qualifiers.
This seems like something that the API should discourage, but
I don't know how to carry that principle out in this instance.
Eliminate this function's need for an ASTContext while we're at it.
This bug affects the ABI, and fixing it brings us into accord with
the Itanium ABI (and GCC's implementation of it), but, obviously,
technically breaks full compatibility with previous releases of Clang.
Just letting you know.
John McCall [Wed, 21 Mar 2012 00:45:33 +0000 (00:45 +0000)]
Test case for rdar://problem/11055105, a bug with the instantiation
of references to function template parameters in noexcept clauses when
the instantiation is forced from a point during parsing when a block
is in scope.