Nick Lewycky [Sun, 22 Sep 2013 10:06:57 +0000 (10:06 +0000)]
Simplify code to equivalent code. No need to test for null after cast<>, use
takeAs<> instead of cast<>(.take()). Fix 80-column violation in whitespace after
comment.
David Majnemer [Sun, 22 Sep 2013 01:24:26 +0000 (01:24 +0000)]
Parse: Don't crash during parsing if we lack a simple-type-specifier
Summary:
Parsing cast expressions during error recovery can put us in a bad
state. Check to see if the token for a simple-type-specifier makes
sense before further parsing.
Richard Smith [Sat, 21 Sep 2013 21:55:46 +0000 (21:55 +0000)]
PR17295: Do not allow explicit conversion functions to be used in cases where
an additional conversion (other than a qualification conversion) would be
required after the explicit conversion.
Conversely, do allow explicit conversion functions to be used when initializing
a temporary for a reference binding in direct-list-initialization.
Richard Smith [Sat, 21 Sep 2013 21:19:19 +0000 (21:19 +0000)]
Rearrange narrowing checks in initialization to be a different form of step
rather than a post-processing action, so we can support inserting these checks
at stages other than the end of the initialization. No functionality change
intended.
Petar Jovanovic [Sat, 21 Sep 2013 01:27:01 +0000 (01:27 +0000)]
[Mips] Allocate NaClTargetInfo for MIPSEL NaCl
A patch to AllocateTarget function to recognize llvm::Triple::NaCl for
MIPSEL and return NaClTargetInfo. Additional test has been added to check
if the expected macros get defined.
Switch tests in test/Headers to use %clang_cc1 rather than %clang. There
is no need to go through the driver indirection here, and it clutters
things up as dependencies can sneak in for specific things the driver is
doing.
Richard Smith [Fri, 20 Sep 2013 20:10:22 +0000 (20:10 +0000)]
Refactor: CheckExplicitInitList is only called to check an entire InitListExpr,
so the Index in/out parameters are pointless (always passed in as 0, always
ignored by the caller).
Jordan Rose [Fri, 20 Sep 2013 16:51:50 +0000 (16:51 +0000)]
[analyzer] Use getParentIgnoreParenCasts instead of doing it by hand.
Apart from being more compact and already implemented, this also handles the
case where the parent is null. (It does also ignore all casts, not just
implicit ones, but this is more efficient to test and in the case we care
about---a message in a PseudoObjectExpr---there should only be implicit casts
anyway.
[ASan] Do not imply -undefined dynamic_lookup when linking dylibs with -fsanitize=address.
Instead add the ASan runtime to the linker command line so that only the ASan API functions can be undefined in the target library.
Richard Trieu [Fri, 20 Sep 2013 03:03:06 +0000 (03:03 +0000)]
Modify the uninitialized field visitor to detect uninitialized use across the
fields in the class. This allows a better checking of member intiailizers and
in class initializers in regards to initialization ordering.
For instance, this code will now produce warnings:
class A {
int x;
int y;
A() : x(y) {} // y is initialized after x, warn here
A(int): y(x) {} // default initialization of leaves x uninitialized, warn here
};
Several test cases were updated with -Wno-uninitialized to silence this warning.
Richard Smith [Fri, 20 Sep 2013 01:15:31 +0000 (01:15 +0000)]
Switch the semantic DeclContext for a block-scope declaration of a function or
variable from being the function to being the enclosing namespace scope (in
C++) or the TU (in C). This allows us to fix a selection of related issues
where we would build incorrect redeclaration chains for such declarations, and
fail to notice type mismatches.
Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern,
which is only found when searching scopes, and not found when searching
DeclContexts. Such a declaration is only made visible in its DeclContext if
there are no non-LocalExtern declarations.
Richard Smith [Fri, 20 Sep 2013 00:27:40 +0000 (00:27 +0000)]
PR17290: Use 'false' macro in fix-it hint for initializing a variable of type
_Bool in C, if the macro is defined. Also teach FixItUtils to look at whether
the macro was defined at the source location for which it is creating a fixit,
rather than looking at whether it's defined *now*. This is especially relevant
for analysis-based warnings which are delayed until end of TU.
Don't correct typos in Sema::BuildCXXNestedNameSpecifier with -fms-extensions
When -fms-extensions is enabled, the typo correction was being called here on
non-error paths (as in test/SemaTemplate/lookup-dependent-bases.cpp) and correct
compilation depended on Sema::CorrectTypo not finding a viable candidate.
Hans Wennborg [Thu, 19 Sep 2013 20:32:16 +0000 (20:32 +0000)]
clang-cl: implement /fallback mode
When this flag is enabled, clang-cl falls back to cl.exe if it
cannot compile the code itself for some reason.
The idea is to use this to help build projects that almost compile
with clang-cl, except for some files that can then be built with
the fallback mechanism.
ObjectiveC: Allow NS_RETURNS_INNER_POINTER annotation
of ObjectiveC properties to mean annotation of
NS_RETURNS_INNER_POINTER on its synthesized getter.
This also facilitates more migration to properties when
methods are annotated with NS_RETURNS_INNER_POINTER.
// rdar://14990439
Eli Friedman [Thu, 19 Sep 2013 00:41:32 +0000 (00:41 +0000)]
Make Preprocessor::Lex non-recursive.
Before this patch, Lex() would recurse whenever the current lexer changed (e.g.
upon entry into a macro). This patch turns the recursion into a loop: the
various lex routines now don't return a token when the current lexer changes,
and at the top level Preprocessor::Lex() now loops until it finds a token.
Normally, the recursion wouldn't end up being very deep, but the recursion depth
can explode in edge cases like a bunch of consecutive macros which expand to
nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this
patch).
Hans Wennborg [Wed, 18 Sep 2013 22:26:39 +0000 (22:26 +0000)]
clang-cl: Don't warn about overriding /MD with /MT, /Fo with another /Fo, etc.
I put in the warnings because MSVC has them, but I don't think they're very
useful.
Clang does not warn about overriding flags in general, e.g. it's perfectly
fine to have -fomit-frame-pointer followed by -fno-omit-frame-pointer.
We should focus on warning where things get confusing, such as with the
/TP and /TC options. In "clang-cl /TC a.c /TP b.cc", the user might not
realize that the /TP flag will apply to both files, and we warn about that.
Adrian Prantl [Wed, 18 Sep 2013 22:08:57 +0000 (22:08 +0000)]
Debug info: Explicitly set the DIVariable::isIndirect() flag for VLAs.
This allows us to get rid of an ugly hack in the backend.
Paired commit with LLVM.
ObjectiveC migrator: For consistency, also infer
'instancetype' for known family of methods
with related result type; such as 'init'
methods. // rdar://14987948
Jordan Rose [Wed, 18 Sep 2013 18:58:58 +0000 (18:58 +0000)]
[analyzer] Don't even try to convert floats to booleans for now.
We now have symbols with floating-point type to make sure that
(double)x == (double)x comes out true, but we still can't do much with
these. For now, don't even bother trying to create a floating-point zero
value; just give up on conversion to bool.
PR16752: 'mode' attribute for unusual targets doesn't work properly
Description:
Troubles could be happened due to some assumptions in handleModeAttr function (see SemaDeclAttr.cpp).
For example, it assumes that 32 bit integer is 'int', while it could be 16 bit only.
Instead of asking target: 'which type do you want to use for int32_t ?' it just hardcodes general opinion. That doesn't looks pretty correct.
Please consider the next solution:
1. In Basic/TargetInfo add getIntTypeByWidth and getRealTypeByWidth methods. Methods asks target for proper type for given bit width.
2. Fix handleModeAttr according to new methods in TargetInfo.
Fixes:
1st Commit (Done): Add new methods for TargetInfo:
getRealTypeByWidth and getIntTypeByWidth
for ASTContext names are almost same(invokes new methods from TargetInfo):
getIntTypeForBitwidth and getRealTypeForBitwidth
Hal Finkel [Wed, 18 Sep 2013 06:19:40 +0000 (06:19 +0000)]
Add new libm LIBBUILTIN definitions, synchronizing with __builtin_*
For all libm __builtin_* functions that are defined, this adds the
corresponding LIBBUILTIN definitions (tagged, as necessary, with "e" instead of
"c" when the function may set errno).
Note that this changes the current definitions for lrint and fma
(unfortunately). The Linux man page documents that these don't set errno, but
the POSIX standard says that they should.
Hal Finkel [Wed, 18 Sep 2013 03:29:45 +0000 (03:29 +0000)]
Add the intrinsic __builtin_convertvector
LLVM supports applying conversion instructions to vectors of the same number of
elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to
cause such instructions to be generated when using builtin vector types.
C-style casting on vectors is already defined in terms of bitcasts, and so
cannot be used for these conversions as well (without leading to a very
confusing set of semantics). As a result, this adds a __builtin_convertvector
intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is
intended to aid the creation of vector intrinsic headers that create generic IR
instead of target-dependent intrinsics (in other words, this is a generic
_mm_cvtepi32_ps). As noted in the documentation, the action of
__builtin_convertvector is defined in terms of the action of a C-style cast on
each vector element.
This will define _MSC_VER to 1700 by default and avoid linker errors
from /failifmismatch linker directives in the C++ standard headers.
Most people trying out the Visual Studio integration are using 2012,
since that's the only version that clang-format works with. This way
they don't have to pass funky -Xclang -fmsc-version=1700 flags just to
link against the standard C++ runtime.
Hans Wennborg [Tue, 17 Sep 2013 23:27:39 +0000 (23:27 +0000)]
clang-cl: ignore ths /GS- flag
The /GS- flag is used to turn off run-time buffer security checks (/GS).
Since no such checks are enabled in the first place, I think we should just
ignore this flag.
David Majnemer [Tue, 17 Sep 2013 22:21:27 +0000 (22:21 +0000)]
[-cxx-abi microsoft] Mangle local TagDecls appropriately
Summary:
When selecting a mangling for an anonymous tag type:
- We should first try it's typedef'd name.
- If that doesn't work, we should mangle in the name of the declarator
that specified it as a declaration specifier.
- If that doesn't work, fall back to a static mangling of
<unnamed-type>.
This should make our anonymous type mangling compatible.
This partially fixes PR16994; we would need to have an implementation of
scope numbering to get it right (a separate issue).
Push contents of X86TargetInfo::setFeatureEnabled down to a static function called by the virtual version and all the places in getDefaultFeatures. This way getDefaultFeatures doesn't make so many virtual calls.
Anna Zaks [Tue, 17 Sep 2013 01:30:57 +0000 (01:30 +0000)]
[analyzer] More reliably detect property accessors.
This has a side effect of preventing a crash, which occurs because we get a
property getter declaration, which is overriding but is declared inside
@protocol. Will file a bug about this inconsistency internally. Getting a
small test case is very challenging.
Hans Wennborg [Tue, 17 Sep 2013 00:25:08 +0000 (00:25 +0000)]
Fix test/Driver/cl-options.c test
The test builds an object file to be able to get into linking mode
with a valid obj file on the command-line. Using clang-cl for this,
which targets win32, caused problems on some buildbots, so just
use regular clang.
Hans Wennborg [Tue, 17 Sep 2013 00:03:41 +0000 (00:03 +0000)]
clang-cl: ignore compile-only options in link-only invocations.
Previously we would warn about unused arguments such as /MD when linking.
Clang already has logic to ignore compile-only options, e.g. for -D and -U.
This patch extends that to include clang-cl's compile-only options too.
Also, some clang-cl options should always be ignored. Doing this earlier
means they get ignored both for compilation and link-only invocations.