Commit Graph

57328 Commits

Author SHA1 Message Date
Francis Visoiu Mistrih 4e799ada58 [CodeGen] Attach no-builtin attributes to function definitions with no Decl
When using -fno-builtin[-<name>], we don't attach the IR attributes to
function definitions with no Decl, like the ones created through
`CreateGlobalInitOrDestructFunction`.

This results in projects using -fno-builtin or -ffreestanding to start
seeing symbols like _memset_pattern16.

The fix changes the behavior to always add the attribute if LangOptions
requests it.

Differential Revision: https://reviews.llvm.org/D73495
2020-01-28 13:59:08 -08:00
Hans Wennborg eaabaf7e04 Revert "[MS] Overhaul how clang passes overaligned args on x86_32"
It broke some Chromium tests, so let's revert until it can be fixed; see
https://crbug.com/1046362

This reverts commit 2af74e27ed.
2020-01-28 22:25:07 +01:00
Artem Belevich 12fefeef20 [CUDA] Assume the latest known CUDA version if we've found an unknown one.
This makes clang somewhat forward-compatible with new CUDA releases
without having to patch it for every minor release without adding
any new function.

If an unknown version is found, clang issues a warning (can be disabled
with -Wno-cuda-unknown-version) and assumes that it has detected
the latest known version. CUDA releases are usually supersets
of older ones feature-wise, so it should be sufficient to keep
released clang versions working with minor CUDA updates without
having to upgrade clang, too.

Differential Revision: https://reviews.llvm.org/D73231
2020-01-28 10:11:42 -08:00
Aaron Ballman 5547919280 Fix a crash when casting _Complex and ignoring the results.
Performing a cast where the result is ignored caused Clang to crash when
performing codegen for the conversion:

  _Complex int a;
  void fn1() { (_Complex double) a; }

This patch addresses the crash by not trying to emit the scalar conversions,
causing it to be a noop. Fixes PR44624.
2020-01-28 13:05:56 -05:00
Konstantin Pyzhov 6d614a82a4 Summary:
This CL adds clang declarations of built-in functions for AMDGPU MFMA intrinsics and instructions.
OpenCL tests for new built-ins are included.

Differential Revision: https://reviews.llvm.org/D72723
2020-01-28 03:51:27 -05:00
Alexey Bataev f117f2cc78 [OPENMP50]Check for lastprivate conditional updates in atomic
constructs.

Added analysis in atomic constrcuts to support checks for updates of
conditional lastprivate variables.
2020-01-28 11:40:31 -05:00
Yaxun (Sam) Liu b7e415f37f [HIP] Fix environment variable HIP_DEVICE_LIB_PATH
Currently device lib path set by environment variable HIP_DEVICE_LIB_PATH
does not work due to extra "-L" added to each entry.

This patch fixes that by allowing argument name to be empty in addDirectoryList.

Differential Revision: https://reviews.llvm.org/D73299
2020-01-28 11:27:01 -05:00
Jonathan Roelofs 39fe440246 [clang] Fix EOL whitespace. NFC 2020-01-28 08:47:37 -07:00
Kadir Cetinkaya 42e9478e0b
[clang][CodeComplete] Support for designated initializers
Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73271
2020-01-28 16:34:15 +01:00
Jonathan Coe 9d212e83e9 [clang-format] Handle quotes and escaped braces in C# interpolated strings
Summary:
This addresses issues raised in https://bugs.llvm.org/show_bug.cgi?id=44454.

There are outstanding issues with multi-line verbatim strings in C# that will be addressed in a follow-up PR.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir, MyDeveloperDay

Subscribers: MyDeveloperDay

Tags: #clang-format

Differential Revision: https://reviews.llvm.org/D73492
2020-01-28 14:46:27 +00:00
Nico Weber e916c8dfe4 Revert "[Clang] Warn about 'z' printf modifier in old MSVC."
This reverts commit fe0d1b6a8a.
Makes Analysis/taint-generic.c fail on some Windows systems.
2020-01-28 09:27:54 -05:00
Nico Weber aaae6b1b61 Revert "PR44684: Look through parens and similar constructs when determining"
This reverts commit af80b8ccc5.
It broke clang-tidy/checkers/modernize-use-uncaught-exceptions.cpp in
check-clang-tools on macOS and Windows, see e.g.
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/13976/steps/stage%201%20check/logs/stdio
2020-01-28 09:03:27 -05:00
Nathan aec6210367 [ASTMatchers] Add cxxNoexceptExpr AST matcher
Summary: Adds a cxxNoexceptExpr matcher that matches the [[ https://en.cppreference.com/w/cpp/language/noexcept |  noexcept operator ]].

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73439
2020-01-28 13:12:28 +00:00
Wang, Pengfei 3239b5034e [FPEnv] Add pragma FP_CONTRACT support under strict FP.
Summary: Support pragma FP_CONTRACT under strict FP.

Reviewers: craig.topper, andrew.w.kaylor, uweigand, RKSimon, LiuChen3

Subscribers: hiraditya, jdoerfert, cfe-commits, llvm-commits, LuoYuanke

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D72820
2020-01-28 20:43:43 +08:00
Simon Tatham fe0d1b6a8a [Clang] Warn about 'z' printf modifier in old MSVC.
Summary:
The 'z' length modifier, signalling that an integer format specifier
takes a `size_t` sized integer, is only supported by the C library of
MSVC 2015 and later. Earlier versions don't recognize the 'z' at all,
and respond to `printf("%zu", x)` by just printing "zu".

So, if the MS compatibility version is set to a value earlier than
MSVC2015, it's useful to warn about 'z' modifiers in printf format
strings we check.

Reviewers: aaron.ballman, lebedev.ri, rnk, majnemer, zturner

Reviewed By: aaron.ballman

Subscribers: amccarth, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73457
2020-01-28 09:04:45 +00:00
Roland McGrath f4261e1121 [Clang] Enable -fsanitize=leak on Fuchsia targets
This required some fixes to the generic code for two issues:

1. -fsanitize=safe-stack is default on x86_64-fuchsia and is *not* incompatible with -fsanitize=leak on Fuchisa
2. -fsanitize=leak and other static-only runtimes must not be omitted under -shared-libsan (which is the default on Fuchsia)

Patch By: mcgrathr

Differential Revision: https://reviews.llvm.org/D73397
2020-01-27 23:37:51 -08:00
Nico Weber 49532137d0 Make AST reading work better with LLVM_APPEND_VC_REV=NO
With LLVM_APPEND_VC_REV=NO, Modules/merge-lifetime-extended-temporary.cpp
would fail if it ran before a0f50d7316 (which changed
the serialization format) and then after, for these reasons:

1. With LLVM_APPEND_VC_REV=NO, the module hash before and after the
   change was the same.

2. Modules/merge-lifetime-extended-temporary.cpp is the only test
   we have that uses -fmodule-cache-path=%t that
   a) actually writes to the cache path
   b) doesn't do `rm -rf %t` at the top of the test

So the old run would write a module file, and then the new run would
try to load it, but the serialized format changed.

Do several things to fix this:

1. Include clang::serialization::VERSION_MAJOR/VERSION_MINOR in
   the module hash, so that when the AST format changes (...and
   we remember to bump these), we use a different module cache dir.
2. Bump VERSION_MAJOR, since a0f50d7316 changed the
   on-disk format in a way that a gch file written before that change
   can't be read after that change.
3. Add `rm -rf %t` to all tests that pass -fmodule-cache-path=%t.
   This is unnecessary from a correctness PoV after 1 and 2,
   but makes it so that we don't amass many cache dirs over time.
   (Arguably, it also makes it so that the test suite doesn't catch
   when we change the serialization format but don't bump
   clang::serialization::VERSION_MAJOR/VERSION_MINOR; oh well.)

Differential Revision: https://reviews.llvm.org/D73202
2020-01-27 22:08:37 -05:00
Richard Smith af80b8ccc5 PR44684: Look through parens and similar constructs when determining
whether a call is to a builtin.

We already had a general mechanism to do this but for some reason
weren't using it. In passing, check for the other unary operators that
can intervene in a reasonably-direct function call (we already handled
'&' but missed '*' and '+').
2020-01-27 18:20:57 -08:00
Gabor Horvath f4c26d993b [analyzer] Add FuchsiaLockChecker and C11LockChecker
These are mostly trivial additions as both of them are reusing existing
PThreadLockChecker logic. I only needed to add the list of functions to
check and do some plumbing to make sure that we display the right
checker name in the diagnostic.

Differential Revision: https://reviews.llvm.org/D73376
2020-01-27 13:55:56 -08:00
Alexey Bataev e6d2583e45 [OPENMP50]Track changes of lastprivate conditional in parallel-based
regions with reductions, lastprivates or linears clauses.

If the lastprivate conditional variable is updated in inner parallel
region with reduction, lastprivate or linear clause, the value must be
considred as a candidate for lastprivate conditional. Also, tracking in
inner parallel regions is not required.
2020-01-27 14:53:25 -05:00
Jinsong Ji 2d0b29e0de [clang] Fix covered default in switch
clang/lib/Format/TokenAnnotator.cpp:3162:7:
error: default label in switch which covers all enumeration values
[-Werror,-Wcovered-switch-default]
      default:
      ^
1 error generated.
2020-01-27 19:28:11 +00:00
Mikhail Gadelha 88c7b16420 [analyzer] Simplify BoolAssignmentChecker
Summary:
Instead of checking the range manually, changed the checker to use assumeInclusiveRangeDual instead.

This patch was part of D28955.

Reviewers: NoQ

Reviewed By: NoQ

Subscribers: ddcc, xazax.hun, baloghadamsoftware, szepet, a.sidorin, Szelethus, donat.nagy, dkrupp, Charusso, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73062
2020-01-27 14:51:35 -04:00
Gabor Horvath c98d98ba9b [analyzer] Fix handle leak false positive when the handle dies too early
Differential Revision: https://reviews.llvm.org/D73151
2020-01-27 09:52:06 -08:00
Teresa Johnson 2f63d549f1 Restore "[LTO/WPD] Enable aggressive WPD under LTO option"
This restores 59733525d3 (D71913), along
with bot fix 19c76989bb.

The bot failure should be fixed by D73418, committed as
af954e441a.

I also added a fix for non-x86 bot failures by requiring x86 in new test
lld/test/ELF/lto/devirt_vcall_vis_public.ll.
2020-01-27 07:55:05 -08:00
Martin Probst 02656f29ab clang-format: [JS] options for arrow functions.
Summary:
clang-format currently always wraps the body of non-empty arrow
functions:

    const x = () => {
      z();
    };

This change implements support for the `AllowShortLambdasOnASingleLine`
style options, controlling the indent style for arrow function bodies
that have one or fewer statements. SLS_All puts all on a single line,
SLS_Inline only arrow functions used in an inline position.

    const x = () => { z(); };

Multi-statement arrow functions continue to be wrapped. Function
expressions (`a = function() {}`) and function/method declarations are
unaffected as well.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73335
2020-01-27 16:27:25 +01:00
Hans Wennborg 739b410f1f Add a warning, flags and pragmas to limit the number of pre-processor tokens in a translation unit
See
https://docs.google.com/document/d/1xMkTZMKx9llnMPgso0jrx3ankI4cv60xeZ0y4ksf4wc/preview
for background discussion.

This adds a warning, flags and pragmas to limit the number of
pre-processor tokens either at a certain point in a translation unit, or
overall.

The idea is that this would allow projects to limit the size of certain
widely included headers, or for translation units overall, as a way to
insert backstops for header bloat and prevent compile-time regressions.

Differential revision: https://reviews.llvm.org/D72703
2020-01-27 16:04:17 +01:00
Teresa Johnson af954e441a [WPD] Emit vcall_visibility metadata for MicrosoftCXXABI
Summary:
The MicrosoftCXXABI uses a separate mechanism for emitting vtable
type metadata, and thus didn't pick up the change from D71907
to emit the vcall_visibility metadata under -fwhole-program-vtables.

I believe this is the cause of a Windows bot failure when I committed
follow on change D71913 that required a revert. The failure occurred
in a CFI test that was expecting to not abort because it expected a
devirtualization to occur, and without the necessary vcall_visibility
metadata we would not get devirtualization.

Note in the equivalent code in CodeGenModule::EmitVTableTypeMetadata
(used by the ItaniumCXXABI), we also emit the vcall_visibility metadata
when Virtual Function Elimination is enabled. Since I am not as familiar
with the details of that optimization, I have marked that as a TODO and
am only inserting under -fwhole-program-vtables.

Reviewers: evgeny777

Subscribers: Prazek, ostannard, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73418
2020-01-27 06:22:24 -08:00
Krasimir Georgiev 36a8f7f6d8 [clang-format] Handle escaped " in C# string-literals
Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, MyDeveloperDay

Tags: #clang-format

Differential Revision: https://reviews.llvm.org/D73353
2020-01-27 12:57:20 +01:00
Stephen Kelly 0a57d14abf [ASTMatchers] Fix parent traversal with InitListExpr
Children of InitListExpr are traversed twice by RAV, so this code
populates a vector to represent the possibly-multiple parents (in
reality in this situation the parent is the same and is therefore
de-duplicated).
2020-01-27 11:19:59 +00:00
Guillaume Chatelet 07c9d53266 [Alignment][NFC] Use Align with CreateAlignedLoad
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, bollu

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D73449
2020-01-27 10:58:36 +01:00
Saar Raz 9c24fca2a3 [Concepts] Fix incorrect TemplateArgs for introduction of local parameters
The wrong set of TemplateArgs was being provided to addInstantiatedParametersToScope.
Caused bug #44658.
2020-01-27 00:59:37 +02:00
Saar Raz a8d096aff6 [Concepts] Add missing null check to transformConstructor
Caused bug 44671 when transforming a constructor with a type-constraint with no explicit template args.
2020-01-27 00:15:42 +02:00
Saar Raz 5043962dd3 [Concepts] Fix parsing of scope specifier in compound-requirements, add more tests for scope specifiers in type-constraints
The code for parsing of type-constraints in compound-requirements was not adapted for the new TryAnnotateTypeConstraint which
caused compound-requirements with scope specifiers to ignore them.

Also add regression tests for scope specifiers in type-constraints in more contexts.
2020-01-26 20:46:53 +02:00
Stephen Kelly f29204d388 NFC: Implement AST node skipping in ParentMapContext
Summary:
This allows ASTContext to store only one parent map, rather than storing
an entire parent map for each traversal mode used.

This is therefore a partial revert of commit 0a717d5b (Make it possible
control matcher traversal kind with ASTContext, 2019-12-06).

Reviewers: aaron.ballman, rsmith, rnk

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73388
2020-01-26 18:35:44 +00:00
Serge Pavlov 4aea70ed32 [FPEnv] Extended FPOptions with new attributes
This change added two new attributes, rounding mode and exception
behavior to the structure FPOptions. These attributes allow more
flexible treatment of specific floating point environment than it is
provided by #pragma STDC FENV_ACCESS.

Differential Revision: https://reviews.llvm.org/D65994
2020-01-26 21:03:53 +07:00
Saar Raz 713562f548 [Concepts] Transform constraints of non-template functions to ConstantEvaluated
We would previously try to evaluate atomic constraints of non-template functions as-is,
and since they are now unevaluated at first, this would cause incorrect evaluation (bugs #44657, #44656).

Substitute into atomic constraints of non-template functions as we would atomic constraints
of template functions, in order to rebuild the expressions in a constant-evaluated context.
2020-01-25 23:00:24 +02:00
serge-sans-paille 6d485ff455 Improve static checks for sprintf and __builtin___sprintf_chk
Implement a pessimistic evaluator of the minimal required size for a buffer
based on the format string, and couple that with the fortified version to emit a
warning when the buffer size is lower than the lower bound computed from the
format string.

Differential Revision: https://reviews.llvm.org/D71566
2020-01-25 18:10:34 +01:00
Richard Smith 04f131da0b DR1753: Don't permit x.NS::~T() as a pseudo-destructor name.
When used as qualified names, pseudo-destructors are always named as if
they were members of the type, never as members of the namespace
enclosing the type.
2020-01-24 18:53:50 -08:00
Reid Kleckner 0ebc8e6c42 [Sema] Remove unneeded TreeTransform.h includes, NFC
SemaDecl.cpp and SemaType.cpp don't have any TreeTransforms.
2020-01-24 17:48:38 -08:00
Reid Kleckner dd8e0a0a23 [Sema] Split availability processing into SemaAvailability.cpp
Reduces compile time of SemaDeclAttr.cpp down to 28s from 50s. The new
TU does a few RecursiveASTVisitor instantiations, so it takes 30s.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D73385
2020-01-24 17:35:39 -08:00
Diogo Sampaio bce360b704 Detect source location overflow due includes
Summary:
As discussed in http://lists.llvm.org/pipermail/cfe-dev/2019-October/063459.html
the overflow of the souce locations (limited to 2^31 chars) can generate all sorts of
weird things (bogus warnings, hangs, crashes, miscompilation and correct compilation).
In debug mode this assert would fail. So it might be a good start, as in PR42301,
to detect the failure and exit with a proper error message.

Reviewers: rsmith, thakis, miyuki

Reviewed By: miyuki

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70183
2020-01-24 23:56:47 +00:00
Duncan P. N. Exon Smith 1e487e4c16 clang: Only define OBJC_NEW_PROPERTIES when -x objective-c
Since 2009 (in r63846) we've been `#define`-ing OBJC_NEW_PROPERTIES all
the time on Darwin, but this macro only makes sense for `-x objective-c`
and `-x objective-c++`.  Restrict it to those cases (for which there is
already separate logic).

https://reviews.llvm.org/D72970
rdar://problem/10050342
2020-01-24 14:55:12 -08:00
Heejin Ahn 65eb11306e [WebAssembly] Update bleeding-edge CPU features
Summary:
This adds bulk memory and tail call to "bleeding-edge" CPU, since their
implementation in LLVM/clang seems mostly complete.

Reviewers: tlively

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73322
2020-01-24 14:27:35 -08:00
Heejin Ahn 764f4089e8 [WebAssembly] Add reference types target feature
Summary:
This adds the reference types target feature. This does not enable any
more functionality in LLVM/clang for now, but this is necessary to embed
the info in the target features section, which is used by Binaryen and
Emscripten. It turned out that after D69832 `-fwasm-exceptions` crashed
because we didn't have the reference types target feature.

Reviewers: tlively

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

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D73320
2020-01-24 14:26:27 -08:00
Reid Kleckner 8a81daaa8b [AST] Split parent map traversal logic into ParentMapContext.h
The only part of ASTContext.h that requires most AST types to be
complete is the parent map. Nothing in Clang proper uses the ParentMap,
so split it out into its own class. Make ASTContext own the
ParentMapContext so there is still a one-to-one relationship.

After this change, 562 fewer files depend on ASTTypeTraits.h, and 66
fewer depend on TypeLoc.h:
  $ diff -u deps-before.txt deps-after.txt | \
    grep '^[-+] ' | sort | uniq -c | sort -nr | less
      562 -    ../clang/include/clang/AST/ASTTypeTraits.h
      340 +    ../clang/include/clang/AST/ParentMapContext.h
       66 -    ../clang/include/clang/AST/TypeLocNodes.def
       66 -    ../clang/include/clang/AST/TypeLoc.h
       15 -    ../clang/include/clang/AST/TemplateBase.h
  ...
I computed deps-before.txt and deps-after.txt with `ninja -t deps`.

This removes a common and key dependency on TemplateBase.h and
TypeLoc.h.

This also has the effect of breaking the ParentMap RecursiveASTVisitor
instantiation into its own file, which roughly halves the compilation
time of ASTContext.cpp (29.75s -> 17.66s). The new file takes 13.8s to
compile.

I left behind forwarding methods for getParents(), but clients will need
to include a new header to make them work:
  #include "clang/AST/ParentMapContext.h"

I noticed that this parent map functionality is unfortunately duplicated
in ParentMap.h, which only works for Stmt nodes.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D71313
2020-01-24 13:42:28 -08:00
Yuta Saito c5bd3d0726 Support Swift calling convention for WebAssembly targets
This adds basic support for the Swift calling convention with WebAssembly
targets.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D71823
2020-01-24 10:30:46 -08:00
David Zarzycki 0d61cd25a6
Verify that clang's max alignment is <= LLVM's max alignment
Reviewers: lebedev.ri

Reviewed By: lebedev.ri

Subscribers: cfe-commits

Tags: #llvm, #clang

Differential Revision: https://reviews.llvm.org/D73363
2020-01-24 12:37:05 -05:00
Artem Dergachev 1484d0f12a [analyzer] PthreadLock: Implement dead region cleanup.
Differential Revision: https://reviews.llvm.org/D37963
2020-01-24 18:43:24 +03:00
Artem Dergachev dd22be1e3d [analyzer] PthreadLock: Implement mutex escaping.
Differential Revision: https://reviews.llvm.org/D37812
2020-01-24 18:43:24 +03:00
Artem Dergachev 152bc7ffdc [analyzer] NFC: PthreadLock: Use CallDescriptionMap, modernize.
https://reviews.llvm.org/D37809
2020-01-24 18:43:23 +03:00