Commit Graph

37943 Commits

Author SHA1 Message Date
Artem Dergachev ead98ea3eb [CFG] Make representation of destructor calls more accurate.
Respect C++17 copy elision; previously it would generate destructor calls
for elided temporaries, including in initialization and return statements.

Don't generate duplicate destructor calls for statement expressions.

Fix destructors in initialization lists and comma operators.

Improve printing of implicit destructors.

Patch by Nicholas Allegra!

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

llvm-svn: 370247
2019-08-28 18:44:42 +00:00
Artem Dergachev 630f7daf80 [analyzer] Fix analyzer warnings on analyzer.
Write tests for the actual crash that was found. Write comments and refactor
code around 17 style bugs and suppress 3 false positives.

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

llvm-svn: 370246
2019-08-28 18:44:38 +00:00
Artem Dergachev 0909a392f3 [analyzer] pr43036: Fix support for operator 'sizeof...'.
It was known to be a compile-time constant so it wasn't evaluated during
symbolic execution, but it wasn't evaluated as a compile-time constant either.

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

llvm-svn: 370245
2019-08-28 18:44:35 +00:00
Artem Dergachev 8b2a39e937 [analyzer] Trust global initializers when analyzing main().
If the global variable has an initializer, we'll ignore it because we're usually
not analyzing the program from the beginning, which means that the global
variable may have changed before we start our analysis.

However when we're analyzing main() as the top-level function, we can rely
on global initializers to still be valid. At least in C; in C++ we have global
constructors that can still break this logic.

This patch allows the Static Analyzer to load constant initializers from
global variables if the top-level function of the current analysis is main().

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

llvm-svn: 370244
2019-08-28 18:44:32 +00:00
Alexandre Ganea 3c307370c8 Try fixing CRLF issues in Git with [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings
Differential Revision: https://reviews.llvm.org/D66556

llvm-svn: 370219
2019-08-28 15:14:37 +00:00
Alexey Bataev 94a170f811 [OPENMP][Analysis] Add analysis of the map clauses.
Summary:
Added basic analysis of map clauses. Only map clauses with to and tofrom
map type must be analyzed since all other map types (alloc, delete, etc.) do not require to use the value of the initial variable, instead they create the new copy of the variable.

Reviewers: NoQ

Subscribers: guansong, cfe-commits, kkwli0, caomhin

Tags: #clang

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

llvm-svn: 370214
2019-08-28 14:55:08 +00:00
Hans Wennborg 248abe2b66 Delete minimize_source_to_dependency_directives_invalid_error.c
It was added in r370129 with a .gitattributes file that means the file
always shows up as having a local diff in Git checkouts (at least on
Linux). Deleting it until we can figure out the right way to do this.

llvm-svn: 370175
2019-08-28 09:14:00 +00:00
Sergey Dmitriev 60a99f4964 [Clang][Bundler] Do not require host triple for extracting device bundles
Bundler currently requires host triple to be provided no matter if you are performing bundling or unbundling, but for unbundling operation such requirement is too restrictive. You may for example want to examine device part of the object for a particular offload target, but you have to extract host part as well even though you do not need it. Host triple isn't really needed for unbundling, so this patch removes that requirement.

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

llvm-svn: 370143
2019-08-28 01:26:13 +00:00
Vlad Tsyrklevich 57076d3199 Revert "Change the X86 datalayout to add three address spaces for 32 bit signed,"
This reverts commit r370083 because it caused check-lld failures on
sanitizer-x86_64-linux-fast.

llvm-svn: 370142
2019-08-28 01:08:54 +00:00
Volodymyr Sapsai 73152a2ec2 [ObjC] Fix type checking for qualified id block parameters.
When checking if block types are compatible, we are checking for
compatibility their return types and parameters' types. As these types
have different variance, we need to check them in different order.

rdar://problem/52788423

Reviewers: erik.pilkington, arphaman

Reviewed By: arphaman

Subscribers: jkorous, dexonsmith, ributzka, cfe-commits

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

llvm-svn: 370130
2019-08-28 00:25:06 +00:00
Alexandre Ganea 57b4e107e4 Re-land [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings
Previously, an #error directive with quoted, multi-line content, along with CR+LF line endings wasn't handled correctly.

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

llvm-svn: 370129
2019-08-28 00:04:06 +00:00
Evgeny Mankov 2ed2e62498 [preprocessor] Add an opportunity to retain excluded conditional blocks
It is handy for clang tooling, for instance, in source to source transformation.

Reviewers: vpykhtin (Valery Pykhtin), erichkeane (Erich Keane)

Subscribers: rsmith (Richard Smith), akyrtzi (Argyrios Kyrtzidis)

Tags: #clang

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

llvm-svn: 370123
2019-08-27 22:15:32 +00:00
Sergey Dmitriev 4368971b05 [Clang][Bundler] Fix for a hang when unbundling fat binary
clang-offload-bundler tool may hang under certain conditions when it extracts a subset of all available device bundles from the fat binary that is handled by the BinaryFileHandler. This patch fixes this problem.

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

llvm-svn: 370115
2019-08-27 21:47:52 +00:00
Aaron Ballman 27e66bf710 Diagnose _Bool as a C99 extension.
llvm-svn: 370108
2019-08-27 20:33:05 +00:00
Shafik Yaghmour 528f5da6d8 Debug Info: Support for DW_AT_export_symbols for anonymous structs
This implements the DWARF 5 feature described in:

http://dwarfstd.org/ShowIssue.php?issue=141212.1

To support recognizing anonymous structs:

  struct A {
    struct { // Anonymous struct
        int y;
    };
  } a;

This patch adds support in CGDebugInfo::CreateLimitedType(...) for this new flag and an accompanying test to verify this feature.

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

llvm-svn: 370107
2019-08-27 20:17:35 +00:00
Matt Arsenault eac783a900 AMDGPU: Always emit amdgpu-flat-work-group-size
The backend default maximum should be the hardware maximum, so the
frontend should set the implementation defined default maximum.

llvm-svn: 370101
2019-08-27 19:25:40 +00:00
Aaron Ballman 9fac4a5d35 Diagnose both _Complex and _Imaginary as C99 extensions.
llvm-svn: 370100
2019-08-27 19:15:24 +00:00
Alex Lorenz 3737c0239a [driver][xray] fix the macOS support checker by supporting -macos
triple in addition to -darwin

The previous check incorrectly checked for macOS support by
allowing -darwin triples only, and -macos triple was not supported.

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

llvm-svn: 370093
2019-08-27 18:26:36 +00:00
Reid Kleckner 39aa8954a4 Move EH spec mismatches under -fms-compatibility
-fms-extensions is intended to enable conforming language extensions and
-fms-compatibility is intended to language rule relaxations, so a user
could plausibly compile with -fno-ms-compatibility on Windows while
still using dllexport, for example.  This exception specification
validation behavior has been handled as a warning since before
-fms-compatibility was added in 2011. I think it's just an oversight
that it hasn't been moved yet.

This will help users find conformance issues in their code such as those
found in _com_ptr_t as described in https://llvm.org/PR42842.

Reviewers: hans

Subscribers: STL_MSFT, cfe-commits

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

llvm-svn: 370087
2019-08-27 17:52:03 +00:00
Amy Huang 1299945b81 Change the X86 datalayout to add three address spaces for 32 bit signed,
32 bit unsigned, and 64 bit pointers.

llvm-svn: 370083
2019-08-27 17:46:53 +00:00
Sam Elliott f260630e8f [RISCV] Set MaxAtomicInlineWidth and MaxAtomicPromoteWidth for RV32/RV64 targets with atomics
Summary: This ensures that libcalls aren't generated when the target supports atomics. Atomics aren't in the base RV32I/RV64I instruction sets, so MaxAtomicInlineWidth and MaxAtomicPromoteWidth are set only when the atomics extension is being targeted. This must be done in setMaxAtomicWidth, as this should be done after handleTargetFeatures has been called.

Reviewers: jfb, jyknight, wmi, asb

Reviewed By: asb

Subscribers: pzheng, MaskRay, s.egerton, lenary, dexonsmith, psnobl, benna, Jim, JohnLLVM, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, lewis-revill, cfe-commits

Tags: #clang

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

llvm-svn: 370073
2019-08-27 15:41:16 +00:00
Joe Ranieri fce4324f92 Update the SARIF exporter to SARIF 2.1
This updates the SARIF exporter to produce SARIF 2.1 output. The bulk of the diffs come from two changes to SARIF:
* https://github.com/oasis-tcs/sarif-spec/issues/309
* https://github.com/oasis-tcs/sarif-spec/issues/179

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

llvm-svn: 370068
2019-08-27 14:43:54 +00:00
Aaron Ballman 1d93522056 Replace some custom C11 extension warnings with the generic warning.
llvm-svn: 370066
2019-08-27 14:41:39 +00:00
Joe Ranieri 3385c5cc4d Fix a SARIF exporter crash with macro expansions
Differential Revision: https://reviews.llvm.org/D65209

llvm-svn: 370061
2019-08-27 14:20:27 +00:00
Joe Ranieri 68a6a28ef8 Fix text range end columns in SARIF to be exclusive
According to the SARIF specification, "a text region does not include the character specified by endColumn".

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

llvm-svn: 370060
2019-08-27 13:49:45 +00:00
Aaron Ballman 99178faf59 Quote the token being diagnosed for C11 extensions.
llvm-svn: 370059
2019-08-27 13:47:51 +00:00
Aaron Ballman 21b1896664 Speculatively fix the build bots after r370052.
llvm-svn: 370058
2019-08-27 13:45:42 +00:00
Aaron Ballman 0299dbd2ae Implement codegen for MSVC unions with reference members.
Currently, clang accepts a union with a reference member when given the -fms-extensions flag. This change fixes the codegen for this case.

Patch by Dominic Ferreira.

llvm-svn: 370052
2019-08-27 12:42:45 +00:00
Gabor Marton f035b75d8f [ASTImporter] Fix name conflict handling with different strategies
There are numorous flaws about the name conflict handling, this patch
attempts fixes them. Changes in details:

* HandleNameConflict return with a false DeclarationName

Hitherto we effectively never returned with a NameConflict error, even
if the preceding StructuralMatch indicated a conflict.
Because we just simply returned with the parameter `Name` in
HandleNameConflict and that name is almost always `true` when converted to
`bool`.

* Add tests which indicate wrong NameConflict handling

* Add to ConflictingDecls only if decl kind is different

Note, we might not indicate an ODR error when there is an existing record decl
and a enum is imported with same name.  But there are other cases. E.g. think
about the case when we import a FunctionTemplateDecl with name f and we found a
simple FunctionDecl with name f. They overload.  Or in case of a
ClassTemplateDecl and CXXRecordDecl, the CXXRecordDecl could be the 'templated'
class, so it would be false to report error.  So I think we should report a
name conflict error only when we are 100% sure of that.  That is why I think it
should be a general pattern to report the error only if the kind is the same.

* Fix failing ctu test with EnumConstandDecl

In ctu-main.c we have the enum class 'A' which brings in the enum
constant 'x' with value 0 into the global namespace.
In ctu-other.c we had the enum class 'B' which brought in the same name
('x') as an enum constant but with a different enum value (42). This is clearly
an ODR violation in the global namespace. The solution was to rename the
second enum constant.

 * Introduce ODR handling strategies

Reviewers: a_sidorin, shafik

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

llvm-svn: 370045
2019-08-27 11:36:10 +00:00
Richard Smith f3f00b2e5e Revert "[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings"
This reverts commit r369986.

This change added a dependency on the 'dos2unix' tool, which is not one
of our accepted test dependencies and may not exist on all machines that
build Clang.

llvm-svn: 370000
2019-08-27 01:06:23 +00:00
Alexandre Ganea e6561e0068 [clang-scan-deps] Skip UTF-8 BOM in source minimizer
Differential Revision: https://reviews.llvm.org/D66511

llvm-svn: 369993
2019-08-27 00:13:52 +00:00
Vitaly Buka a8e8dd91f0 NFC: Make test work with or without assertions
llvm-svn: 369992
2019-08-27 00:11:33 +00:00
Alexandre Ganea 6137cecf87 [clang-scan-deps] Minimizer: Correctly skip over double slashes in angle bracket #include
Previously, double slashes (//) occurring in angle brackets #include were incorrectly interpreted as comments. eg. #include <dir//file.h>

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

llvm-svn: 369988
2019-08-26 23:28:05 +00:00
Alexandre Ganea 2abca4f06c [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings
Previously, an #error directive with quoted, multi-line content, along with CR+LF line endings wasn't handled correctly.

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

llvm-svn: 369986
2019-08-26 23:19:21 +00:00
Richard Smith b26bc34e3a PR42587: diagnose unexpanded uses of a pack parameter of a generic
lambda from within the lambda-declarator.

Instead of trying to reconstruct whether a parameter pack was declared
inside a lambda (which we can't do correctly in general because we might
not have attached parameters to their declaration contexts yet), track
the set of parameter packs introduced in each live lambda scope, and
require only those parameters to be immediately expanded when they
appear inside that lambda.

In passing, fix incorrect disambiguation of a lambda-expression starting
with an init-capture pack in a braced-init-list. We previously
incorrectly parsed that as a designated initializer.

llvm-svn: 369985
2019-08-26 22:51:28 +00:00
Vitaly Buka 669d111c52 hwasan, codegen: Keep more lifetime markers used for hwasan
Reviewers: eugenis

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 369980
2019-08-26 22:16:05 +00:00
Vitaly Buka aeca56964f msan, codegen, instcombine: Keep more lifetime markers used for msan
Reviewers: eugenis

Subscribers: hiraditya, cfe-commits, #sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

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

llvm-svn: 369979
2019-08-26 22:15:50 +00:00
Vitaly Buka ba3d40a145 Revert r369843 "[Testing] Unbreak r369830"
That was not the fix.

This reverts commit 8bcf690ae03db85608b2ea22eac7a91c84df4dc.

llvm-svn: 369971
2019-08-26 21:29:06 +00:00
Aaron Ballman 72797ba072 Updating a test case that was missed in r369957.
llvm-svn: 369968
2019-08-26 20:55:43 +00:00
Vedant Kumar 91968d4008 [DebugInfo] Add debug-entry-values test coverage, NFC
Check that call site descriptions are emitted in dwarf4 + lldb +
debug-entry-values mode.

llvm-svn: 369964
2019-08-26 20:50:54 +00:00
Aaron Ballman 3c5bd65154 Fixing a weird copy-pasta to get bots back to green.
llvm-svn: 369960
2019-08-26 20:46:20 +00:00
Aaron Ballman 33d563e59e Reword the C11 extension diagnostic.
This makes it more consistent with other language extension diagnostics.

llvm-svn: 369957
2019-08-26 20:29:08 +00:00
Alex Lorenz 29f10822a7 Fix gen-cdb-fragment test for Windows
Windows bots didn't seem to like the empty argument, so I rewrote the test.

llvm-svn: 369956
2019-08-26 20:02:40 +00:00
Sergey Dmitriev ed153ef044 [Clang][Bundler] Use llvm-objcopy for creating fat object files
clang-offload-bundler currently uses partial linking for creating fat object files, but such technique cannot be used on Windows due to the absence of partial linking support in the linker. This patch changes implementation to use llvm-objcopy for merging device and host objects instead of doing partial linking. This is one step forward towards enabling OpenMP offload on Windows.

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

llvm-svn: 369955
2019-08-26 19:48:43 +00:00
Aaron Ballman 774bd6ef1c Diagnose use of _Thread_local as an extension when not in C11 mode.
llvm-svn: 369954
2019-08-26 19:44:07 +00:00
Alexey Bataev 2cd7fafc11 [OPENMP][NVPTX]Fix critical region codegen.
Summary:
Previously critical regions were emitted with the barrier making it a
worksharing construct though it is not. Also, it leads to incorrect
behavior in Cuda9+. Patch fixes this problem.

Reviewers: ABataev, jdoerfert

Subscribers: jholewinski, guansong, cfe-commits, grokos

Tags: #clang

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

llvm-svn: 369946
2019-08-26 19:07:48 +00:00
Richard Smith 26a92d5852 Improve behavior in the case of stack exhaustion.
Summary:
Clang performs various recursive operations (such as template instantiation),
and may use non-trivial amounts of stack space in each recursive step (for
instance, due to recursive AST walks). While we try to keep the stack space
used by such steps to a minimum and we have explicit limits on the number of
such steps we perform, it's impractical to guarantee that we won't blow out the
stack on deeply recursive template instantiations on complex ASTs, even with
only a moderately high instantiation depth limit.

The user experience in these cases is generally terrible: we crash with
no hint of what went wrong. Under this patch, we attempt to do better:

 * Detect when the stack is nearly exhausted, and produce a warning with a
   nice template instantiation backtrace, telling the user that we might
   run slowly or crash.

 * For cases where we're forced to trigger recursive template
   instantiation in arbitrarily-deeply-nested contexts, check whether
   we're nearly out of stack space and allocate a new stack (by spawning
   a new thread) after producing the warning.

Reviewers: rnk, aaron.ballman

Subscribers: mgorny, cfe-commits

Tags: #clang

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

llvm-svn: 369940
2019-08-26 18:18:07 +00:00
Alex Lorenz 8679ef4e46 [driver] add a new option `-gen-cdb-fragment-path` to emit
a fragment of a compilation database for each compilation

This patch adds a new option called -gen-cdb-fragment-path to the driver,
which can be used to specify a directory path to which clang can emit a fragment
of a CDB for each compilation it needs to invoke.

This option emits the same CDB contents as -MJ, and will be ignored if -MJ is specified.

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

llvm-svn: 369938
2019-08-26 17:59:41 +00:00
Dmitri Gribenko c955e4a910 [Wdocumentation] improve wording of a warning message
Based on @davezarzycki remarks in D64696 improved the wording of the warning
message.

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

Patch by Mark de Wever.

llvm-svn: 369873
2019-08-25 18:20:18 +00:00
David Zarzycki 98bcf690ae [Testing] Unbreak r369830
llvm-svn: 369843
2019-08-24 08:12:51 +00:00