]> granicus.if.org Git - clang/log
clang
6 years ago[ODRHash] Support ODR violation detection in functions.
Richard Trieu [Sat, 23 Dec 2017 00:41:01 +0000 (00:41 +0000)]
[ODRHash] Support ODR violation detection in functions.

Extend the hashing to functions, which allows detection of function definition
mismatches across modules.  This is a re-commit of r320230.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321395 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd an explicit `LLVM_FALLTHROUGH` annotation to an intentional
Chandler Carruth [Fri, 22 Dec 2017 23:29:49 +0000 (23:29 +0000)]
Add an explicit `LLVM_FALLTHROUGH` annotation to an intentional
fallthrough. Fixes GCC and Clang warnings about this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321392 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Captured arguments of the capturable clauses by value.
Alexey Bataev [Fri, 22 Dec 2017 21:01:52 +0000 (21:01 +0000)]
[OPENMP] Captured arguments of the capturable clauses by value.

If the clause is applied to the combined construct and has captured
expression, try to capture this expression by value rather than by
reference.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321386 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUnit tests for TBAA metadata generation.
Serge Pavlov [Fri, 22 Dec 2017 15:22:45 +0000 (15:22 +0000)]
Unit tests for TBAA metadata generation.

Now tests for metadata created by clang involve compiling code snippets
placed into c/c++ source files and matching interesting patterns in the
obtained textual representation of IR. Writting such tests is a painful
process as metadata often form complex tree-like structures but textual
representation of IR contains only a pile of metadata at the module end.

This change implements IR matchers that may be used to match required
patterns in the binary IR representation. In this case the metadata
structure is not broken and creation of match patterns is easier.

The change adds unit tests for TBAA metadata generation.

Differential Revision: https://reviews.llvm.org/D41433

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321360 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Represent array members in new-format TBAA type descriptors
Ivan A. Kosarev [Fri, 22 Dec 2017 09:57:24 +0000 (09:57 +0000)]
[CodeGen] Represent array members in new-format TBAA type descriptors

Now that in the new TBAA format we allow access types to be of
any object types, including aggregate ones, it becomes critical
to specify types of all sub-objects such aggregates comprise as
their members. In order to meet this requirement, this patch
enables generation of field descriptors for members of array
types.

Differential Revision: https://reviews.llvm.org/D41399

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321352 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Support generation of TBAA info in the new format
Ivan A. Kosarev [Fri, 22 Dec 2017 09:54:23 +0000 (09:54 +0000)]
[CodeGen] Support generation of TBAA info in the new format

Now that the MDBuilder helpers generating TBAA type and access
descriptors in the new format are in place, we can teach clang to
use them when requested.

Differential Revision: https://reviews.llvm.org/D41394

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321351 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix unused variable warning in SemaTemplate. NFC
Sam McCall [Fri, 22 Dec 2017 07:09:51 +0000 (07:09 +0000)]
Fix unused variable warning in SemaTemplate. NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321346 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add missing check lines for the silvermont cases in predefined-arch-macros...
Craig Topper [Fri, 22 Dec 2017 05:09:38 +0000 (05:09 +0000)]
[X86] Add missing check lines for the silvermont cases in predefined-arch-macros.c test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321343 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Modules] Map missing private submodules from Foo.Private to Foo_Private
Bruno Cardoso Lopes [Fri, 22 Dec 2017 05:04:43 +0000 (05:04 +0000)]
[Modules] Map missing private submodules from Foo.Private to Foo_Private

In case `@import Foo.Private` fails because the submodule doesn't exist,
look for `Foo_Private` (if available) and build/load that module
instead. In that process emit a warning and tell the user about the
assumption.

The intention here is to assist all existing private modules owners
(in ObjC and Swift) to migrate to the new `Foo_Private` syntax.

rdar://problem/36023940

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321342 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add 'prfchw' to the correct CPUs to match the backend.
Craig Topper [Fri, 22 Dec 2017 04:51:00 +0000 (04:51 +0000)]
[X86] Add 'prfchw' to the correct CPUs to match the backend.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321341 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDiagnose the various invalid decl-specifiers on nontype template parameters.
Faisal Vali [Fri, 22 Dec 2017 03:50:55 +0000 (03:50 +0000)]
Diagnose the various invalid decl-specifiers on nontype template parameters.

The standard correctly forbids various decl-specifiers that dont make sense on non-type template parameters - such as the extern in:
    template<extern int> struct X;

This patch implements those restrictions (in a fashion similar to the corresponding checks on function parameters within ActOnParamDeclarator).

Credit goes to miyuki (Mikhail Maltsev) for drawing attention to this issue,  authoring the initial versions of this patch, and supporting the effort to re-engineer it slightly.  Thank you!

For details of how this patch evolved please see: https://reviews.llvm.org/D40705

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321339 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Modules] Change private modules rules and warnings
Bruno Cardoso Lopes [Fri, 22 Dec 2017 02:53:30 +0000 (02:53 +0000)]
[Modules] Change private modules rules and warnings

We used to advertise private modules to be declared as submodules
(Foo.Private). This has proven to not scale well since private headers
might carry several dependencies, introducing unwanted content into the
main module and often causing dep cycles.

Change the canonical way to name it to Foo_Private, forcing private
modules as top level ones, and provide warnings under -Wprivate-module
to suggest fixes for other private naming. Update documentation to
reflect that.

rdar://problem/31173501

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321337 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] More fixes for __shfl_* intrinsics.
Artem Belevich [Thu, 21 Dec 2017 23:52:09 +0000 (23:52 +0000)]
[CUDA] More fixes for __shfl_* intrinsics.

* __shfl_{up,down}* uses unsigned int for the third parameter.
* added [unsigned] long overloads for non-sync shuffles.

Differential Revision: https://reviews.llvm.org/D41521

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321326 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Allow _mm_prefetch (both the header implementation and the builtin) to accept...
Craig Topper [Thu, 21 Dec 2017 23:50:22 +0000 (23:50 +0000)]
[X86] Allow _mm_prefetch (both the header implementation and the builtin) to accept bit 2 which is supposed to indicate the prefetched addresses will be written to

Add the appropriate _MM_HINT_ET0/ET1 defines to match gcc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321325 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCorrect hasFeature/isValidFeatureName's handling of shstk/adx/mwaitx
Erich Keane [Thu, 21 Dec 2017 23:27:36 +0000 (23:27 +0000)]
Correct hasFeature/isValidFeatureName's handling of shstk/adx/mwaitx

https://bugs.llvm.org/show_bug.cgi?id=35721 reports that x86intrin.h
is issuing a few warnings. This is because attribute target is using
isValidFeatureName for its source. It was also discovered that two of
these were missing from hasFeature.

Additionally, shstk is and ibu are reordered alphabetically, as came
up during code review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321324 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDelete dead code.
Adrian Prantl [Thu, 21 Dec 2017 23:03:05 +0000 (23:03 +0000)]
Delete dead code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321321 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Add Javascript to analyzer HTML output to allow keyboard navigation.
George Karpenkov [Thu, 21 Dec 2017 22:57:51 +0000 (22:57 +0000)]
[analyzer] Add Javascript to analyzer HTML output to allow keyboard navigation.

Differential Revision: https://reviews.llvm.org/D41414

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321320 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ODRHash] Canonicalize Decl's before processing.
Richard Trieu [Thu, 21 Dec 2017 22:38:29 +0000 (22:38 +0000)]
[ODRHash] Canonicalize Decl's before processing.

Canonicalizing the Decl before processing it as part of the hash should reduce
issues with non-canonical types showing up as mismatches.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321319 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSuppress "redundant parens" warning for "A (::B())".
Richard Smith [Thu, 21 Dec 2017 22:26:47 +0000 (22:26 +0000)]
Suppress "redundant parens" warning for "A (::B())".

This is a slightly odd construct (it's more common to see "A (::B)()") but can
happen in friend declarations, and the parens are not redundant as they prevent
the :: binding to the left.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321318 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CMake][Fuchsia] Enable assertions
Petr Hosek [Thu, 21 Dec 2017 22:10:27 +0000 (22:10 +0000)]
[CMake][Fuchsia] Enable assertions

Enable assertions in both stages.
Release+Asserts is fast enough.
No need to let insanity through.

Patch By: mcgrathr

Reviewers: phosek

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D41471

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321316 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[scudo] Add -fsanitize=scudo option to Fuchsia
Petr Hosek [Thu, 21 Dec 2017 22:04:31 +0000 (22:04 +0000)]
[scudo] Add -fsanitize=scudo option to Fuchsia

Apparently the -fsanitize flag hadn't been added for Scudo upstream yet.

Patch By: flowerhack

Reviewers: cryptoad, alekseyshl, mcgrathr, phosek

Reviewed By: mcgrathr, phosek

Differential Revision: https://reviews.llvm.org/D41413

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321314 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Incorrectly qualified unscoped enumeration as template actual parameter.
Paul Robinson [Thu, 21 Dec 2017 21:47:22 +0000 (21:47 +0000)]
[AST] Incorrectly qualified unscoped enumeration as template actual parameter.

An unscoped enumeration used as template argument, should not have any
qualified information about its enclosing scope, as its visibility is
global.

In the case of scoped enumerations, they must include information
about their enclosing scope.

Patch by Carlos Alberto Enciso!

Differential Revision: https://reviews.llvm.org/D39239

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321312 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRe-commit r321223, which adds a printing policy to the ASTDumper.
Aaron Ballman [Thu, 21 Dec 2017 21:42:42 +0000 (21:42 +0000)]
Re-commit r321223, which adds a printing policy to the ASTDumper.

This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

Fixes the -Wreorder issue and fixes the ast-dump-color.cpp test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321310 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[CodeGen] Fix crash when a function taking transparent union is redeclared."
Volodymyr Sapsai [Thu, 21 Dec 2017 20:52:59 +0000 (20:52 +0000)]
Revert "[CodeGen] Fix crash when a function taking transparent union is redeclared."

This reverts commit r321296. It caused performance regressions
FAIL: imp.execution_time
FAIL: 2007-01-04-KNR-Args.execution_time
FAIL: sse_expandfft.execution_time
FAIL: sse_stepfft.execution_time

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321306 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDon't produce redundant parentheses warning for "A (::B);" and the like.
Richard Smith [Thu, 21 Dec 2017 20:50:39 +0000 (20:50 +0000)]
Don't produce redundant parentheses warning for "A (::B);" and the like.

The parentheses here are not redundant as they affect the binding of the
'::' token.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321304 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AArch64] Enable fp16 data type for the Builtin for AArch64 only.
Abderrazek Zaafrani [Thu, 21 Dec 2017 20:10:03 +0000 (20:10 +0000)]
[AArch64] Enable fp16 data type for the Builtin for AArch64 only.

Differential Revision: https:://reviews.llvm.org/D41360

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321301 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "Fix for PR32990"
Reid Kleckner [Thu, 21 Dec 2017 19:44:23 +0000 (19:44 +0000)]
Revert "Fix for PR32990"

This reverts commit r321239. It broke the Chromium DLL build:

[8834/50217] LINK(DLL) icui18n.dll icui18n.dll.lib icui18n.dll.pdb
FAILED: icui18n.dll icui18n.dll.lib icui18n.dll.pdb
zrule.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __cdecl icu_60::UnicodeString::`vbase destructor'(void)"
(__imp_??_DUnicodeString@icu_60@@QEAAXXZ)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321298 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoWhen instantiating a deduction guide, transform its name.
Richard Smith [Thu, 21 Dec 2017 19:43:39 +0000 (19:43 +0000)]
When instantiating a deduction guide, transform its name.

Otherwise it will serve as a deduction guide for the wrong class template.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321297 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Fix crash when a function taking transparent union is redeclared.
Volodymyr Sapsai [Thu, 21 Dec 2017 19:42:37 +0000 (19:42 +0000)]
[CodeGen] Fix crash when a function taking transparent union is redeclared.

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

The fix is in checking for the trivial case if ABIArgInfo type matches with
parameter declaration type. It exposed inconsistency that we check
hasScalarEvaluationKind for different types in EmitParmDecl and
EmitFunctionProlog, and comment says they should match.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D41311

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321296 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AARch64] Add ARMv8.2-A FP16 vector intrinsics
Abderrazek Zaafrani [Thu, 21 Dec 2017 19:20:01 +0000 (19:20 +0000)]
[AARch64] Add ARMv8.2-A FP16 vector intrinsics

Putting back the code that was reverted few weeks ago.

Differential Revision: https://reviews.llvm.org/D34161

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321294 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix zero-initialization of stack VLAs under ObjC ARC.
Artem Dergachev [Thu, 21 Dec 2017 18:43:02 +0000 (18:43 +0000)]
[analyzer] Fix zero-initialization of stack VLAs under ObjC ARC.

Using ARC, strong, weak, and autoreleasing stack variables are implicitly
initialized with nil. This includes variable-length arrays of Objective-C object
pointers. However, in the analyzer we don't zero-initialize them. We used to,
but it accidentally regressed after r289618.

Under ARC, the array variable's initializer within DeclStmt is an
ImplicitValueInitExpr. Environment doesn't maintain any bindings for this
expression kind - instead it always knows that it's a known constant
(0 in our case), so it just returns the known value by calling
SValBuilder::makeZeroVal() (see EnvironmentManager::getSVal().
Commit r289618 had introduced reasonable behavior of SValBuilder::makeZeroVal()
for the arrays, which produces a zero-length compoundVal{}. When such value
is bound to arrays, in RegionStoreManager::bindArray() "remaining" items in the
array are default-initialized with zero, as in
RegionStoreManager::setImplicitDefaultValue(). The similar mechanism works when
an array is initialized by an initializer list that is too short, eg.
  int a[3] = { 1, 2 };
would result in a[2] initialized with 0. However, in case of variable-length
arrays it didn't know if any more items need to be added,
because, well, the length is variable.

Add the default binding anyway, regardless of how many actually need
to be added. We don't really care how many, because the default binding covers
the whole array anyway.

Differential Revision: https://reviews.llvm.org/D41478
rdar://problem/35477763

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321290 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTImporterTest] Add mandatory testing with '-fdelayed-template-parsing'
Aleksei Sidorin [Thu, 21 Dec 2017 17:41:06 +0000 (17:41 +0000)]
[ASTImporterTest] Add mandatory testing with '-fdelayed-template-parsing'

 * While running ASTImporterTests, we often forget about Windows MSVC
   buildbots which enable '-fdelayed-template-parsing' by default.
   This leads to AST import errors because templates are not parsed
   and corresponding parts of AST are not built so importer cannot import them.
   It takes both reviewing time to find such issues and post-commit time
   to fix unexpected buildbot failures. To solve this issue, we enable testing
   with '-fdelayed-template-parsing' option enabled by default in addition
   to testing with default compiler options. This allows us to catch
   the problem during development.

Differential Revision: https://reviews.llvm.org/D41444

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321285 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdded helper to get size of PrecompiledPreamble
Ilya Biryukov [Thu, 21 Dec 2017 14:04:39 +0000 (14:04 +0000)]
Added helper to get size of PrecompiledPreamble

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321266 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Fix access sizes in new-format TBAA tags
Ivan A. Kosarev [Thu, 21 Dec 2017 08:14:16 +0000 (08:14 +0000)]
[CodeGen] Fix access sizes in new-format TBAA tags

The new format requires to specify both the type of the access
and its size. This patch fixes setting access sizes for TBAA tags
that denote accesses to structure members. This fix affects all
future TBAA metadata tests for the new format, so I guess we
don't need any special tests for this fix.

Differential Revision: https://reviews.llvm.org/D41452

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321250 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix for PR32990
Erich Keane [Thu, 21 Dec 2017 02:07:46 +0000 (02:07 +0000)]
Fix for PR32990

This fixes the bug in https://bugs.llvm.org/show_bug.cgi?id=32990.

Patch By: zahiraam
Differential Revision: https://reviews.llvm.org/D39063

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321239 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReverting a file that snuck in with r321229 by accident.
Aaron Ballman [Thu, 21 Dec 2017 01:34:46 +0000 (01:34 +0000)]
Reverting a file that snuck in with r321229 by accident.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321237 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ubsan] Diagnose noreturn functions which return
Vedant Kumar [Thu, 21 Dec 2017 00:10:25 +0000 (00:10 +0000)]
[ubsan] Diagnose noreturn functions which return

Diagnose 'unreachable' UB when a noreturn function returns.

  1. Insert a check at the end of functions marked noreturn.

  2. A decl may be marked noreturn in the caller TU, but not marked in
     the TU where it's defined. To diagnose this scenario, strip away the
     noreturn attribute on the callee and insert check after calls to it.

Testing: check-clang, check-ubsan, check-ubsan-minimal, D40700

rdar://33660464

Differential Revision: https://reviews.llvm.org/D40698

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321231 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Ensure no overlap between trapping & recoverable sanitizers. NFC.
Vedant Kumar [Thu, 21 Dec 2017 00:10:24 +0000 (00:10 +0000)]
[Driver] Ensure no overlap between trapping & recoverable sanitizers. NFC.

This is NFC because in EmitCheck(), -fsanitize-trap=X overrides
-fsanitize-recover=X.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321230 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReverting r321223 and its follow-up commit because of failing bots due to Misc/ast...
Aaron Ballman [Wed, 20 Dec 2017 23:17:29 +0000 (23:17 +0000)]
Reverting r321223 and its follow-up commit because of failing bots due to Misc/ast-dump-color.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321229 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSilence a -Wreorder warning from r321223.
Aaron Ballman [Wed, 20 Dec 2017 23:11:05 +0000 (23:11 +0000)]
Silence a -Wreorder warning from r321223.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321228 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd a printing policy to the ASTDumper.
Aaron Ballman [Wed, 20 Dec 2017 22:04:54 +0000 (22:04 +0000)]
Add a printing policy to the ASTDumper.

This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321223 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix an assertion failure regression in isDesignatorAtObjectEnd for
Alex Lorenz [Wed, 20 Dec 2017 21:03:38 +0000 (21:03 +0000)]
Fix an assertion failure regression in isDesignatorAtObjectEnd for
__builtin_object_size with incomplete array type in struct

The commit r316245 introduced a regression that causes an assertion failure when
Clang tries to cast an IncompleteArrayType to a PointerType when evaluating
__builtin_object_size.

rdar://36094951

Differential Revision: https://reviews.llvm.org/D41405

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321222 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[hwasan] Implement -fsanitize-recover=hwaddress.
Evgeniy Stepanov [Wed, 20 Dec 2017 19:05:44 +0000 (19:05 +0000)]
[hwasan] Implement -fsanitize-recover=hwaddress.

Summary: Very similar to AddressSanitizer, with the exception of the error type encoding.

Reviewers: kcc, alekseyshl

Subscribers: cfe-commits, kubamracek, llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D41417

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321203 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd support for ObjectFormat to TargetSpecificAttr
Erich Keane [Wed, 20 Dec 2017 18:51:08 +0000 (18:51 +0000)]
Add support for ObjectFormat to TargetSpecificAttr

Looking through the code, I saw a FIXME on IFunc to switch it
to a target specific attribute. In looking through it, i saw that
the no-longer-appropriately-named TargetArch didn't support ObjectFormat
checking.

This patch changes the name of TargetArch to TargetSpecific
(since it checks much more than just Arch), makes "Arch" optional, adds
support for ObjectFormat, better documents the TargetSpecific type, and
changes IFunc over to a TargetSpecificAttr.

Differential Revision: https://reviews.llvm.org/D41303

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321201 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMake DiagnosticIDs::getAllDiagnostics use std::vector. NFC.
Gabor Horvath [Wed, 20 Dec 2017 16:55:41 +0000 (16:55 +0000)]
Make DiagnosticIDs::getAllDiagnostics use std::vector. NFC.

The size of the result vector is currently around 4600 with
Flavor::WarningOrError, which makes std::vector a better candidate than
llvm::SmallVector.

Patch by: Andras Leitereg!

Differential Revision: https://reviews.llvm.org/D39372

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321190 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang] Add BeforeExecute method to PrecompiledPreamble
Ilya Biryukov [Wed, 20 Dec 2017 16:48:56 +0000 (16:48 +0000)]
[clang] Add BeforeExecute method to PrecompiledPreamble

Summary: Adds BeforeExecute method to PrecompiledPreamble to be called
before Execute(). This method can be overriden.

Patch by William Enright.

Reviewers: malaperle, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: arphaman, cfe-commits, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D41365

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321189 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Complex] Don't use __div?c3 when building with fast-math.
Florian Hahn [Wed, 20 Dec 2017 15:50:52 +0000 (15:50 +0000)]
[Complex] Don't use __div?c3 when building with fast-math.

Summary: Plant an inline version of "((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd))" instead.

Patch by Paul Walker.

Reviewed By: hfinkel

Differential Revision: https://reviews.llvm.org/D40299

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321183 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Frontend] Handle skipped bodies in template instantiations
Ilya Biryukov [Wed, 20 Dec 2017 14:32:38 +0000 (14:32 +0000)]
[Frontend] Handle skipped bodies in template instantiations

Summary:
- Fixed an assert in Sema::InstantiateFunctionDefinition and added
  support for instantiating a function template with skipped body.
- Properly call setHasSkippedBody for FunctionTemplateDecl passed to
  Sema::ActOnSkippedFunctionBody.

Reviewers: sepavloff, bkramer

Reviewed By: sepavloff

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D41237

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321174 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove llvm::MemoryBuffer const_casts
Pavel Labath [Wed, 20 Dec 2017 11:34:38 +0000 (11:34 +0000)]
Remove llvm::MemoryBuffer const_casts

Summary:
llvm has grown a WritableMemoryBuffer class, which is convertible
(inherits from) a MemoryBuffer. We can use it to avoid conts_casting the
buffer contents when we want to write to it.

Reviewers: dblaikie, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D41387

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321167 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[darwin][driver] Warn about mismatching -<os>-version-min rather than
Alex Lorenz [Wed, 20 Dec 2017 02:31:30 +0000 (02:31 +0000)]
[darwin][driver] Warn about mismatching -<os>-version-min rather than
superfluous -<os>-version-min compiler option

rdar://35813850

Differential Revision: https://reviews.llvm.org/D41425

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321145 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r320942, "[ASTImporter] Support importing FunctionTemplateDecl and CXXDependen...
Peter Collingbourne [Wed, 20 Dec 2017 01:47:08 +0000 (01:47 +0000)]
Revert r320942, "[ASTImporter] Support importing FunctionTemplateDecl and CXXDependentScopeMemberExpr"

Caused a test failure on Windows:

[ RUN      ] ImportExpr.ImportCXXDependentScopeMemberExpr
C:\b\rr\tmppzcp4w\w\src\third_party\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(526): error: Value of: testImport("template <typename T> class C { T t; };" "template <typename T> void declToImport() {" "  C<T> d;" "  d.t;" "}", Lang_CXX, "", Lang_CXX, Verifier, functionTemplateDecl(has(functionDecl(has(compoundStmt( has(cxxDependentScopeMemberExpr())))))))
  Actual: false (Could not find match)
Expected: true
C:\b\rr\tmppzcp4w\w\src\third_party\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(534): error: Value of: testImport("template <typename T> class C { T t; };" "template <typename T> void declToImport() {" "  C<T> d;" "  (&d)->t;" "}", Lang_CXX, "", Lang_CXX, Verifier, functionTemplateDecl(has(functionDecl(has(compoundStmt( has(cxxDependentScopeMemberExpr())))))))
  Actual: false (Could not find match)
Expected: true
[  FAILED  ] ImportExpr.ImportCXXDependentScopeMemberExpr (37 ms)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321139 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] De-duplicate path diagnostics for each exploded graph node.
Artem Dergachev [Wed, 20 Dec 2017 01:17:53 +0000 (01:17 +0000)]
[analyzer] De-duplicate path diagnostics for each exploded graph node.

The bugreporter::trackNullOrUndefValue() mechanism contains a system of bug
reporter visitors that recursively call each other in order to track where a
null or undefined value came from, where each visitor represents a particular
tracking mechanism (track how the value was stored, track how the value was
returned from a function, track how the value was constrained to null, etc.).

Each visitor is only added once per value it needs to track. Almost. One
exception from this rule would be FindLastStoreBRVisitor that has two operation
modes: it contains a flag that indicates whether null stored values should be
suppressed. Two instances of FindLastStoreBRVisitor with different values of
this flag are considered to be different visitors, so they can be added twice
and produce the same diagnostic twice. This was indeed the case in the affected
test.

With the current logic of this whole machinery, such duplication seems
unavoidable. We should be able to safely add visitors with different flag
values without constructing duplicate diagnostic pieces. Hence the effort
in this commit to de-duplicate diagnostics regardless of what visitors
have produced them.

Differential Revision: https://reviews.llvm.org/D41258

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321135 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] trackNullOrUndefValue: always track through parentheses and casts.
Artem Dergachev [Wed, 20 Dec 2017 01:03:22 +0000 (01:03 +0000)]
[analyzer] trackNullOrUndefValue: always track through parentheses and casts.

When trying to figure out where a null or undefined value came from,
parentheses and cast expressions are either completely irrelevant, or,
in the case of lvalue-to-rvale cast, straightforwardly lead us in the right
direction when we remove them.

There is a regression that causes a certain diagnostic to appear twice in the
path-notes.cpp test (changed to FIXME). It would be addressed in the next
commit.

Differential revision: https://reviews.llvm.org/D41254

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321133 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] trackNullOrUndefValue: track last store to non-variables.
Artem Dergachev [Wed, 20 Dec 2017 00:47:17 +0000 (00:47 +0000)]
[analyzer] trackNullOrUndefValue: track last store to non-variables.

When reporting certain kinds of analyzer warnings, we use the
bugreporter::trackNullOrUndefValue mechanism, which is part of public checker
API, to understand where a zero, null-pointer, or garbage value came from,
which would highlight important events with respect to that value in the
diagnostic path notes, and help us suppress various false positives that result
from values appearing from particular sources.

Previously, we've lost track of the value when it was written into a memory
region that is not a plain variable. Now try to resume tracking in this
situation by finding where the last write to this region has occured.

Differential revision: https://reviews.llvm.org/D41253

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321130 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add more CPUID bits to cpuid.h to match gcc and support icelake features.
Craig Topper [Wed, 20 Dec 2017 00:46:09 +0000 (00:46 +0000)]
[X86] Add more CPUID bits to cpuid.h to match gcc and support icelake features.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321129 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix a crash during C++17 aggregate construction of base objects.
Artem Dergachev [Wed, 20 Dec 2017 00:40:38 +0000 (00:40 +0000)]
[analyzer] Fix a crash during C++17 aggregate construction of base objects.

Since C++17, classes that have base classes can potentially be initialized as
aggregates. Trying to construct such objects through brace initialization was
causing the analyzer to crash when the base class has a non-trivial constructor,
while figuring target region for the base class constructor, because the parent
stack frame didn't contain the constructor of the subclass, because there is
no constructor for subclass, merely aggregate initialization.

This patch avoids the crash, but doesn't provide the actually correct region
for the constructor, which still remains to be fixed. Instead, construction
goes into a fake temporary region which would be immediately discarded. Similar
extremely conservative approach is used for other cases in which the logic for
finding the target region is not yet implemented, including aggregate
initialization with fields instead of base-regions (which is not C++17-specific
but also never worked, just didn't crash).

Differential revision: https://reviews.llvm.org/D40841

rdar://problem/35441058

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321128 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd explicit break (PR35700).
Adrian Prantl [Tue, 19 Dec 2017 22:21:48 +0000 (22:21 +0000)]
Add explicit break (PR35700).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321116 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSilence a bunch of implicit fallthrough warnings
Adrian Prantl [Tue, 19 Dec 2017 22:06:11 +0000 (22:06 +0000)]
Silence a bunch of implicit fallthrough warnings

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321115 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[driver][darwin] Set the 'simulator' environment when it's specified
Alex Lorenz [Tue, 19 Dec 2017 19:56:14 +0000 (19:56 +0000)]
[driver][darwin] Set the 'simulator' environment when it's specified
in '-target'

rdar://35742458

Differential Revision: https://reviews.llvm.org/D41076

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321102 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[driver][darwin] Take the OS version specified in "-target" as the target
Alex Lorenz [Tue, 19 Dec 2017 19:05:04 +0000 (19:05 +0000)]
[driver][darwin] Take the OS version specified in "-target" as the target
OS instead of inferring it from SDK / environment

The OS version is specified in -target should be used instead of the one in an
environment variable / SDK name.

rdar://35813850

Differential Revision: https://reviews.llvm.org/D40998

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321099 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang] -foptimization-record-file= should imply -fsave-optimization-record
Jonas Devlieghere [Tue, 19 Dec 2017 17:16:45 +0000 (17:16 +0000)]
[clang] -foptimization-record-file= should imply -fsave-optimization-record

The Clang option -foptimization-record-file= controls which file an
optimization record is output to. Optimization records are output if you
use the Clang option -fsave-optimization-record. If you specify the
first option without the second, you get a warning that the command line
argument was unused. Passing -foptimization-record-file= should imply
-fsave-optimization-record.

This fixes PR33670

Patch by: Dmitry Venikov <venikov@phystech.edu>

Differential revision: https://reviews.llvm.org/D39834

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321090 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd renamed .o files that were omitted by "git llvm push" command
Walter Lee [Tue, 19 Dec 2017 16:34:13 +0000 (16:34 +0000)]
Add renamed .o files that were omitted by "git llvm push" command

Original commit is at: https://reviews.llvm.org/D41295.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321082 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRename sparc-myriad-elf triplet to sparc-myriad-rtems
Walter Lee [Tue, 19 Dec 2017 16:19:11 +0000 (16:19 +0000)]
Rename sparc-myriad-elf triplet to sparc-myriad-rtems

Summary: This is to be consistent with latest Movidius MDK releases.
Also, don't inherit any gcc paths for shave triple.

Reviewers: jyknight

Subscribers: emaste, fedor.sergeev

Differential Revision: https://reviews.llvm.org/D41295

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321080 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTeach clang/NetBSD about additional dependencies for sanitizers
Kamil Rytarowski [Tue, 19 Dec 2017 07:10:33 +0000 (07:10 +0000)]
Teach clang/NetBSD about additional dependencies for sanitizers

Summary:
Sanitizers on NetBSD require additional linkage:

 - libutil for forkpty(3)
 - libexecinfo for backtrace(3)

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka, kcc

Reviewed By: eugenis

Subscribers: #sanitizers, cfe-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D41054

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321060 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Coverage] Fix use-after free in coverage emission
Eli Friedman [Tue, 19 Dec 2017 01:54:09 +0000 (01:54 +0000)]
[Coverage] Fix use-after free in coverage emission

Fixes regression from r320533.

This fixes the undefined behavior, but I'm not sure it's really right...
I think we end up with missing coverage for code in modules.

Differential Revision: https://reviews.llvm.org/D41374

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321052 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[hwasan] update the design doc
Kostya Serebryany [Mon, 18 Dec 2017 21:40:07 +0000 (21:40 +0000)]
[hwasan] update the design doc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321027 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix more inconsistent line endings. NFC.
Dimitry Andric [Mon, 18 Dec 2017 19:46:56 +0000 (19:46 +0000)]
Fix more inconsistent line endings. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321016 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix the reference to the now renamed member of TBAAStructField
Ivan A. Kosarev [Mon, 18 Dec 2017 16:50:11 +0000 (16:50 +0000)]
Fix the reference to the now renamed member of TBAAStructField

See https://reviews.llvm.org/D39956 for details.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320994 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r320978 "No -fsanitize=function warning when calling noexcept function through...
Stephan Bergmann [Mon, 18 Dec 2017 13:51:48 +0000 (13:51 +0000)]
Revert r320978 "No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17"

At least <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/
builds/6013/steps/annotate/logs/stdio> complains about
__ubsan::__ubsan_handle_function_type_mismatch_abort (compiler-rt
lib/ubsan/ubsan_handlers.cc) returning now despite being declared 'noreturn', so
looks like a different approach is needed for the function_type_mismatch check
to be called also in cases that may ultimately succeed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320982 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoNo -fsanitize=function warning when calling noexcept function through non-noexcept...
Stephan Bergmann [Mon, 18 Dec 2017 13:05:42 +0000 (13:05 +0000)]
No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/
#!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non-
noexcept pointer is undefined behavior?", such a call should not be UB.
However, Clang currently warns about it.

There is no cheap check whether two function type_infos only differ in noexcept,
so pass those two type_infos as additional data to the function_type_mismatch
handler (with the optimization of passing a null "static callee type" info when
that is already noexcept, so the additional check can be avoided anyway).  For
the Itanium ABI (which appears to be the only one that happens to be used on
platforms that support -fsanitize=function, and which appears to only record
noexcept information for pointer-to-function type_infos, not for function
type_infos themselves), we then need to check the mangled names for occurrence
of "Do" representing "noexcept".

This is the cfe part of a patch covering both cfe and compiler-rt.

Differential Revision: https://reviews.llvm.org/D40720

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320978 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Use {{.*}} instead of hardcoded %1 in knot test.
Martin Bohme [Mon, 18 Dec 2017 11:29:21 +0000 (11:29 +0000)]
[X86] Use {{.*}} instead of hardcoded %1 in knot test.

This makes the test more resilient and consistent with the other tests
introduced in r320919.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320971 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRefactor overridden methods iteration to avoid double lookups.
Benjamin Kramer [Sun, 17 Dec 2017 23:52:45 +0000 (23:52 +0000)]
Refactor overridden methods iteration to avoid double lookups.

Convert most uses to range-for loops. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320954 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTImporter] Support importing FunctionTemplateDecl and CXXDependentScopeMemberExpr
Aleksei Sidorin [Sun, 17 Dec 2017 14:16:17 +0000 (14:16 +0000)]
[ASTImporter] Support importing FunctionTemplateDecl and CXXDependentScopeMemberExpr

* Also introduces ImportTemplateArgumentListInfo facility (A. Sidorin)

Patch by Peter Szecsi!

Differential Revision: https://reviews.llvm.org/D38692

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320942 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver, CodeGen] pass through and apply -fassociative-math
Sanjay Patel [Sat, 16 Dec 2017 16:11:17 +0000 (16:11 +0000)]
[Driver, CodeGen] pass through and apply -fassociative-math

There are 2 parts to getting the -fassociative-math command-line flag translated to LLVM FMF:

1. In the driver/frontend, we accept the flag and its 'no' inverse and deal with the
   interactions with other flags like -ffast-math -fno-signed-zeros -fno-trapping-math.
   This was mostly already done - we just need to translate the flag as a codegen option.
   The test file is complicated because there are many potential combinations of flags here.
   Note that we are matching gcc's behavior that requires 'nsz' and no-trapping-math.

2. In codegen, we map the codegen option to FMF in the IR builder. This is simple code and
   corresponding test.

For the motivating example from PR27372:

float foo(float a, float x) { return ((a + x) - x); }

$ ./clang -O2 27372.c -S -o - -ffast-math  -fno-associative-math -emit-llvm  | egrep 'fadd|fsub'
  %add = fadd nnan ninf nsz arcp contract float %0, %1
  %sub = fsub nnan ninf nsz arcp contract float %add, %2

So 'reassoc' is off as expected (and so is the new 'afn' but that's a different patch).
This case now works as expected end-to-end although the underlying logic is still wrong:

$ ./clang  -O2 27372.c -S -o - -ffast-math  -fno-associative-math | grep xmm
addss %xmm1, %xmm0
subss %xmm1, %xmm0

We're not done because the case where 'reassoc' is set is ignored by optimizer passes. Example:

$ ./clang  -O2 27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math -emit-llvm  | grep fadd
  %add = fadd reassoc float %0, %1

$ ./clang -O2  27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math | grep xmm
addss %xmm1, %xmm0
subss %xmm1, %xmm0

Differential Revision: https://reviews.llvm.org/D39812

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320920 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Implement kand/kandn/kor/kxor/kxnor/knot intrinsics using native IR.
Craig Topper [Sat, 16 Dec 2017 08:26:22 +0000 (08:26 +0000)]
[X86] Implement kand/kandn/kor/kxor/kxnor/knot intrinsics using native IR.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320919 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add the two files I forgot to commit in r320915.
Craig Topper [Sat, 16 Dec 2017 06:10:24 +0000 (06:10 +0000)]
[X86] Add the two files I forgot to commit in r320915.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320916 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins and tests for 128 and 256 bit vpopcntdq.
Craig Topper [Sat, 16 Dec 2017 06:02:31 +0000 (06:02 +0000)]
[X86] Add builtins and tests for 128 and 256 bit vpopcntdq.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320915 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[VerifyDiagnosticConsumer] support -verify=<prefixes>
Hal Finkel [Sat, 16 Dec 2017 02:23:22 +0000 (02:23 +0000)]
[VerifyDiagnosticConsumer] support -verify=<prefixes>

This mimics FileCheck's --check-prefixes option.

The default prefix is "expected". That is, "-verify" is equivalent to
"-verify=expected".

The goal is to permit exercising a single test suite source file with different
compiler options producing different sets of diagnostics.  While cpp can be
combined with the existing -verify to accomplish the same goal, source is often
easier to maintain when it's not cluttered with preprocessor directives or
duplicate passages of code. For example, this patch also rewrites some existing
clang tests to demonstrate the benefit of this feature.

Patch by Joel E. Denny, thanks!

Differential Revision: https://reviews.llvm.org/D39694

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320908 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[TextDiagnosticBuffer] Fix diagnostic note emission order
Hal Finkel [Sat, 16 Dec 2017 01:40:19 +0000 (01:40 +0000)]
[TextDiagnosticBuffer] Fix diagnostic note emission order

The frontend currently groups diagnostics from the command line according to
diagnostic level, but that places all notes last. Fix that by emitting such
diagnostics in the order they were generated.

Patch by Joel E. Denny, thanks!

Differential Revision: https://reviews.llvm.org/D40995

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320904 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Specialize mixed-sign mul-with-overflow (fix PR34920)
Vedant Kumar [Sat, 16 Dec 2017 01:28:25 +0000 (01:28 +0000)]
[CodeGen] Specialize mixed-sign mul-with-overflow (fix PR34920)

This patch introduces a specialized way to lower overflow-checked
multiplications with mixed-sign operands. This fixes link failures and
ICEs on code like this:

  void mul(int64_t a, uint64_t b) {
    int64_t res;
    __builtin_mul_overflow(a, b, &res);
  }

The generic checked-binop irgen would use a 65-bit multiplication
intrinsic here, which requires runtime support for _muloti4 (128-bit
multiplication), and therefore fails to link on i386. To get an ICE
on x86_64, change the example to use __int128_t / __uint128_t.

Adding runtime and backend support for 65-bit or 129-bit checked
multiplication on all of our supported targets is infeasible.

This patch solves the problem by using simpler, specialized irgen for
the mixed-sign case.

llvm.org/PR34920, rdar://34963321

Testing: Apart from check-clang, I compared the output from this fairly
comprehensive test driver using unpatched & patched clangs:
https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081

Differential Revision: https://reviews.llvm.org/D41149

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320902 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago__is_target_environment: Check the environment after parsing it
Alex Lorenz [Fri, 15 Dec 2017 20:07:53 +0000 (20:07 +0000)]
__is_target_environment: Check the environment after parsing it

This ensures that target triples with environment versions can still work with
__is_target_environment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320854 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago__is_target_arch: Check the arch and subarch instead of the arch name
Alex Lorenz [Fri, 15 Dec 2017 19:58:38 +0000 (19:58 +0000)]
__is_target_arch: Check the arch and subarch instead of the arch name

This ensures that when compiling for "arm64" __is_target_arch will succeed for
both "arm64" and "aarch64".

Thanks to Bob Wilson who pointed this out!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320853 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove "FunctionName -" from docs on FunctionDecl(NFC)
Erich Keane [Fri, 15 Dec 2017 16:37:14 +0000 (16:37 +0000)]
Remove "FunctionName -" from docs on FunctionDecl(NFC)

Removed the repetative usage of the operator name on the
documentation for FunctionDecl.  Also reflowed some of the
comments since this changes the 80 character rule.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320829 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Codegen `declare simd` for function declarations.
Alexey Bataev [Fri, 15 Dec 2017 16:28:31 +0000 (16:28 +0000)]
[OPENMP] Codegen `declare simd` for function declarations.

Previously the attributes were emitted only for function definitions.
Patch adds emission of the attributes for function declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320826 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang] Add PPCallbacks list to preprocessor when building a preacompiled preamble.
Ilya Biryukov [Fri, 15 Dec 2017 11:27:51 +0000 (11:27 +0000)]
[clang] Add PPCallbacks list to preprocessor when building a preacompiled preamble.

Summary:
Revision D38639 needs this commit in order to properly make open
definition calls on include statements work.

Patch by William Enright.

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Reviewed By: malaperle, ilya-biryukov

Subscribers: cfe-commits, arphaman, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D39375

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320804 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove duplicate python libclang changes from r320748
Alex Lorenz [Thu, 14 Dec 2017 23:40:42 +0000 (23:40 +0000)]
Remove duplicate python libclang changes from r320748

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320766 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCorrect UnaryTransformTypeLoc to properly initialize.
Erich Keane [Thu, 14 Dec 2017 23:37:08 +0000 (23:37 +0000)]
Correct UnaryTransformTypeLoc to properly initialize.

The initializeLocal function of UnaryTransformTypeLoc missed
the UnderlyingTInfo member.  This caused a null-dereference
issue, as reported in PR23421. This patch correctly initializss
the UnderlyingTInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320765 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoD40901: Refactor lazy loading of template specializations. NFC
Vassil Vassilev [Thu, 14 Dec 2017 23:30:18 +0000 (23:30 +0000)]
D40901: Refactor lazy loading of template specializations. NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320763 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDon't trigger -Wuser-defined-literals for system headers
Dimitry Andric [Thu, 14 Dec 2017 22:32:24 +0000 (22:32 +0000)]
Don't trigger -Wuser-defined-literals for system headers

Summary:
In D41064, I proposed adding `#pragma clang diagnostic ignored
"-Wuser-defined-literals"` to some of libc++'s headers, since these
warnings are now triggered by clang's new `-std=gnu++14` default:

```
$ cat test.cpp
#include <string>

$ clang -std=c++14 -Wsystem-headers -Wall -Wextra -c test.cpp
In file included from test.cpp:1:
In file included from /usr/include/c++/v1/string:470:
/usr/include/c++/v1/string_view:763:29: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char> operator "" sv(const char *__str, size_t __len)
                            ^
/usr/include/c++/v1/string_view:769:32: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
                               ^
/usr/include/c++/v1/string_view:775:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
                                ^
/usr/include/c++/v1/string_view:781:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
                                ^
In file included from test.cpp:1:
/usr/include/c++/v1/string:4012:24: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char> operator "" s( const char *__str, size_t __len )
                       ^
/usr/include/c++/v1/string:4018:27: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
                          ^
/usr/include/c++/v1/string:4024:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
                           ^
/usr/include/c++/v1/string:4030:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
                           ^
8 warnings generated.
```

Both @aaron.ballman and @mclow.lists felt that adding this workaround to
the libc++ headers was the wrong way, and it should be fixed in clang
instead.

Here is a proposal to do just that.  I verified that this suppresses the
warning, even when -Wsystem-headers is used, and that the warning is
still emitted for a declaration outside of system headers.

Reviewers: aaron.ballman, mclow.lists, rsmith

Reviewed By: aaron.ballman

Subscribers: mclow.lists, aaron.ballman, andrew, emaste, cfe-commits

Differential Revision: https://reviews.llvm.org/D41080

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320755 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ThreadSafetyAnalysis] Fix isCapabilityExpr
Yi Kong [Thu, 14 Dec 2017 22:24:45 +0000 (22:24 +0000)]
[ThreadSafetyAnalysis] Fix isCapabilityExpr

There are many more expr types that can be a capability expr, like
CXXThisExpr, CallExpr, MemberExpr. Instead of enumerating all of them,
just check typeHasCapability for any type given.

Also add & and * operators to allowed unary operators.

Differential Revision: https://reviews.llvm.org/D41224

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320753 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoHarmonize GNU- and C++-style attribute spellings.
Aaron Ballman [Thu, 14 Dec 2017 22:17:09 +0000 (22:17 +0000)]
Harmonize GNU- and C++-style attribute spellings.

Most attributes will now use the Clang<"name"> construct to provide both __attribute__((name)) and [[clang::name]] syntaxes for the attribute. Attributes deviating from this should be marked with a comment explaining why they are not supported under both spellings. Common reasons are: the attribute is provided by some other specification that controls the syntax or the attribute cannot be exposed under a particular spelling for some given reason.

Because this is a mechanical change that only introduces new spellings, there are no test cases for the commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320752 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[debuginfo] Remove temporary FIXME.
Don Hinton [Thu, 14 Dec 2017 22:12:46 +0000 (22:12 +0000)]
[debuginfo] Remove temporary FIXME.

Summary:
Now that r320495, "[debuginfo-tests] Support moving
debuginfo-tests to llvm/projects," has landed, remove temporary FIXME
that supported the old mechanism.

Reviewers: zturner, aprantl

Reviewed By: aprantl

Subscribers: JDevlieghere, cfe-commits

Differential Revision: https://reviews.llvm.org/D41259

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320751 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix many -Wsign-compare and -Wtautological-constant-compare warnings.
Zachary Turner [Thu, 14 Dec 2017 22:07:03 +0000 (22:07 +0000)]
Fix many -Wsign-compare and -Wtautological-constant-compare warnings.

Most of the -Wsign-compare warnings are due to the fact that
enums are signed by default in the MS ABI, while the
tautological comparison warnings trigger on x86 builds where
sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max()
is always false.

Differential Revision: https://reviews.llvm.org/D41256

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320750 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Add support for checking abstractness of records
Alex Lorenz [Thu, 14 Dec 2017 22:01:50 +0000 (22:01 +0000)]
[libclang] Add support for checking abstractness of records

This patch allows checking whether a C++ record declaration is abstract through
libclang and clang.cindex (Python).

Patch by Johann Klähn!

Differential Revision: https://reviews.llvm.org/D36952

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320748 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[ClangFormat] IndentWrappedFunctionNames should be true in the google ObjC...
Ben Hamilton [Thu, 14 Dec 2017 21:44:11 +0000 (21:44 +0000)]
Revert "[ClangFormat] IndentWrappedFunctionNames should be true in the google ObjC style"

This reverts commit 37e69667f748e1458b46483b7c1b8f9ba33eec44.

We're going to discuss its ramifications further before making a
conclusion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320747 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCommit missing tests for r320734
Alex Lorenz [Thu, 14 Dec 2017 19:22:41 +0000 (19:22 +0000)]
Commit missing tests for r320734

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320735 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Preprocessor] Implement __is_target_{arch|vendor|os|environment} function-like
Alex Lorenz [Thu, 14 Dec 2017 19:22:02 +0000 (19:22 +0000)]
[Preprocessor] Implement __is_target_{arch|vendor|os|environment} function-like
builtin macros

This patch implements the __is_target_arch, __is_target_vendor, __is_target_os,
and __is_target_environment Clang preprocessor extensions that were proposed by
@compnerd in Bob's cfe-dev post:
http://lists.llvm.org/pipermail/cfe-dev/2017-November/056166.html.

These macros can be used to examine the components of the target triple at
compile time. A has_builtin(is_target_???) preprocessor check can be used to
check for their availability.

__is_target_arch allows you to check if an arch is specified without worring
about a specific subarch, e.g.

__is_target_arch(arm) returns 1 for the target arch "armv7"
__is_target_arch(armv7) returns 1 for the target arch "armv7"
__is_target_arch(armv6) returns 0 for the target arch "armv7"

__is_target_vendor and __is_target_environment match the specific vendor
or environment. __is_target_os matches the specific OS, but
__is_target_os(darwin) will match any Darwin-based OS. "Unknown" can be used
to test if the triple's component is specified.

rdar://35753116

Differential Revision: https://reviews.llvm.org/D41087

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320734 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen][X86] Implement _InterlockedCompareExchange128 intrinsic
Reid Kleckner [Thu, 14 Dec 2017 19:00:21 +0000 (19:00 +0000)]
[CodeGen][X86] Implement _InterlockedCompareExchange128 intrinsic

Summary:
InterlockedCompareExchange128 is a bit more complicated than the other
InterlockedCompareExchange functions, so it requires a bit more work. It
doesn't directly refer to 128bit ints, instead it takes pointers to
64bit ints for Destination and ComparandResult, and exchange is taken as
two 64bit ints (high & low). The previous value is written to
ComparandResult, and success is returned. This implementation does the
following in order to produce a cmpxchg instruction:

  1. Cast everything to 128bit ints or int pointers, and glues together
     the Exchange values
  2. Reads from CompareandResult to get the comparand
  3. Calls cmpxchg volatile (on X86 this will produce a lock cmpxchg16b
     instruction)
    1. Result 0 (previous value) is written back to ComparandResult
    2. Result 1 (success bool) is zext'ed to a uchar and returned

Resolves bug https://llvm.org/PR35251

Patch by Colden Cullen!

Reviewers: rnk, agutowski

Reviewed By: rnk

Subscribers: majnemer, cfe-commits

Differential Revision: https://reviews.llvm.org/D41032

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320730 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoIn an ARC lambda-to-block conversion thunk, reclaim the return value of
John McCall [Thu, 14 Dec 2017 18:21:14 +0000 (18:21 +0000)]
In an ARC lambda-to-block conversion thunk, reclaim the return value of
the lambda so that we don't over-release it.

Patch by Dan Zimmerman!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320721 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Add codegen for target data constructs with `nowait` clause.
Alexey Bataev [Thu, 14 Dec 2017 17:00:17 +0000 (17:00 +0000)]
[OPENMP] Add codegen for target data constructs with `nowait` clause.

Added codegen for the `nowait` clause in target data constructs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320717 91177308-0d34-0410-b5e6-96231b3b80d8