Commit Graph

79589 Commits

Author SHA1 Message Date
Reid Kleckner 7859fed6ea Mark clang-scan-deps test as requiring thread support
Otherwise the test calls a pure virtual method and crashes. Perhaps this
could be improved.

llvm-svn: 368354
2019-08-08 21:45:59 +00:00
Reid Kleckner 1d63b02f53 Fix up fd limit diagnosis code
Apparently Windows returns the "invalid argument" error code when the
path contains invalid characters such as '<'. The
test/Preprocessor/include-likely-typo.c test does this, so it was
failing after r368322.

Also, the diagnostic requires two arguments, so add the filename.

llvm-svn: 368348
2019-08-08 21:35:03 +00:00
Artem Dergachev 8b49e0fd39 [analyzer] Fix scan-build's plist output in plist-html mode.
r366941 accidentally made it delete all plist files
as soon as they're produced.

llvm-svn: 368338
2019-08-08 20:22:32 +00:00
Brian Cain 83df122039 [clang] add REQUIRES: linux to driver test case
The test case explicitly leverages linux, so should include it as
a test requirement.

llvm-svn: 368334
2019-08-08 20:12:54 +00:00
Brian Cain 37a1aa7eb7 [clang] add REQUIRES to driver test case
The test case explicitly leverages x86, so should include it as
a test requirement.

llvm-svn: 368332
2019-08-08 20:04:39 +00:00
Brian Cain 7b953b6455 [clang] Add no-warn support for Wa
llvm-svn: 368328
2019-08-08 19:19:20 +00:00
Brian Cain 6dbbd0f343 [llvm-mc] Add reportWarning() to MCContext
Adding reportWarning() to MCContext, so that it can be used from
the Hexagon assembler backend.

llvm-svn: 368327
2019-08-08 19:13:23 +00:00
Yitzhak Mandelbaum a3c3530958 [clang][NFC] Move matcher ignoringElidableConstructorCall's tests to appropriate file.
Summary:
`ignoringElidableConstructorCall` is a traversal matcher, but its tests are
grouped with narrowing-matcher tests. This revision moves them to the correct
file.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 368326
2019-08-08 18:55:42 +00:00
Hiroshi Yamauchi cb30590da1 Recommit Devirtualize destructor of final class.
Original patch commited as r364100, reverted as r364359, recommitted as r365509,
reverted as r365850.

llvm-svn: 368323
2019-08-08 18:00:49 +00:00
Nico Weber babdfdec90 clang: Diag running out of file handles while looking for files
clang would only print "file not found" when it's unable to find a
header file.  If the reason for that is a file handle leak, that's not a
very useful error message.  For errors that aren't in a small whitelist
("file not found", "file is directory"), print an error with the
strerror() output.

This changes behavior in corner cases: If clang was out of file handles
while looking in one -I dir but then suddenly wasn't when looking in the
next -I dir, and both directories contained a file with the desired
name, previously we'd silently return the file from the second
directory. For this reason, it's important to ignore "is a directory"
for this new diag: if a file foo/foo exists and -I -Ifoo are passed, an
include of "foo" should successfully open file "foo" in directory "foo/"
instead of complaining that "./foo" is a directory.

No test since we mostly hit this when there's a handle leak somewhere,
and currently there isn't one. I manually tested this with the repro
steps in comment 2 on the bug below.

Fixes PR42524.

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

llvm-svn: 368322
2019-08-08 17:58:32 +00:00
Yitzhak Mandelbaum 57f471f4ff [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

llvm-svn: 368319
2019-08-08 17:41:44 +00:00
Diogo N. Sampaio dd591977e0 [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

llvm-svn: 368301
2019-08-08 14:45:42 +00:00
Alexey Bataev 195ae90307 [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

llvm-svn: 368295
2019-08-08 13:42:45 +00:00
Diogo N. Sampaio 9427aa2d54 [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

llvm-svn: 368288
2019-08-08 12:50:36 +00:00
Krasimir Georgiev 9ab051bdda [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

llvm-svn: 368280
2019-08-08 11:56:18 +00:00
Shaurya Gupta 7137736e49 [Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCase
Reviewers: arphaman, sammccall

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

llvm-svn: 368267
2019-08-08 08:37:49 +00:00
Rui Ueyama 6fd13f0849 [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

llvm-svn: 368259
2019-08-08 07:04:01 +00:00
Fangrui Song 2a0ae1c2e4 [Driver] Delete XFAIL: windows-msvc after D65880/r368245
`-target %itanium_abi_triple` fixed the problem.

llvm-svn: 368251
2019-08-08 04:56:21 +00:00
Fangrui Song 7dbdc8de18 [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

llvm-svn: 368245
2019-08-08 01:55:27 +00:00
Richard Trieu 07e6798baf Inline diagnostic text into .td file. NFC.
llvm-svn: 368244
2019-08-08 01:45:31 +00:00
Richard Trieu 155b8d02c3 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

llvm-svn: 368237
2019-08-08 00:12:51 +00:00
Bill Wendling 85f07cbb54 Add target requirements for those bots which don't handle x86.
llvm-svn: 368202
2019-08-07 19:36:48 +00:00
Diego Astiazaran ba55970c15 [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

llvm-svn: 368196
2019-08-07 18:35:28 +00:00
Yitzhak Mandelbaum fb991596e3 [clang][NFC] Fix typo in matcher comment
Also updates corresponding html doc.

llvm-svn: 368188
2019-08-07 17:01:31 +00:00
Benjamin Kramer 762bc3351f Remove LLVM mutexes from clang in favor of std::mutex
None of those need to be recursive mutexes. No functionality change
intended.

llvm-svn: 368173
2019-08-07 14:44:40 +00:00
Alexey Bataev a06155ddc4 [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.

llvm-svn: 368172
2019-08-07 14:39:17 +00:00
Alexey Bataev 2e3a07fcb8 [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.

llvm-svn: 368170
2019-08-07 14:02:11 +00:00
Balazs Keri e9719f9e9e [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

llvm-svn: 368163
2019-08-07 12:40:17 +00:00
Benjamin Kramer e57b60f321 Replace non-recursive sys::Mutex users with std::mutex
Also remove a use of sys::MutexImpl, that's just evil. No functionality
change intended.

llvm-svn: 368157
2019-08-07 11:59:44 +00:00
Anton Bikineev 45f721ff05 [clang] Fix mismatched args constructing AddressSpaceAttr.
Differential Revision: https://reviews.llvm.org/D65589

llvm-svn: 368152
2019-08-07 11:12:43 +00:00
Benjamin Kramer 3d5360a439 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.

llvm-svn: 368149
2019-08-07 10:57:25 +00:00
Matthias Gehre 23092ca9ba 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

llvm-svn: 368147
2019-08-07 10:45:36 +00:00
Dmitri Gribenko 8840cd3141 Remove inclusion of a private gmock header from a test
llvm-svn: 368132
2019-08-07 08:16:29 +00:00
Rui Ueyama cac8df1ab9 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.

llvm-svn: 368131
2019-08-07 08:08:17 +00:00
Roger Ferrer Ibanez 371bdc9b7f [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

llvm-svn: 368128
2019-08-07 07:08:00 +00:00
Puyan Lotfi 1dcf216f9f [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

llvm-svn: 368108
2019-08-06 23:25:34 +00:00
Bill Wendling ce29291fc3 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

llvm-svn: 368104
2019-08-06 22:41:22 +00:00
Peter Collingbourne 0930643ff6 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

llvm-svn: 368102
2019-08-06 22:07:29 +00:00
Guanzhong Chen b3292a8469 [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

llvm-svn: 368101
2019-08-06 21:52:58 +00:00
Alex Lorenz d27a5086a8 fix clang-scan-deps test to match filepaths on Windows
llvm-svn: 368092
2019-08-06 21:45:43 +00:00
Alex Lorenz e1f4c4aad2 [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

llvm-svn: 368086
2019-08-06 20:43:25 +00:00
Gabor Horvath e5e10b526f 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

llvm-svn: 368072
2019-08-06 19:13:29 +00:00
Ilya Biryukov bfbf6b6cab [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

llvm-svn: 368062
2019-08-06 17:07:58 +00:00
Ilya Biryukov 4b03364d72 [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

llvm-svn: 368052
2019-08-06 15:46:12 +00:00
Mike Spertus 49068a054b Improve MSVC visualizations so the parser shows where we are in the code
Also provide a visualizer for lambda introducers

llvm-svn: 368029
2019-08-06 13:29:35 +00:00
Balazs Keri 4e79097dc7 [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

llvm-svn: 368020
2019-08-06 12:10:16 +00:00
Gabor Marton f89c8f20e1 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

llvm-svn: 368009
2019-08-06 09:52:21 +00:00
Shoaib Meenai fe08528c8e [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.

llvm-svn: 367984
2019-08-06 07:13:53 +00:00
Shoaib Meenai b50e8c5927 [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

llvm-svn: 367982
2019-08-06 06:48:43 +00:00
Fangrui Song c37022b22a [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

llvm-svn: 367981
2019-08-06 06:25:32 +00:00