]> granicus.if.org Git - clang/log
clang
5 years agoFix reliance on lax vector conversions in tests for x86 intrinsics.
Richard Smith [Tue, 17 Sep 2019 03:56:28 +0000 (03:56 +0000)]
Fix reliance on lax vector conversions in tests for x86 intrinsics.

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

5 years agoRemove reliance on lax vector conversions from altivec.h in VSX mode.
Richard Smith [Tue, 17 Sep 2019 03:56:26 +0000 (03:56 +0000)]
Remove reliance on lax vector conversions from altivec.h in VSX mode.

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

5 years agoPush lambda scope earlier when transforming lambda expression
Nicholas Allegra [Tue, 17 Sep 2019 01:43:33 +0000 (01:43 +0000)]
Push lambda scope earlier when transforming lambda expression

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

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

5 years ago[OPENMP] Fix the test, NFC
Alexey Bataev [Tue, 17 Sep 2019 00:08:50 +0000 (00:08 +0000)]
[OPENMP] Fix the test, NFC

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

5 years ago[OPENMP]Fix the test, NFC.
Alexey Bataev [Mon, 16 Sep 2019 22:17:10 +0000 (22:17 +0000)]
[OPENMP]Fix the test, NFC.

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

5 years ago[Modules][Objective-C] Use complete decl from module when diagnosing missing import
Bruno Cardoso Lopes [Mon, 16 Sep 2019 22:00:29 +0000 (22:00 +0000)]
[Modules][Objective-C] Use complete decl from module when diagnosing missing import

Summary:
Otherwise the definition (first found) for ObjCInterfaceDecl's might
precede the module one, which will eventually lead to crash, since
diagnoseMissingImport needs one coming from a module.

This behavior changed after Richard's r342018, which started to look
into the definition of ObjCInterfaceDecls.

rdar://problem/49237144

Reviewers: rsmith, arphaman

Subscribers: jkorous, dexonsmith, ributzka, cfe-commits

Tags: #clang

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

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

5 years agodo not emit -Wunused-macros warnings in -frewrite-includes mode (PR15614)
Lubos Lunak [Mon, 16 Sep 2019 19:18:37 +0000 (19:18 +0000)]
do not emit -Wunused-macros warnings in -frewrite-includes mode (PR15614)

-frewrite-includes calls PP.SetMacroExpansionOnlyInDirectives() to avoid
macro expansions that are useless in that mode, but this can lead
to -Wunused-macros false positives. As -frewrite-includes does not emit
normal warnings, block -Wunused-macros too.

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

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

5 years ago[Clang][Codegen] Disable arm_acle.c test.
Roman Lebedev [Mon, 16 Sep 2019 17:46:08 +0000 (17:46 +0000)]
[Clang][Codegen] Disable arm_acle.c test.

This test is broken by design. Clang codegen tests should not depend
on llvm middle-end behaviour, they should *only* test clang codegen.
Yet this test runs whole optimization pipeline.
I've really tried to fix it, but there isn't just a few things
that depend on passes, but everything there does.

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

5 years ago[Clang][Codegen] Relax available-externally-suppress.c test
Roman Lebedev [Mon, 16 Sep 2019 17:46:01 +0000 (17:46 +0000)]
[Clang][Codegen] Relax available-externally-suppress.c test

That test is broken by design.
It depends on llvm middle-end behavior.
No clang codegen test should be doing that.
This one is salvageable by relaxing check lines.

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

5 years ago[OPENMP]Fix parsing/sema for function templates with declare simd.
Alexey Bataev [Mon, 16 Sep 2019 17:06:31 +0000 (17:06 +0000)]
[OPENMP]Fix parsing/sema for function templates with declare simd.

Need to return original declaration group with FunctionTemplateDecl, not
the inner FunctionDecl, to correctly handle parsing of directives with
the templates parameters.

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

5 years agoMove some definitions from Sema to Basic to fix shared libs build
Erich Keane [Mon, 16 Sep 2019 13:58:59 +0000 (13:58 +0000)]
Move some definitions from Sema to Basic to fix shared libs build

r371875 moved some functionality around to a Basic header file, but
didn't move its definitions as well.  This patch moves some things
around so that shared library building can work.

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

5 years ago[clangd] Fix a crash when renaming operator.
Haojian Wu [Mon, 16 Sep 2019 10:16:56 +0000 (10:16 +0000)]
[clangd] Fix a crash when renaming operator.

Summary:
The renamelib uses a tricky way to calculate the end location by relying
on decl name, this is incorrect for the overloaded operator (the name is
"operator++" instead of "++"), which will cause out-of-file offset.

We also disable renaming operator symbol, this case is tricky, and
renamelib doesnt handle it properly.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

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

5 years agoChange signature of __builtin_rotateright64 back to unsigned
Karl-Johan Karlsson [Mon, 16 Sep 2019 09:52:23 +0000 (09:52 +0000)]
Change signature of __builtin_rotateright64 back to unsigned

The signature of __builtin_rotateright64 was by misstake changed from
unsigned to signed in r360863, this patch will change it back to
unsigned as intended.

This fixes pr43309

Reviewers: efriedma, hans

Reviewed By: hans

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

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

5 years ago[OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.
Simon Pilgrim [Sun, 15 Sep 2019 16:05:20 +0000 (16:05 +0000)]
[OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.

Fixes static analyzer uninitialized variable warning for the OMPClause - the function appears to cover all cases, but I've added an assertion to make sure.

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

5 years ago[Diagnostics] Added silence note for -Wsizeof-array-div; suggest extra parens
David Bolvansky [Sat, 14 Sep 2019 19:38:55 +0000 (19:38 +0000)]
[Diagnostics] Added silence note for -Wsizeof-array-div; suggest extra parens

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

5 years ago[clang-scan-deps] Add -M to work around -MT issue after r371918
Fangrui Song [Sat, 14 Sep 2019 07:25:27 +0000 (07:25 +0000)]
[clang-scan-deps] Add -M to work around -MT issue after r371918

gcc will complain if -MT is used but neither -M nor -MM is specified:

> cc1: error: to generate dependencies you must specify either -M or -MM

r371918 changed our behavior to match GCC, but apparently
clang-scan-deps is not happy.

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

5 years ago[Driver] Fix multiple bugs related to dependency file options: -M -MM -MD -MMD -MT -MQ
Fangrui Song [Sat, 14 Sep 2019 06:01:22 +0000 (06:01 +0000)]
[Driver] Fix multiple bugs related to dependency file options: -M -MM -MD -MMD -MT -MQ

-M -o test.i => dependency file is test.d, not test.i
-MM -o test.i => dependency file is test.d, not test.i
-M -MMD => bogus warning -Wunused-command-line-argument
-M MT dummy => -w not rendered

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

5 years ago[Driver] Improve Clang::getDependencyFileName and its tests after rC371853
Fangrui Song [Sat, 14 Sep 2019 04:13:15 +0000 (04:13 +0000)]
[Driver] Improve Clang::getDependencyFileName and its tests after rC371853

The test file name metadata-with-dots.c is confusing because -MD and -MMD
have nothing to do with metadata.

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

5 years ago[WebAssembly] Narrowing and widening SIMD ops
Thomas Lively [Fri, 13 Sep 2019 22:54:41 +0000 (22:54 +0000)]
[WebAssembly] Narrowing and widening SIMD ops

Summary:
Implements target-specific LLVM intrinsics and clang builtins for
these new SIMD operations, as described at https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

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

5 years agoMake test check position independent as they sometimes come out reversed. NFCI.
Douglas Yung [Fri, 13 Sep 2019 22:12:27 +0000 (22:12 +0000)]
Make test check position independent as they sometimes come out reversed. NFCI.

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

5 years ago[clang-scan-deps] Fix for headers having the same name as a directory
Alex Lorenz [Fri, 13 Sep 2019 22:12:02 +0000 (22:12 +0000)]
[clang-scan-deps] Fix for headers having the same name as a directory

Scan deps tool crashes when called on a C++ file, containing an include
that has the same name as a directory.
The tool crashes since it finds foo/dir and tries to read that as a file and fails.

Patch by: kousikk (Kousik Kumar)

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

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

5 years agoFix test to use %t for newly created files.
Tim Shen [Fri, 13 Sep 2019 21:06:47 +0000 (21:06 +0000)]
Fix test to use %t for newly created files.

This is both for consistency with other `mkdir`s in tests, and
fixing permission issues with the non-temporary cwd during testing (they
are not always writable).

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

5 years ago[OPENMP5.0]Add basic support for declare variant directive.
Alexey Bataev [Fri, 13 Sep 2019 20:18:17 +0000 (20:18 +0000)]
[OPENMP5.0]Add basic support for declare variant directive.

Added basic support for declare variant directive and its match clause
with user context selector.

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

5 years ago[Support] Add overload writeFileAtomically(std::function Writer)
Jan Korous [Fri, 13 Sep 2019 20:08:27 +0000 (20:08 +0000)]
[Support] Add overload writeFileAtomically(std::function Writer)

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

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

5 years agoReland r371785: Add -Wpoison-system-directories warning
Manoj Gupta [Fri, 13 Sep 2019 18:00:51 +0000 (18:00 +0000)]
Reland r371785: Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

This is reland of r371785 with a fix to test file.

Patch by: denik (Denis Nikitin)

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

5 years agoFix build error in 371875
Erich Keane [Fri, 13 Sep 2019 17:56:38 +0000 (17:56 +0000)]
Fix build error in 371875

Apparently Clang complains about the name hiding here in a way that my
GCC build does not, so a shocking number of buildbots decided to tell me
about it.  Change the name of the variable to prevent the name hiding
and hope we don't have to fix this again.

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

5 years ago[NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.
Erich Keane [Fri, 13 Sep 2019 17:39:31 +0000 (17:39 +0000)]
[NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

In order to enable future improvements to our attribute diagnostics,
this moves info from ParsedAttr into CommonAttributeInfo, then makes
this type the base of the *Attr and ParsedAttr types. Quite a bit of
refactoring took place, including removing a bunch of redundant Spelling
Index propogation.

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

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

5 years ago[Sema][Typo Correction] Fix potential infite loop on ambiguity checks
David Goldman [Fri, 13 Sep 2019 14:43:24 +0000 (14:43 +0000)]
[Sema][Typo Correction] Fix potential infite loop on ambiguity checks

Summary:
This fixes a bug introduced in D62648, where Clang could infinite loop
if it became stuck on a single TypoCorrection when it was supposed to
be testing ambiguous corrections. Although not a common case, it could
happen if there are multiple possible corrections with the same edit
distance.

The fix is simply to wipe the TypoExpr from the `TransformCache` so that
the call to `TransformTypoExpr` doesn't use the `CachedEntry`.

Reviewers: rsmith

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoclang-format: Add support for formatting (some) lambdas with explicit template parame...
Nico Weber [Fri, 13 Sep 2019 13:18:55 +0000 (13:18 +0000)]
clang-format: Add support for formatting (some) lambdas with explicit template parameters.

This patch makes cases work where the lambda's template list doesn't
contain any of + - ! ~ / % << | || && ^ == != >= <= ? : true false
(see added FIXME).

Ports r359967 to clang-format.

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

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

5 years agoFix depfile name construction
Luke Cheeseman [Fri, 13 Sep 2019 13:15:35 +0000 (13:15 +0000)]
Fix depfile name construction

- When using -o, the provided filename is using for constructing the depfile
  name (when -MMD is passed).
- The logic looks for the rightmost '.' character and replaces what comes after
  with 'd'.
- This works incorrectly when the filename has no extension and the directories
  have '.' in them (e.g. out.dir/test)
- This replaces the funciton to just llvm::sys::path functionality

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

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

5 years ago[ASTImporter] Add development internals docs
Gabor Marton [Fri, 13 Sep 2019 11:21:52 +0000 (11:21 +0000)]
[ASTImporter] Add development internals docs

Reviewers: a_sidorin, shafik, teemperor, gamesh411, balazske, dkrupp, a.sidorin

Subscribers: rnkovacs, Szelethus, cfe-commits

Tags: #clang

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

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

5 years ago[Clang Interpreter] Initial patch for the constexpr interpreter
Nandor Licker [Fri, 13 Sep 2019 09:46:16 +0000 (09:46 +0000)]
[Clang Interpreter] Initial patch for the constexpr interpreter

Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

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

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

5 years agoFix a perl warning: Scalar value @ArgParts[0] better written as $ArgParts[0] at ...
Sylvestre Ledru [Fri, 13 Sep 2019 09:31:19 +0000 (09:31 +0000)]
Fix a perl warning: Scalar value @ArgParts[0] better written as $ArgParts[0] at /usr/share/clang/scan-build-10/libexec/ccc-analyzer line 502.

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

5 years ago[Clang][ASTImporter] Added visibility check for FunctionTemplateDecl.
Balazs Keri [Fri, 13 Sep 2019 08:03:49 +0000 (08:03 +0000)]
[Clang][ASTImporter] Added visibility check for FunctionTemplateDecl.

Summary:
ASTImporter makes now difference between function templates with same
name in different translation units if these are not visible outside.

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

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

5 years agoFor PR17164: split -fno-lax-vector-conversion into three different
Richard Smith [Fri, 13 Sep 2019 06:02:15 +0000 (06:02 +0000)]
For PR17164: split -fno-lax-vector-conversion into three different
levels:

 -- none: no lax vector conversions [new GCC default]
 -- integer: only conversions between integer vectors [old GCC default]
 -- all: all conversions between same-size vectors [Clang default]

For now, Clang still defaults to "all" mode, but per my proposal on
cfe-dev (2019-04-10) the default will be changed to "integer" as soon as
that doesn't break lots of testcases. (Eventually I'd like to change the
default to "none" to match GCC and general sanity.)

Following GCC's behavior, the driver flag -flax-vector-conversions is
translated to -flax-vector-conversions=integer.

This reinstates r371805, reverted in r371813, with an additional fix for
lldb.

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

5 years agoFix interaction between r371813 and r371814.
Richard Smith [Fri, 13 Sep 2019 05:29:16 +0000 (05:29 +0000)]
Fix interaction between r371813 and r371814.

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

5 years agoRemove reliance on lax vector conversions from altivec.h and its test.
Richard Smith [Fri, 13 Sep 2019 05:19:12 +0000 (05:19 +0000)]
Remove reliance on lax vector conversions from altivec.h and its test.

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

5 years agoRevert "For PR17164: split -fno-lax-vector-conversion into three different"
Jonas Devlieghere [Fri, 13 Sep 2019 05:16:59 +0000 (05:16 +0000)]
Revert "For PR17164: split -fno-lax-vector-conversion into three different"

This breaks the LLDB build. I tried reaching out to Richard, but haven't
gotten a reply yet.

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

5 years agoFor PR17164: split -fno-lax-vector-conversion into three different
Richard Smith [Fri, 13 Sep 2019 02:20:00 +0000 (02:20 +0000)]
For PR17164: split -fno-lax-vector-conversion into three different
levels:

 -- none: no lax vector conversions [new GCC default]
 -- integer: only conversions between integer vectors [old GCC default]
 -- all: all conversions between same-size vectors [Clang default]

For now, Clang still defaults to "all" mode, but per my proposal on
cfe-dev (2019-04-10) the default will be changed to "integer" as soon as
that doesn't break lots of testcases. (Eventually I'd like to change the
default to "none" to match GCC and general sanity.)

Following GCC's behavior, the driver flag -flax-vector-conversions is
translated to -flax-vector-conversions=integer.

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

5 years agoRevert r371785.
Manoj Gupta [Fri, 13 Sep 2019 00:28:37 +0000 (00:28 +0000)]
Revert r371785.

r371785 is causing fails on clang-hexagon-elf buildbots.

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

5 years ago[libclang] Fix UninstallAbortingLLVMFatalErrorHandler test
Jan Korous [Thu, 12 Sep 2019 23:51:48 +0000 (23:51 +0000)]
[libclang] Fix UninstallAbortingLLVMFatalErrorHandler test

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

5 years ago[libclang] Expose abort()-ing LLVM fatal error handler
Jan Korous [Thu, 12 Sep 2019 22:55:55 +0000 (22:55 +0000)]
[libclang] Expose abort()-ing LLVM fatal error handler

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

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

5 years agoAdd -Wpoison-system-directories warning
Manoj Gupta [Thu, 12 Sep 2019 22:36:13 +0000 (22:36 +0000)]
Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

Patch by: denik (Denis Nikitin)

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

5 years ago[analyzer] Fix the 'analyzer-enabled-checkers.c' test on non-linux machines.
Artem Dergachev [Thu, 12 Sep 2019 22:11:15 +0000 (22:11 +0000)]
[analyzer] Fix the 'analyzer-enabled-checkers.c' test on non-linux machines.

'-Xclang -triple' doesn't seem to override the default target triple
as reliably as '--target'. This leads to test failing due to
platform-specific checks getting unexpectedly enabled.

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

5 years agoImprove code generation for thread_local variables:
Richard Smith [Thu, 12 Sep 2019 20:00:24 +0000 (20:00 +0000)]
Improve code generation for thread_local variables:

Summary:
 * Don't bother using a thread wrapper when the variable is known to
   have constant initialization.
 * Emit the thread wrapper as discardable-if-unused in TUs that don't
   contain a definition of the thread_local variable.
 * Don't emit the thread wrapper at all if the thread_local variable
   is unused and discardable; it will be emitted by all TUs that need
   it.

Reviewers: rjmccall, jdoerfert

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[Clang][CodeGen] support alias attribute w/ gnu_inline
Nick Desaulniers [Thu, 12 Sep 2019 19:53:35 +0000 (19:53 +0000)]
[Clang][CodeGen] support alias attribute w/ gnu_inline

Summary:
r369705 did not consider the addition of gnu_inline on function
declarations of alias attributed functions. This resulted in a reported
regression in the clang-9-rc4 release from the Zig developers building
glibc, which was observable as a failed assertion:

llvm-project/clang/lib/AST/Decl.cpp:3336: bool
clang::FunctionDecl::isInlineDefinitionExternallyVisible() const:
Assertion `(doesThisDeclarationHaveABody() || willHaveBody()) && "Must
be a function definition"' failed.

Alias function declarations do not have bodies, so allow us to proceed
if we have the alias function attribute but no body/definition, and add
a test case.  The emitted symbols and their linkage matches GCC for the
added test case.

Link: https://bugs.llvm.org/show_bug.cgi?id=43268
Reviewers: aaron.ballman, rsmith, erichkeane, andrewrk

Reviewed By: andrewrk

Subscribers: cfe-commits, andrewrk, hans, srhines

Tags: #clang

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

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

5 years ago[CFG] Add dumps for CFGElement and CFGElementRef
Kristof Umann [Thu, 12 Sep 2019 19:52:34 +0000 (19:52 +0000)]
[CFG] Add dumps for CFGElement and CFGElementRef

Seems like we never had these, so here we go! I also did some refactoring as I
was chasing a bug unrelated to this revision.

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

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

5 years ago[analyzer][NFC] Fix inconsistent references to checkers as "checks"
Kristof Umann [Thu, 12 Sep 2019 19:09:24 +0000 (19:09 +0000)]
[analyzer][NFC] Fix inconsistent references to checkers as "checks"

Traditionally, clang-tidy uses the term check, and the analyzer uses checker,
but in the very early years, this wasn't the case, and code originating from the
early 2010's still incorrectly refer to checkers as checks.

This patch attempts to hunt down most of these, aiming to refer to checkers as
checkers, but preserve references to callback functions (like checkPreCall) as
checks.

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

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

5 years agoNFC, add missing cl::cat option category to clang-scan-deps options to ensure they...
Alex Lorenz [Thu, 12 Sep 2019 19:00:32 +0000 (19:00 +0000)]
NFC, add missing cl::cat option category to clang-scan-deps options to ensure they show up in -help

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

5 years ago[analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers
Kristof Umann [Thu, 12 Sep 2019 18:53:48 +0000 (18:53 +0000)]
[analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers

Short and sweet. Whenever I use -analyzer-list-enabled-checkers, I'm only
interested about the configuration, not about the analysis.

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

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

5 years ago[MS] Warn when shadowing template parameters under -fms-compatibility
Reid Kleckner [Thu, 12 Sep 2019 18:26:34 +0000 (18:26 +0000)]
[MS] Warn when shadowing template parameters under -fms-compatibility

Summary:
C++ does not allow shadowing template parameters, but previously we
allowed it under -fms-extensions. Now this behavior is controlled by
-fms-compatibility, and we emit a -Wmicrosoft-template warning when it
happens.

Fixes PR43265

Reviewers: thakis, hans

Subscribers: amccarth, rsmith, STL_MSFT, cfe-commits

Tags: #clang

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

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

5 years ago[clang-scan-deps] remove dots and dots dots from the reported file dependency paths
Alex Lorenz [Thu, 12 Sep 2019 18:03:24 +0000 (18:03 +0000)]
[clang-scan-deps] remove dots and dots dots from the reported file dependency paths

This resolves differences observed on LLVM + Clang when running the comparison between canonical
dependencies (full preprocessing, no file manager reused), and dependencies obtained
when the file manager was reused between the full preprocessing invocations.

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

5 years agoDon't warn about selectany on implicitly inline variables
Reid Kleckner [Thu, 12 Sep 2019 17:55:48 +0000 (17:55 +0000)]
Don't warn about selectany on implicitly inline variables

Summary:
This avoids a -Wignored-attribute warning on the code pattern Microsoft
recommends for integral const static data members defined in headers
here:
https://docs.microsoft.com/en-us/cpp/build/reference/microsoft-extensions-to-c-and-cpp?view=vs-2019

The attribute is redundant, but it is necessary when compiling in C++14
modes with /Za, which disables MSVC's extension that treats such
variables as implicitly inline.

Fixes PR43270

Reviewers: epastor, thakis, hans

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[Alignment] Move OffsetToAlignment to Alignment.h
Guillaume Chatelet [Thu, 12 Sep 2019 15:20:36 +0000 (15:20 +0000)]
[Alignment] Move OffsetToAlignment to Alignment.h

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, JDevlieghere, alexshap, rupprecht, jhenderson

Subscribers: sdardis, nemanjai, hiraditya, kbarton, jakehehrlich, jrtc27, MaskRay, atanasyan, jsji, seiya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

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

5 years ago[clang] [unittest] Import LLVMTestingSupport if necessary
Michal Gorny [Thu, 12 Sep 2019 13:06:12 +0000 (13:06 +0000)]
[clang] [unittest] Import LLVMTestingSupport if necessary

Add LLVMTestingSupport directory from LLVM_MAIN_SRC_DIR when building
clang stand-alone and LLVMTestingSupport library is not present.  This
is needed to fix stand-alone builds without clang-tools-extra.

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

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

5 years agoRemoved some questionable default arguments from setters
Dmitri Gribenko [Thu, 12 Sep 2019 12:16:43 +0000 (12:16 +0000)]
Removed some questionable default arguments from setters

Summary:
They can be confusing -- what does it mean to call a setter without a
value? Also, some setters, like `setPrintTemplateTree` had `false` as
the default value!

The callers are largely not using these default arguments anyway.

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoSwitch "windows" to "system-windows" in some XFAILs
Jeremy Morse [Thu, 12 Sep 2019 11:19:12 +0000 (11:19 +0000)]
Switch "windows" to "system-windows" in some XFAILs

The test failure mode appears to be due to the host machine rather than the
target. The PS4 buildbots are windows-hosted targeting x86_64-scei-ps4,
and are currently reporting these as unexpected failures:

  http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/28114

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

5 years agoRemoved dead code from DiagnosticBuilder
Dmitri Gribenko [Thu, 12 Sep 2019 10:39:53 +0000 (10:39 +0000)]
Removed dead code from DiagnosticBuilder

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

5 years ago[clang-format] [PR43100] clang-format C# support does not add a space between "using...
Paul Hoad [Thu, 12 Sep 2019 10:18:53 +0000 (10:18 +0000)]
[clang-format] [PR43100] clang-format C#  support does not add a space between "using" and paren

Summary:
Addresses https://bugs.llvm.org/show_bug.cgi?id=43100

Formatting using statement in C# with clang-format removes the space between using and paren even when SpaceBeforeParens is !

```
using(FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize : 1))
```

this change simply overcomes this for when using C# settings in the .clang-format file

```
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize : 1))
```

All FormatTests pass..

```
[==========] 688 tests from 21 test cases ran. (88508 ms total)
[  PASSED  ] 688 tests.
```

Reviewers: djasper, klimek, owenpan

Reviewed By: owenpan

Subscribers: llvm-commits, cfe-commits

Tags: #clang

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

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

5 years ago[clang-format] Add new style option IndentGotoLabels
Paul Hoad [Thu, 12 Sep 2019 10:07:14 +0000 (10:07 +0000)]
[clang-format] Add new style option IndentGotoLabels

Summary:
This option determines whether goto labels are indented according to scope. Setting this option to false causes goto labels to be flushed to the left.
This is mostly copied from [[ http://lists.llvm.org/pipermail/cfe-dev/2015-September/045014.html | this patch ]] submitted by Christian Neukirchen that didn't make its way into trunk.

```
     true:                                  false:
     int f() {                      vs.     int f() {
       if (foo()) {                           if (foo()) {
       label1:                              label1:
         bar();                                 bar();
       }                                      }
     label2:                                label2:
       return 1;                              return 1;
     }                                      }
```

Reviewers: klimek, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang, #clang-tools-extra

Patch by: tetsuo-cpp

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

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

5 years ago[WebAssembly] Delete duplicate REQUIRES line
Heejin Ahn [Thu, 12 Sep 2019 06:56:17 +0000 (06:56 +0000)]
[WebAssembly] Delete duplicate REQUIRES line

r371710 and r371711 committed the same line, so this deletes one of
them.

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

5 years ago[WebAssembly] Make wasm-eh.cpp requires WebAssembly
Heejin Ahn [Thu, 12 Sep 2019 06:52:24 +0000 (06:52 +0000)]
[WebAssembly] Make wasm-eh.cpp requires WebAssembly

D67208 added a new test line to wasm-eh.cpp that invokes the LLVM
backend and this test fails on bots that don't have WebAssembly target.
This makes wasm-eh.cpp explicitly require WebAssembly so this will be
skipped on those targets.

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

5 years ago[WebAssembly] Add REQUIRES to test
David Zarzycki [Thu, 12 Sep 2019 06:50:33 +0000 (06:50 +0000)]
[WebAssembly] Add REQUIRES to test

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

5 years ago[WebAssembly] Add -fwasm-exceptions for wasm EH
Heejin Ahn [Thu, 12 Sep 2019 04:01:37 +0000 (04:01 +0000)]
[WebAssembly] Add -fwasm-exceptions for wasm EH

Summary:
This adds `-fwasm-exceptions` (in similar fashion with
`-fdwarf-exceptions` or `-fsjlj-exceptions`) that turns on everything
with wasm exception handling from the frontend to the backend.

We currently have `-mexception-handling` in clang frontend, but this is
only about the architecture capability and does not turn on other
necessary options such as the exception model in the backend. (This can
be turned on with `llc -exception-model=wasm`, but llc is not invoked
separately as a command line tool, so this option has to be transferred
from clang.)

Turning on `-fwasm-exceptions` in clang also turns on
`-mexception-handling` if not specified, and will error out if
`-mno-exception-handling` is specified.

Reviewers: dschuff, tlively, sbc100

Subscribers: aprantl, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

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

5 years ago[clang-scan-deps] Add dependency targets
Jan Korous [Thu, 12 Sep 2019 00:48:45 +0000 (00:48 +0000)]
[clang-scan-deps] Add dependency targets

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

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

5 years ago[X86] Enable -mprefer-vector-width=256 by default for Skylake-avx512 and later Intel...
Craig Topper [Wed, 11 Sep 2019 23:54:36 +0000 (23:54 +0000)]
[X86] Enable -mprefer-vector-width=256 by default for Skylake-avx512 and later Intel CPUs.

AVX512 instructions can cause a frequency drop on these CPUs. This
can negate the performance gains from using wider vectors. Enabling
prefer-vector-width=256 will prevent generation of zmm registers
unless explicit 512 bit operations are used in the original source
code.

I believe gcc and icc both do something similar to this by default.

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

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

5 years agoFix up a test updated in r371655 - require case-insensitive file system.
Volodymyr Sapsai [Wed, 11 Sep 2019 21:19:27 +0000 (21:19 +0000)]
Fix up a test updated in r371655 - require case-insensitive file system.

On case-sensitive file systems include with wrong case is not found instead of
showing a warning.

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

5 years ago[clang-scan-deps] cast Result to ErrorOr<unique_ptr<vfs::File>> explicitly to avoid...
Alex Lorenz [Wed, 11 Sep 2019 21:00:13 +0000 (21:00 +0000)]
[clang-scan-deps] cast Result to ErrorOr<unique_ptr<vfs::File>> explicitly to avoid s390x-linux buildbot failure

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

5 years agoStart porting ivfsoverlay tests to Windows
Reid Kleckner [Wed, 11 Sep 2019 20:56:25 +0000 (20:56 +0000)]
Start porting ivfsoverlay tests to Windows

Part of PR43272, the changes are:

1. Use @ as the sed pattern delimiter instead of : so that the drive
letter in lit substitutions isn't an issue.

2. Use the %/t and %/S substitutions to get paths with forward slashes
to work around string quoting issues in the yaml file.

3. Replace REQUIRES:shell with XFAIL:windows. These tests should pass on
Windows, but do not for reasons that are not yet understood. We would
like to know if they pass unexpectedly.

I was able to remove the XFAILs from two tests, since they already pass
with my sed fix:
  clang/test/VFS/module_missing_vfs.m
  clang/test/VFS/test_nonmodular.c

Reviewers: amccarth

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

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

5 years ago[analyzer] NFC: Move PathDiagnostic classes to libAnalysis.
Artem Dergachev [Wed, 11 Sep 2019 20:54:27 +0000 (20:54 +0000)]
[analyzer] NFC: Move PathDiagnostic classes to libAnalysis.

At this point the PathDiagnostic, PathDiagnosticLocation, PathDiagnosticPiece
structures no longer rely on anything specific to Static Analyzer, so we can
move them out of it for everybody to use.

PathDiagnosticConsumers are still to be handed off.

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

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

5 years ago[analyzer] NFC: Move resetDiagnosticLocationToMainFile() to BugReporter.
Artem Dergachev [Wed, 11 Sep 2019 20:54:24 +0000 (20:54 +0000)]
[analyzer] NFC: Move resetDiagnosticLocationToMainFile() to BugReporter.

This method of PathDiagnostic is a part of Static Analyzer's particular
path diagnostic construction scheme. As such, it doesn't belong to
the PathDiagnostic class, but to the Analyzer.

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

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

5 years ago[analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.
Artem Dergachev [Wed, 11 Sep 2019 20:54:21 +0000 (20:54 +0000)]
[analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

These static functions deal with ExplodedNodes which is something we don't want
the PathDiagnostic interface to know anything about, as it's planned to be
moved out of libStaticAnalyzerCore.

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

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

5 years ago[analyzer] NFC: Re-implement stack hints as a side map in BugReport.
Artem Dergachev [Wed, 11 Sep 2019 20:54:17 +0000 (20:54 +0000)]
[analyzer] NFC: Re-implement stack hints as a side map in BugReport.

That's one of the few random entities in the PathDiagnostic interface that
are specific to the Static Analyzer. By moving them out we could let
everybody use path diagnostics without linking against Static Analyzer.

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

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

5 years ago[clang-scan-deps] add skip excluded conditional preprocessor block preprocessing...
Alex Lorenz [Wed, 11 Sep 2019 20:40:31 +0000 (20:40 +0000)]
[clang-scan-deps] add skip excluded conditional preprocessor block preprocessing optimization

This commit adds an optimization to clang-scan-deps and clang's preprocessor that skips excluded preprocessor
blocks by bumping the lexer pointer, and not lexing the tokens until reaching appropriate #else/#endif directive.
The skip positions and lexer offsets are computed when the file is minimized, directly from the minimized tokens.

On an 18-core iMacPro with macOS Catalina Beta I got 10-15% speed-up from this optimization when running clang-scan-deps on
the compilation database for a recent LLVM and Clang (3511 files).

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

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

5 years agoFix -Wnonportable-include-path suppression for header maps with absolute paths.
Volodymyr Sapsai [Wed, 11 Sep 2019 20:39:04 +0000 (20:39 +0000)]
Fix -Wnonportable-include-path suppression for header maps with absolute paths.

In `DirectoryLookup::LookupFile` parameter `HasBeenMapped` doesn't cover
the case when clang finds a file through a header map but doesn't remap
the lookup filename because the target path is an absolute path. As a
result, -Wnonportable-include-path suppression for header maps
introduced in r301592 wasn't triggered.

Change parameter `HasBeenMapped` to `IsInHeaderMap` and use parameter
`MappedName` to track the filename remapping. This way we can handle
both relative and absolute paths in header maps, and account for their
specific properties, like filename remapping being a property preserved
across lookups in multiple directories.

rdar://problem/39516483

Reviewers: dexonsmith, bruno

Reviewed By: dexonsmith

Subscribers: jkorous, cfe-commits, ributzka

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

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

5 years ago[NFC] Added triple to test file to avoid arm buildbots failures
David Bolvansky [Wed, 11 Sep 2019 18:55:56 +0000 (18:55 +0000)]
[NFC] Added triple to test file to avoid arm buildbots failures

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

5 years ago[MS] Consder constexpr globals to be inline, as in C++17
Reid Kleckner [Wed, 11 Sep 2019 18:09:10 +0000 (18:09 +0000)]
[MS] Consder constexpr globals to be inline, as in C++17

Summary:
Microsoft seems to do this regardless of the language mode, so we must
also do it in order to be ABI compatible.

Fixes PR36125

Reviewers: thakis

Subscribers: cfe-commits

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

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

5 years ago[Clang][Bundler] Replace std::vector by SmallVector [NFC]
Sergey Dmitriev [Wed, 11 Sep 2019 16:28:47 +0000 (16:28 +0000)]
[Clang][Bundler] Replace std::vector by SmallVector [NFC]

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

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

5 years agoReland "clang-misexpect: Profile Guided Validation of Performance Annotations in...
Petr Hosek [Wed, 11 Sep 2019 16:19:50 +0000 (16:19 +0000)]
Reland "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

This patch contains the basic functionality for reporting potentially
incorrect usage of __builtin_expect() by comparing the developer's
annotation against a collected PGO profile. A more detailed proposal and
discussion appears on the CFE-dev mailing list
(http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a
prototype of the initial frontend changes appear here in D65300

We revised the work in D65300 by moving the misexpect check into the
LLVM backend, and adding support for IR and sampling based profiles, in
addition to frontend instrumentation.

We add new misexpect metadata tags to those instructions directly
influenced by the llvm.expect intrinsic (branch, switch, and select)
when lowering the intrinsics. The misexpect metadata contains
information about the expected target of the intrinsic so that we can
check against the correct PGO counter when emitting diagnostics, and the
compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight.
We use these branch weight values to determine when to emit the
diagnostic to the user.

A future patch should address the comment at the top of
LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and
UnlikelyBranchWeight values into a shared space that can be accessed
outside of the LowerExpectIntrinsic pass. Once that is done, the
misexpect metadata can be updated to be smaller.

In the long term, it is possible to reconstruct portions of the
misexpect metadata from the existing profile data. However, we have
avoided this to keep the code simple, and because some kind of metadata
tag will be required to identify which branch/switch/select instructions
are influenced by the use of llvm.expect

Patch By: paulkirth
Differential Revision: https://reviews.llvm.org/D66324

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

5 years ago[Clang][Bundler] Fix for a potential memory leak [NFC]
Sergey Dmitriev [Wed, 11 Sep 2019 16:03:21 +0000 (16:03 +0000)]
[Clang][Bundler] Fix for a potential memory leak [NFC]

Bundler leaks memory if it is called with -type=o but given input isn't an object file (though it has to have a known binary type like IR, archive, etc...). Memory leak is happening when binary object returned by the createBinary(...) call cannot be casted to an ObjectFile type. In this case returned BinaryOrErr object releases ownership of the binary, but no one is taking it (see line 626).

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

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

5 years ago[OPENMP] Update the diagnosis message for canonical loop form, by Chi
Alexey Bataev [Wed, 11 Sep 2019 15:44:06 +0000 (15:44 +0000)]
[OPENMP] Update the diagnosis message for canonical loop form, by Chi
Chun Chen.

The previous patch (https://reviews.llvm.org/D54441) support the
relational-op != very well for openmp canonical loop form, however,
it didn't update the diagnosis message. So this patch is simply
update the diagnosis message by adding !=, update the test
related to it, and update the section number for canonical loop
form for OpenMP 5.0 in comment.

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

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

5 years ago[OPENMP]Updated status page, NFC.
Alexey Bataev [Wed, 11 Sep 2019 14:44:30 +0000 (14:44 +0000)]
[OPENMP]Updated status page, NFC.

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

5 years ago[Diagnostics] Add -Wsizeof-array-div
David Bolvansky [Wed, 11 Sep 2019 10:59:47 +0000 (10:59 +0000)]
[Diagnostics] Add -Wsizeof-array-div

Summary: Clang version of https://www.viva64.com/en/examples/v706/

Reviewers: rsmith

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

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

5 years agoRevert "clang-misexpect: Profile Guided Validation of Performance Annotations in...
Dmitri Gribenko [Wed, 11 Sep 2019 09:16:17 +0000 (09:16 +0000)]
Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

This reverts commit r371584. It introduced a dependency from compiler-rt
to llvm/include/ADT, which is problematic for multiple reasons.

One is that it is a novel dependency edge, which needs cross-compliation
machinery for llvm/include/ADT (yes, it is true that right now
compiler-rt included only header-only libraries, however, if we allow
compiler-rt to depend on anything from ADT, other libraries will
eventually get used).

Secondly, depending on ADT from compiler-rt exposes ADT symbols from
compiler-rt, which would cause ODR violations when Clang is built with
the profile library.

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

5 years ago[ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature
Diogo N. Sampaio [Wed, 11 Sep 2019 09:06:17 +0000 (09:06 +0000)]
[ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature

Submittin in behalf of krisb (Kristina Bessonova) <ch.bessonova@gmail.com>

Summary:
'+crypto' means '+aes' and '+sha2' for arch >= ARMv8 when they were
not disabled explicitly. But this is correctly handled only in case of
'-march' option, though the feature may also be specified through
the '-mcpu' or '-mfpu' options. In the following example:

  $ clang -mcpu=cortex-a57 -mfpu=crypto-neon-fp-armv8

'aes' and 'sha2' are disabled that is quite unexpected:

  $ clang -cc1 -triple armv8--- -target-cpu cortex-a57
    <...> -target-feature -sha2 -target-feature -aes -target-feature +crypto

This exposed by https://reviews.llvm.org/D63936 that makes
the 'aes' and 'sha2' features disabled by default.

So, while handling the 'crypto' feature we need to take into account:
  - a CPU name, as it provides the information about architecture
    (if no '-march' option specified),
  - features, specified by the '-mcpu' and '-mfpu' options.

Reviewers: SjoerdMeijer, ostannard, labrinea, dnsampaio

Reviewed By: dnsampaio

Subscribers: ikudrin, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Author: krisb

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

5 years ago[CodeGen] Add alias for cpu_dispatch function with IFunc & Fix resolver linkage type
Fangrui Song [Wed, 11 Sep 2019 01:54:48 +0000 (01:54 +0000)]
[CodeGen] Add alias for cpu_dispatch function with IFunc & Fix resolver linkage type

Multi-versioned functions defined by cpu_dispatch and implemented with IFunc
can not be called outside the translation units where they are defined due to
lack of symbols. This patch add function aliases for these functions and thus
make them visible outside.

Differential Revision: https://reviews.llvm.org/D67058
Patch by Senran Zhang

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

5 years agoclang-misexpect: Profile Guided Validation of Performance Annotations in LLVM
Petr Hosek [Wed, 11 Sep 2019 01:09:16 +0000 (01:09 +0000)]
clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

This patch contains the basic functionality for reporting potentially
incorrect usage of __builtin_expect() by comparing the developer's
annotation against a collected PGO profile. A more detailed proposal and
discussion appears on the CFE-dev mailing list
(http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a
prototype of the initial frontend changes appear here in D65300

We revised the work in D65300 by moving the misexpect check into the
LLVM backend, and adding support for IR and sampling based profiles, in
addition to frontend instrumentation.

We add new misexpect metadata tags to those instructions directly
influenced by the llvm.expect intrinsic (branch, switch, and select)
when lowering the intrinsics. The misexpect metadata contains
information about the expected target of the intrinsic so that we can
check against the correct PGO counter when emitting diagnostics, and the
compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight.
We use these branch weight values to determine when to emit the
diagnostic to the user.

A future patch should address the comment at the top of
LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and
UnlikelyBranchWeight values into a shared space that can be accessed
outside of the LowerExpectIntrinsic pass. Once that is done, the
misexpect metadata can be updated to be smaller.

In the long term, it is possible to reconstruct portions of the
misexpect metadata from the existing profile data. However, we have
avoided this to keep the code simple, and because some kind of metadata
tag will be required to identify which branch/switch/select instructions
are influenced by the use of llvm.expect

Patch By: paulkirth
Differential Revision: https://reviews.llvm.org/D66324

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

5 years agoEmit -Wmicrosoft-enum-value warning instead of error in MS ABI
Reid Kleckner [Wed, 11 Sep 2019 01:01:06 +0000 (01:01 +0000)]
Emit -Wmicrosoft-enum-value warning instead of error in MS ABI

Summary:
The first NFC change is to replace a getCXXABI().isMicrosoft() check
with getTriple().isWindowsMSVCEnvironment(). This code takes effect in
non-C++ compilations, so it doesn't make sense to check the C++ ABI. In
the MS ABI, enums are always considered to be "complete" because the
underlying type of an unfixed enum will always be 'int'. This behavior
was moved from -fms-compatibility to MS ABI back in r249656.

The second change is functional, and it downgrades an error to a warning
when the MS ABI is used rather than only under -fms-compatibility. The
reasoning is that it's unreasonable for the following code to reject the
following code for all MS ABI targets with -fno-ms-compatibility:
  enum Foo { Foo_Val = 0xDEADBEEF };
This is valid code for any other target, but in the MS ABI, Foo_Val just
happens to be negative. With this change, clang emits a
-Wmicrosoft-enum-value warning on this code, but compiles it without
error.

Fixes PR38478

Reviewers: hans, rsmith, STL_MSFT

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[clang-scan-deps][NFC] Fix tests - prevent FileCheck matching test dir path
Jan Korous [Wed, 11 Sep 2019 00:30:26 +0000 (00:30 +0000)]
[clang-scan-deps][NFC] Fix tests - prevent FileCheck matching test dir path

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

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

5 years ago[clang-format] Apply BAS_AlwaysBreak to C++11 braced lists
Owen Pan [Tue, 10 Sep 2019 23:26:45 +0000 (23:26 +0000)]
[clang-format] Apply BAS_AlwaysBreak to C++11 braced lists

See PR18455.

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

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

5 years agoReland "Change the X86 datalayout to add three address spaces
Amy Huang [Tue, 10 Sep 2019 23:15:38 +0000 (23:15 +0000)]
Reland "Change the X86 datalayout to add three address spaces
 for 32 bit signed, 32 bit unsigned, and 64 bit pointers."
This reverts 57076d3199fc2b0af4a3736b7749dd5462cacda5.

Original review at https://reviews.llvm.org/D64931.
Review for added fix at https://reviews.llvm.org/D66843.

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

5 years agoActually reorder not and env in crash-recovery-modules.m
Reid Kleckner [Tue, 10 Sep 2019 21:54:16 +0000 (21:54 +0000)]
Actually reorder not and env in crash-recovery-modules.m

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

5 years agoWhen evaluating a __builtin_constant_p conditional, always enter
Richard Smith [Tue, 10 Sep 2019 21:24:09 +0000 (21:24 +0000)]
When evaluating a __builtin_constant_p conditional, always enter
constant-folding mode regardless of the original evaluation mode.

In order for this to be correct, we need to track whether we're checking
for a potential constant expression or checking for undefined behavior
separately from the evaluation mode enum, since we don't want to clobber
those states when entering constant-folding mode.

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

5 years ago[OPENMP5.0]Allow teams directive outside of the target directives.
Alexey Bataev [Tue, 10 Sep 2019 20:19:58 +0000 (20:19 +0000)]
[OPENMP5.0]Allow teams directive outside of the target directives.

According to OpenMP 5.0, teams directives are allowed not only in the
target context, but also in the implicit parallel regions.

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

5 years agoRe-land Remove REQUIRES:shell from tests that pass for me on Windows
Reid Kleckner [Tue, 10 Sep 2019 20:15:45 +0000 (20:15 +0000)]
Re-land Remove REQUIRES:shell from tests that pass for me on Windows

This reverts r371497 (git commit 3d7e9ab7b9f8c53aa41420c54970f0fb421004a2)

Reorder `not` with `env` in these two tests so they pass:
  Driver/rewrite-map-in-diagnostics.c
  Index/crash-recovery-modules.m.

This will not be necessary after D66531 lands.

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

5 years agoFix for PR43175: compiler crash when trying to emit noncapturable
Alexey Bataev [Tue, 10 Sep 2019 19:16:56 +0000 (19:16 +0000)]
Fix for PR43175: compiler crash when trying to emit noncapturable
constant.

If the constexpr variable is partially initialized, the initializer can
be emitted as the structure, not as an array, because of some early
optimizations. The llvm variable gets the type from this constant and,
thus, gets the type which is pointer to struct rather than pointer to an
array. We need to convert this type to be truely array, otherwise it may
lead to the compiler crash when trying to emit array subscript
expression.

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

5 years agoDon't emit .gnu_pubnames when tuning for LLDB.
Adrian Prantl [Tue, 10 Sep 2019 15:53:18 +0000 (15:53 +0000)]
Don't emit .gnu_pubnames when tuning for LLDB.

LLDB reads the various .apple* accelerator tables (and in the near
future: the DWARF 5 accelerator tables) which should make
.gnu_pubnames redundant. This changes the Clang driver to no longer
pass -ggnu-pubnames when tuning for LLDB.

Thanks to David Blaikie for pointing this out!
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190422/thread.html#646062

rdar://problem/50142073

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

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

5 years ago[clang][codegen][NFC] Make test patterns more permissive.
Clement Courbet [Tue, 10 Sep 2019 14:20:08 +0000 (14:20 +0000)]
[clang][codegen][NFC] Make test patterns more permissive.

See the discussion in:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190909/692736.html

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

5 years agoRevert Remove REQUIRES:shell from tests that pass for me on Windows
James Henderson [Tue, 10 Sep 2019 08:48:33 +0000 (08:48 +0000)]
Revert Remove REQUIRES:shell from tests that pass for me on Windows

This reverts r371478 (git commit a9980f60ce083fa6d5fd03c12c58ca0b293e3d60)

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

5 years ago[RISCV] Make -march=rv{32,64}gc the default in RISC-V Linux
Roger Ferrer Ibanez [Tue, 10 Sep 2019 08:16:24 +0000 (08:16 +0000)]
[RISCV] Make -march=rv{32,64}gc the default in RISC-V Linux

This is the logical follow-up of D65634.

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

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