Commit Graph

79589 Commits

Author SHA1 Message Date
Gheorghe-Teodor Bercea 625f59d190 [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

llvm-svn: 367613
2019-08-01 21:15:58 +00:00
Csaba Dabis 7740c6d643 [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

llvm-svn: 367608
2019-08-01 20:41:13 +00:00
Yuanfang Chen f6d42dccb5 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.

llvm-svn: 367602
2019-08-01 18:49:59 +00:00
Serge Pavlov 3c26163d1a [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

llvm-svn: 367575
2019-08-01 15:15:10 +00:00
Nico Weber 5c2d5f066f 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.)

llvm-svn: 367574
2019-08-01 15:06:57 +00:00
Sam Elliott 1fc2a47f0b 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)

llvm-svn: 367565
2019-08-01 14:23:56 +00:00
Sam Elliott f46d413fa0 [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)

llvm-svn: 367557
2019-08-01 13:14:30 +00:00
Serge Pavlov 0c50319927 [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

llvm-svn: 367545
2019-08-01 11:46:28 +00:00
Ilya Biryukov b455fc429f [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

llvm-svn: 367530
2019-08-01 09:10:37 +00:00
Hans Wennborg c5877e9803 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

llvm-svn: 367520
2019-08-01 08:01:09 +00:00
Ziang Wan 7f62ff9114 [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss
Fix one test case for it to be system-independent.

llvm-svn: 367502
2019-08-01 01:39:21 +00:00
Ziang Wan 87b668befe [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss
Issue an warning when the code tries to do an implicit int -> float
conversion, where the float type ha a narrower significant than the
float type.

The new warning is controlled by flag -Wimplicit-int-float-conversion,
under -Wimplicit-float-conversion and -Wconversion. It is also silenced
when c++11 narrowing warning is issued.

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

llvm-svn: 367497
2019-08-01 00:16:43 +00:00
Michael J. Spencer 33703fb9f9 [clang][ARM] Fix msvc arm{64} builtins to use int on LP64 systems.
The `InterlockedX_{acq,nf,rel}` functions deal with 32 bits which is long on
MSVC, but int on most other systems.

This also checks that `ReadStatusRegister` and `WriteStatusRegister` have
the correct type on aarch64-darwin.

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

llvm-svn: 367479
2019-07-31 20:42:28 +00:00
Puyan Lotfi 61b6b0eb1b [NFC][clang] Refactor getCompilationPhases()+Types.def step 3.
Second landing attempt: Changed TY_ObjCXXHeader to TY_PP_ObjCXXHeader to fix
                        -xobjective-c++-header. This time I verified against
                        preprocessor output.

Dropping the 'u' entry and the entire Flags table from Types.def.
Now it'll be a bit easier to tablegenify this.

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

llvm-svn: 367478
2019-07-31 20:40:08 +00:00
Sanjay Patel 435cdecdf7 [InstCombine] canonicalize fneg before fmul/fdiv
Reverse the canonicalization of fneg relative to fmul/fdiv. That makes it
easier to implement the transforms (and possibly other fneg transforms) in
1 place because we can always start the pattern match from fneg (either the
legacy binop or the new unop).

There's a secondary practical benefit seen in PR21914 and PR42681:
https://bugs.llvm.org/show_bug.cgi?id=21914
https://bugs.llvm.org/show_bug.cgi?id=42681
...hoisting fneg rather than sinking seems to play nicer with LICM in IR
(although this change may expose analysis holes in the other direction).

1. The instcombine test changes show the expected neutral IR diffs from
   reversing the order.

2. The reassociation tests show that we were missing an optimization
   opportunity to fold away fneg-of-fneg. My reading of IEEE-754 says
   that all of these transforms are allowed (regardless of binop/unop
   fneg version) because:

   "For all other operations [besides copy/abs/negate/copysign], this
   standard does not specify the sign bit of a NaN result."
   In all of these transforms, we always have some other binop
   (fadd/fsub/fmul/fdiv), so we are free to flip the sign bit of a
   potential intermediate NaN operand.
   (If that interpretation is wrong, then we must already have a bug in
   the existing transforms?)

3. The clang tests shouldn't exist as-is, but that's effectively a
   revert of rL367149 (the test broke with an extension of the
   pre-existing fneg canonicalization in rL367146).

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

llvm-svn: 367447
2019-07-31 16:53:22 +00:00
Matt Arsenault 64d7af09f5 AMDGPU: Add missing builtin declarations
llvm-svn: 367431
2019-07-31 14:03:05 +00:00
Momchil Velikov a36d31478c [AArch64] Add support for Transactional Memory Extension (TME)
Re-commit r366322 after some fixes

TME is a future architecture technology, documented in

  https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools
  https://developer.arm.com/docs/ddi0601/a

More about the future architectures:

  https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/new-technologies-for-the-arm-a-profile-architecture

This patch adds support for the TME instructions TSTART, TTEST, TCOMMIT, and
TCANCEL and the target feature/arch extension "tme".

It also implements TME builtin functions, defined in ACLE Q2 2019
(https://developer.arm.com/docs/101028/latest)

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

Patch by Javed Absar and Momchil Velikov

llvm-svn: 367428
2019-07-31 12:52:17 +00:00
Sam Elliott 9e6b2e1605 [RISCV] Support 'f' Inline Assembly Constraint
Summary:
This adds the 'f' inline assembly constraint, as supported by GCC. An
'f'-constrained operand is passed in a floating point register. Exactly
which kind of floating-point register (32-bit or 64-bit) is decided
based on the operand type and the available standard extensions (-f and
-d, respectively).

This patch adds support in both the clang frontend, and LLVM itself.

Reviewers: asb, lewis-revill

Reviewed By: asb

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

Tags: #clang, #llvm

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

llvm-svn: 367403
2019-07-31 09:45:55 +00:00
Simon Cook 7deaeee753 [RISCV] Add support for floating point registers in inlineasm
This adds support for parsing/emitting in IR the floating-point RISC-V
registers in inline assembly clobber lists.

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

llvm-svn: 367399
2019-07-31 09:12:00 +00:00
Johannes Doerfert 3be25e7947 [Fix] Customize warnings for missing built-in types
If we detect a built-in declaration for which we cannot derive a type
matching the pattern in the Builtins.def file, we currently emit a
warning that the respective header is needed. However, this is not
necessarily the behavior we want as it has no connection to the location
of the declaration (which can actually be in the header in question).
Instead, this warning is generated
  - if we could not build the type for the pattern on file (for some
    reason). Here we should make the reason explicit. The actual problem
    is otherwise circumvented as the warning is misleading, see [0] for
    an example.
  - if we could not build the type for the pattern because we do not
    have a type on record, possible since D55483, we should not emit any
    warning. See [1] for a legitimate problem.

This patch address both cases. For the "setjmp" family a new warning is
introduced and for built-ins without type on record, so far
"pthread_create", we do not emit the warning anymore.

Also see: PR40692

[0] https://lkml.org/lkml/2019/1/11/718
[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235583

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

llvm-svn: 367387
2019-07-31 05:16:38 +00:00
JF Bastien e825b834ec [NFC] Remove LLVM_ALIGNAS
Summary: The minimum compilers support all have alignas, and we don't use LLVM_ALIGNAS anywhere anymore. This also removes an MSVC diagnostic which, according to the comment above, isn't relevant anymore.

Reviewers: rnk

Subscribers: mgorny, jkorous, dexonsmith, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 367383
2019-07-31 03:22:08 +00:00
Alex Lorenz 50044763f6 NFCI, optimize layout of FileEntry
The reordering of the UID field makes the size of a
FileEntry 8 bytes smaller on 64bit platforms.

llvm-svn: 367371
2019-07-31 00:12:00 +00:00
Erik Pilkington 4cae092099 [Sema] Actually map a variable template specialization from pattern to instantiation
We were previously just using a specialization in the class template instead of
creating a new specialization in the class instantiation.

Fixes llvm.org/PR42779.

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

llvm-svn: 367367
2019-07-30 23:38:18 +00:00
Sam McCall 71d4544961 Revert "[NFC][clang] Refactor getCompilationPhases()+Types.def step 3."
This reverts commit d2254dbf21.
This (unintentionally?) changed behavior, disallowing e.g. -x objective-c++-header

llvm-svn: 367353
2019-07-30 20:38:11 +00:00
Rainer Orth bb669c25ba [Driver] Support -fsanitize=function on Solaris/x86
UBSan-Standalone-x86_64 :: TestCases/TypeCheck/Function/function.cpp currently
FAILs on Solaris/x86_64:

  clang-9: error: unsupported option '-fsanitize=function' for target 'x86_64-pc-solaris2.11'

AFAICS, there's nothing more to do then enable that sanitizer in the driver (for x86 only),
which is what this patch does, together with updating another testcase.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 367351
2019-07-30 20:04:53 +00:00
JF Bastien 42c9f3c911 [NFC] simplify Darwin environment handling
The previous code detected conflicts through copy-pasta, this versions
uses a 'loop'.

llvm-svn: 367350
2019-07-30 20:01:46 +00:00
Erik Pilkington be19c48f6d [Parser] Lambda capture lists can start with '*'
Fixes llvm.org/PR42778

llvm-svn: 367346
2019-07-30 19:21:20 +00:00
Puyan Lotfi d2254dbf21 [NFC][clang] Refactor getCompilationPhases()+Types.def step 3.
Dropping the 'u' entry and the entire Flags table from Types.def.
Now it'll be a bit easier to tablegenify this.

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

llvm-svn: 367345
2019-07-30 19:03:17 +00:00
Reid Kleckner c0e275df3d Remove cache for macro arg stringization
Summary:
The cache recorded the wrong expansion location for all but the first
stringization. It seems uncommon to stringize the same macro argument
multiple times, so this cache doesn't seem that important.

Fixes PR39942

Reviewers: vsk, rsmith

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 367337
2019-07-30 17:58:22 +00:00
David Major 027bb52790 [COFF][ARM64] Reorder handling of aarch64 MSVC builtins
In `CodeGenFunction::EmitAArch64BuiltinExpr()`, bulk move all of the aarch64 MSVC-builtin cases to an earlier point in the function (the `// Handle non-overloaded intrinsics first` switch block) in order to avoid an unreachable in `GetNeonType()`. The NEON type-overloading logic is not appropriate for the Windows builtins.

Fixes https://llvm.org/pr42775

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

llvm-svn: 367323
2019-07-30 15:32:49 +00:00
Aaron Ballman d5e206ee73 Add typedef declaration information to the JSON AST dump.
When dumping a desugared QualType and the type is a type alias, also print out the id for the type alias declaration.

llvm-svn: 367312
2019-07-30 13:42:19 +00:00
Rainer Orth b9f8ab2c7e [Driver] Define _FILE_OFFSET_BITS=64 on Solaris
make check-all currently fails on x86_64-pc-solaris2.11 when building with GCC 9:

  Undefined                       first referenced
   symbol                             in file
  _ZN11__sanitizer14internal_lseekEimi SANITIZER_TEST_OBJECTS.sanitizer_libc_test.cc.i386.o
  _ZN11__sanitizer23MapWritableFileToMemoryEPvmim SANITIZER_TEST_OBJECTS.sanitizer_libc_test.cc.i386.o
  ld: fatal: symbol referencing errors
  clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
  make[3]: *** [projects/compiler-rt/lib/sanitizer_common/tests/CMakeFiles/TSanitizer-i386-Test.dir/build.make:92: projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-i386-Test] Error 1

While e.g. __sanitizer::internal_lseek is defined in sanitizer_solaris.cc, g++ 9
predefines _FILE_OFFSET_BITS=64 while clang++ currently does not.

This patch resolves this inconsistency by following the gcc lead, which allows
make check-all to finish successfully.

There's one caveat: gcc defines _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE for C++ only, while clang has long been doing it for
all languages.  I'd like to keep it this way because those macros do is to make
declarations of fseek/ftello (_LARGEFILE_SOURCE) resp. the 64-bit versions
of largefile functions (*64 with _LARGEFILE64_SOURCE) visible additionally.
However, _FILE_OFFSET_BITS=64 changes all affected functions to be largefile-aware.
I'd like to restrict this to C++, just like gcc does.

To avoid a similar inconsistence with host compilers that don't predefine _FILE_OFFSET_BITS=64
(e.g. clang < 9, gcc < 9), this needs a compantion patch https://reviews.llvm.org/D64483.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 367305
2019-07-30 10:38:41 +00:00
Sander de Smalen 405c999d97 [AArch64] Disable __ARM_FEATURE_SVE without ACLE.
The Arm C Language Extensions for SVE document specifies that 
__ARM_FEATURE_SVE should be set when the compiler supports SVE and
implements all the extensions described in the document.

This is currently not yet the case, so the feature should be disabled
until the compiler can provide all the extensions as described.

Reviewers: c-rhodes, rengolin, rovka, ktkachov

Reviewed By: rengolin

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

llvm-svn: 367301
2019-07-30 10:14:39 +00:00
Qiu Chaofan 852d444671 [PowerPC] [Clang] Add platform guards to PPC vector intrinsics headers
Move the platform check out of PPC Linux toolchain code and add platform guards
to the intrinsic headers, since they are supported currently only on 64-bit
PowerPC targets.

Reviewed By: Jinsong Ji

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

llvm-svn: 367281
2019-07-30 02:18:11 +00:00
JF Bastien d9e55fa521 Fix Linux build
r367274 broke it

llvm-svn: 367276
2019-07-29 23:28:44 +00:00
JF Bastien ac8686205b [NFC] avoid AlignedCharArray in clang
As discussed in D65249, don't use AlignedCharArray or std::aligned_storage. Just use alignas(X) char Buf[Size];. This will allow me to remove AlignedCharArray entirely, and works on the current minimum version of Visual Studio.

llvm-svn: 367274
2019-07-29 23:12:48 +00:00
Jonas Devlieghere 2562bec939 [DependencyCollector] Make maybeAddDependency virtual (NFC)
Make DependencyCollector::maybeAddDependency, just like its other
methods, which I made virtual a while ago. The motivation for this
change is still the LLDB reproducer.

llvm-svn: 367271
2019-07-29 23:02:11 +00:00
Vedant Kumar 00d186a5a9 [docs] Add a note about where UBSan emits logs
llvm-svn: 367270
2019-07-29 22:54:43 +00:00
Vedant Kumar 04818d8386 [DebugInfo] Don't emit incorrect descriptions of thunk params (PR42627)
The `this` parameter of a thunk requires adjustment. Stop emitting an
incorrect dbg.declare pointing to the unadjusted pointer.

We could describe the adjusted value instead, but there may not be much
benefit in doing so as users tend not to debug thunks.

Robert O'Callahan reports that this matches gcc's behavior.

Fixes PR42627.

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

llvm-svn: 367269
2019-07-29 22:49:55 +00:00
Jordan Rupprecht ab356d87be [driver][test] Use /dev/null in as-options.s instead
llvm-svn: 367256
2019-07-29 20:09:20 +00:00
Richard Smith e8b659fc1f Give the 'signed/unsigned wchar_t' extension a warning flag, and follow
GCC 9 in promoting it to an error by default.

llvm-svn: 367255
2019-07-29 20:00:46 +00:00
Richard Smith a625da716c When determining whether a lambda-expression is implicitly constexpr,
check the formal rules rather than seeing if the normal checks produce a
diagnostic.

This fixes the handling of C++2a extensions in lambdas in C++17 mode,
as well as some corner cases in earlier language modes where we issue
diagnostics for things other than not satisfying the formal constexpr
requirements.

llvm-svn: 367254
2019-07-29 19:59:45 +00:00
Jordan Rupprecht 8e9516f2aa [driver][test] Update as-options.s to not write to a readonly tree
The as-options.s test writes to the build tree as of r367165. Some build systems configure this to be readonly, so this fails. Explicitly write to the output tree using `%t` to avoid this.

llvm-svn: 367253
2019-07-29 19:57:31 +00:00
Reid Kleckner 2336c1b872 Fix taint-generic.c on Windows, handle case in OS error
llvm-svn: 367249
2019-07-29 18:48:50 +00:00
Sven van Haastregt 89fb9e8ce1 [OpenCL] Rename builtin definition classes
Factor out some of the renames from D63434 and D63442, and generate
half type convert_ builtins.

Patch by Pierre Gondois and Sven van Haastregt.

llvm-svn: 367229
2019-07-29 14:55:29 +00:00
Nico Weber ff9f4b5489 clang-format clang/lib/Format
llvm-svn: 367225
2019-07-29 13:26:48 +00:00
Rafael Stahl 0e074fa0fc doc: Fix Google C++ Style Guide link.
llvm-svn: 367219
2019-07-29 11:00:23 +00:00
Mike Spertus 9aeab53eba Improve MSVC visualizers for DeclSpec and TemplateName
DeclSpec now shows the TypeRep, ExprRep, or DeclRep as appropriate
TemplateName decodes and displays the StorageType
A few minor refinements to other types

llvm-svn: 367199
2019-07-29 03:34:40 +00:00
Gabor Borsik 2c8098374b Buildbot fix for r367190
llvm-svn: 367193
2019-07-28 14:57:41 +00:00
Gabor Borsik 4bde15fe1e [analyzer] Add yaml parser to GenericTaintChecker
While we implemented taint propagation rules for several
builtin/standard functions, there's a natural desire for users to add
such rules to custom functions.

A series of patches will implement an option that allows users to
annotate their functions with taint propagation rules through a YAML
file. This one adds parsing of the configuration file, which may be
specified in the commands line with the analyzer config:
alpha.security.taint.TaintPropagation:Config. The configuration may
contain propagation rules, filter functions (remove taint) and sink
functions (give a warning if it gets a tainted value).

I also added a new header for future checkers to conveniently read YAML
files as checker options.

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

llvm-svn: 367190
2019-07-28 13:38:04 +00:00
Hideto Ueno cc0a4cdc89 [FunctionAttrs] Annotate "willreturn" for intrinsics
Summary:
In D62801, new function attribute `willreturn` was introduced. In short, a function with `willreturn` is guaranteed to come back to the call site(more precise definition is in LangRef).

In this patch, willreturn is annotated for LLVM intrinsics.

Reviewers: jdoerfert

Reviewed By: jdoerfert

Subscribers: jvesely, nhaehnle, sstefan1, llvm-commits

Tags: #llvm

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

llvm-svn: 367184
2019-07-28 06:09:56 +00:00
Bjorn Pettersson 197c08d64e [Driver] Additional fixup of NOWARN test case from r367165
Same kind of fix as in r367176, but for "RUN on line 76"
this time.

I'll ask for a post-commit review, to ensure this
matches the intention with the test added in r367165.
But I think this at least will make the buildbots a
little bit happier.

llvm-svn: 367182
2019-07-27 20:22:47 +00:00
Bjorn Pettersson 60c1ee23ff [Driver] Fix "unannotated fall-through between switch labels". NFC
Just a simple fix of Werror problem after r367165.

llvm-svn: 367177
2019-07-27 17:09:08 +00:00
Nico Weber 464cb6c8c8 Attempt to make test in r367165 more robust.
Some people were seeing this failure:

```
: 'RUN: at line 83';   clang -mrelax-all -fno-integrated-as /b/s/w/ir/k/llvm-project/clang/test/Driver/as-options.s -S 2>&1 \
         | /FileCheck --check-prefix=WARN --allow-empty clang/test/Driver/as-options.s
--
Exit Code: 1

Command Output (stderr):
--
clang/test/Driver/as-options.s:66:16: error: NOWARN-NOT: excluded string found in input
// NOWARN-NOT: unused
               ^
<stdin>:1:95: note: found here
clang-10: warning: clang/test/Driver/as-options.s: 'assembler' input unused [-Wunused-command-line-argument]
```

Maybe this helps with that.

llvm-svn: 367176
2019-07-27 16:57:19 +00:00
Nico Weber 1361a4c2d8 clang-format: Support `if CONSTEXPR` if CONSTEXPR is a macro.
This is like r305666 (which added support for `if constexpr`) except
that it allows a macro name after the if.

This is slightly tricky for two reasons:

1. r305666 didn't add test coverage for all cases where it added a
   kw_constexpr, so I had to figure out what all the added cases were
   for. I now added tests for all `if constexpr` bits that didn't have
   tests. (This took a while, see e.g. https://reviews.llvm.org/D65223)

2. Parsing `if <ident> (` as an if means that `#if defined(` and
   `#if __has_include(` parse as ifs too. Add some special-case code
   to prevent this from happening where it's incorrect.

Fixes PR39248.

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

llvm-svn: 367167
2019-07-27 02:41:40 +00:00
Petr Hosek 92a2e1bbb9 Revert "[ARM] Set default alignment to 64bits"
This reverts commit r367119.

This broke several bots:

http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/26891/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Aexception-alignment.cpp
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/245/consoleFull

llvm-svn: 367166
2019-07-27 01:59:23 +00:00
Nico Weber b28ffd8f35 driver: Don't warn about assembler flags being unused when not assembling; different approach
This morally relands r365703 (and r365714), originally reviewed at
https://reviews.llvm.org/D64527, but with a different implementation.

Relanding the same approach with a fix for the revert reason got a bit
involved (see https://reviews.llvm.org/D65108) so use a simpler approach
with a more localized implementation (that in return duplicates code
a bit more).

This approach also doesn't validate flags for the integrated assembler
if the assembler step doesn't run.

Fixes PR42066.

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

llvm-svn: 367165
2019-07-27 01:13:00 +00:00
Leonard Chan 01ba91e6af [NewPM] Run avx*-builtins.c tests under the new pass manager only
This patch changes the following tests to run under the new pass manager only:

```
Clang :: CodeGen/avx512-reduceMinMaxIntrin.c (1 of 4)
Clang :: CodeGen/avx512vl-builtins.c (2 of 4)
Clang :: CodeGen/avx512vlbw-builtins.c (3 of 4)
Clang :: CodeGen/avx512f-builtins.c (4 of 4)
```

The new PM added extra bitcasts that weren't checked before. For
reduceMinMaxIntrin.c, the issue was mostly the alloca's being in a different
order. Other changes involved extra bitcasts, and differently ordered loads and
stores, but the logic should still be the same.

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

llvm-svn: 367157
2019-07-26 21:19:37 +00:00
Sanjay Patel c0fc24bb8e [CodeGen] fix test that broke with rL367146
This should be fixed properly to not depend on LLVM (so much).

llvm-svn: 367149
2019-07-26 20:36:57 +00:00
Hubert Tong e3a0fc72d7 Partially revert rC365414; `ln -n` is not portable
This restores the use of `rm` instead of the non-portable `ln -n`. Such
use being the status quo for the 12-month period between rC334972 and
rC365414.

llvm-svn: 367147
2019-07-26 20:09:37 +00:00
Nathan Huckleberry 2e040398f8 [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression
Summary:
Do not automatically report self references of structs in statement expression
as warnings. Instead wait for uninitialized cfg analysis.
https://bugs.llvm.org/show_bug.cgi?id=42604

Reviewers: aaron.ballman, rsmith, nickdesaulniers

Reviewed By: aaron.ballman, nickdesaulniers

Subscribers: nathanchance, cfe-commits

Tags: #clang

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

llvm-svn: 367134
2019-07-26 17:29:35 +00:00
Simi Pallipurath 92363a3ada [ARM] Set default alignment to 64bits
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

Patch by: Diogo Sampaio(diogo.sampaio@arm.com)

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

Change-Id: I5a62b766491f15dd51e4cfe6625929db897f67e3
llvm-svn: 367119
2019-07-26 15:05:19 +00:00
Alexey Bataev 8a8c69808c [OPENMP]Add support for analysis of reduction variables.
Summary:
Reduction variables are the variables, for which the private copies
must be created in the OpenMP regions. Then they are initialized with
the predefined values depending on the reduction operation. After exit
from the OpenMP region the original variable is updated using the
reduction value and the value of the original reduction variable.

Reviewers: NoQ

Subscribers: guansong, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: #clang

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

llvm-svn: 367116
2019-07-26 14:50:05 +00:00
Erich Keane 61478ec6ac Make the CXXABIs respect the target's default calling convention.
SPIR targets need to have all functions be SPIR calling convention,
however the CXXABIs were just returning CC_C in all non-'this-CC' cases.

https://reviews.llvm.org/D65294

llvm-svn: 367103
2019-07-26 12:36:12 +00:00
Akira Hatanaka 6f6156b9fc Revert "[Sema] Diagnose default-initialization, destruction, and copying of"
This reverts commit r365985.

Prior to r365985, clang used to mark C union fields that have
non-trivial ObjC ownership qualifiers as unavailable if the union was
declared in a system header. r365985 stopped doing so, which caused the
swift compiler to crash when it tried to import a non-trivial union.

I have a patch that fixes the crash (https://reviews.llvm.org/D65256),
but I'm temporarily reverting the original patch until we can decide on
whether it's taking the right approach.

llvm-svn: 367076
2019-07-26 00:02:17 +00:00
George Burgess IV 9d045a5c1e [Sema] add -Walloca to flag uses of `alloca`
This CL adds an optional warning to diagnose uses of the
`__builtin_alloca` family of functions. The use of these functions is
discouraged by many, so it seems like a good idea to allow clang to warn
about it.

Patch by Elaina Guan!

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

llvm-svn: 367067
2019-07-25 22:23:40 +00:00
Puyan Lotfi c07c83b162 [NFC][clang] Refactor getCompilationPhases()+Types.def step 2.
- Removing a few of the entries in the Flags for the Types.def table.
- Removing redundant parts of getCompilationPhases().

Flags have been removed from Types.def:

 a - The type should only be assembled: Now, check that Phases contains
     phases::Assemble but not phases::Compile or phases::Backend.
 p - The type should only be precompiled: Now, check that Phases contains
     phases::Precompile but that Flags does not contain 'm'.
 m - Precompiling this type produces a module file: Now, check that
     isPrepeocessedModuleType.



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

llvm-svn: 367063
2019-07-25 22:05:55 +00:00
Saleem Abdulrasool 3bdb7a9044 Revert "Revert "CodeGen: ensure placeholder instruction for cleanup is created""
This reverts commit fd1274fa78cb0fd32cc1fa2e6f5bb8e62d29df19.

Add an explicit triple for the test which is pattern matching overly
aggressively.

llvm-svn: 367055
2019-07-25 20:59:48 +00:00
Leonard Chan 007f674c6a Reland the "[NewPM] Port Sancov" patch from rL365838. No functional
changes were made to the patch since then.

--------

[NewPM] Port Sancov

This patch contains a port of SanitizerCoverage to the new pass manager. This one's a bit hefty.

Changes:

- Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over
  functions and ModuleSanitizerCoverage for passing over modules.
- ModuleSanitizerCoverage exists for adding 2 module level calls to initialization
  functions but only if there's a function that was instrumented by sancov.
- Added legacy and new PM wrapper classes that own instances of the 2 new classes.
- Update llvm tests and add clang tests.

llvm-svn: 367053
2019-07-25 20:53:15 +00:00
JF Bastien 7c424d8b4d Revert "CodeGen: ensure placeholder instruction for cleanup is created"
Originally in https://reviews.llvm.org/D64656

Causes bot failures:

/home/buildslave/buildslave/clang-cmake-armv8-full/llvm/tools/clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp:20:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: call void @_ZN1RC1E1Q(%struct.R* [[TMP_R]])
               ^
<stdin>:37:2: note: scanning from here
 %8 = call %struct.R* @_ZN1RC1E1Q(%struct.R* %1)
 ^
<stdin>:37:2: note: with "TMP_R" equal to "%1"
 %8 = call %struct.R* @_ZN1RC1E1Q(%struct.R* %1)
 ^
<stdin>:37:17: note: possible intended match here
 %8 = call %struct.R* @_ZN1RC1E1Q(%struct.R* %1)
                ^

llvm-svn: 367051
2019-07-25 20:50:09 +00:00
Saleem Abdulrasool 930df11a0d CodeGen: ensure placeholder instruction for cleanup is created
A placeholder instruction for use in generation of cleanup code for an
initializer list would not be emitted if the base class contained a
non-trivial destructor and the class contains no fields of its own. This
would be the case when using CTAD to deduce the template arguments for a
struct with an overloaded call operator, e.g.

```
template <class... Ts> struct ctad : Ts... {};
template <class... Ts> ctad(Ts...)->ctad<Ts...>;
```

and this class was initialized with a list of lambdas capturing by copy,
e.g.

```
ctad c {[s](short){}, [s](long){}};
```

In a release build the bug would manifest itself as a crash in the SROA
pass, however, in a debug build the following assert in CGCleanup.cpp
would fail:

```
assert(dominatingIP && "no existing variable and no dominating IP!");
```

By ensuring that a placeholder instruction is emitted even if there's no
fields in the class, neither the assert nor the crash is reproducible.

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

Patch by Øystein Dale!

llvm-svn: 367042
2019-07-25 17:59:29 +00:00
Matthias Gehre d293cbd5fd Add lifetime categories attributes
Summary:
This is the first part of work announced in
"[RFC] Adding lifetime analysis to clang" [0],
i.e. the addition of the [[gsl::Owner(T)]] and
[[gsl::Pointer(T)]] attributes, which
will enable user-defined types to participate in
the lifetime analysis (which will be part of the
next PR).
The type `T` here is called "DerefType" in the paper,
and denotes the type that an Owner owns and a Pointer
points to. E.g. `std::vector<int>` should be annotated
with `[[gsl::Owner(int)]]` and
a `std::vector<int>::iterator` with `[[gsl::Pointer(int)]]`.

[0] http://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 367040
2019-07-25 17:50:51 +00:00
Erich Keane 393094859e Remove CallingConvMethodType
This seems to be an old vestage of a previous implementation of getting
the default calling convention, and everything is now using
CXXABI/ASTContext's getDefaultCallingConvention.  Remove it, since it
isn't doing anything.

llvm-svn: 367039
2019-07-25 17:14:45 +00:00
Erich Keane ad137fa788 Fix cxx_status html for r367027
llvm-svn: 367038
2019-07-25 17:14:37 +00:00
JF Bastien dbc0a5df8d Allow prefetching from non-zero address spaces
Summary:
This is useful for targets which have prefetch instructions for non-default address spaces.

<rdar://problem/42662136>

Subscribers: nemanjai, javed.absar, hiraditya, kbarton, jkorous, dexonsmith, cfe-commits, llvm-commits, RKSimon, hfinkel, t.p.northover, craig.topper, anemet

Tags: #clang, #llvm

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

llvm-svn: 367032
2019-07-25 16:11:57 +00:00
Erich Keane 46441fdb3c Implement P1771
As passed in the Cologne meeting and treated by Core as a DR,
[[nodiscard]] was applied to constructors so that they can be diagnosed
in cases where the user forgets a variable name for a type.

The intent is to enable the library to start using this on the
constructors of scope_guard/lock_guard.

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

llvm-svn: 367027
2019-07-25 15:10:56 +00:00
Anton Bikineev 207726c882 [clang] Remove IsDerivedFromDeathTest.DiesOnEmptyBaseName test.
The semantics of an empty basename passed to isDerivedFrom matchers
changed in r367022, so this test is no longer relevant.

llvm-svn: 367026
2019-07-25 15:09:37 +00:00
Anton Bikineev 0ef3f27458 [clang] Fail for empty names in is*DerivedFrom matchers.
Differential Revision: https://reviews.llvm.org/D65279

llvm-svn: 367022
2019-07-25 14:48:55 +00:00
Balazs Keri f34da181d2 Fix failing test plist-macros-with-expansion-ctu.c
llvm-svn: 367013
2019-07-25 12:46:42 +00:00
Krasimir Georgiev 369dd3407c Update some tests after r366702
Summary:
r366702 added a set of new clang-cl -- specific openmp flags together with tests.
The way the newly added tests work is problematic: consider for example this
asertion:
```
// RUN: %clang_cl --target=x86_64-windows-msvc /openmp -### -- %s 2>&1 | FileCheck --check-prefix=CHECK-CC1-OPENMP %s
...
// CHECK-CC1-OPENMP: "-fopenmp"
```

It asserts that an `/openmp` flag should expand into `-fopenmp`. This however
depends on the default value of Clang's CLANG_DEFAULT_OPENMP_RUNTIME value.
Indeed, the code that adds `-fopenmp` to the output only does it if the default
runtime is `libomp` or `libiomp5`, not when it is `libgomp`.

I've updated the tests to not depend on the default value of this setting by
specifying the runtime to use explicitly in each assertion.

Reviewers: jdoerfert

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 367012
2019-07-25 12:15:46 +00:00
Anton Bikineev 4e1d188be2 [clang] Add isDirectlyDerivedFrom AST matcher.
Differential Revision: https://reviews.llvm.org/D65092

llvm-svn: 367010
2019-07-25 11:54:13 +00:00
Anastasia Stulova 88ed70e247 [OpenCL] Rename lang mode flag for C++ mode
Rename lang mode flag to -cl-std=clc++/-cl-std=CLC++
or -std=clc++/-std=CLC++.

This aligns with OpenCL C conversion and removes ambiguity
with OpenCL C++. 

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

llvm-svn: 367008
2019-07-25 11:04:29 +00:00
Balazs Keri aeac909329 [CrossTU] Fix plist macro expansion if macro in other file.
Summary:
When cross TU analysis is used it is possible that a macro expansion
is generated for a macro that is defined (and used) in other than
the main translation unit. To get the expansion for it the source
location in the original source file and original preprocessor
is needed.

Reviewers: martong, xazax.hun, Szelethus, ilya-biryukov

Reviewed By: Szelethus

Subscribers: mgorny, NoQ, ilya-biryukov, rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

llvm-svn: 367006
2019-07-25 10:53:22 +00:00
Gabor Marton 48b16e1005 [ASTImporter] Reorder fields after structure import is finished
We reorder declarations in RecordDecls because they may have another order
in the "to" context than they have in the "from" context. This may happen
e.g when we import a class like this:
   struct declToImport {
       int a = c + b;
       int b = 1;
       int c = 2;
   };
During the import of `a` we import first the dependencies in sequence,
thus the order would be `c`, `b`, `a`. We will get the normal order by
first removing the already imported members and then adding them in the
order as they apper in the "from" context.

Keeping field order is vital because it determines structure layout.

Reviewers: a_sidorin, shafik

Tags: #clang

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

llvm-svn: 366997
2019-07-25 09:07:17 +00:00
Sjoerd Meijer a48f58c97f [Clang] New loop pragma vectorize_predicate
This adds a new vectorize predication loop hint:

  #pragma clang loop vectorize_predicate(enable)

that can be used to indicate to the vectoriser that all (load/store)
instructions should be predicated (masked). This allows, for example, folding
of the remainder loop into the main loop.

This patch will be followed up with D64916 and D65197. The former is a
refactoring in the loopvectorizer and the groundwork to make tail loop folding
a more general concept, and in the latter the actual tail loop folding
transformation will be implemented.

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

llvm-svn: 366989
2019-07-25 07:33:13 +00:00
Petr Hosek f55f51b7be Revert "[Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss"
This reverts commit r366972 which broke the following tests:

  Clang :: CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
  Clang :: CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp

llvm-svn: 366979
2019-07-25 03:11:49 +00:00
Ziang Wan 2028d97d09 [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss
Issue an warning when the code tries to do an implicit int -> float
conversion, where the float type ha a narrower significant than the
float type.

The new warning is controlled by flag -Wimplicit-int-float-conversion,
under -Wimplicit-float-conversion and -Wconversion.

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

llvm-svn: 366972
2019-07-25 00:32:50 +00:00
Azharuddin Mohammed 5f4426e517 Revert "NFC: utils/perf-training: Python 3 compatibility for lit.cfg"
This reverts commit 9178b10163 (r365969).

We are back to using Python2 and this is failing. This should instead be made
to be compatible with both Python 2 and 3.

llvm-svn: 366953
2019-07-24 22:42:50 +00:00
Aaron Ballman 70964d42ea Fix exporting SARIF files from scan-build on Windows.
In Perl, -z is defined as checking if a "file has zero size" and makes no mention what it does when given a directory. It looks like the behavior differs across platforms, which is why on Windows the SARIF file was always being deleted.

Patch by Joe Ranieri.

llvm-svn: 366941
2019-07-24 20:03:27 +00:00
Nico Weber c913d1f2d6 clang-format: Add another test like r366926
llvm-svn: 366929
2019-07-24 17:15:47 +00:00
Nico Weber a659de77e7 clang-format: Add a test that shows that some code I thought was dead is not dead.
llvm-svn: 366926
2019-07-24 17:01:57 +00:00
Anton Afanasyev 4fdcabf259 [Support] Fix `-ftime-trace-granularity` option
Summary:
Move `-ftime-trace-granularity` option to frontend options. Without patch
this option is showed up in the help for any tool that links libSupport.

Reviewers: sammccall

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 366911
2019-07-24 14:55:40 +00:00
Sjoerd Meijer a19f5a76e6 Test commit. NFC.
Removed 2 trailing whitespaces in 2 files that used to be in different
repos to test my new github monorepo workflow.

llvm-svn: 366904
2019-07-24 13:30:36 +00:00
Balazs Keri d22f877356 [CrossTU] Add a function to retrieve original source location.
Summary:
A new function will be added to get the original SourceLocation
for a SourceLocation that was imported as result of getCrossTUDefinition.
The returned SourceLocation is in the context of the (original)
SourceManager for the original source file. Additionally the
ASTUnit object for that source file is returned. This is needed
to get a SourceManager to operate on with the returned source location.

The new function works if multiple different source files are loaded
with the same CrossTU context.

Reviewers: martong, shafik

Reviewed By: martong

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

Tags: #clang

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

llvm-svn: 366884
2019-07-24 10:16:37 +00:00
Fangrui Song 5a43ba8a62 [Format] getFormattingLangOpts: make LS_Auto uses LS_Cpp11 lexing rule
Suggested by sammccall in post-commit review of D65183

Reviewed By: sammccall

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

llvm-svn: 366883
2019-07-24 09:50:56 +00:00
Sander de Smalen 2b290885d9 [SVE][Inline-Asm] Add support to specify SVE registers in the clobber list
Adds the SVE vector and predicate registers to the list of known registers.

Patch by Kerry McLaughlin.

Reviewers: erichkeane, sdesmalen, rengolin

Reviewed By: sdesmalen

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

llvm-svn: 366878
2019-07-24 08:42:34 +00:00
Fangrui Song 00e8ac3beb [Format] Make it easy to add new format::FormatStyle::LanguageStandard. NFCI
Preparatory change for D65043.

We current use `!=LS_Cpp03` to enable language standards 11,14,17, and
2a. `>=LS_Cpp11` is better if we decide to add new LanguageStandard in
the future.

Reviewed By: sammccall

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

llvm-svn: 366876
2019-07-24 08:04:29 +00:00
Nico Weber 37944130f9 clang-format: Fix namespace end comments for namespaces with attributes and macros.
Fixes PR39247.

While here, also make C++20 `namespace A::inline B::inline C` nested
inline namespaced definitions work.

Before:
    #define DEPRECATE_WOOF [[deprecated("meow")]]

    namespace DEPRECATE_WOOF woof {
    void f() {}
    } // namespace DEPRECATE_WOOFwoof

    namespace [[deprecated("meow")]] woof {
      void f() {}
    } // namespace [[deprecated("meow")]]woof

    namespace woof::inline bark {
      void f() {}
    } // namespace woof::inlinebark

Now:
    #define DEPRECATE_WOOF [[deprecated("meow")]]

    namespace DEPRECATE_WOOF woof {
    void f() {}
    } // namespace woof

    namespace [[deprecated("meow")]] woof {
    void f() {}
    } // namespace woof

    namespace woof::inline bark {
    void f() {}
    } // namespace woof::inline bark

(In addition to the fixed namespace end comments, also note the correct
indent of the namespace contents.)

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

llvm-svn: 366831
2019-07-23 17:49:45 +00:00
Nico Weber 532f756555 Improve clang-format-diff help output
The description in clang-format-diff.py is more useful than the one
in `clang-format-diff -h`, so use the same description in both places.

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

llvm-svn: 366828
2019-07-23 17:34:18 +00:00
Jan Korous e72321f38e [clang][NFCI] Fix random typos
llvm-svn: 366823
2019-07-23 16:54:11 +00:00
Rainer Orth 2da6eea07c [clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC
Clang :: Headers/max_align.c currently FAILs on 64-bit SPARC:

  error: 'error' diagnostics seen but not expected: 
    File /vol/llvm/src/clang/dist/test/Headers/max_align.c Line 12: static_assert failed due to requirement '8 == _Alignof(max_align_t)' ""
  1 error generated.

This happens because SuitableAlign isn't defined for SPARCv9 unlike SPARCv8
(which uses the default of 64 bits).  gcc's sparc/sparc.h has

  #define BIGGEST_ALIGNMENT (TARGET_ARCH64 ? 128 : 64)

This patch sets SuitableAlign to match and updates the corresponding testcase.

Tested on sparcv9-sun-solaris2.11.

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

llvm-svn: 366820
2019-07-23 16:24:00 +00:00
Gabor Marton 123f6ff299 [ASTImporter] Fix inequivalence of ClassTemplateInstantiations
Summary:
We falsely state inequivalence if the template parameter is a
qualified/nonquialified template in the first/second instantiation.
Also, different kinds of TemplateName should be equal if the template
decl (if available) is equal (even if the name kind is different).

Reviewers: a_sidorin, a.sidorin

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

Tags: #clang

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

llvm-svn: 366818
2019-07-23 15:46:38 +00:00
Balazs Keri 739a93558f PlistDiagnostics Fix for compile warning (NFC).
llvm-svn: 366792
2019-07-23 10:21:42 +00:00
Balazs Keri 32f220c5fb [CrossTU] Added CTU argument to diagnostic consumer create fn.
Summary:
The PListDiagnosticConsumer needs a new CTU parameter that is passed
through the create functions.

Reviewers: NoQ, Szelethus, xazax.hun, martong

Reviewed By: Szelethus

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

Tags: #clang

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

llvm-svn: 366782
2019-07-23 07:04:20 +00:00
Puyan Lotfi 298a1ed4ad [NFC][clang] Refactor getCompilationPhases()+Types.def step 1.
Moves list of phases into Types.def table: Currently Types.def contains a
table of strings that are used to assemble a list of compilation phases to be
setup in the clang driver's jobs pipeline. This change makes it so that the table
itself contains the list of phases. A subsequent patch will remove the strings.

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

llvm-svn: 366761
2019-07-22 23:10:10 +00:00
Vedant Kumar 7b124c0903 [Driver] Set the default win32-macho debug format to DWARF
rdar://53267670

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

llvm-svn: 366744
2019-07-22 21:46:45 +00:00
Ben Hamilton d9212ef77b Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM and CF_ENUM.
Summary:
Addresses the formatting of NS_CLOSED_ENUM and CF_CLOSED_ENUM, introduced in Swift 5.

Before:

```
typedef NS_CLOSED_ENUM(NSInteger, Foo){FooValueOne = 1, FooValueTwo,
                                       FooValueThree};
```

After:

```
typedef NS_CLOSED_ENUM(NSInteger, Foo) {
  FooValueOne = 1,
  FooValueTwo,
  FooValueThree
};
```

Contributed by heijink.

Reviewers: benhamilton, krasimir

Reviewed By: benhamilton

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 366719
2019-07-22 18:20:01 +00:00
Alexey Bataev 7994e1d071 [OPENMP][MSVC]Enable /openmp[:experimental] to compile OpenMP.
Mapped /openmp[:experimental] to -fopenmp option and /openmp- option to
-fno-openmp

llvm-svn: 366702
2019-07-22 16:49:59 +00:00
Paul Robinson d2c0eefd5c [X86] Remove const from some intrinsics that shouldn't have them
llvm-svn: 366699
2019-07-22 16:14:09 +00:00
Sam McCall 7fc8f415ea [clangd] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cpp
Summary:
SelectionTree is a RecursiveASTVisitor which processes getSourceRange() for
every node. This is a lot of surface area with the AST, as getSourceRange()
is specialized for *many* node types.
And the resulting SelectionTree depends on the source ranges of many
visited nodes, and the order of traversal.

Put together, this means we really need a traversal log to debug when we
get an unexpected SelectionTree. I've built this ad-hoc a few times, now
it's time to check it in.

Example output:
```
D[14:07:44.184] Computing selection for </usr/local/google/home/sammccall/test.cc:1:7, col:8>
D[14:07:44.184]  push: VarDecl const auto x = 42
D[14:07:44.184]   claimRange: </usr/local/google/home/sammccall/test.cc:1:12, col:13>
D[14:07:44.184]   push: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
D[14:07:44.184]   pop: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
D[14:07:44.184]   push: QualifiedTypeLoc const auto
D[14:07:44.184]   pop: QualifiedTypeLoc const auto
D[14:07:44.184]    claimRange: </usr/local/google/home/sammccall/test.cc:1:7, col:11>
D[14:07:44.184]    hit selection: </usr/local/google/home/sammccall/test.cc:1:7, col:8>
D[14:07:44.184]   skip: IntegerLiteral 42
D[14:07:44.184]    skipped range = </usr/local/google/home/sammccall/test.cc:1:16>
D[14:07:44.184]  pop: VarDecl const auto x = 42
D[14:07:44.184]   claimRange: </usr/local/google/home/sammccall/test.cc:1:1, col:18>
D[14:07:44.184]  skip: VarDecl int y = 43
D[14:07:44.184]   skipped range = </usr/local/google/home/sammccall/test.cc:2:1, col:9>
D[14:07:44.184] Built selection tree
TranslationUnitDecl
  VarDecl const auto x = 42
     .QualifiedTypeLoc const auto

```

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, llvm-commits

Tags: #llvm

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

llvm-svn: 366698
2019-07-22 15:55:53 +00:00
Marco Antognini 1b2da771f5 [NFC] Relaxed regression tests for PR42665
Following up on the buildbot failures, this commits relaxes some tests:
instead of checking for specific IR output, it now ensures that the
underlying issue (the crash), and only that, doesn't happen.

llvm-svn: 366694
2019-07-22 14:47:36 +00:00
Alexey Bataev 25569296c6 [OPENMP]Add support for analysis of firstprivate variables.
Summary:
Firstprivate variables are the variables, for which the private copies
must be created in the OpenMP regions and must be initialized with the
original values. Thus, we must report if the uninitialized variable is
used as firstprivate.

Reviewers: NoQ

Subscribers: guansong, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: #clang

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

llvm-svn: 366689
2019-07-22 13:51:07 +00:00
Christudasan Devadasan 8c5e6fa657 Updated the signature for some stack related intrinsics (CLANG)
Modified the intrinsics
int_addressofreturnaddress,
int_frameaddress & int_sponentry.
This commit depends on the changes in rL366679

Reviewed By: arsenm

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

llvm-svn: 366683
2019-07-22 12:50:30 +00:00
Aaron Ballman 1f5712ebb5 Revert the change to the [[nodiscard]] feature test macro value.
This value only gets bumped once both P1301 and P1771 are implemented.

llvm-svn: 366682
2019-07-22 12:49:28 +00:00
Ilya Biryukov 0a42fe70a5 [AST] Treat semantic form of InitListExpr as implicit code in traversals
Summary:
In particular, do not traverse the semantic form if shouldVisitImplicitCode()
returns false.

This simplifies the common case of traversals, avoiding the need to
worry about some expressions being traversed twice.

No tests break after the change, the change would allow to simplify at
least one of the usages, i.e. r366070 which had to handle this in
clangd.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 366672
2019-07-22 09:58:53 +00:00
Marco Antognini 8855963764 [OpenCL] Improve destructor support in C++ for OpenCL
This re-applies r366422 with a fix for Bug PR42665 and a new regression
test.

llvm-svn: 366670
2019-07-22 09:39:13 +00:00
Fangrui Song 1a1af4392a [analyzer] Fix -Wunused-function in NDEBUG builds with #ifdef LLVM_DUMP_METHOD
llvm-svn: 366663
2019-07-22 04:14:09 +00:00
Yuanfang Chen ff22ec3d70 [Clang] Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer'
with '-mframe-pointer'

After D56351 and D64294, frame pointer handling is migrated to tri-state
(all, non-leaf, none) in clang driver and on the function attribute.
This patch makes the frame pointer handling cc1 option tri-state.

Reviewers: chandlerc, rnk, t.p.northover, MaskRay

Reviewed By: MaskRay

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

llvm-svn: 366645
2019-07-20 22:50:50 +00:00
Simon Pilgrim 12b48b1607 Fix cppcheck reduce scope variable warnings. NFCI
Move a couple of variables inside the block where they are actually needed.

llvm-svn: 366635
2019-07-20 13:01:16 +00:00
Richard Smith 6a38205039 [c++20] P1161R3: a[b,c] is deprecated.
llvm-svn: 366630
2019-07-20 09:32:27 +00:00
Aaron Ballman 7017a6d3a3 Mark P1301R4 in C++2a as being SVN instead.
llvm-svn: 366629
2019-07-20 08:57:08 +00:00
Aaron Ballman 1358af27c0 We support P1301R4 in C++2a as of r366626.
llvm-svn: 366628
2019-07-20 08:24:56 +00:00
Richard Smith 1f8aa536f3 [cxx_status] Update status page for WG21 Cologne meeting motions.
Note that many of the paper links will be dead until the post-meeting
mailing is released.

llvm-svn: 366627
2019-07-20 08:20:54 +00:00
Aaron Ballman 3bef014e7d Implement P1301R4, which allows specifying an optional message on the [[nodiscard]] attribute.
This also bumps the attribute feature test value and introduces the notion of a C++2a extension warning.

llvm-svn: 366626
2019-07-20 07:56:34 +00:00
Guanzhong Chen 5204f7611f [WebAssembly] Compute and export TLS block alignment
Summary:
Add immutable WASM global `__tls_align` which stores the alignment
requirements of the TLS segment.

Add `__builtin_wasm_tls_align()` intrinsic to get this alignment in Clang.

The expected usage has now changed to:

    __wasm_init_tls(memalign(__builtin_wasm_tls_align(),
                             __builtin_wasm_tls_size()));

Reviewers: tlively, aheejin, sbc100, sunfish, alexcrichton

Reviewed By: tlively

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

Tags: #clang, #llvm

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

llvm-svn: 366624
2019-07-19 23:34:16 +00:00
Teresa Johnson 604f802fd3 [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1
Summary:
Regular LTO modules do not need LTO Unit splitting, only ThinLTO does
(they must be consistently split into regular and Thin units for
optimizations such as whole program devirtualization and lower type
tests). In order to avoid spurious errors from LTO when combining with
split ThinLTO modules, always set this flag for regular LTO modules.

Reviewers: pcc

Subscribers: mehdi_amini, Prazek, inglorion, steven_wu, dexonsmith, cfe-commits

Tags: #clang

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

llvm-svn: 366623
2019-07-19 23:02:58 +00:00
Denis Bakhvalov a29002e59b [NFC] Remove unused variable
Change-Id: I5aee24dcdf6eebfbf788e52be22463387f23d927
llvm-svn: 366620
2019-07-19 21:59:42 +00:00
Sunil Srivastava f4038e75d2 Disallow most calling convention attributes on PS4
PS4 now only allows "cdecl", and its equivalent on PS4, "sysv_abi".

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

llvm-svn: 366617
2019-07-19 21:38:34 +00:00
Ben Hamilton 86383e6626 [Format/ObjC] Avoid breaking between unary operators and operands
Summary:
Test Plan:
  New tests added. Ran tests with:
  % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
  Confirmed tests failed before change and passed after change.

Reviewers: krasimir, djasper, sammccall, klimek

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

Tags: #clang

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

llvm-svn: 366592
2019-07-19 16:50:24 +00:00
Sven van Haastregt e9e59ad79f [OpenCL] Define CLK_NULL_EVENT without cast
Defining CLK_NULL_EVENT with a `(void*)` cast has the (unintended?)
side-effect that the address space will be fixed (as generic in OpenCL
2.0 mode).  The consequence is that any target specific address space
for the clk_event_t type will not be applied.

It is not clear why the void pointer cast was needed in the first
place, and it seems we can do without it.

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

llvm-svn: 366546
2019-07-19 09:11:48 +00:00
Hubert Tong 2711e16b35 [sanitizers] Use covering ObjectFormatType switches
Summary:
This patch removes the `default` case from some switches on
`llvm::Triple::ObjectFormatType`, and cases for the missing enumerators
(`UnknownObjectFormat`, `Wasm`, and `XCOFF`) are then added.

For `UnknownObjectFormat`, the effect of the action for the `default`
case is maintained; otherwise, where `llvm_unreachable` is called,
`report_fatal_error` is used instead.

Where the `default` case returns a default value, `report_fatal_error`
is used for XCOFF as a placeholder. For `Wasm`, the effect of the action
for the `default` case in maintained.

The code is structured to avoid strongly implying that the `Wasm` case
is present for any reason other than to make the switch cover all
`ObjectFormatType` enumerator values.

Reviewers: sfertile, jasonliu, daltenty

Reviewed By: sfertile

Subscribers: hiraditya, aheejin, sunfish, llvm-commits, cfe-commits

Tags: #clang, #llvm

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

llvm-svn: 366544
2019-07-19 08:46:18 +00:00
Sam Clegg a5ee6397e1 Fix formatting of inline argument comments. NFC.
Also, remove the final arg from ItaniumCXXABI in the PNaCl case since
its not needed.

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

llvm-svn: 366518
2019-07-19 00:30:23 +00:00
Lang Hames bcccd04b7a Update the SimpleJIT class in the clang-interpreter example to use ORCv2.
This will remove the ORCv1 deprecation warnings.

llvm-svn: 366511
2019-07-18 22:47:18 +00:00
Alex Lorenz 4cd905bdc1 [clang-scan-deps] Dependency directives source minimizer: handle #pragma once
We should re-emit `#pragma once` to ensure the preprocessor will
still honor it when running on minimized sources.

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

llvm-svn: 366509
2019-07-18 22:33:14 +00:00
Guanzhong Chen df4479200b [WebAssembly] Fix __builtin_wasm_tls_base intrinsic
Summary:
Properly generate the outchain for the `__builtin_wasm_tls_base` intrinsic.

Also marked the intrinsic pure, per @sunfish's suggestion.

Reviewers: tlively, aheejin, sbc100, sunfish

Reviewed By: tlively

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

Tags: #clang, #llvm

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

llvm-svn: 366499
2019-07-18 21:17:52 +00:00
Alexey Bataev 0c99d19470 [OPENMP]Fix sharing of threadprivate variables with TLS support.
If the threadprivate variable is used in the copyin clause on inner
parallel directive with TLS support, we capture this variable in all
outer OpenMP scopes. It leads to the fact that in all scopes we're
working with the original variable, not the threadprivate copies.

llvm-svn: 366483
2019-07-18 19:40:24 +00:00
Alex Bradbury e078967adf [RISCV] Hard float ABI support
The RISC-V hard float calling convention requires the frontend to:

* Detect cases where, once "flattened", a struct can be passed using
int+fp or fp+fp registers under the hard float ABI and coerce to the
appropriate type(s)
* Track usage of GPRs and FPRs in order to gate the above, and to
determine when signext/zeroext attributes must be added to integer
scalars

This patch attempts to do this in compliance with the documented ABI,
and uses ABIArgInfo::CoerceAndExpand in order to do this. @rjmccall, as
author of that code I've tagged you as reviewer for initial feedback on
my usage.

Note that a previous version of the ABI indicated that when passing an
int+fp struct using a GPR+FPR, the int would need to be sign or
zero-extended appropriately. GCC never did this and the ABI was changed,
which makes life easier as ABIArgInfo::CoerceAndExpand can't currently
handle sign/zero-extension attributes.

Re-landed after backing out 366450 due to missed hunks.

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

llvm-svn: 366480
2019-07-18 18:29:59 +00:00
Guanzhong Chen 801fa8e6b9 [WebAssembly] Implement __builtin_wasm_tls_base intrinsic
Summary:
Add `__builtin_wasm_tls_base` so that LeakSanitizer can find the thread-local
block and scan through it for memory leaks.

Reviewers: tlively, aheejin, sbc100

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

Tags: #clang, #llvm

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

llvm-svn: 366475
2019-07-18 17:53:22 +00:00
Alexey Bataev 05be1da24c [OPENMP]Provide correct data sharing attributes for loop control
variables.

Loop control variables are private in loop-based constructs and we shall
take this into account when generate the code for inner constructs.
Currently, those variables are reported as shared in many cases. Moved
the analysis of the data-sharing attributes of the loop control variable
to an early semantic stage to correctly handle their attributes.

llvm-svn: 366474
2019-07-18 17:49:13 +00:00
Yitzhak Mandelbaum 3f1ab737e2 [LibTooling] Relax Transformer to allow rewriting macro expansions
Summary:
Currently, Transformer rejects any changes to source locations inside macro
expansions. This change relaxes that constraint to allow rewrites when the
entirety of the expansion is replaced, since that can be mapped to replacing the
entirety of the expansion range in the file source.  This change makes
Transformer consistent with the handling of edit ranges in `clang::edit::Commit`
(which is used, for example, for applying `FixItHint`s from diagnostics).

Reviewers: ilya-biryukov

Subscribers: gribozavr, cfe-commits

Tags: #clang

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

llvm-svn: 366473
2019-07-18 17:44:54 +00:00
Yitzhak Mandelbaum 2e97a1e19e [LibTooling] Add function to translate and validate source range for editing
Summary:
Adds the function `getRangeForEdit` to validate that a given source range is
editable and, if needed, translate it into a range in the source file (for
example, if it's sourced in macro expansions).

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 366469
2019-07-18 17:26:57 +00:00
Ilya Biryukov cf41271448 [ASTUnit] Attempt to unbreak Windows buildbots after r366448
llvm-svn: 366457
2019-07-18 16:24:09 +00:00
Alex Bradbury 9b732fe99b Revert "[RISCV] Hard float ABI support" r366450
The commit was missing a few hunks. Will fix and recommit.

llvm-svn: 366454
2019-07-18 16:13:17 +00:00
Ilya Biryukov abc744d263 Revert r366449: [CrossTU] Add a function to retrieve original source location.
Reason: the commit breaks layering by adding a dependency on ASTUnit
(which is inside clangFrontend) from the ASTImporter (which is inside
clangAST).

llvm-svn: 366453
2019-07-18 15:43:26 +00:00
Alex Bradbury fc3aa2ab48 [RISCV] Hard float ABI support
The RISC-V hard float calling convention requires the frontend to:

* Detect cases where, once "flattened", a struct can be passed using
int+fp or fp+fp registers under the hard float ABI and coerce to the
appropriate type(s) * Track usage of GPRs and FPRs in order to gate the
above, and to
determine when signext/zeroext attributes must be added to integer
scalars

This patch attempts to do this in compliance with the documented ABI,
and uses ABIArgInfo::CoerceAndExpand in order to do this. @rjmccall, as
author of that code I've tagged you as reviewer for initial feedback on
my usage.

Note that a previous version of the ABI indicated that when passing an
int+fp struct using a GPR+FPR, the int would need to be sign or
zero-extended appropriately. GCC never did this and the ABI was changed,
which makes life easier as ABIArgInfo::CoerceAndExpand can't currently
handle sign/zero-extension attributes.

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

llvm-svn: 366450
2019-07-18 15:33:41 +00:00
Balazs Keri d2c576110e [CrossTU] Add a function to retrieve original source location.
Summary:
A new function will be added to get the original SourceLocation
for a SourceLocation that was imported as result of getCrossTUDefinition.
The returned SourceLocation is in the context of the (original)
SourceManager for the original source file. Additionally the
ASTUnit object for that source file is returned. This is needed
to get a SourceManager to operate on with the returned source location.

The new function works if multiple different source files are loaded
with the same CrossTU context.

This patch can be treated as part of a bigger change that is needed to
improve macro expansion handliong at plist generation.

Reviewers: martong, shafik, a_sidorin, xazax.hun

Reviewed By: martong

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

Tags: #clang

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

llvm-svn: 366449
2019-07-18 15:23:10 +00:00
Ilya Biryukov 5de0c85e88 [ASTUnit] Fix a regression in cached completions
Summary:
After r345152 cached completions started adding namespaces after
nested name specifiers, e.g. in `some_name::^`

The CCC_Symbol indicates the completed item cannot be a namespace (it is
described as being "a type, a function or a variable" in the comments).

Therefore, 'nested specifier' completions should only be added from cache
when the context is CCC_SymbolOrNewName (which roughly seems to indicate
that a nested name specifier is allowed).

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

Reviewers: kadircet, sammccall

Reviewed By: kadircet, sammccall

Subscribers: arphaman, nik, sammccall, cfe-commits

Tags: #clang

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

llvm-svn: 366448
2019-07-18 15:21:34 +00:00
Jonas Devlieghere a5359b1b07 [CMake] Don't set Python_ADDITIONAL_VERSIONS
Until recently, Python_ADDITIONAL_VERSIONS was used to limit LLVM's
Python support to 2.7. Now that both LLVM and LLDB both support Python
3, there's no longer a need to put an arbitrary limit on this.

However, instead of removing the variable, r365692 expanded the list,
which has the (presumably unintentional) side-effect of expression
preference for Python 3.

Instead, as Michal proposed in the original code review, we should just
not set the list at all, and let CMake pick whatever Python interpreter
you have in your path.

This patch removes the Python_ADDITIONAL_VERSIONS variable in llvm,
clang and lld. I've also updated the docs with the default behavior and
how to force a different Python version to be used.

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

llvm-svn: 366447
2019-07-18 15:17:42 +00:00
Gabor Marton 6d3bb71c8f [analyzer] Add CTU user docs
Reviewers: dkrupp, a_sidorin, Szelethus, NoQ

Subscribers: whisperity, xazax.hun, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, gamesh411, Charusso, cfe-commits

Tags: #clang

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

llvm-svn: 366439
2019-07-18 14:03:25 +00:00
Alexey Bataev a44b216036 [OPENMP][NVPTX]Mark barrier functions calls as convergent.
Added convergent attribute to the barrier functions calls for correct
optimizations.

llvm-svn: 366437
2019-07-18 13:49:24 +00:00