Kaelyn Uhrain [Mon, 12 Nov 2012 23:48:05 +0000 (23:48 +0000)]
Enable C++11 attribute syntax for warn_unused_result and allow it to be
applied to CXXRecordDecls, where functions with that return type will
inherit the warn_unused_result attribute.
Also includes a tiny fix (with no discernable behavior change for
existing code) to re-sync AttributeDeclKind enum and
err_attribute_wrong_decl_type with warn_attribute_wrong_decl_type since
the enum is used with both diagnostic messages to chose the correct
description.
Anna Zaks [Mon, 12 Nov 2012 23:40:29 +0000 (23:40 +0000)]
[analyzer] Follow up to r167762 - precisely determine the adjustment
conditions.
The adjustment is needed only in case of dynamic dispatch performed by
the analyzer - when the runtime declaration is different from the static
one.
Document this explicitly in the code (by adding a helper). Also, use
canonical Decls to avoid matching against the case where the definition
is different from found declaration.
This fix suppresses the testcase I added in r167762, so add another
testcase to make sure we do test commit r167762.
Richard Smith [Mon, 12 Nov 2012 23:33:00 +0000 (23:33 +0000)]
Factor duplicated implicit memcpy call generation code out of copy/move
assignment generation. This incidentally avoids reusing the same Expr* across
multiple statements in the same object; that was generating slightly broken
ASTs, but I couldn't trigger any observable bad behavior, so no test.
Anna Zaks [Mon, 12 Nov 2012 22:06:24 +0000 (22:06 +0000)]
[analyzer] Fix a regression (from r 165079): compare canonical types.
Suppresses a leak false positive (radar://12663777).
In addition, we'll need to rewrite the adjustReturnValue() method not to
return UnknownVal by default, but rather assert in cases we cannot
handle. To make it possible, we need to correctly handle some of the
edge cases we already know about.
Richard Smith [Mon, 12 Nov 2012 21:38:00 +0000 (21:38 +0000)]
Remove abuse of hasTrivial*, and fix miscompile wherein global arrays with
internal linkage, no uses, trivial construction, and nontrivial destruction
were not emitted.
Chad Rosier [Mon, 12 Nov 2012 21:32:24 +0000 (21:32 +0000)]
If we encounter a fatal error, exit with status 70. For BSD systems this is
defined as an internal software error. This notifies the driver to report
diagnostics information.
rdar://11951540
Ted Kremenek [Mon, 12 Nov 2012 21:20:48 +0000 (21:20 +0000)]
Per discussion on cfe-dev, re-enable suppression of -Wimplicit-fallthrough on C, but also include dialects of C++ earlier than C++11.
There was enough consensus that we *can* get a good language solution
to have an annotation outside of C++11, and without this annotation
this warning doesn't quite mean's completeness criteria for this
kind of warning. For now, restrict this warning to C++11 (where an
annotation exists), and make this the behavior for the LLVM 3.2 release.
Afterwards, we will hammer out a language solution that we are all
happy with.
Bill Wendling [Mon, 12 Nov 2012 06:42:51 +0000 (06:42 +0000)]
Check that the input size is correct for the given constraint.
The 'a', 'c', and 'd' constraints on i386 mean a 32-bit register. We cannot
place a 64-bit value into the 32-bit register. Error out instead of causing the
compiler to spew general badness.
<rdar://problem/12415959>
Rafael Espindola [Mon, 12 Nov 2012 04:10:23 +0000 (04:10 +0000)]
In Sema::MergeVarDecl we handle merging of storage classes and visibility
attributes. In cases where the merged declaration is fully equivalent to the
two original ones, some of the code was getLVForDecl was duplicated.
Cases that are still handled in getLVForDecl are things like
__private_extern__ int N;
int N;
For which we cannot produce a single merged decl with all the information.
Daniel Jasper [Sun, 11 Nov 2012 22:14:55 +0000 (22:14 +0000)]
Fix binding of nodes in case of forEach..() matchers.
When recursively visiting the generated matches, the aggregated bindings need
to be copied during the recursion. Otherwise, we they might not be properly
overwritten (which is shown by the test), or there might be bound nodes present
that were bound on a different matching branch.
Douglas Gregor [Sat, 10 Nov 2012 07:24:09 +0000 (07:24 +0000)]
Rework my implementation of circular-reference finding to not use
CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the
failure introduced in r167651.
Michael Liao [Sat, 10 Nov 2012 05:17:46 +0000 (05:17 +0000)]
Add clang support of RTM from TSX
- New options '-mrtm'/'-mno-rtm' are added to enable/disable RTM feature
- Builtin macro '__RTM__' is defined if RTM feature is enabled
- RTM intrinsic header is added and introduces 3 new intrinsics, namely
'_xbegin', '_xend', and '_xabort'.
- 3 new builtins are added to keep compatible with gcc, namely
'__builtin_ia32_xbegin', '__builtin_ia32_xend', and '__builtin_ia32_xabort'.
- Test cases for pre-defined macro and new intrinsic codegen are added.
Ted Kremenek [Sat, 10 Nov 2012 01:47:40 +0000 (01:47 +0000)]
Disable -Wimplicit-fallthrough when not using C++.
The rationale is that there is no good workflow to silence the warning
for specific cases, other than using pragmas. This is because the
attribute to decorate an explicit fall through is only available
in C++11.
By that argument, this should probably also be disabled unless one
is using C++11, but apparently there is an explicit test case for
this warning when using C++98. This will require further discussion
on cfe-commits.
Jordan Rose [Sat, 10 Nov 2012 01:40:08 +0000 (01:40 +0000)]
[analyzer] When invalidating symbolic offset regions, take fields into account.
Previously, RegionStore was being VERY conservative in saying that because
p[i].x and p[i].y have a concrete base region of 'p', they might overlap.
Now, we check the chain of fields back up to the base object and check if
they match.
This only kicks in when dealing with symbolic offset regions because
RegionStore's "base+offset" representation of concrete offset regions loses
all information about fields. In cases where all offsets are concrete
(s.x and s.y), RegionStore will already do the right thing, but mixing
concrete and symbolic offsets can cause bindings to be invalidated that
are known to not overlap (e.g. p[0].x and p[i].y).
This additional refinement is tracked by <rdar://problem/12676180>.
Douglas Gregor [Sat, 10 Nov 2012 01:18:17 +0000 (01:18 +0000)]
Diagnostic circular inheritance involving dependent base classes. We
would have diagnosed this at instantiation time anyway, if only we
didn't hang on all of these test cases. Fixes <rdar://problem/12629723>
David Blaikie [Sat, 10 Nov 2012 01:04:23 +0000 (01:04 +0000)]
PR14296: function parameter name collisions in function try/catch
C++11 3.3.3/2 "A parameter name shall not be redeclared in the outermost block
of the function definition nor in the outermost block of any handler associated
with a function-try-block."
It's not totally clear to me whether the "FIXME" case is covered by this, but
Richard Smith thinks it probably should be. It's just a bit more involved to
fix that case.
Richard Smith [Fri, 9 Nov 2012 23:03:14 +0000 (23:03 +0000)]
PR13788: Don't perform checks on the initializer of a dependently-typed
variable. Previously we didn't notice the type was dependent if the only
dependence came from an array bound.
Richard Smith [Fri, 9 Nov 2012 22:36:44 +0000 (22:36 +0000)]
PR14303: Add a NoDriverOption flag to those options which are not accepted by
the driver (the options defined in CC1Options.td) and exclude their help from
"clang --help".
Add a FileCharacteristic parameter to SourceManager::createFileIDForMemBuffer
for completeness and use it in CompilerInstance::InitializeSourceManager if
the input is a memory buffer.
Andy Gibbs [Fri, 9 Nov 2012 13:24:30 +0000 (13:24 +0000)]
Improved support for removing the comma preceding __VA_ARGS__ where __VA_ARGS__
is empty in a variadic macro expansion. This fixes a divergence in support for
the ", ## __VA_ARGS__" GCC extension which differed in behaviour when in strict
C99 mode (note: there is no change in behaviour has been made in the gnu99 mode
that clang uses by default). In addition, there is improved support for the
Microsoft alternative extension ", __VA_ARGS__".
Fix a bug I found while preparing my devmtg talk: When passing NULL to a
function that takes a const Foo&, where Foo is convertible from a large number
of pointer types, we print ALL the overloads, no matter the setting of
-fshow-overloads.
There is potential follow-on work in unifying the "print candidates, but not
too many" logic between OverloadCandidateSet::NoteCandidates and
ImplicitConversionSequence::DiagnoseAmbiguousConversion.
Benjamin Kramer [Thu, 8 Nov 2012 12:59:15 +0000 (12:59 +0000)]
Set TLSSupported to false on Haiku.
Haiku does not support this (yet). Leaving it set to true leads to
configure scripts detecting __thread being available and Clang emitting
code for it, resulting in binaries the runtime_loader will refuse to
load.
Richard Smith [Wed, 7 Nov 2012 23:56:21 +0000 (23:56 +0000)]
When deciding whether to convert an array construction loop into a memcpy, look
at whether the *selected* constructor would be trivial rather than considering
whether the array's element type has *any* non-trivial constructors of the
relevant kind.
Dmitri Gribenko [Wed, 7 Nov 2012 23:52:25 +0000 (23:52 +0000)]
Force C89 for c-index-test.c
MSVC supports only C89, so it is important to keep c-index-test.c
buildable with C89. However, Clang defaults to C99, so while building
Clang with Clang one can introduce C99 constructs into c-index-test.c
without noticing.
Thanks to Nakamura Takumi for helping with MSVC bits.
Richard Trieu [Wed, 7 Nov 2012 21:17:13 +0000 (21:17 +0000)]
When template deduction fails on a derived class, try a template deduction on
the base class. If the base class deduction succeeds, use those results. If
it fails, keep using the results from the derived class template deduction.
This prevents an assertion later where the type of deduction failure doesn't
match up with the template deduction info.
David Chisnall [Wed, 7 Nov 2012 16:50:40 +0000 (16:50 +0000)]
Fix the Objective-C exception rethrow from cleanups (GNU runtimes). Note that
a bug in the inliner still causes the wrong thing to happen at -O2 and above
(PR14116).
Richard Smith [Wed, 7 Nov 2012 01:14:25 +0000 (01:14 +0000)]
PR11851 (and duplicates): Whenever a constexpr function is referenced,
instantiate it if it can be instantiated and implicitly define it if it can be
implicitly defined. This matches g++'s approach. Remove some cases from
SemaOverload which were marking functions as referenced when just planning how
overload resolution would proceed; such cases are not actually references.