Nico Weber [Sun, 13 Mar 2016 02:44:13 +0000 (02:44 +0000)]
clang-cl: Add /Yc argument to /showIncludes output.
To make this work, delay printing of ExtraDeps in HeaderIncludesCallback a bit,
so that it happens after CompilerInstance::InitializeSourceManager() has run.
General /FI arguments are still missing from /showIncludes output, this still
needs to be fixed.
Nico Weber [Sat, 12 Mar 2016 19:55:59 +0000 (19:55 +0000)]
clang-cl: Add a test for the interaction of /Yc and /showIncludes.
We almost get this right, but not completely (see FIXME). It looks like /FI
headers generally aren't included in /showIncludes yet, but they should be.
But it seems good to have test coverage for the bits that already work.
Reid Kleckner [Fri, 11 Mar 2016 18:59:12 +0000 (18:59 +0000)]
Allow sizeof(UnrelatedClass::field) in C++11 class template methods
This feature works outside of templates by forming a DeclRefExpr to a
FieldDecl instead of a MemberExpr, which requires a base object in
addition to the FieldDecl.
Previously, while building up the template AST before instantiation, we
formed a CXXDependentScopeMemberExpr, which always instantiates to a
MemberExpr. Now, in unevaluated contexts we form a
DependentScopeDeclRefExpr, which is a more flexible node that can
instantiate to either a MemberExpr or a DeclRefExpr depending on lookup
results.
Add doxygen comments to avxintrin.h's intrinsics.
Only around 25% of the intrinsics in this file are documented here. The patches for the other half will be sent out later.
The doxygen comments are automatically generated based on Sony's intrinsics document.
I got an OK from Eric Christopher to commit doxygen comments without prior code review upstream.
Manman Ren [Thu, 10 Mar 2016 18:53:19 +0000 (18:53 +0000)]
Add TreatUnavailableAsInvalid for the verification-only mode in InitListChecker.
Given the following test case:
typedef struct {
const char *name;
id field;
} Test9;
extern void doSomething(Test9 arg);
void test9() {
Test9 foo2 = {0, 0};
doSomething(foo2);
}
With a release compiler, we don't emit any message and silently ignore the
variable "foo2". With an assert compiler, we get an assertion failure.
The root cause —————————————
Back in r140457 we gave InitListChecker a verification-only mode, and will use
CanUseDecl instead of DiagnoseUseOfDecl for verification-only mode.
These two functions handle unavailable issues differently:
In Sema::CanUseDecl, we say the decl is invalid when the Decl is unavailable and
the current context is available.
In Sema::DiagnoseUseOfDecl, we say the decl is usable by ignoring the return
code of DiagnoseAvailabilityOfDecl
So with an assert build, we will hit an assertion in diagnoseListInit
assert(DiagnoseInitList.HadError() &&
"Inconsistent init list check result.");
The fix -------------------
If we follow what is implemented in CanUseDecl and treat Decls with
unavailable issues as invalid, the variable decl of “foo2” will be marked as
invalid. Since unavailable checking is processed in delayed diagnostics
(r197627), we will silently ignore the diagnostics when we find out that
the variable decl is invalid.
We add a flag "TreatUnavailableAsInvalid" for the verification-only mode.
For overload resolution, we want to say decls with unavailable issues are
invalid; but for everything else, we should say they are valid and
emit diagnostics. Depending on the value of the flag, CanUseDecl
can return different values for unavailable issues.
Add doxygen comments to xmmintrin.h's intrinsics.
Only half of the intrinsics in this file is documented here. The patch for the other half will be sent out later.
The doxygen comments are automatically generated based on Sony's intrinsics document.
I got an OK from Eric Christopher to commit doxygen comments without prior code review upstream.
Richard Trieu [Thu, 10 Mar 2016 04:04:12 +0000 (04:04 +0000)]
Disable failing test and fix RUN line.
See https://llvm.org/bugs/show_bug.cgi?id=26894 for details. This change
fixes the incorrect flags to Clang and the piping issue. It also disables
the FileCheck portion of the test, which is currently failing.
Steven Wu [Thu, 10 Mar 2016 02:02:48 +0000 (02:02 +0000)]
Fix false positives for for-loop-analysis warning
Summary:
For PseudoObjectExpr, the DeclMatcher need to search only all the semantics
but also need to search pass OpaqueValueExpr for all potential uses for the
Decl.
Ben Langmuir [Wed, 9 Mar 2016 23:31:34 +0000 (23:31 +0000)]
[Modules] Add stdatomic to the list of builtin headers
Since it's provided by the compiler. This allows a system module map
file to declare a module for it.
No test change for cstd.m, since stdatomic.h doesn't function without a
relatively complete stdint.h and stddef.h, which tests using this module
don't provide.
Kit Barton [Wed, 9 Mar 2016 19:28:31 +0000 (19:28 +0000)]
[PPC] FE support for generating VSX [negated] absolute value instructions
Includes new built-in, conversion of built-in to target-independent intrinsic
and update in the header file. Tests are also updated. There is a second part in
the backend for which I will post a separate code-review. BACKEND PART SHOULD BE
COMMITTED FIRST.
Tim Northover [Wed, 9 Mar 2016 18:54:42 +0000 (18:54 +0000)]
ARM & AArch64: convert asm tests to LLVM IR and restrict optimizations.
This is mostly a one-time autoconversion of tests that checked assembly after
"-Owhatever" compiles to only run "opt -mem2reg" and check the assembly. This
should make them much more stable to changes in LLVM so they won't break on
unrelated changes.
"opt -mem2reg" is a compromise designed to increase the readability of tests
that check dataflow, while minimizing dependency on LLVM. Hopefully mem2reg is
stable enough that no surpises will come along.
Aaron Ballman [Wed, 9 Mar 2016 16:48:08 +0000 (16:48 +0000)]
Implement support for [[maybe_unused]] in C++1z that is based off existing support for unused, and treat it as an extension pre-C++1z. This also means extending the existing unused attribute so that it can be placed on an enum and enumerator, in addition to the other subjects.
Samuel Antao [Wed, 9 Mar 2016 15:46:05 +0000 (15:46 +0000)]
[OpenMP] Add support for multidimensional array sections in map clause SEMA.
Summary: In some cases it can be proved statically that multidimensional array section refer to contiguous storage and can therefore be allowed in a map clause. This patch adds support for those cases in SEMA.
Dmitry Polukhin [Wed, 9 Mar 2016 15:30:53 +0000 (15:30 +0000)]
[GCC] PR23529 Sema part of attrbute abi_tag support
Original patch by Stefan Bühler http://reviews.llvm.org/D12834
Difference between original and this one:
- fixed all comments in original code review
- added more tests, all new diagnostics now covered by tests
- moved abi_tag on re-declaration checks to Sema::mergeDeclAttributes
where they actually may work as designed
- clang-format + other stylistic changes
Mangle part will be sent for review as a separate patch.
Peter Zotov [Wed, 9 Mar 2016 05:18:16 +0000 (05:18 +0000)]
Accept absolute paths in the -fuse-ld option.
This patch extends the -fuse-ld option to accept a full path to an executable
and use it verbatim to invoke the linker. There are generally two reasons
to desire this.
The first reason relates to the sad truth is that Clang is retargetable,
Binutils are not.
While any Clang from a binary distribution is sufficient to compile code
for a wide range of architectures and prefixed BFD linkers (e.g.
installed as /usr/bin/arm-none-linux-gnueabi-ld) as well as cross-compiled
libc's (for non-bare-metal targets) are widely available, including on all
Debian derivatives, it is impossible to use them together because
the -fuse-ld= option allows to specify neither a linker prefix nor
a full path to one.
The second reason is linker development, both when porting existing linkers
to new architectures and when working on a new linker such as LLD.
Richard Smith [Tue, 8 Mar 2016 23:17:35 +0000 (23:17 +0000)]
Fix crash in access check for aggregate initialization of base classes. It's
not obvious how to access-check these, so pick a conservative rule until we get
feedback from CWG.
Aaron Ballman [Tue, 8 Mar 2016 21:31:32 +0000 (21:31 +0000)]
Silence duplicate diagnostics because parsing of a standards-based attribute triggers parsing diagnostics that may also be picked up during semantic analysis.
Mike Spertus [Tue, 8 Mar 2016 16:14:23 +0000 (16:14 +0000)]
Add Visual Studio native visualizers for several Clang types
This is one of a series of changes to improve the MSVC visualization of Clang types.
This one focuses on Record and SubstTemplateTypeParmType meaning that, for example,
a TemplateArgumentLoc no longer displays incomprehensibly in the locals window as
Sema: Methods in unavailable classes are unavailable
Similar to the template cases in r262050, when a C++ method in an
unavailable struct/class calls unavailable API, don't diagnose an error.
I.e., this case was failing:
Since A is unavailable, A::bar is allowed to call foo. However, we were
emitting a diagnostic here. This commit checks up the context chain
from A::bar, in a manner inspired by SemaDeclAttr.cpp:isDeclUnavailable.
I expected to find other related issues but failed to trigger them:
- I wondered if DeclBase::getAvailability should check for
`TemplateDecl` instead of `FunctionTemplateDecl`, but I couldn't find
a way to trigger this. I left behind a few extra tests to make sure
we don't regress.
- I wondered if Sema::isFunctionConsideredUnavailable should be
symmetric, checking up the context chain of the callee (this commit
only checks up the context chain of the caller). However, I couldn't
think of a testcase that didn't require first referencing the
unavailable type; this, we already diagnose.
Sema: Treat 'strict' availability flag like unavailable
This is a follow-up to r261512, which made the 'strict' availability
attribute flag behave like 'unavailable'. However, that fix was
insufficient. The following case would (erroneously) error when the
deployment target was older than 10.9:
The use of A* in the argument list for f is valid here, since f and A
have the same availability.
The fix is to return AR_Unavailable from DeclBase::getAvailability
instead of AR_NotYetIntroduced. This also reverts the special handling
added in r261163, instead relying on the well-tested logic for
AR_Unavailable.
Anna Zaks [Tue, 8 Mar 2016 01:21:51 +0000 (01:21 +0000)]
[analyzer] Fix missed leak from MSVC specific allocation functions
Add the wide character strdup variants (wcsdup, _wcsdup) and the MSVC
version of alloca (_alloca) and other differently named function used
by the Malloc checker.
Richard Smith [Tue, 8 Mar 2016 00:32:55 +0000 (00:32 +0000)]
P0188R1: add support for standard [[fallthrough]] attribute. This is almost
exactly the same as clang's existing [[clang::fallthrough]] attribute, which
has been updated to have the same semantics. The one significant difference
is that [[fallthrough]] is ill-formed if it's not used immediately before a
switch label (even when -Wimplicit-fallthrough is disabled). To support that,
we now build a CFG of any function that uses a '[[fallthrough]];' statement
to check.
In passing, fix some bugs with our support for statement attributes -- in
particular, diagnose their use on declarations, rather than asserting.
Aaron Ballman [Mon, 7 Mar 2016 22:44:55 +0000 (22:44 +0000)]
Implement support for [[nodiscard]] in C++1z that is based off existing support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_unused_result attribute so that it can be placed on an enum as well as a class.
Marina Yatsina [Mon, 7 Mar 2016 18:10:25 +0000 (18:10 +0000)]
[ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces
Until now curly braces could only be used in MS inline assembly to mark block start/end.
All curly braces were removed completely at a very early stage.
This approach caused bugs like:
"m{o}v eax, ebx" turned into "mov eax, ebx" without any error.
In addition, AVX-512 added special operands (e.g., k registers), which are also surrounded by curly braces that mark them as such.
Now, we need to keep the curly braces and identify at a later stage if they are marking block start/end (if so, ignore them), or surrounding special AVX-512 operands (if so, parse them as such).
This patch fixes the bug described above and enables the use of AVX-512 special operands.
This commit is the the clang part of the patch.
The clang part of the review is: http://reviews.llvm.org/D17766
The llvm part of the review is: http://reviews.llvm.org/D17767
Carlo Bertolli [Mon, 7 Mar 2016 16:04:49 +0000 (16:04 +0000)]
Reapply r262741 [OPENMP] Codegen for distribute directive
This patch provide basic implementation of codegen for teams directive, excluding all clauses except dist_schedule. It also fixes parts of AST reader/writer to enable correct pre-compiled header handling.
David Majnemer [Mon, 7 Mar 2016 08:51:17 +0000 (08:51 +0000)]
[MS ABI] Mangle symbols names longer than 4096 characters correctly
Really long symbols are hashed using MD5 and prefixed/suffixed with the
usual sigils. There is an additional reason beyond the usual
compatibility with MSVC, it is important to keep COFF symbols shorter
than 0xFFFF because the CodeView debugging format has a maximum
symbol/record size of 0xFFFF.
There are some quirks worth noting:
- Some mangled names reference other entities which are mangled
separately. A quick example:
int I;
template <int *> struct S {};
S<I> s;
In this case, the mangling for 's' doesn't depend directly on the
mangling for 'I'. While 's' would need an MD5 hash if 'I' also needed
one, the hash for 's' applied to the fully realized mangled name. In
other words, the mangled name for 's' will not depend on the MD5 of the
mangled name for 'I'.
- Some mangled names, like the venerable CatchableType, embed the MD5
verbatim.
- Finally, the complete object locator is handled as a special case.
A complete object locators are mangled exactly like a VFTable except for
a small deviation in the prefix sigils. However, complete object
locators for hashed vftables result in a complete object locator whose
name is identical to the vftable except for an additional suffix.