Richard Smith [Wed, 28 Nov 2012 03:45:24 +0000 (03:45 +0000)]
C++ core issue 1344, PR10618: promote "addition of default argument makes this
a special member" diagnostic from warning to error, and fix the cases where it
produced diagnostics with incorrect wording.
We don't support this as an extension, and we ban it even in C++98 mode. This
breaks too much (for instance, the ABI-specified calling convention for a type
can change if it acquires a copy constructor through the addition of a default
argument).
Ted Kremenek [Tue, 27 Nov 2012 23:05:37 +0000 (23:05 +0000)]
Provide stop-gap solution to crash reported in PR 14436.
This was also covered by <rdar://problem/12753384>. The static analyzer
evaluates a CXXConstructExpr within an initializer expression and
RegionStore doesn't know how to handle the resulting CXXTempObjectRegion
that gets created. We need a better solution than just dropping the
value, but we need to better understand how to implement the right
semantics here.
Thanks to Jordan for his help diagnosing the behavior here.
objective-C arc: load of a __weak object happens via call to
objc_loadWeak. This retains and autorelease the weakly-refereced
object. This hidden autorelease sometimes makes __weak variable alive even
after the weak reference is erased, because the object is still referenced
by an autorelease pool. This patch overcomes this behavior by loading a
weak object via call to objc_loadWeakRetained(), followng it by objc_release
at appropriate place, thereby removing the hidden autorelease. // rdar://10849570
Bill Schmidt [Tue, 27 Nov 2012 02:46:43 +0000 (02:46 +0000)]
This patch addresses an incompatibility relative to the 64-bit PowerPC
ELF ABI.
Complex values are to be passed in registers as though the real and
imaginary parts were passed as separate parameters. Prior to this
patch, complex values were passed as byval aggregates. It turns out
that specifying getDirect() for all complex types when classifying the
argument type results in the desired behavior.
The new Clang test case verifies that the correct LLVM IR is generated
for caller and callee for each of the underlying types for _Complex.
Michael Han [Mon, 26 Nov 2012 22:54:45 +0000 (22:54 +0000)]
Improve diagnostic on C++11 attribute specifiers that appear at wrong syntactic locations around class specifiers.
This change list implemented logic that explicitly detects several combinations of locations where C++11 attribute
specifiers might be incorrectly placed within a class specifier. Previously we emit generic diagnostics like
"expected identifier" for such cases; now we emit specific diagnostic against the misplaced attributes, this also
fixed a bug in old code where attributes appear at legitimate locations were incorrectly rejected.
Jordan Rose [Mon, 26 Nov 2012 19:59:57 +0000 (19:59 +0000)]
[analyzer] SATestBuild.py: allow make builds to disable parallelization
Before, SATestBuild unilaterally added '-j<n>' to every project built with
'make'. Now, we check and see if there's a -j option already specified, which
allows a project to explicitly be marked '-j1'.
Anna Zaks [Mon, 26 Nov 2012 19:11:46 +0000 (19:11 +0000)]
[analyzer] Fix a crash reported in PR 14400.
The AllocaRegion did not have the superRegion (based on LocationContext)
as part of it's hash. As a consequence, the AllocaRegions from
different frames were uniqued to be the same region.
Richard Smith [Mon, 26 Nov 2012 08:32:48 +0000 (08:32 +0000)]
PR14428: When instantiating a 'new' expression, if we had a non-dependent
initialization, don't rebuild it. Remove a couple of hacks which were trying to
work around this. Fix the special case for one-argument CXXConstructExprs to
not apply if the one argument is a default argument.
NAKAMURA Takumi [Sat, 24 Nov 2012 23:17:09 +0000 (23:17 +0000)]
Revert r168519, "Merge used flags so that we don't have to iterate on isUsed. With this change"
It brought bunch of (possibly false) warnings.
llvm/unittests/VMCore/PassManagerTest.cpp:60:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
char ModuleNDNM::ID=0;
^
llvm/unittests/VMCore/PassManagerTest.cpp:86:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
char ModuleNDM2::ID=0;
^
llvm/unittests/VMCore/PassManagerTest.cpp:106:21: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
char ModuleDNM::ID=0;
^
llvm/unittests/VMCore/PassManagerTest.cpp:217:16: warning: variable 'initcount' is not needed and will not be emitted [-Wunneeded-internal-declaration]
int LPass::initcount=0;
^
llvm/unittests/VMCore/PassManagerTest.cpp:218:16: warning: variable 'fincount' is not needed and will not be emitted [-Wunneeded-internal-declaration]
int LPass::fincount=0;
^
llvm/unittests/VMCore/PassManagerTest.cpp:259:16: warning: variable 'inited' is not needed and will not be emitted [-Wunneeded-internal-declaration]
int BPass::inited=0;
^
llvm/unittests/VMCore/PassManagerTest.cpp:260:16: warning: variable 'fin' is not needed and will not be emitted [-Wunneeded-internal-declaration]
int BPass::fin=0;
^
llvm/unittests/VMCore/PassManagerTest.cpp:283:24: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
char OnTheFlyTest::ID=0;
^
8 warnings generated.
Rafael Espindola [Fri, 23 Nov 2012 13:54:40 +0000 (13:54 +0000)]
Check that we don't warn on this testcase. This is basically a test that
Decl::isUsed checks the attribute. If the function had a body just the check
is DeclMustBeEmitted would be sufficient.
Bob Wilson [Fri, 23 Nov 2012 06:14:39 +0000 (06:14 +0000)]
Reapply a subset of r167567 to clean up Darwin-specific code for invoking gcc.
Unlike my previous attempt at this, this patch leaves intact the check for
whether clang can handle the input file type, and for non-Darwin toolchains it
will invoke gcc for things it cannot handle. For Darwin toolchains, the
behavior reported in pr14338 still occurs with this patch, but that is a
definite improvement from what happens currently, where it just crashes with
an assertion failure.
Richard Smith [Thu, 22 Nov 2012 00:24:47 +0000 (00:24 +0000)]
Fix CXXRecordDecl::forallBases to not look through bases which are dependent
and defined within the current instantiation, but which are not part of the
current instantiation. Previously, it would look at bases which could be
specialized separately from the current template.
Chandler Carruth [Wed, 21 Nov 2012 23:40:23 +0000 (23:40 +0000)]
Fix the '-fuse-init-array' option to actually be an option.
Previously, this flag to CC1 was never exposed at the clang driver
layer, and if you happened to enable it (by being on Android or GCC 4.7
platform), you couldn't *disable* it, because there was no 'no' variant.
The whole thing was confusingly implemented.
Now, the target-specific flag processing gets the driver arg list, and
we use standard hasFlag with a default based on the GCC version and/or
Android platform. The user can still pass the 'no-' variant to forcibly
disable the flag, or pass the positive variant to clang itself to enable
the flag.
The test has also been substantially cleaned up and extended to cover
these use cases.
Alexey Samsonov [Wed, 21 Nov 2012 14:17:42 +0000 (14:17 +0000)]
[Sanitizer] force linking with static sanitizer runtimes on Darwin even if they are not found in resource directory. Add test checking sanitizer linker flags on Darwin.
Rafael Espindola [Tue, 20 Nov 2012 23:23:57 +0000 (23:23 +0000)]
Don't walk a linked list twice in the same function. On my machine this takes
"clang -cc1" on a file with 10k repetitions of
extern int no_such_variable;
from 1.434s to 1.133s.
Kaelyn Uhrain [Mon, 19 Nov 2012 18:49:53 +0000 (18:49 +0000)]
When adding a NamedDecl to a correction, add the underlying Decl (via
getUnderlyingDecl()) so that derivatives of
CorrectionCandidateCallback::ValidateCandidate(...) don't have to worry
about being thrown by UsingDecls and such.
Logan Chien [Mon, 19 Nov 2012 11:45:31 +0000 (11:45 +0000)]
Enable -fuse-init-array for Android X86/MIPS.
The dynamic linker of Android does not support .ctors/.dtors.
We should emit .init_array and .fini_array regardless the
gcc version.
NOTE: This patch does not affect the ARM backend, because
it is required to generate .init_array and .fini_array
for program targeting ARM AAPCS and AEABI.
Chandler Carruth [Mon, 19 Nov 2012 03:52:03 +0000 (03:52 +0000)]
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
objective-C: Do not issue deprecated warning about implementation
of a deprecated method in original class (or category), only
in overrides. // rdar://12717705
Andy Gibbs [Sat, 17 Nov 2012 19:18:27 +0000 (19:18 +0000)]
Prevent premature macro expansion in __has_builtin, __has_feature,
__has_attribute, __has_extension, making them behave more akin to
conventional macros.
Andy Gibbs [Sat, 17 Nov 2012 19:15:38 +0000 (19:15 +0000)]
Refactored duplicate string literal lexing code within Preprocessor, into a
common LexStringLiteral function. In doing so, some consistency problems have
been ironed out (e.g. where the first token in the string literal was lexed
with macro expansion, but subsequent ones were not) and also an erroneous
diagnostic has been corrected.
LexStringLiteral is complemented by a FinishLexStringLiteral function which
can be used in the situation where the first token of the string literal has
already been lexed.
Ted Kremenek [Sat, 17 Nov 2012 02:00:00 +0000 (02:00 +0000)]
Switch -Wuninitialized to use a reverse-post order traversal as
an initial baseline for enqueued blocks, but use a simple DFS stack
for propagating changes quickly up back edges.
This provides a 3.5% reduction in -fsyntax-only time on sqlite3.c.
Chad Rosier [Fri, 16 Nov 2012 22:31:39 +0000 (22:31 +0000)]
[driver] Add the missing TY_PP_ObjCXX_Alias case to the isCXX function.
This was causing different behavior when using -x objective-c++-cpp-output as
compared to -x objc++-cpp-output. Specifically, the driver was not adding the
-fcxx-exceptions flag in the latter case.
rdar://12680312
Dmitri Gribenko [Fri, 16 Nov 2012 21:43:31 +0000 (21:43 +0000)]
StmtDumper: remove incomplete support for limiting the maximum dump depth.
There are better ways of limiting the amount of information if there is a need
for that.
Daniel Jasper [Fri, 16 Nov 2012 18:39:22 +0000 (18:39 +0000)]
Fix partial-match-bind-behavior with forEachDescendant() matchers.
The problem is that a partial match of an (explicit or implicit) allOf matcher
binds results, i.e.
recordDecl(decl().bind("x"), hasName("A"))
can very well bind a record that is not named "A". With this fix, the common
cases of stumbling over this bug are fixed by the BoundNodesMap overwriting the
results of a partial match. An error can still be created with a weird
combination of anyOf and allOf (see inactive test). We need to decide whether
this is worth fixing, as the fix will have performance impact.
This has been broken for a while, but the branch was never being taken.
(We were trying to do 'str + floatVal'; now we do 'str % intVal' and use
the '%d' format.)