In {CG,}ExprConstant.cpp, we weren't treating vector splats properly.
This patch makes us treat splats more properly.
Additionally, this patch adds a new cast kind which allows a bool->int
cast to result in -1 or 0, instead of 1 or 0 (for true and false,
respectively), so we can sanely model OpenCL bool->int casts in the AST.
Justin Lebar [Wed, 13 Jan 2016 01:24:35 +0000 (01:24 +0000)]
[CUDA] Rename check-prefixes in cuda-options.cu and cuda-unused-arg-warning.cu.
Summary:
Rename the args to be more human-readable. Among other things, this
lets us get rid of a bunch of comments (e.g. "ensure we don't run the
linker"), greatly shortening these tests.
Also apply consistent formatting and fix some English nits while we're
at it.
Bob Wilson [Wed, 13 Jan 2016 01:19:02 +0000 (01:19 +0000)]
Generalize r256026 to apply to all MachO targets, not just Darwin targets.
The PIC default is set for the MachO toolchain, not just the Darwin toolchain,
so this treats those the same. The behavior with -static should be the same
for all MachO targets. rdar://24152327
Frederic Riss [Tue, 12 Jan 2016 23:47:59 +0000 (23:47 +0000)]
[Darwin] Fix deployment target detection
There was a thinko in the deployment target detection code that
made the -isysroot parsing have precedence over the environment
variable for tvOS. This patch makes this logic symetric for all
platforms (the env variable must have precedence).
Richard Smith [Tue, 12 Jan 2016 21:59:26 +0000 (21:59 +0000)]
Improve AST dumping:
1) When dumping a declaration that declares a name for a type, also dump the named type.
2) Add a #pragma clang __debug dump X, that dumps the lookup results for X in
the current context.
Adrian Prantl [Tue, 12 Jan 2016 21:01:56 +0000 (21:01 +0000)]
Module debugging: Make the module format part of the module hash instead
of the file name. This is consistent with how other HeaderSearchOptions
are handled.
Due to the other inputs of the module hash (revision number) this is not
really testable in a meaningful way.
Ismail Donmez [Tue, 12 Jan 2016 10:41:20 +0000 (10:41 +0000)]
Revert r253898 and r253899, this breaks mingw compilation on openSUSE.
Will re-apply after llvm 3.8 is branched.
Original commit message:
Driver: fallback to the location of clang if no sysroot,
hard coding /usr makes little sense for mingw-w64.
If we have portable toolchains having /usr breaks that.
If the clang we use is in /usr/bin or /usr/sbin etc this will
still detect as though it was hard coded to /usr
This makes the most sense going forward for mingw-w64 toolchains
on both linux and mac
Pierre Gousseau [Tue, 12 Jan 2016 10:07:56 +0000 (10:07 +0000)]
[analyzer] Evaluate integral casts as cast symbols if truncations are detected.
The current workaround for truncations not being modelled is that the evaluation of integer to integer casts are simply bypassed and so the original symbol is used as the new casted symbol (cf SimpleSValBuilder::evalCastFromNonLoc).
This lead to the issue described in PR25078, as the RangeConstraintManager associates ranges with symbols.
The new evalIntegralCast method added by this patch wont bypass the cast if it finds the range of the symbol to be greater than the maximum value of the target type.
The fix to RangeSet::pin mentioned in the initial review will be committed separately.
Alexey Bataev [Tue, 12 Jan 2016 09:12:20 +0000 (09:12 +0000)]
PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute, by Dmitry Polukhin
Fix binary compatibility issue with GCC.
Differential Revision: http://reviews.llvm.org/D14980
Alexey Bataev [Tue, 12 Jan 2016 09:01:25 +0000 (09:01 +0000)]
Fix infinite recursion for invalid declaration, by Dmitry Polukhin
Fix for a case found by fuzzing PR23057 (comment #25 https://llvm.org/bugs/show_bug.cgi?id=23057#c25).
Differential Revision: http://reviews.llvm.org/D16065
Richard Smith [Mon, 11 Jan 2016 22:41:53 +0000 (22:41 +0000)]
When a tag is declared in prototype scope in C, if we've decided that it
redeclares an existing tag but are creating a new declaration anyway (because
it has attributes or changes the visibility of the name), don't warn that it
won't be visible outside the current scope. That's not true.
Also narrow down the set of cases where we create these extra declarations when
building modules; previously, all tag declarations but the first in a module
header would get this treatment if -fmodules-local-submodule-visibility. (This
isn't a functional change, but we try to avoid creating these extra
declarations whenever we can.)
James Y Knight [Mon, 11 Jan 2016 22:00:22 +0000 (22:00 +0000)]
PR26087: Use nonstandard MSVC extension for VS2015 as well.
In r256564, I had conditioned the workaround in has_getDecl to only be
used for MSVC before the 2015 release, believing that 2015 could handle
the standard code. But, that was incorrect.
Benjamin Kramer [Mon, 11 Jan 2016 16:27:16 +0000 (16:27 +0000)]
[clang-format] Fix comment aligning when there are changes within the comment
As soon as a comment had whitespace changes inside of the token, we
couldn't identify the whole comment as a trailing comment anymore and
alignment stopped working. Add a new boolean to Change for this special
case and fix trailing comment identification to use it.
This also changes WhitespaceManager to sum the length of all Changes
inside of a token into the first Change.
Daniel Jasper [Mon, 11 Jan 2016 11:01:05 +0000 (11:01 +0000)]
clang-format: Slightly row back on r257257.
r257257 change the way clang-format enforces line breaks after a
templated type has been line-wrapped. This was to fix an incorrect line
break if BinPackParameters is set to false. However, it also leads to
an unwanted line break in a different case. Thus, for now, only do this
when BinPackParameters is false. This isn't ideal yet, but helps us
until we have a better solution.
Yury Gribov [Mon, 11 Jan 2016 09:38:48 +0000 (09:38 +0000)]
AnalysisConsumer: use canonical decl for both lookup and store of
visited decls.
Due to redeclarations, the function may have different declarations used
in CallExpr and in the definition. However, we need to use a unique
declaration for both store and lookup in VisitedCallees. This patch
fixes issues with analysis in topological order. A simple test is
included.
Daniel Jasper [Sat, 9 Jan 2016 21:12:45 +0000 (21:12 +0000)]
clang-format: Fix the counting of leading whitespace in tok::unknown tokens
Previously, all whitespace characters would increase the starting
column, which doesn't make sense. This fixes a problem, e.g. with the
length calculation in JS template strings.
Benjamin Kramer [Sat, 9 Jan 2016 16:33:16 +0000 (16:33 +0000)]
[vfs] Normalize working directory if requested.
FixedCompilationDatabase sets the working dir to "." by default. For
chdir(".") this is a noop but this lead to InMemoryFileSystem to create
bogus paths. Fixes PR25327.
Richard Smith [Sat, 9 Jan 2016 06:58:48 +0000 (06:58 +0000)]
[modules] If we're treating an elaborated-type-specifier as if it introduces a
tag (because the previous declaration was found in a different module), inject
the tag into the appropriate scope (that is, the enclosing scope if we're in a
function prototype scope in C++).
Richard Smith [Fri, 8 Jan 2016 22:36:45 +0000 (22:36 +0000)]
[modules] Make sure we always include the contents of private headers when
building a module. Prior to this change, the private header's content would
only be included if the header were included by another header in the same
module. If not (if the private header is only used by the .cc files of the
module, or is included from outside the module via -Wno-private-header),
a #include of that file would be silently ignored.
David Majnemer [Fri, 8 Jan 2016 20:48:26 +0000 (20:48 +0000)]
[MS ABI] Complete and base constructor GlobalDecls must have the same name
Clang got itself into the situation where we mangled the same
constructor twice with two different constructor types. After one of
the constructors were utilized, the tag used for one of the types
changed from class to struct because a class template became complete.
This resulted in one of the constructor types varying from the other
constructor.
Instead, force "base" constructor types to "complete" if the ABI doesn't
have constructor variants. This will ensure that GlobalDecls for both
variants will get the same mangled name.
Teresa Johnson [Fri, 8 Jan 2016 17:04:29 +0000 (17:04 +0000)]
[ThinLTO] Leverage new in-place renaming support
Due to the new in-place renaming support added in r257174, we no
longer need to invoke ThinLTO global renaming from clang. It will be
invoked on the module in the FunctionImport pass (by an immediately
following llvm commit).
As a result, we don't need to load the FunctionInfoIndex as early,
so that is moved down into EmitAssemblyHelper::EmitAssembly.
Dimitry Andric [Thu, 7 Jan 2016 22:09:47 +0000 (22:09 +0000)]
Turn off lldb debug tuning by default for FreeBSD
Summary:
This is the clang part of D15966. In rL256104, debugger tuning was
added to the clang driver, and again the default for FreeBSD was set to
lldb. The default needs to be gdb instead.
Coverage mapping data may reference names of functions
that are skipped by FE (e.g, unused inline functions). Since
those functions are skipped, normal instr-prof function lowering
pass won't put those names in the right section, so special
handling is needed to walk through coverage mapping structure
and recollect the references.
With this patch, only names that are skipped are processed. This
simplifies the lowering code and it no longer needs to make
assumptions coverage mapping data layout. It should also be
more efficient.
[Sema] Teach overload resolution about unaddressable functions.
Given an expression like `(&Foo)();`, we perform overload resolution as
if we are calling `Foo` directly. This causes problems if `Foo` is a
function that can't have its address taken. This patch teaches overload
resolution to ignore functions that can't have their address taken in
such cases.
John McCall [Wed, 6 Jan 2016 23:34:20 +0000 (23:34 +0000)]
Properly bind up any cleanups in an ExprWithCleanups after
instantiating a default argument expression.
This was previously just working implicitly by reinstantiating
in the current context, but caching means that we weren't
registering cleanups in subsequent uses.
Richard Smith [Wed, 6 Jan 2016 22:49:11 +0000 (22:49 +0000)]
PR26048, PR26050: put non-type template parameters and indirect field decls
into IDNS_Tag in C++, because they conflict with redeclarations of tags. (This
doesn't affect elaborated-type-specifier lookup, which looks for IDNS_Type in
C++).
John McCall [Wed, 6 Jan 2016 22:34:54 +0000 (22:34 +0000)]
Only instantiate a default argument once.
By storing the instantiated expression back in the ParmVarDecl,
we remove the last need for separately storing the sub-expression
of a CXXDefaultArgExpr. This makes PCH/Modules merging quite
simple: CXXDefaultArgExpr records are serialized as references
to the ParmVarDecl, and we ignore redundant attempts to overwrite
the instantiated expression.
This has some extremely marginal impact on user-facing semantics.
However, the major effect is that it avoids IRGen errors about
conflicting definitions due to lambdas in the argument being
instantiated multiple times while sharing the same mangling.
It should also slightly improve memory usage and module file size.
Richard Trieu [Wed, 6 Jan 2016 21:11:18 +0000 (21:11 +0000)]
Improve conditional checking during template instantiation.
When the condition in an if statement, while statement, or for loop is created
during template instantiation, it calls MakeFullExpr with only the condition
expression. However, when these conditions are created for non-templated
code in the Parser, an additional SourceLocation is passed to MakeFullExpr.
The impact of this was that non-dependent templated code could produce
diagnostics that the same code outside templates would not. Adding the missing
SourceLocation makes diagnostics consistent between templated and non-templated
code.
Nico Weber [Wed, 6 Jan 2016 20:55:00 +0000 (20:55 +0000)]
Add -Wfor-loop-analysis to -Wall.
This warning seems to have 0 false positives and some true positives in
practice, without a measurable compile time cost. It should be in -Wall, and
possibly even become a default warning at some point.
Dan Gohman [Wed, 6 Jan 2016 19:43:32 +0000 (19:43 +0000)]
[WebAssembly] Add --gc-sections to the link line.
This will eventually be accompanied with a change to enable -ffunction-sections
and -fdata-sections by default, which is currently delayed by some development
process issues.