Commit Graph

72969 Commits

Author SHA1 Message Date
Eugene Zelenko bc5858b8fb [AST] Fix some Clang-tidy modernize-use-auto and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 329766
2018-04-10 22:54:42 +00:00
Aaron Ballman 0652534131 Introduce a new builtin, __builtin_dump_struct, that is useful for dumping structure contents at runtime in circumstances where debuggers may not be easily available (such as in kernel work).
Patch by Paul Semel.

llvm-svn: 329762
2018-04-10 21:58:13 +00:00
Petr Hosek 52b1f9a30b Revert "Handle the default case"
This reverts commit r329758.

llvm-svn: 329760
2018-04-10 21:29:18 +00:00
Petr Hosek d5c9420ff5 Handle the default case
This was omitted in D45422 resulting in a warning.

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

llvm-svn: 329758
2018-04-10 21:19:05 +00:00
Chad Rosier d880416722 [Driver] Handle the default case missed in r329748.
Differential Revision: https://reviews.llvm.org/D45499

llvm-svn: 329754
2018-04-10 20:30:16 +00:00
Alexey Bataev c0f879bcec [OPENMP] Additional attributes for the pointer parameters.
Added attributes for better optimization of the OpenMP code.

llvm-svn: 329751
2018-04-10 20:10:53 +00:00
Petr Hosek 8d612149db [Driver] Allow drivers to add multiple libc++ include paths
This allows toolchain drivers to add multiple libc++ include paths akin
to libstdc++. This is useful in multiarch setup when some headers might
be in target specific include directory. There should be no functional
change.

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

llvm-svn: 329748
2018-04-10 19:55:55 +00:00
Gabor Buella 8701b18a25 [X86] Split up -march=icelake to -client & -server
Reviewers: craig.topper, zvi, echristo

Reviewed By: craig.topper

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

llvm-svn: 329741
2018-04-10 18:58:26 +00:00
Nico Weber ade321e7dd Revert r329684 (and follow-ups 329693, 329714). See discussion on https://reviews.llvm.org/D43578.
llvm-svn: 329739
2018-04-10 18:53:28 +00:00
Craig Topper 298e1712d8 [X86] Add test case for llvm change r329734
This test ensures the popfd instruction in MS inline assembly can properly find a clobber name for the dirflag register. Previously the register was named 'DF', but it needs to be named 'dirflag' to match the name in the GCC register name list.

llvm-svn: 329738
2018-04-10 18:43:44 +00:00
Artem Belevich dde3dc27ee [CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.
Currently we always include PTX into the fatbin along
with the GPU code.It about doubles the size of the GPU binary
we need to carry in the executable. These options allow control
inclusion of PTX into GPU binary.

This patch does not change the defaults, though we may consider
making no-PTX the default in the future.

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

llvm-svn: 329737
2018-04-10 18:38:22 +00:00
Volodymyr Sapsai 9f7b5cc073 [Parser] Fix assertion-on-invalid for unexpected typename.
In `ParseDeclarationSpecifiers` for the code

    class A typename A;

we were able to annotate token `kw_typename` because it refers to
existing type. But later during processing token `annot_typename` we
failed to `SetTypeSpecType` and exited switch statement leaving
annotation token unconsumed. The code after the switch statement failed
because it didn't expect a special token.

The fix is not to assume that switch statement consumes all special
tokens and consume any token, not just non-special.

rdar://problem/37099386

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: jkorous-apple, cfe-commits

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

llvm-svn: 329735
2018-04-10 18:29:47 +00:00
Andrew V. Tischenko 38cd74b1c1 I removed the failed test.
llvm-svn: 329714
2018-04-10 15:45:43 +00:00
Gabor Buella 5966507c4e [X86] Disable SGX for Skylake Server - CPP test
Summary: Fix test case - corresponding to r329701

Reviewers: craig.topper, davezarzycki

Reviewed By: davezarzycki

Subscribers: cfe-commits

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

llvm-svn: 329710
2018-04-10 15:03:03 +00:00
Nico Weber a3e7510a4c Attempt to fix Windows build after r329698.
llvm-svn: 329702
2018-04-10 14:08:25 +00:00
Gabor Buella e3330c1b61 [X86] Disable SGX for Skylake Server
Reviewers: craig.topper, zvi, echristo

Reviewed By: craig.topper

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

llvm-svn: 329701
2018-04-10 14:04:21 +00:00
Nico Weber 148c8cb4bf Use llvm::sys::fs::real_path() in clang.
No expected behavior change.
https://reviews.llvm.org/D45165

llvm-svn: 329698
2018-04-10 13:36:38 +00:00
Andrew V. Tischenko 23b8bd1220 The test was fixed.
llvm-svn: 329693
2018-04-10 12:17:01 +00:00
Gabor Buella 58fe46d99f CodeGen tests - typo fixes NFC
llvm-svn: 329689
2018-04-10 11:20:05 +00:00
Sam McCall 44f2f4ec45 [Tooling] fix UB when interpolating compile commands with an empty index
llvm-svn: 329685
2018-04-10 10:36:46 +00:00
Andrew V. Tischenko c88deb100f -ftime-report switch support in Clang.
The current support of the feature produces only 2 lines in report:
 -Some general Code Generation Time;
 -Total time of Backend Consumer actions.
This patch extends Clang time report with new lines related to Preprocessor, Include Filea Search, Parsing, etc.
Differential Revision: https://reviews.llvm.org/D43578

llvm-svn: 329684
2018-04-10 10:34:13 +00:00
Akira Hatanaka 4e2698ca9e [ExprConstant] Use an AST node and a version number as a key to create
an APValue and retrieve it from map Temporaries.

The version number is needed when a single AST node is visited multiple
times and is used to create APValues that are required to be distinct
from each other (for example, MaterializeTemporaryExprs in default
arguments and VarDecls in loops).

rdar://problem/36505742

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

llvm-svn: 329671
2018-04-10 05:15:01 +00:00
George Burgess IV 37b1dd62bb [AST] Attempt to fix buildbot warnings + appease MSVC; NFCI
GCC 4.8.4 on a bot was warning about `ArgPassingKind` not fitting in
`ArgPassingRestrictions`, which appears to be incorrect, since
`ArgPassingKind` only has three potential values:

"warning: 'clang::RecordDecl::ArgPassingRestrictions' is too small to
hold all values of 'enum clang::RecordDecl::ArgPassingKind'"

Additionally, I remember hearing (though my knowledge may be outdated)
that MSVC won't merge adjacent bitfields if their types are different.

Try to fix both issues by turning these into `uint8_t`s.

llvm-svn: 329652
2018-04-10 01:11:26 +00:00
Akira Hatanaka e6313ace66 [ObjC++] Never pass structs that transitively contain __weak fields in
registers.

This patch fixes a bug in r328731 that caused structs transitively
containing __weak fields to be passed in registers. The patch replaces
the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
whether the struct or structs containing the struct are forced to be
passed indirectly.

This reapplies r329617. r329617 didn't specify the underlying type for
enum ArgPassingKind, which caused regression tests to fail on a windows
bot.

rdar://problem/39194693

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

llvm-svn: 329635
2018-04-09 22:48:22 +00:00
Eugene Zelenko 2a1ba94f24 [AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
llvm-svn: 329630
2018-04-09 22:14:10 +00:00
Eugene Zelenko 9a9c823388 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 329628
2018-04-09 21:54:38 +00:00
Akira Hatanaka d236a34ddb Revert "[ObjC++] Never pass structs that transitively contain __weak fields in"
This reverts commit r329617. It broke a windows bot.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16372/steps/test/logs/stdio

llvm-svn: 329627
2018-04-09 21:47:58 +00:00
Akira Hatanaka f15d29ccc7 [ObjC++] Never pass structs that transitively contain __weak fields in
registers.

This patch fixes a bug in r328731 that caused structs transitively
containing __weak fields to be passed in registers. The patch replaces
the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
whether the struct or structs containing the struct are forced to be
passed indirectly.

rdar://problem/39194693

llvm-svn: 329617
2018-04-09 20:39:47 +00:00
Vitaly Buka 69a2e18b4a asan: kernel: make no_sanitize("address") attribute work with -fsanitize=kernel-address
Summary:
Right now to disable -fsanitize=kernel-address instrumentation, one needs to use no_sanitize("kernel-address"). Make either no_sanitize("address") or no_sanitize("kernel-address")  disable both ASan and KASan instrumentation. Also remove redundant test.

Patch by Andrey Konovalov

Reviewers: eugenis, kcc, glider, dvyukov, vitalybuka

Reviewed By: eugenis, vitalybuka

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

llvm-svn: 329612
2018-04-09 20:10:29 +00:00
Akira Hatanaka 367b1a8985 Revert "[ObjC] Make C++ triviality type traits available to non-trivial C"
This reverts commit r329289.

It was decided that we shouldn't expose the __has_* traits to C since
they are deprecated and useless.

See the discussion here:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180402/thread.html#223921

llvm-svn: 329608
2018-04-09 19:39:27 +00:00
Craig Topper 304edc1e75 [X86] Emit native IR for pmuldq/pmuludq builtins.
I believe all the pieces are now in place in the backend to make this work correctly. We can either mask the input to 32 bits for pmuludg or shl/ashr for pmuldq and use a regular mul instruction. The backend should combine this to PMULUDQ/PMULDQ and then SimplifyDemandedBits will remove the and/shifts.

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

llvm-svn: 329605
2018-04-09 19:17:54 +00:00
Yaxun Liu bec8a66454 [CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets
amdgcn targets only support HIP, which does not define __CUDA_ARCH__.

this is a partial unroll of r329232 / D45277.

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

llvm-svn: 329584
2018-04-09 15:43:01 +00:00
Sam McCall ea9773ac69 [Tooling] A CompilationDatabase wrapper that infers header commands.
Summary:
The wrapper finds the closest matching compile command using filename heuristics
and makes minimal tweaks so it can be used with the header.

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 329580
2018-04-09 15:17:39 +00:00
Sam McCall cc026ebf32 [Index] Return SourceLocation to consumers, not FileID/Offset pair.
Summary:
The FileID/Offset conversion is lossy. The code takes the fileLoc, which loses
e.g. the spelling location in some macro cases.
Instead, pass the original SourceLocation which preserves all information, and
update consumers to match current behavior.

This allows us to fix two bugs in clangd that need the spelling location.

Reviewers: akyrtzi, arphaman

Subscribers: ilya-biryukov, ioeric, cfe-commits

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

llvm-svn: 329570
2018-04-09 14:12:51 +00:00
Hans Wennborg 66f7225277 Try to fix libclang reproducer tests after r329465
They were failing on Windows because the output YAML didn't parse:

  YAML:1:664: error: Unrecognized escape code!

  {"toolchain":"D:\\buildslave\\clang-x64-ninja-win7\\stage1",
    "libclang.operation":"complete", "libclang.opts":1, "args":["clang",
    "-fno-spell-checking",
    "D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\test\Index\create-libclang-completion-reproducer.c",
    "-Xclang", "-detailed-preprocessing-record",
    "-fallow-editor-placeholders"],
    "invocation-args":["-code-completion-at=D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\test\Index\create-libclang-completion-reproducer.c:10:1"],
    "unsaved_file_hashes":[{"name":"D:\\buildslave\\clang-x64-ninja-win7\\llvm\\tools\\clang\\test\\Index\\create-libclang-completion-reproducer.c",
      "md5":"aee23773de90e665992b48209351d70e"}]}

This adds some more escaping to try to make it work.

llvm-svn: 329558
2018-04-09 12:21:12 +00:00
Dean Michael Berris 20dc6ef746 [XRay][llvm+clang] Consolidate attribute list files
Summary:
This change consolidates the always/never lists that may be provided to
clang to externally control which functions should be XRay instrumented
by imbuing attributes. The files follow the same format as defined in
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html for the
sanitizer blacklist.

We also deprecate the existing `-fxray-instrument-always=` and
`-fxray-instrument-never=` flags, in favour of `-fxray-attr-list=`.

This fixes http://llvm.org/PR34721.

Reviewers: echristo, vlad.tsyrklevich, eugenis

Reviewed By: vlad.tsyrklevich

Subscribers: llvm-commits, cfe-commits

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

llvm-svn: 329543
2018-04-09 04:02:09 +00:00
Eric Fiselier 4b8c991870 [Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.
Summary:
Currently clang doesn't do qualified lookup when building indirect field decl references. This causes ambiguity when the field is in a base class to which there are multiple valid paths  even though a qualified name is used.

For example:
```
class B {
protected:
 int i;
 union { int j; };
};

class X : public B { };
class Y : public B { };

class Z : public X, public Y {
 int a() { return X::i; } // works
 int b() { return X::j; } // fails
};
```

Reviewers: rsmith, aaron.ballman, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 329521
2018-04-08 06:21:33 +00:00
Eric Fiselier 80440deed4 Revert "[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases."
This reverts commit r329519. There are some unaddressed test failures.

llvm-svn: 329520
2018-04-08 06:05:33 +00:00
Eric Fiselier 35177d0fec [Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.
Summary:
Currently clang doesn't do qualified lookup when building indirect field decl references. This causes ambiguity when the field is in a base class to which there are multiple valid paths  even though a qualified name is used.

For example:
```
class B {
protected:
 int i;
 union { int j; };
};

class X : public B { };
class Y : public B { };

class Z : public X, public Y {
 int a() { return X::i; } // works
 int b() { return X::j; } // fails
};
```

Reviewers: rsmith, aaron.ballman, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 329519
2018-04-08 05:50:01 +00:00
Eric Fiselier e099fc1806 [Sema] Remove dead code in BuildAnonymousStructUnionMemberReference. NFCI
Summary:
This patch cleans up a bunch of dead or unused code in BuildAnonymousStructUnionMemberReference.

The dead code was a branch that built a new CXXThisExpr when we weren't given a base object expression or base variable.
However, BuildAnonymousFoo has only two callers. One of which always builds a base object expression first, the second only calls when the IndirectFieldDecl is not a C++ class member. Even within C this branch seems entirely unused.

I tried diligently to write a test which hit it with no success. 

This patch removes the branch and replaces it with an assertion that we were given either a base object expression or a base variable.


Reviewers: rsmith, aaron.ballman, majnemer, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 329518
2018-04-08 05:12:55 +00:00
Eric Fiselier 84393619eb [Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during template instantiation.
Summary:
Currently Clang fails to propagate qualifiers from the `CXXThisExpr` to the rebuilt `FieldDecl` for IndirectFieldDecls. For example:

```
template <class T> struct Foo {
  struct { int x; };
  int y;
  void foo() const { 
      static_assert(__is_same(int const&, decltype((y))));
      static_assert(__is_same(int const&, decltype((x)))); // assertion fails
  }
};
template struct Foo<int>;
```

The fix is to delegate rebuilding of the MemberExpr to `BuildFieldReferenceExpr` which correctly propagates the qualifiers.

Reviewers: rsmith, lebedev.ri, aaron.ballman, bkramer, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 329517
2018-04-08 05:11:59 +00:00
Fangrui Song e46ac5fb9d [libclang] Add clang_File_tryGetRealPathName
Summary:
clang_getFileName() may return a path relative to WorkingDir.
On Arch Linux, during clang_indexTranslationUnit(), clang_getFileName() on
CXIdxIncludedIncludedFileInfo::file may return
"/../lib64/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/string",
for `#include <string>`.

I presume WorkingDir is somehow changed to /usr/lib or /usr/include and
clang_getFileName() returns a path relative to WorkingDir.

clang_File_tryGetRealPathName() returns "/usr/include/c++/7.3.0/string"
which is more useful for the indexer in this case.

Subscribers: cfe-commits

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

llvm-svn: 329515
2018-04-07 20:50:35 +00:00
John McCall bfbc05e2f5 Generalize the swiftcall API since being passed indirectly isn't
C++-specific anymore.

llvm-svn: 329513
2018-04-07 20:16:47 +00:00
Manoj Gupta 9487d90e22 [Driver] Update GCC libraries detection logic for Gentoo.
Summary:
1. Find GCC's LDPATH from the actual GCC config file.
2. Avoid picking libraries from a similar named tuple if the exact
   tuple is installed.

Reviewers: mgorny, chandlerc, thakis, rnk

Reviewed By: mgorny, rnk

Subscribers: cfe-commits, mgorny

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

llvm-svn: 329512
2018-04-07 19:59:58 +00:00
John McCall 48f4d4f428 Allow equality comparisons between block pointers and
block-pointer-compatible ObjC object pointer types.

Patch by Dustin Howett!

llvm-svn: 329508
2018-04-07 17:42:06 +00:00
Roman Lebedev 61061d69ea [Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded self-assignment (classes)
Summary:
This has just bit me, so i though it would be nice to avoid that next time :)
Motivational case:
  https://godbolt.org/g/cq9UNk
Basically, it's likely to happen if you don't like shadowing issues,
and use `-Wshadow` and friends. And it won't be diagnosed by clang.

The reason is, these self-assign diagnostics only work for builtin assignment
operators. Which makes sense, one could have a very special operator=,
that does something unusual in case of self-assignment,
so it may make sense to not warn on that.

But while it may be intentional in some cases, it may be a bug in other cases,
so it would be really great to have some diagnostic about it...

Reviewers: aaron.ballman, rsmith, rtrieu, nikola, rjmccall, dblaikie

Reviewed By: rjmccall

Subscribers: EricWF, lebedev.ri, thakis, Quuxplusone, cfe-commits

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

llvm-svn: 329493
2018-04-07 10:39:21 +00:00
Nico Weber 4c28cfea78 Sort source lists in lib/StaticAnalyzer.
llvm-svn: 329481
2018-04-07 04:25:01 +00:00
Nico Weber 727f22bff2 Make CodeGen depend just once on clangAnalysis.
llvm-svn: 329477
2018-04-07 03:29:47 +00:00
Nico Weber 4f48279e02 Remove another unnecessary -I flag passed to clang-tblgen.
llvm-svn: 329476
2018-04-07 01:34:36 +00:00
Richard Smith 269c26ab9b Generalize test for 32-bit targets.
llvm-svn: 329467
2018-04-07 00:28:32 +00:00