]> granicus.if.org Git - clang/log
clang
5 years ago[clang] Update `ignoringElidableConstructorCall` matcher to ignore `ExprWithCleanups`.
Yitzhak Mandelbaum [Thu, 8 Aug 2019 17:41:44 +0000 (17:41 +0000)]
[clang] Update `ignoringElidableConstructorCall` matcher to ignore `ExprWithCleanups`.

Summary:
The `ExprWithCleanups` node is added to the AST along with the elidable
CXXConstructExpr.  If it is the outermost node of the node being matched, ignore
it as well.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[FIX][NFC] Update clang sema test
Diogo N. Sampaio [Thu, 8 Aug 2019 14:45:42 +0000 (14:45 +0000)]
[FIX][NFC] Update clang sema test

Try to fix Sema test for default alignment for when
compiling to ARM, but not to android, due
r9427aa2d543b

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

5 years ago[OPENMP]Add support for analysis of linear variables and step.
Alexey Bataev [Thu, 8 Aug 2019 13:42:45 +0000 (13:42 +0000)]
[OPENMP]Add support for analysis of linear variables and step.

Summary:
Added support for basic analysis of the linear variables and linear step
expression. Linear loop iteration variables must be excluded from this
analysis, only non-loop iteration variables must be analyzed.

Reviewers: NoQ

Subscribers: guansong, cfe-commits, caomhin, kkwli0

Tags: #clang

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

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

5 years ago[ARM] Set default alignment to 64bits
Diogo N. Sampaio [Thu, 8 Aug 2019 12:50:36 +0000 (12:50 +0000)]
[ARM] Set default alignment to 64bits

Summary:
The maximum alignment used by ARM arch
is 64bits, not 128.

This could cause overaligned memory
access for 128 bit neon vector that
have unpredictable behaviour.

This fixes: https://bugs.llvm.org/show_bug.cgi?id=42668

Reviewers: ostannard, dmgreen, srhines, danalbert, pirama, peter.smith

Reviewed By: pirama, peter.smith

Subscribers: phosek, thegameg, thakis, llvm-commits, carwil, peter.smith, javed.absar, kristof.beyls, cfe-commits

Tags: #clang, #llvm

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

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

5 years ago[clang-format] fix crash involving invalid preprocessor line
Krasimir Georgiev [Thu, 8 Aug 2019 11:56:18 +0000 (11:56 +0000)]
[clang-format] fix crash involving invalid preprocessor line

Summary:
This (invalid) fragment is crashing clang-format:
```
#if 1
int x;
#elif
int y;
#endif
```

The reason being that the parser expects a token after `#elif`, and the
subsequent parsing of the next line does not check if `CurrentToken` is null.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCase
Shaurya Gupta [Thu, 8 Aug 2019 08:37:49 +0000 (08:37 +0000)]
[Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCase

Reviewers: arphaman, sammccall

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

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

5 years ago[diagtool] Use `operator<<(Colors)` to print out colored output.
Rui Ueyama [Thu, 8 Aug 2019 07:04:01 +0000 (07:04 +0000)]
[diagtool] Use `operator<<(Colors)` to print out colored output.

r368131 introduced this new API to print out messages in colors.
If the colored output is disabled, `operator<<(Colors)` becomes nop.
No functionality change intended.

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

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

5 years ago[Driver] Delete XFAIL: windows-msvc after D65880/r368245
Fangrui Song [Thu, 8 Aug 2019 04:56:21 +0000 (04:56 +0000)]
[Driver] Delete XFAIL: windows-msvc after D65880/r368245

`-target %itanium_abi_triple` fixed the problem.

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

5 years ago[Driver] Move LIBRARY_PATH before user inputs
Fangrui Song [Thu, 8 Aug 2019 01:55:27 +0000 (01:55 +0000)]
[Driver] Move LIBRARY_PATH before user inputs

Fixes PR16786

Currently, library paths specified by LIBRARY_PATH are placed after inputs: `inputs LIBRARY_PATH stdlib`
In gcc, the order is: `LIBRARY_PATH inputs stdlib` if not cross compiling.
(On Darwin targets, isCrossCompiling() always returns false.)

This patch changes the behavior to match gcc.

Reviewed By: hfinkel

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

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

5 years agoInline diagnostic text into .td file. NFC.
Richard Trieu [Thu, 8 Aug 2019 01:45:31 +0000 (01:45 +0000)]
Inline diagnostic text into .td file.  NFC.

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

5 years agoUpdate fix-it hints for std::move warnings.
Richard Trieu [Thu, 8 Aug 2019 00:12:51 +0000 (00:12 +0000)]
Update fix-it hints for std::move warnings.

Fix -Wpessimizing-move and -Wredundant-move when warning on initializer lists.
The new fix-it hints for removing the std::move call will now also suggest
removing the braces for the initializer list so that the resulting code will
still be compilable.

This fixes PR42832

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

5 years agoAdd target requirements for those bots which don't handle x86.
Bill Wendling [Wed, 7 Aug 2019 19:36:48 +0000 (19:36 +0000)]
Add target requirements for those bots which don't handle x86.

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

5 years ago[Tooling] Expose ExecutorConcurrency option.
Diego Astiazaran [Wed, 7 Aug 2019 18:35:28 +0000 (18:35 +0000)]
[Tooling] Expose ExecutorConcurrency option.

D65628 requires a flag to specify the number of threads for a clang-doc step. It would be good to use ExecutorConcurrency after exposing it instead of creating a new one that has the same purpose.

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

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

5 years ago[clang][NFC] Fix typo in matcher comment
Yitzhak Mandelbaum [Wed, 7 Aug 2019 17:01:31 +0000 (17:01 +0000)]
[clang][NFC] Fix typo in matcher comment

Also updates corresponding html doc.

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

5 years agoRemove LLVM mutexes from clang in favor of std::mutex
Benjamin Kramer [Wed, 7 Aug 2019 14:44:40 +0000 (14:44 +0000)]
Remove LLVM mutexes from clang in favor of std::mutex

None of those need to be recursive mutexes. No functionality change
intended.

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

5 years ago[OPENMP]Set default version to OpenMP 4.5.
Alexey Bataev [Wed, 7 Aug 2019 14:39:17 +0000 (14:39 +0000)]
[OPENMP]Set default version to OpenMP 4.5.

Since clang fully supports OpenMP 4.5, set the default version to 4.5
instead of 3.1.

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

5 years ago[OPENMP]Add standard macro value _OPENMP for OpenMP 5.0.
Alexey Bataev [Wed, 7 Aug 2019 14:02:11 +0000 (14:02 +0000)]
[OPENMP]Add standard macro value _OPENMP for OpenMP 5.0.

According to the OpenMP standard, compiler must define _OPENMP macro,
which has value in format yyyymm, where yyyy is the year of the standard
and mm is the month of the standard. For OpenMP 5.0 this value must be
set to 201811.

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

5 years ago[ASTImporter] Do not import FunctionTemplateDecl in record twice.
Balazs Keri [Wed, 7 Aug 2019 12:40:17 +0000 (12:40 +0000)]
[ASTImporter] Do not import FunctionTemplateDecl in record twice.

Summary:
For functions there is a check to not duplicate the declaration if it is in a
record (class). For function templates there was no similar check, if a
template (in the same class) was imported multiple times the
FunctionTemplateDecl was created multiple times with the same templated
FunctionDecl. This can result in problems with the declaration chain.

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/D65203

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

5 years agoReplace non-recursive sys::Mutex users with std::mutex
Benjamin Kramer [Wed, 7 Aug 2019 11:59:44 +0000 (11:59 +0000)]
Replace non-recursive sys::Mutex users with std::mutex

Also remove a use of sys::MutexImpl, that's just evil. No functionality
change intended.

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

5 years ago[clang] Fix mismatched args constructing AddressSpaceAttr.
Anton Bikineev [Wed, 7 Aug 2019 11:12:43 +0000 (11:12 +0000)]
[clang] Fix mismatched args constructing AddressSpaceAttr.

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

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

5 years agoReplace llvm::MutexGuard/UniqueLock with their standard equivalents
Benjamin Kramer [Wed, 7 Aug 2019 10:57:25 +0000 (10:57 +0000)]
Replace llvm::MutexGuard/UniqueLock with their standard equivalents

All supported platforms have <mutex> now, so we don't need our own
copies any longer. No functionality change intended.

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

5 years agogsl::Owner/gsl::Pointer: Add implicit annotations for some std types
Matthias Gehre [Wed, 7 Aug 2019 10:45:36 +0000 (10:45 +0000)]
gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

Summary:
Hard code gsl::Owner/gsl::Pointer for std types. The paper mentions
some types explicitly. Generally, all containers and their iterators are
covered. For iterators, we cover both the case that they are defined
as an nested class or as an typedef/using. I have started to test this
implementation against some real standard library implementations, namely
libc++ 7.1.0, libc++ 8.0.1rc2, libstdc++ 4.6.4, libstdc++ 4.8.5,
libstdc++ 4.9.4, libstdc++ 5.4.0, libstdc++ 6.5.0, libstdc++ 7.3.0,
libstdc++ 8.3.0 and libstdc++ 9.1.0.

The tests are currently here
  https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.sh
  https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
I think due to their dependency on a standard library, they are not a good fit
for clang/test/. Where else could I put them?

Reviewers: gribozavr, xazax.hun

Subscribers: rnkovacs, cfe-commits

Tags: #clang

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

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

5 years agoRemove inclusion of a private gmock header from a test
Dmitri Gribenko [Wed, 7 Aug 2019 08:16:29 +0000 (08:16 +0000)]
Remove inclusion of a private gmock header from a test

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

5 years agoRe-submit r367649: Improve raw_ostream so that you can "write" colors using operator<<
Rui Ueyama [Wed, 7 Aug 2019 08:08:17 +0000 (08:08 +0000)]
Re-submit r367649: Improve raw_ostream so that you can "write" colors using operator<<

The original patch broke buildbots, perhaps because it changed the
default setting whether colors are enabled or not.

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

5 years ago[RISCV] Remove duplicated logic when determining the target ABI
Roger Ferrer Ibanez [Wed, 7 Aug 2019 07:08:00 +0000 (07:08 +0000)]
[RISCV] Remove duplicated logic when determining the target ABI

We were calculating twice ilp32/lp64. Do this in one place instead.

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

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

5 years ago[clang][DirectoryWatcher][NFC] Swapping asserts for llvm fatal_error in create
Puyan Lotfi [Tue, 6 Aug 2019 23:25:34 +0000 (23:25 +0000)]
[clang][DirectoryWatcher][NFC] Swapping asserts for llvm fatal_error in create

I also have replaced all the instances of
"auto DW = DirectoryWatcher::create" with
llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW = DirectoryWatcher::create
to make it more clear that DirectoryWatcher::create is returning an Expected.

I've also allowed for logAllUnhandledErrors to consume errors in the case were
DirectoryWatcher::create produces them.

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

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

5 years agoDelay diagnosing asm constraints that require immediates until after inlining
Bill Wendling [Tue, 6 Aug 2019 22:41:22 +0000 (22:41 +0000)]
Delay diagnosing asm constraints that require immediates until after inlining

Summary:
An inline asm call may result in an immediate input value after inlining.
Therefore, don't emit a diagnostic here if the input isn't an immediate.

Reviewers: joerg, eli.friedman, rsmith

Subscribers: asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, s.egerton, krytarowski, mgorny, riccibruno, eraman, cfe-commits

Tags: #clang

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

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

5 years agohwasan: Instrument globals.
Peter Collingbourne [Tue, 6 Aug 2019 22:07:29 +0000 (22:07 +0000)]
hwasan: Instrument globals.

Globals are instrumented by adding a pointer tag to their symbol values
and emitting metadata into a special section that allows the runtime to tag
their memory when the library is loaded.

Due to order of initialization issues explained in more detail in the comments,
shadow initialization cannot happen during regular global initialization.
Instead, the location of the global section is marked using an ELF note,
and we require libc support for calling a function provided by the HWASAN
runtime when libraries are loaded and unloaded.

Based on ideas discussed with @evgeny777 in D56672.

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

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

5 years ago[WebAssembly] Lower ASan constructor priority on Emscripten
Guanzhong Chen [Tue, 6 Aug 2019 21:52:58 +0000 (21:52 +0000)]
[WebAssembly] Lower ASan constructor priority on Emscripten

Summary:
This change gives Emscripten the ability to use more than one constructor
priorities that runs before ASan. By convention, constructor priorites 0-100
are reserved for use by the system. ASan on Emscripten now uses priority 50,
leaving plenty of room for use by Emscripten before and after ASan.

This change is done in response to:
https://github.com/emscripten-core/emscripten/pull/9076#discussion_r310323723

Reviewers: kripken, tlively, aheejin

Reviewed By: tlively

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

Tags: #llvm, #clang

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

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

5 years agofix clang-scan-deps test to match filepaths on Windows
Alex Lorenz [Tue, 6 Aug 2019 21:45:43 +0000 (21:45 +0000)]
fix clang-scan-deps test to match filepaths on Windows

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

5 years ago[clang-scan-deps] Implementation of dependency scanner over minimized sources
Alex Lorenz [Tue, 6 Aug 2019 20:43:25 +0000 (20:43 +0000)]
[clang-scan-deps] Implementation of dependency scanner over minimized sources

This commit implements the fast dependency scanning mode in clang-scan-deps: the
preprocessing is done on files that are minimized using the dependency directives source minimizer.

A shared file system cache is used to ensure that the file system requests and source minimization
is performed only once. The cache assumes that the underlying filesystem won't change during the course
of the scan (or if it will, it will not affect the output), and it can't be evicted. This means that the
service and workers can be used for a single run of a dependency scanner, and can't be reused across multiple,
incremental runs. This is something that we'll most likely support in the future though.
Note that the driver still utilizes the underlying real filesystem.

This commit is also still missing the fast skipped PP block skipping optimization that I mentioned at EuroLLVM talk.
Additionally, the file manager is still not reused by the threads as well.

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

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

5 years agoTeach some warnings to respect gsl::Pointer and gsl::Owner attributes
Gabor Horvath [Tue, 6 Aug 2019 19:13:29 +0000 (19:13 +0000)]
Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

This patch extends some existing warnings to utilize the knowledge about the gsl::Pointer and gsl::Owner attributes.

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

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

5 years ago[Syntax] Do not add a node for 'eof' into the tree
Ilya Biryukov [Tue, 6 Aug 2019 17:07:58 +0000 (17:07 +0000)]
[Syntax] Do not add a node for 'eof' into the tree

Summary:
While useful as a sentinel value when iterating over tokens, having
'eof' in the tree, seems to do more harm than good.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

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

5 years ago[AST] Traverse attributes inside DEF_TRAVERSE_DECL macro
Ilya Biryukov [Tue, 6 Aug 2019 15:46:12 +0000 (15:46 +0000)]
[AST] Traverse attributes inside DEF_TRAVERSE_DECL macro

Summary:
Instead of traversing inside the TraverseDecl() function.
Previously the attributes were traversed after Travese(Some)Decl
returns.

Logically attributes are properties of particular Decls and should be
traversed alongside other "child" nodes.

None of the tests relied on this behavior, hopefully this is an indication
that the change is relatively safe.

This change started with a discussion on cfe-dev, for details see:
https://lists.llvm.org/pipermail/cfe-dev/2019-July/062899.html

Reviewers: rsmith, gribozavr

Reviewed By: gribozavr

Subscribers: mgorny, cfe-commits

Tags: #clang

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

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

5 years agoImprove MSVC visualizations so the parser shows where we are in the code
Mike Spertus [Tue, 6 Aug 2019 13:29:35 +0000 (13:29 +0000)]
Improve MSVC visualizations so the parser shows where we are in the code

Also provide a visualizer for lambda introducers

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

5 years ago[CrossTU] Handle case when no USR could be generated during Decl search.
Balazs Keri [Tue, 6 Aug 2019 12:10:16 +0000 (12:10 +0000)]
[CrossTU] Handle case when no USR could be generated during Decl search.

Summary:
When searching for a declaration to be loaded the "lookup name" for every
other Decl is computed. If the USR can not be determined here should be
not an assert, instead skip this Decl.

Reviewers: martong

Reviewed By: martong

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

Tags: #clang

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

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

5 years agoAdd User docs for ASTImporter
Gabor Marton [Tue, 6 Aug 2019 09:52:21 +0000 (09:52 +0000)]
Add User docs for ASTImporter

Summary:
This document includes the description of the ASTImporter from the user/client
perspective.
A subsequent patch will describe the development internals.

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

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

Tags: #clang

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

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

5 years ago[DirectoryWatcher] Fix asserts Mac builds
Shoaib Meenai [Tue, 6 Aug 2019 07:13:53 +0000 (07:13 +0000)]
[DirectoryWatcher] Fix asserts Mac builds

Add a missing semicolon after an assert. Remove the period from the
assert message while I'm here, because we don't usually have those.

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

5 years ago[Driver] Introduce -stdlib++-isystem
Shoaib Meenai [Tue, 6 Aug 2019 06:48:43 +0000 (06:48 +0000)]
[Driver] Introduce -stdlib++-isystem

There are times when we wish to explicitly control the C++ standard
library search paths used by the driver. For example, when we're
building against the Android NDK, we might want to use the NDK's C++
headers (which have a custom inline namespace) even if we have C++
headers installed next to the driver. We might also be building against
a non-standard directory layout and wanting to specify the C++ standard
library include directories explicitly.

We could accomplish this by passing -nostdinc++ and adding an explicit
-isystem for our custom search directories. However, users of our
toolchain may themselves want to use -nostdinc++ and a custom C++ search
path (libc++'s build does this, for example), and our added -isystem
won't respect the -nostdinc++, leading to multiple C++ header
directories on the search path, which causes build failures.

Add a new driver option -stdlib++-isystem to support this use case.
Passing this option suppresses adding the default C++ library include
paths in the driver, and it also respects -nostdinc++ to allow users to
still override the C++ library paths themselves.

It's a bit unfortunate that we end up with both -stdlib++-isystem and
-cxx-isystem, but their semantics differ significantly. -cxx-isystem is
unaffected by -nostdinc++ and is added to the end of the search path
(which is not appropriate for C++ standard library headers, since they
often #include_next into other system headers), while -stdlib++-isystem
respects -nostdinc++, is added to the beginning of the search path, and
suppresses the default C++ library include paths.

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

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

5 years ago[Driver] Prioritize SYSROOT/usr/include over RESOURCE_DIR/include on linux-musl
Fangrui Song [Tue, 6 Aug 2019 06:25:32 +0000 (06:25 +0000)]
[Driver] Prioritize SYSROOT/usr/include over RESOURCE_DIR/include on linux-musl

On a musl-based Linux distribution, stdalign.h stdarg.h stdbool.h stddef.h stdint.h stdnoreturn.h are expected to be provided by musl (/usr/include), instead of RESOURCE_DIR/include.
Reorder RESOURCE_DIR/include to fix the search order problem.
(Currently musl doesn't provide stdatomic.h. stdatomic.h is still found in RESOURCE_DIR/include.)

gcc on musl has a similar search order:

```
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/x86_64-alpine-linux-musl
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/backward
 /usr/local/include
 /usr/include/fortify
 /usr/include
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/include
```

This is different from a glibc-based distribution where RESOURCE_DIR/include is placed before SYSROOT/usr/include.

According to the maintainer of musl:

> musl does not support use/mixing of compiler-provided std headers with its headers, and intentionally has no mechanism for communicating with such headers as to which types have already been defined or still need to be defined. If the current include order, with clang's headers before the libc ones, works in some situations, it's only by accident.

Reviewed by: phosek

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

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

5 years ago[clang][DirectoryWatcher] Adding llvm::Expected error handling to create.
Puyan Lotfi [Tue, 6 Aug 2019 05:12:23 +0000 (05:12 +0000)]
[clang][DirectoryWatcher] Adding llvm::Expected error handling to create.

Prior to this patch Unix style errno error reporting from the inotify layer was
used by DirectoryWatcher::create to simply return a nullptr on error. This
would generally be ok, except that in LLVM we have much more robust error
reporting through the facilities of llvm::Expected.

The other critical thing I stumbled across was that the unit tests for
DirectoryWatcher were not failing abruptly when inotify_init() was reporting an
error, but would continue with the testing and eventually hit a deadlock in a
pathological machine state (ie in the unit test, the return nullptr on ::create
was ignored).

Generally this pathological state never happens on any build bot, so it is
totally understandable that it was overlooked, but on a Linux desktop running
a dubious desktop environment (which I will not name) there is a chance that
said desktop environment could use up enough inotify instances to exceed the
user's limit. These are the conditions that led me to hit the deadlock I am
addressing in this patch with more robust error handling.

With the new llvm::Expected error handling when your system runs out of inotify
instances for your user, the unit test will be forced to handle the error or
crash and report the issue to the user instead of weirdly deadlocking on a
condition variable wait.

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

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

5 years agoBuiltins: Start adding half versions of math builtins
Matt Arsenault [Tue, 6 Aug 2019 03:28:37 +0000 (03:28 +0000)]
Builtins: Start adding half versions of math builtins

The implementation of the OpenCL builtin currently library uses 2
different hacks to get to the corresponding IR intrinsics from the
source. This will allow removal of those.

This is the set that is currently used (minus a few vector ones).

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

5 years ago[NFC][DirectoryWatchedTests] Unlocks mutexes before signaling condition variable
Puyan Lotfi [Tue, 6 Aug 2019 01:26:46 +0000 (01:26 +0000)]
[NFC][DirectoryWatchedTests] Unlocks mutexes before signaling condition variable

This should not affect actual behavior, but should pessimize the threading less
by avoiding the situation where:

  * mutex is still locked
  * T1 notifies on condition variable
  * T2 wakes to check mutex
  * T2 sees mutex is still locked
  * T2 waits
  * T1 unlocks mutex
  * T2 tries again, acquires mutex.

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

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

5 years ago[Sema] attempt to appease buildbots after r367940
George Burgess IV [Mon, 5 Aug 2019 23:19:15 +0000 (23:19 +0000)]
[Sema] attempt to appease buildbots after r367940

A buildbot got angry about this new test, with error messages like:

warn-nullchar-nullptr.c Line 16: use of undeclared identifier 'u'

It looks like this `u'c'` syntax was introduced in C11; I'm guessing
some bots may default to something before that. Let's see if explicitly
specifying the standard version makes it happy...

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

5 years ago[Sema] Add -Wpointer-compare
George Burgess IV [Mon, 5 Aug 2019 22:15:40 +0000 (22:15 +0000)]
[Sema] Add -Wpointer-compare

This patch adds a warning that diagnoses comparisons of pointers to
'\0'. This is often indicative of a bug (e.g. the user might've
forgotten to dereference the pointer).

Patch by Elaina Guan!

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

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

5 years ago[docs] don't use :option: for Wall Wextra
JF Bastien [Mon, 5 Aug 2019 19:59:07 +0000 (19:59 +0000)]
[docs] don't use :option: for Wall Wextra

The bots are sad that they're not documented.

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

5 years ago[docs] don't use :option: for C++ compat
JF Bastien [Mon, 5 Aug 2019 19:45:23 +0000 (19:45 +0000)]
[docs] don't use :option: for C++ compat

The bots are sad that they're not documented.

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

5 years agoFix another uninit read found by msan after r367829
Nico Weber [Mon, 5 Aug 2019 19:35:59 +0000 (19:35 +0000)]
Fix another uninit read found by msan after r367829

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

5 years ago[DirectoryWatcher][linux] Fix build for older kernels
Jan Korous [Mon, 5 Aug 2019 18:44:07 +0000 (18:44 +0000)]
[DirectoryWatcher][linux] Fix build for older kernels

Apparently kernel support for IN_EXCL_UNLINK in inotify_add_watch() doesn't imply it's defined in sys/inotify.h.

https://bugs.llvm.org/show_bug.cgi?id=42824

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

5 years ago[OpenMP 5.0] Codegen support for user-defined mappers.
Michael Kruse [Mon, 5 Aug 2019 18:43:21 +0000 (18:43 +0000)]
[OpenMP 5.0] Codegen support for user-defined mappers.

This patch implements the code generation for OpenMP 5.0 declare mapper
(user-defined mapper) constructs. For each declare mapper, a mapper
function is generated. These mapper functions will be called by the
runtime and/or other mapper functions to achieve user defined mapping.

The design slides can be found at
https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx

Re-commit after revert in r367773 because r367755 changed the LLVM-IR
output such that a CHECK line failed.

Patch by Lingda Li <lildmh@gmail.com>

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

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

5 years ago[AST] Fix buildbot failure because of raw string inside macro from 367839.
Johan Vikstrom [Mon, 5 Aug 2019 17:14:46 +0000 (17:14 +0000)]
[AST] Fix buildbot failure because of raw string inside macro from 367839.

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

5 years ago[docs] document -Weveything more betterer
JF Bastien [Mon, 5 Aug 2019 16:53:45 +0000 (16:53 +0000)]
[docs] document -Weveything more betterer

Reviewers: aaron.ballman

Subscribers: jkorous, dexonsmith, cfe-commits

Tags: #clang

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

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

5 years ago[AST] Fix RecursiveASTVisitorTest multiline string literal. NFC
David Green [Mon, 5 Aug 2019 16:27:36 +0000 (16:27 +0000)]
[AST] Fix RecursiveASTVisitorTest multiline string literal. NFC

Some compiler, notably older gccs (< 8) can have trouble with multiline raw
string literals inside macros. This just moves the code outsize the macro, to
attempt to appease the bots.

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

5 years agoUndo what looks like an unintentional change in r367829
Nico Weber [Mon, 5 Aug 2019 15:23:10 +0000 (15:23 +0000)]
Undo what looks like an unintentional change in r367829

The MSan bot was (rightfully) complaining that NumASTLoaded was
unitialized, so put the initialization removed in r367829 back in.

While here, remove two needless semicolons added in that change.

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

5 years ago[Driver] Properly use values-X[ca].o, values-xpg[46].o on Solaris
Rainer Orth [Mon, 5 Aug 2019 14:06:16 +0000 (14:06 +0000)]
[Driver] Properly use values-X[ca].o, values-xpg[46].o on Solaris

Builtins-*-sunos :: compiler_rt_logbf_test.c currently FAILs on Solaris, both SPARC and
x86, 32 and 64-bit.

It turned out that this is due to different behaviour of logb depending on the C
standard compiled for, as documented on logb(3M):

  RETURN VALUES
         Upon successful completion, these functions return the exponent of x.

         If x is subnormal:

             o      For SUSv3-conforming applications compiled with the c99 com-
                    piler  driver  (see standards(7)), the exponent of x as if x
                    were normalized is returned.

             o      Otherwise, if compiled with the cc compiler  driver,  -1022,
                    -126,  and  -16382  are  returned  for  logb(), logbf(), and
                    logbl(), respectively.

Studio c99 and gcc control this by linking with the appropriate version of values-xpg[46].o, but clang uses neither of those.

The following patch fixes this by following what gcc does, as corrected some time ago in

  Fix use of Solaris values-Xc.o (PR target/40411)
  https://gcc.gnu.org/ml/gcc-patches/2018-01/msg02350.html and
  https://gcc.gnu.org/ml/gcc-patches/2018-01/msg02384.html.

Tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.

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

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

5 years agoMove LangStandard*, InputKind::Language to Basic
Rainer Orth [Mon, 5 Aug 2019 13:59:26 +0000 (13:59 +0000)]
Move LangStandard*, InputKind::Language to Basic

This patch is a prerequisite for using LangStandard from Driver in
https://reviews.llvm.org/D64793.

It moves LangStandard* and InputKind::Language to Basic.  It is mostly
mechanical, with only a few changes of note:

- enum Language has been changed into enum class Language : uint8_t to
  avoid a clash between OpenCL in enum Language and OpenCL in enum
  LangFeatures and not to increase the size of class InputKind.

- Now that getLangStandardForName, which is currently unused, also checks
  both canonical and alias names, I've introduced a helper getLangKind
  which factors out a code pattern already used 3 times.

The patch has been tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11,
and x86_64-pc-linux-gnu.

There's a companion patch for lldb which uses LangStandard.h
(https://reviews.llvm.org/D65717).

While polly includes isl which in turn uses InputKind::C, that part of the
code isn't even built inside the llvm tree.  I've posted a patch to allow
for both InputKind::C and Language::C upstream
(https://groups.google.com/forum/#!topic/isl-development/6oEvNWOSQFE).

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

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

5 years ago[clang][NFC] Remove unused private variable 'CI' in CrossTranslationUnit.h
Raphael Isemann [Mon, 5 Aug 2019 12:23:39 +0000 (12:23 +0000)]
[clang][NFC] Remove unused private variable 'CI' in CrossTranslationUnit.h

It seems because of the recent refactorings this variable has become unused
and now we get this warning in the build logs:

In file included from llvm/clang/lib/CrossTU/CrossTranslationUnit.cpp:12:
llvm/clang/include/clang/CrossTU/CrossTranslationUnit.h:200:21: warning: private field 'CI' is not used [-Wunused-private-field]
  CompilerInstance &CI;
                    ^

I'll remove them for now to get the builds back to green.

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

5 years ago[AST] Fix RecursiveASTVisitor visiting implicit constructor initializers.
Johan Vikstrom [Mon, 5 Aug 2019 12:20:43 +0000 (12:20 +0000)]
[AST] Fix RecursiveASTVisitor visiting implicit constructor initializers.

Summary: RecursiveASTVisitor was visiting implcit constructor initializers. This caused semantic highlighting in clangd to emit error logs. Fixes this by checking if the constructor is written or if the visitor should visit implicit decls.

Reviewers: hokein, ilya-biryukov

Subscribers: kadircet, cfe-commits

Tags: #clang

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

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

5 years ago[CrossTU][NFCI] Refactor loadExternalAST function
Endre Fulop [Mon, 5 Aug 2019 11:06:41 +0000 (11:06 +0000)]
[CrossTU][NFCI] Refactor loadExternalAST function

Summary:
Refactor loadExternalAST method of CrossTranslationUnitContext in order to
reduce maintenance burden and so that features are easier to add in the future.

Reviewers: martong

Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits

Tags: #clang

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

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

5 years agoSidestep false positive due to a matching git repository name
Roger Ferrer Ibanez [Mon, 5 Aug 2019 10:09:06 +0000 (10:09 +0000)]
Sidestep false positive due to a matching git repository name

I have failures in this test because the grep @b gets confused by the
clang version including a repository name like this

!1 = !{!"clang version 10.0.0 (git@build-machine:llvm/llvm-monorepo.git fe958c0e8c89ec663c8e551936778e2cbb460154)"}

I considered something like grep -w but my understanding of the manpages
was that that isn't super portable. So I think it is easier to make
clang not to output that metadata using -fno-ident.

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

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

5 years ago[OpenCL] Fix vector literal test broken in rL367675.
Anastasia Stulova [Mon, 5 Aug 2019 09:50:28 +0000 (09:50 +0000)]
[OpenCL] Fix vector literal test broken in rL367675.

Avoid checking alignment unnecessary that is not portable
among targets.

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

5 years agoAdds a warning when an inline Doxygen comment has no argument
Dmitri Gribenko [Mon, 5 Aug 2019 08:05:16 +0000 (08:05 +0000)]
Adds a warning when an inline Doxygen comment has no argument

Summary:
It warns for for comments like
/** \pre \em */

where \em has no argument

This warning is enabled with the -Wdocumentation option.

Reviewers: gribozavr, rsmith

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Patch by Mark de Wever.

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

5 years ago[Analyzer] Iterator Checkers - Fix for Crash on Iterator Differences
Adam Balogh [Mon, 5 Aug 2019 06:45:41 +0000 (06:45 +0000)]
[Analyzer] Iterator Checkers - Fix for Crash on Iterator Differences

Iterators differences were mistakenly handled as random decrements which
causes an assertion. This patch fixes this.

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

5 years agoRename F_{None,Text,Append} to OF_{None,Text,Append}. NFC
Fangrui Song [Mon, 5 Aug 2019 05:43:48 +0000 (05:43 +0000)]
Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC

F_{None,Text,Append} are kept for compatibility since r334221.

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

5 years ago[Driver] Don't disable -fsanitizer-coverage for safe-stack or shadow-call-stack
Petr Hosek [Mon, 5 Aug 2019 04:48:56 +0000 (04:48 +0000)]
[Driver] Don't disable -fsanitizer-coverage for safe-stack or shadow-call-stack

These "sanitizers" are hardened ABIs that are wholly orthogonal
to the SanitizerCoverage instrumentation.

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

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

5 years ago[Driver] Derive Fuchsia Linker directly from Tool
Petr Hosek [Mon, 5 Aug 2019 01:36:51 +0000 (01:36 +0000)]
[Driver] Derive Fuchsia Linker directly from Tool

Fuchsia Linker tool doesn't need any of the GnuTool behavior.

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

5 years ago[Driver] Always use -z separate-code with lld on Fuchsia
Petr Hosek [Mon, 5 Aug 2019 01:15:33 +0000 (01:15 +0000)]
[Driver] Always use -z separate-code with lld on Fuchsia

Previously -z separate-code was the default lld behavior, but now it
has to be explicitly requested by specifying the flag.

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

5 years ago[Driver] Support for disabling sanitizer runtime linking
Petr Hosek [Sun, 4 Aug 2019 22:24:14 +0000 (22:24 +0000)]
[Driver] Support for disabling sanitizer runtime linking

This change introduces a pair of -fsanitize-link-runtime and
-fno-sanitize-link-runtime flags which can be used to control linking of
sanitizer runtimes. This is useful in certain environments like kernels
where existing runtime libraries cannot be used.

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

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

5 years ago[Parser] Emit descriptive diagnostic for misplaced pragma
Serge Pavlov [Sun, 4 Aug 2019 10:08:51 +0000 (10:08 +0000)]
[Parser] Emit descriptive diagnostic for misplaced pragma

If a class or struct or union declaration contains a pragma that
is not valid in this context, compiler issues generic error like
"expected member name or ';' after declaration specifiers". With this
change the error tells that this pragma cannot appear in this declaration.

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

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

5 years agoRevert "[OpenMP 5.0] Codegen support for user-defined mappers."
Michael Kruse [Sun, 4 Aug 2019 05:16:52 +0000 (05:16 +0000)]
Revert "[OpenMP 5.0] Codegen support for user-defined mappers."

This reverts commit r367773. The test case
OpenMP/declare_mapper_codegen.cpp is failing.

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

5 years ago[OpenMP 5.0] Codegen support for user-defined mappers.
Michael Kruse [Sun, 4 Aug 2019 04:18:42 +0000 (04:18 +0000)]
[OpenMP 5.0] Codegen support for user-defined mappers.

This patch implements the code generation for OpenMP 5.0 declare mapper
(user-defined mapper) constructs. For each declare mapper, a mapper
function is generated. These mapper functions will be called by the
runtime and/or other mapper functions to achieve user defined mapping.

The design slides can be found at
https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx

Patch by Lingda Li <lildmh@gmail.com>

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

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

5 years agoUse switch instead of series of comparisons
Serge Pavlov [Sat, 3 Aug 2019 16:32:49 +0000 (16:32 +0000)]
Use switch instead of series of comparisons

This is style correction, no functional changes.

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

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

5 years agoIR: print value numbers for unnamed function arguments
Tim Northover [Sat, 3 Aug 2019 14:28:34 +0000 (14:28 +0000)]
IR: print value numbers for unnamed function arguments

For consistency with normal instructions and clarity when reading IR,
it's best to print the %0, %1, ... names of function arguments in
definitions.

Also modifies the parser to accept IR in that form for obvious reasons.

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

5 years agoThe MinGW linker supports response files
Reid Kleckner [Fri, 2 Aug 2019 22:55:00 +0000 (22:55 +0000)]
The MinGW linker supports response files

This affects both LLD and ld.bfd.

This isn't testable with a normal driver test with -### because those
command lines are printed before response file setup. I tested manually
and confirmed it seems to do the right thing.

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

5 years ago[BPF] annotate DIType metadata for builtin preseve_array_access_index()
Yonghong Song [Fri, 2 Aug 2019 21:28:28 +0000 (21:28 +0000)]
[BPF] annotate DIType metadata for builtin preseve_array_access_index()

Previously, debuginfo types are annotated to
IR builtin preserve_struct_access_index() and
preserve_union_access_index(), but not
preserve_array_access_index(). The debug info
is useful to identify the root type name which
later will be used for type comparison.

For user access without explicit type conversions,
the previous scheme works as we can ignore intermediate
compiler generated type conversions (e.g., from union types to
union members) and still generate correct access index string.

The issue comes with user explicit type conversions, e.g.,
converting an array to a structure like below:
  struct t { int a; char b[40]; };
  struct p { int c; int d; };
  struct t *var = ...;
  ... __builtin_preserve_access_index(&(((struct p *)&(var->b[0]))->d)) ...
Although BPF backend can derive the type of &(var->b[0]),
explicit type annotation make checking more consistent
and less error prone.

Another benefit is for multiple dimension array handling.
For example,
  struct p { int c; int d; } g[8][9][10];
  ... __builtin_preserve_access_index(&g[2][3][4].d) ...
It would be possible to calculate the number of "struct p"'s
before accessing its member "d" if array debug info is
available as it contains each dimension range.

This patch enables to annotate IR builtin preserve_array_access_index()
with proper debuginfo type. The unit test case and language reference
is updated as well.

Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D65664

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

5 years ago[Driver][test] Avoid undefined grep in darwin-ld.c
Hubert Tong [Fri, 2 Aug 2019 19:26:05 +0000 (19:26 +0000)]
[Driver][test] Avoid undefined grep in darwin-ld.c

Summary:
question-mark is not a BRE special character.

POSIX.1-2017 XBD Section 9.3.2 indicates that the interpretation of `\?`
as used by rC366282 is undefined. This patch uses an ERE instead.

Reviewers: rnk, daltenty, xingxue, jasonliu

Reviewed By: rnk

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoRemove a dead diagnostic, NFC
Erik Pilkington [Fri, 2 Aug 2019 19:25:58 +0000 (19:25 +0000)]
Remove a dead diagnostic, NFC

This was issued in Objective-C 1 mode, but we not longer support that, so this
is just unreachable.

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

5 years ago[Sema] Disable -Wbitwise-op-parentheses and -Wlogical-op-parentheses by default
Fangrui Song [Fri, 2 Aug 2019 16:31:38 +0000 (16:31 +0000)]
[Sema] Disable -Wbitwise-op-parentheses and -Wlogical-op-parentheses by default

Summary:
The -Wparentheses warnings are enabled by default in clang but they are under
-Wall in gcc (gcc/c-family/c.opt). Some of the operator precedence warnings are
oftentimes criticized as noise (clang: default; gcc: -Wall). If a warning is
very controversial, it is probably not a good idea to enable it by default.
This patch disables the rather annoying ones:

-Wbitwise-op-parentheses, e.g. i & i | i
-Wlogical-op-parentheses, e.g. i && i || i

After this change:

```
* = enabled by default

-Wall
  -Wparentheses
    -Wlogical-op-parentheses
    -Wlogical-not-parentheses*
    -Wbitwise-op-parentheses
    -Wshift-op-parentheses*
    -Woverloaded-shift-op-parentheses*
    -Wparentheses-equality*
    -Wdangling-else*
```

-Woverloaded-shift-op-parentheses is typically followed by overload
resolution failure. We can instead improve the error message, and
probably delete -Woverloaded-shift-op-parentheses in the future. Keep it
for now because it gives some diagnostics.

Reviewers: akyrtzi, jyknight, rtrieu, rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

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

5 years ago[OpenCL] Allow OpenCL C style vector initialization in C++
Anastasia Stulova [Fri, 2 Aug 2019 11:19:35 +0000 (11:19 +0000)]
[OpenCL] Allow OpenCL C style vector initialization in C++

Allow creating vector literals from other vectors.

 float4 a = (float4)(1.0f, 2.0f, 3.0f, 4.0f);
 float4 v = (float4)(a.s23, a.s01);

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

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

5 years agoDon't try emitting dllexported explicitly defaulted non-trivial ctors twice during...
Hans Wennborg [Fri, 2 Aug 2019 07:51:41 +0000 (07:51 +0000)]
Don't try emitting dllexported explicitly defaulted non-trivial ctors twice during explicit template instantiation definition (PR42857)

Trying to emit the definition twice triggers an assert.

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

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

5 years agoRevert r367649: Improve raw_ostream so that you can "write" colors using operator<<
Rui Ueyama [Fri, 2 Aug 2019 07:22:34 +0000 (07:22 +0000)]
Revert r367649: Improve raw_ostream so that you can "write" colors using operator<<

This reverts commit r367649 in an attempt to unbreak Windows bots.

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

5 years ago[PGO] Fix bolt failures from r367628
Rong Xu [Fri, 2 Aug 2019 07:21:50 +0000 (07:21 +0000)]
[PGO] Fix bolt failures from r367628

Relaxed the check in a test because the windows bolt generates different
profile variables.

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

5 years agoImprove raw_ostream so that you can "write" colors using operator<<
Rui Ueyama [Fri, 2 Aug 2019 04:48:30 +0000 (04:48 +0000)]
Improve raw_ostream so that you can "write" colors using operator<<

1. raw_ostream supports ANSI colors so that you can write messages to
the termina with colors. Previously, in order to change and reset
color, you had to call `changeColor` and `resetColor` functions,
respectively.

So, if you print out "error: " in red, for example, you had to do
something like this:

  OS.changeColor(raw_ostream::RED);
  OS << "error: ";
  OS.resetColor();

With this patch, you can write the same code as follows:

  OS << raw_ostream::RED << "error: " << raw_ostream::RESET;

2. Add a boolean flag to raw_ostream so that you can disable colored
output. If you disable colors, changeColor, operator<<(Color),
resetColor and other color-related functions have no effect.

Most LLVM tools automatically prints out messages using colors, and
you can disable it by passing a flag such as `--disable-colors`.
This new flag makes it easy to write code that works that way.

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

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

5 years ago[clang-format] Fix a bug that doesn't break braces before unions for Allman
Owen Pan [Fri, 2 Aug 2019 04:30:42 +0000 (04:30 +0000)]
[clang-format] Fix a bug that doesn't break braces before unions for Allman
Differential Revision: https://reviews.llvm.org/D65631

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

5 years ago[DirectoryWatcher] Relax assumption to prevent test flakiness
Jan Korous [Thu, 1 Aug 2019 23:24:30 +0000 (23:24 +0000)]
[DirectoryWatcher] Relax assumption to prevent test flakiness

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

5 years ago[PGO] Add PGO support at -O0 in the experimental new pass manager
Rong Xu [Thu, 1 Aug 2019 22:36:34 +0000 (22:36 +0000)]
[PGO] Add PGO support at -O0 in the experimental new pass manager

Add PGO support at -O0 in the experimental new pass manager to sync the
behavior of the legacy pass manager.

Also change the test of gcc-flag-compatibility.c for more complete test:
(1) change the match string to "profc" and "profd" to ensure the
    instrumentation is happening.
(2) add IR format proftext so that PGO use compilation is tested.

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

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

5 years agoFix Windows branch of FileManagerTest changes
Harlan Haskins [Thu, 1 Aug 2019 21:58:56 +0000 (21:58 +0000)]
Fix Windows branch of FileManagerTest changes

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

5 years agoFix use-after-move in ClangBasicTests
Harlan Haskins [Thu, 1 Aug 2019 21:50:16 +0000 (21:50 +0000)]
Fix use-after-move in ClangBasicTests

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

5 years ago[clang] Adopt new FileManager error-returning APIs
Harlan Haskins [Thu, 1 Aug 2019 21:31:56 +0000 (21:31 +0000)]
[clang] Adopt new FileManager error-returning APIs

Update the callers of FileManager::getFile and FileManager::getDirectory to handle the new llvm::ErrorOr-returning methods.

Signed-off-by: Harlan Haskins <harlan@apple.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367616 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] Adopt llvm::ErrorOr in FileManager methods
Harlan Haskins [Thu, 1 Aug 2019 21:31:49 +0000 (21:31 +0000)]
[clang] Adopt llvm::ErrorOr in FileManager methods

Previously, the FileManager would use NULL returns to signify whether a file existed, but that doesn’t cover permissions issues or anything else that might occur while trying to stat or read a file. Instead, convert getFile and getDirectory into returning llvm::ErrorOr

Signed-off-by: Harlan Haskins <harlan@apple.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367615 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenMP] Fix declare target link implementation
Gheorghe-Teodor Bercea [Thu, 1 Aug 2019 21:15:58 +0000 (21:15 +0000)]
[OpenMP] Fix declare target link implementation

Summary:
This patch fixes the case where variables in different compilation units or the same compilation unit are under the declare target link clause AND have the same name.
This also fixes the name clash error that occurs when unified memory is activated.
The changes in this patch include:
- Pointers to internal variables are given unique names.
- Externally visible variables are given the same name as before.
- All pointer variables (external or internal) are weakly linked.

Reviewers: ABataev, jdoerfert, caomhin

Reviewed By: ABataev

Subscribers: lebedev.ri, guansong, cfe-commits

Tags: #clang

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

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

5 years ago[analyzer] StackFrameContext: Add NodeBuilderContext::blockCount() to its profile
Csaba Dabis [Thu, 1 Aug 2019 20:41:13 +0000 (20:41 +0000)]
[analyzer] StackFrameContext: Add NodeBuilderContext::blockCount() to its profile

Summary:
It allows discriminating between stack frames of the same call that is
called multiple times in a loop.

Thanks to Artem Dergachev for the great idea!

Reviewed By: NoQ

Tags: #clang

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

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

5 years agoTest linux only for absolute paths in the -fuse-ld option
Yuanfang Chen [Thu, 1 Aug 2019 18:49:59 +0000 (18:49 +0000)]
Test linux only for absolute paths in the -fuse-ld option

Some target do not use this option and may emit a error message for
using it.

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

5 years ago[Parser] Use special definition for pragma annotations
Serge Pavlov [Thu, 1 Aug 2019 15:15:10 +0000 (15:15 +0000)]
[Parser] Use special definition for pragma annotations

Previously pragma annotation tokens were described as any other
annotations in TokenKinds.def. This change introduces special macro
PRAGMA_ANNOTATION for the pragma descriptions. It allows implementing
checks that deal with pragma annotations only.

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

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

5 years agoRename two clang tests from .cc to .cpp.
Nico Weber [Thu, 1 Aug 2019 15:06:57 +0000 (15:06 +0000)]
Rename two clang tests from .cc to .cpp.

clang/test/lit.cfg.py doesn't list .cc as test extension, so these
tests never ran.

Tweak one of the two tests to actually pass, now that it runs.
(The other one was already passing.)

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

5 years agoAdd support for openSUSE RISC-V triple
Sam Elliott [Thu, 1 Aug 2019 14:23:56 +0000 (14:23 +0000)]
Add support for openSUSE RISC-V triple

Reviewers: asb

Reviewed By: asb

Subscribers: lenary, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lebedev.ri, kito-cheng, shiva0217, rogfer01, dexonsmith, rkruppe, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Patch by Andreas Schwab (schwab)

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

5 years ago[RISCV] Add FreeBSD targets
Sam Elliott [Thu, 1 Aug 2019 13:14:30 +0000 (13:14 +0000)]
[RISCV] Add FreeBSD targets

Reviewers: asb

Reviewed By: asb

Subscribers: simoncook, s.egerton, lenary, psnobl, benna, mhorne, emaste, kito-cheng, shiva0217, rogfer01, rkruppe, cfe-commits

Tags: #clang

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

Patch by James Clarke (jrtc27)

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

5 years ago[Parser] Change parameter type from int to enum
Serge Pavlov [Thu, 1 Aug 2019 11:46:28 +0000 (11:46 +0000)]
[Parser] Change parameter type from int to enum

Some parser functions accept argument of type unsigned while it is
actually of type DeclSpec::TST. No functional changes.

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

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

5 years ago[Preprocessor] Always discard body of #define if we failed to parse it
Ilya Biryukov [Thu, 1 Aug 2019 09:10:37 +0000 (09:10 +0000)]
[Preprocessor] Always discard body of #define if we failed to parse it

Summary:
Preivously we would only discard it if we failed to parse parameter lists.
If we do not consume the body, parser sees tokens inside directive. In
turn, this leads to spurious diagnostics and a crash in TokenBuffer, see
the added tests.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoDelay emitting dllexport explicitly defaulted members until the class is fully parsed...
Hans Wennborg [Thu, 1 Aug 2019 08:01:09 +0000 (08:01 +0000)]
Delay emitting dllexport explicitly defaulted members until the class is fully parsed (PR40006)

This is similar to r245139, but that only addressed dllexported classes.
It was still possible to run into the same problem with dllexported
members in an otherwise normal class (see bug). This uses the same
strategy to fix: delay defining the method until the whole class has
been parsed.

(The easiest way to see the ordering problem is in
Parser::ParseCXXMemberSpecification(): it calls
ParseLexedMemberInitializers() *after* ActOnFinishCXXMemberDecls(),
which was trying to define the dllexport method. Now we delay it to
ActOnFinishCXXNonNestedClass() which is called after both of those.)

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

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