[clang-tools-extra] 734aa1d - [clangd] Publish xref for macros from Index and AST.

2020-01-13 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2020-01-13T11:11:18+01:00
New Revision: 734aa1d133f264746f721a244d2c66bc99648ee5

URL: 
https://github.com/llvm/llvm-project/commit/734aa1d133f264746f721a244d2c66bc99648ee5
DIFF: 
https://github.com/llvm/llvm-project/commit/734aa1d133f264746f721a244d2c66bc99648ee5.diff

LOG: [clangd] Publish xref for macros from Index and AST.

Summary:
With this patch the `findReferences` API will return Xref for macros.
If the symbol under the cursor is a macro then we collect the references to it 
from:
1. Main file by looking at the ParsedAST. (These were added to the ParsedAST in 
https://reviews.llvm.org/D70008)
2. Files other than the mainfile by looking at the:
* static index (Added in https://reviews.llvm.org/D70489)
* file index (Added in https://reviews.llvm.org/D71406)
This patch collects all the xref from the above places and outputs it in 
`findReferences` API.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index fa33c796ce29..ac62393541aa 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -432,52 +432,73 @@ ReferencesResult findReferences(ParsedAST , Position 
Pos, uint32_t Limit,
 elog("Failed to get a path for the main file, so no references");
 return Results;
   }
+  auto URIMainFile = URIForFile::canonicalize(*MainFilePath, *MainFilePath);
   auto Loc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, SM, AST.getLangOpts()));
-  // TODO: should we handle macros, too?
-  // We also show references to the targets of using-decls, so we include
-  // DeclRelation::Underlying.
-  DeclRelationSet Relations = DeclRelation::TemplatePattern |
-  DeclRelation::Alias | DeclRelation::Underlying;
-  auto Decls = getDeclAtPosition(AST, Loc, Relations);
-
-  // We traverse the AST to find references in the main file.
-  auto MainFileRefs = findRefs(Decls, AST);
-  // We may get multiple refs with the same location and 
diff erent Roles, as
-  // cross-reference is only interested in locations, we deduplicate them
-  // by the location to avoid emitting duplicated locations.
-  MainFileRefs.erase(std::unique(MainFileRefs.begin(), MainFileRefs.end(),
- [](const ReferenceFinder::Reference ,
-const ReferenceFinder::Reference ) {
-   return L.Loc == R.Loc;
- }),
- MainFileRefs.end());
-  for (const auto  : MainFileRefs) {
-if (auto Range = getTokenRange(SM, AST.getLangOpts(), Ref.Loc)) {
-  Location Result;
-  Result.range = *Range;
-  Result.uri = URIForFile::canonicalize(*MainFilePath, *MainFilePath);
-  Results.References.push_back(std::move(Result));
+  RefsRequest Req;
+
+  if (auto Macro = locateMacroAt(Loc, AST.getPreprocessor())) {
+// Handle references to macro.
+if (auto MacroSID = getSymbolID(Macro->Name, Macro->Info, SM)) {
+  // Collect macro references from main file.
+  const auto  = AST.getMacros().MacroRefs;
+  auto Refs = IDToRefs.find(*MacroSID);
+  if (Refs != IDToRefs.end()) {
+for (const auto Ref : Refs->second) {
+  Location Result;
+  Result.range = Ref;
+  Result.uri = URIMainFile;
+  Results.References.push_back(std::move(Result));
+}
+  }
+  Req.IDs.insert(*MacroSID);
+}
+  } else {
+// Handle references to Decls.
+
+// We also show references to the targets of using-decls, so we include
+// DeclRelation::Underlying.
+DeclRelationSet Relations = DeclRelation::TemplatePattern |
+DeclRelation::Alias | DeclRelation::Underlying;
+auto Decls = getDeclAtPosition(AST, Loc, Relations);
+
+// We traverse the AST to find references in the main file.
+auto MainFileRefs = findRefs(Decls, AST);
+// We may get multiple refs with the same location and 
diff erent Roles, as
+// cross-reference is only interested in locations, we deduplicate them
+// by the location to avoid emitting duplicated locations.
+MainFileRefs.erase(std::unique(MainFileRefs.begin(), MainFileRefs.end(),
+   [](const ReferenceFinder::Reference ,
+  const ReferenceFinder::Reference ) {
+ return L.Loc == R.Loc;
+   }),
+   MainFileRefs.end());
+for (const auto  : MainFileRefs) {
+  if (auto Range = 

[PATCH] D72395: [clangd] Publish xref for macros from Index and AST.

2020-01-13 Thread UTKARSH SAXENA via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG734aa1d133f2: [clangd] Publish xref for macros from Index 
and AST. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72395/new/

https://reviews.llvm.org/D72395

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -937,6 +937,13 @@
   [[CAT]](Fo, o) foo4;
 }
   )cpp",
+
+  R"cpp(// Macros
+#define [[MA^CRO]](X) (X+1)
+void test() {
+  int x = [[MACRO]]([[MACRO]](1));
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
@@ -1011,7 +1018,7 @@
   }
 }
 
-TEST(FindReferences, NeedsIndex) {
+TEST(FindReferences, NeedsIndexForSymbols) {
   const char *Header = "int foo();";
   Annotations Main("int main() { [[f^oo]](); }");
   TestTU TU;
@@ -1040,13 +1047,49 @@
   EXPECT_EQ(1u, LimitRefs.References.size());
   EXPECT_TRUE(LimitRefs.HasMore);
 
-  // If the main file is in the index, we don't return duplicates.
-  // (even if the references are in a different location)
+  // Avoid indexed results for the main file. Use AST for the mainfile.
   TU.Code = ("\n\n" + Main.code()).str();
   EXPECT_THAT(findReferences(AST, Main.point(), 0, TU.index().get()).References,
   ElementsAre(RangeIs(Main.range(;
 }
 
+TEST(FindReferences, NeedsIndexForMacro) {
+  const char *Header = "#define MACRO(X) (X+1)";
+  Annotations Main(R"cpp(
+int main() {
+  int a = [[MA^CRO]](1);
+}
+  )cpp");
+  TestTU TU;
+  TU.Code = Main.code();
+  TU.HeaderCode = Header;
+  auto AST = TU.build();
+
+  // References in main file are returned without index.
+  EXPECT_THAT(
+  findReferences(AST, Main.point(), 0, /*Index=*/nullptr).References,
+  ElementsAre(RangeIs(Main.range(;
+
+  Annotations IndexedMain(R"cpp(
+int indexed_main() {
+  int a = [[MACRO]](1);
+}
+  )cpp");
+
+  // References from indexed files are included.
+  TestTU IndexedTU;
+  IndexedTU.Code = IndexedMain.code();
+  IndexedTU.Filename = "Indexed.cpp";
+  IndexedTU.HeaderCode = Header;
+  EXPECT_THAT(
+  findReferences(AST, Main.point(), 0, IndexedTU.index().get()).References,
+  ElementsAre(RangeIs(Main.range()), RangeIs(IndexedMain.range(;
+  auto LimitRefs =
+  findReferences(AST, Main.point(), /*Limit*/ 1, IndexedTU.index().get());
+  EXPECT_EQ(1u, LimitRefs.References.size());
+  EXPECT_TRUE(LimitRefs.HasMore);
+}
+
 TEST(FindReferences, NoQueryForLocalSymbols) {
   struct RecordingIndex : public MemIndex {
 mutable Optional> RefIDs;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -432,52 +432,73 @@
 elog("Failed to get a path for the main file, so no references");
 return Results;
   }
+  auto URIMainFile = URIForFile::canonicalize(*MainFilePath, *MainFilePath);
   auto Loc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, SM, AST.getLangOpts()));
-  // TODO: should we handle macros, too?
-  // We also show references to the targets of using-decls, so we include
-  // DeclRelation::Underlying.
-  DeclRelationSet Relations = DeclRelation::TemplatePattern |
-  DeclRelation::Alias | DeclRelation::Underlying;
-  auto Decls = getDeclAtPosition(AST, Loc, Relations);
-
-  // We traverse the AST to find references in the main file.
-  auto MainFileRefs = findRefs(Decls, AST);
-  // We may get multiple refs with the same location and different Roles, as
-  // cross-reference is only interested in locations, we deduplicate them
-  // by the location to avoid emitting duplicated locations.
-  MainFileRefs.erase(std::unique(MainFileRefs.begin(), MainFileRefs.end(),
- [](const ReferenceFinder::Reference ,
-const ReferenceFinder::Reference ) {
-   return L.Loc == R.Loc;
- }),
- MainFileRefs.end());
-  for (const auto  : MainFileRefs) {
-if (auto Range = getTokenRange(SM, AST.getLangOpts(), Ref.Loc)) {
-  Location Result;
-  Result.range = *Range;
-  Result.uri = URIForFile::canonicalize(*MainFilePath, *MainFilePath);
-  Results.References.push_back(std::move(Result));
+  RefsRequest Req;
+
+  if (auto Macro = locateMacroAt(Loc, AST.getPreprocessor())) {
+// Handle references to macro.
+if (auto MacroSID = getSymbolID(Macro->Name, Macro->Info, SM)) {
+  // Collect macro references from main file.
+  const auto  

[PATCH] D71688: [AArch64] Add -mtls-size option for ELF targets

2020-01-13 Thread Peter Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10c11e4e2d05: This option allows selecting the TLS size in 
the local exec TLS model, which is… (authored by kawashima-fj, committed by 
peter.smith).
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71688/new/

https://reviews.llvm.org/D71688

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/tls-size.c
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/test/CodeGen/AArch64/arm64-tls-execs.ll
  llvm/test/CodeGen/AArch64/arm64-tls-initial-exec.ll
  llvm/test/CodeGen/AArch64/arm64-tls-local-exec.ll

Index: llvm/test/CodeGen/AArch64/arm64-tls-local-exec.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/arm64-tls-local-exec.ll
@@ -0,0 +1,106 @@
+; Test each TLS size option
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -tls-size=12 < %s | FileCheck %s --check-prefix=CHECK-12
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -tls-size=12 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-12-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=tiny -tls-size=24 < %s | FileCheck %s --check-prefix=CHECK-24
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=tiny -tls-size=24 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=small -tls-size=32 < %s | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=small -tls-size=32 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-32-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=large -tls-size=48 < %s | FileCheck %s --check-prefix=CHECK-48
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=large -tls-size=48 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-48-RELOC %s
+;
+; Test the maximum TLS size for each code model (fallback to a smaller size from the specified size)
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -tls-size=32 < %s | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -tls-size=32 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-32-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=tiny -tls-size=32 < %s | FileCheck %s --check-prefix=CHECK-24
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=tiny -tls-size=32 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=small -tls-size=48 < %s | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=small -tls-size=48 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-32-RELOC %s
+;
+; Test the default TLS size for each code model
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding < %s | FileCheck --check-prefix=CHECK-24 %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=tiny < %s | FileCheck %s --check-prefix=CHECK-24
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=tiny | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=small < %s | FileCheck %s --check-prefix=CHECK-24
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=small | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
+; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=large < %s | FileCheck %s --check-prefix=CHECK-24
+; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=large | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
+
+@local_exec_var = thread_local(localexec) global i32 0
+
+define i32 @test_local_exec() {
+; CHECK-LABEL: test_local_exec:
+  %val = load i32, i32* @local_exec_var
+
+; CHECK-12: mrs x[[R1:[0-9]+]], TPIDR_EL0
+; CHECK-12: add x[[R2:[0-9]+]], x[[R1]], :tprel_lo12:local_exec_var
+; CHECK-12: ldr w0, 

[PATCH] D72395: [clangd] Publish xref for macros from Index and AST.

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61641 tests passed, 0 failed 
and 777 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72395/new/

https://reviews.llvm.org/D72395



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D72498#1816244 , @ilya-biryukov 
wrote:

> In D72498#1815500 , @lh123 wrote:
>
> > - hover over the `front` , you'll see "instance-method `front` → 
> > `std::vector >::reference`".
> > - hover over the `push_back`, you'll see "`std::vector > std::allocator >::value_type && __x`".
>
>
> These look terrible and are the great examples where showing canonical types 
> results in better output than canonical types.
>  I wonder why we add `std::vector>::` in the 
> first place, I believe the standard library uses `value_type` in the 
> declaration. Showing `value_type` is not great, but at least that doesn't 
> uglify what was written in the code in the first place.
>  FWIW, I think the perfect output in those cases would be `int (aka 
> value_type)`


Indeed. Another illustrative example, the return type of 
`vector::at()` - we'd probably want `int64&` here, rather than 
`vector<...>::reference` or `unsigned long long`/`unsigned long` depending on 
platform.

It seems like:

- unwrapping nothing isn't ideal
- unwrapping everything isn't ideal
- brevity might be a good heuristic, but unclear
- there's value sometimes in showing multiple forms, unclear exactly when

(Machine learning time? Mostly joking...)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72498/new/

https://reviews.llvm.org/D72498



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72401: Fixes for spaces around C# object initializers

2020-01-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2869
+// space before '{' in "new MyType {"
+if (Left.is(TT_Unknown) && Right.is(tok::l_brace) && Left.Previous &&
+Left.Previous->is(tok::kw_new))

krasimir wrote:
> This test feels a bit too rigid: you might additionally want to consider `new 
> Type {` and `new Type /*comment*/ {` and `new [] /* comment */ {`.
> For these you might find the `MatchingParen` and `getPreviousNonComment` 
> useful. And example for this is below, at line 2880-2885 in javascript 
> handling.
Sorry, disregard the patterns with `/* comment */` above. I guess the spaces 
around the comment there are enforced at another place.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72401/new/

https://reviews.llvm.org/D72401



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69970: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood (reland with fixes)

2020-01-13 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

I guess this should be closed? :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69970/new/

https://reviews.llvm.org/D69970



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2020-01-13 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 237620.
lewis-revill added a comment.

Fix .cfi_offset signedness error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62686/new/

https://reviews.llvm.org/D62686

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-features.c
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.h
  llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.h
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/saverestore.ll
  llvm/test/CodeGen/RISCV/shrinkwrap.ll

Index: llvm/test/CodeGen/RISCV/shrinkwrap.ll
===
--- llvm/test/CodeGen/RISCV/shrinkwrap.ll
+++ llvm/test/CodeGen/RISCV/shrinkwrap.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple riscv32 < %s | FileCheck %s -check-prefix=RV32I-NOSW
 ; RUN: llc -mtriple riscv32 -enable-shrink-wrap < %s | FileCheck %s -check-prefix=RV32I-SW
+; RUN: llc -mtriple riscv32 -enable-shrink-wrap -mattr=+save-restore < %s \
+; RUN: | FileCheck %s -check-prefix=RV32I-SW-SR
 
 
 declare void @abort()
@@ -29,6 +31,16 @@
 ; RV32I-SW-NEXT:addi sp, sp, -16
 ; RV32I-SW-NEXT:sw ra, 12(sp)
 ; RV32I-SW-NEXT:call abort
+;
+; RV32I-SW-SR-LABEL: eliminate_restore:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bgeu a1, a0, .LBB0_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.end
+; RV32I-SW-SR-NEXT:ret
+; RV32I-SW-SR-NEXT:  .LBB0_2: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_0
+; RV32I-SW-SR-NEXT:call abort
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
@@ -84,6 +96,23 @@
 ; RV32I-SW-NEXT:addi sp, sp, 16
 ; RV32I-SW-NEXT:  .LBB1_2: # %if.end
 ; RV32I-SW-NEXT:ret
+;
+; RV32I-SW-SR-LABEL: conditional_alloca:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bltu a1, a0, .LBB1_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_1
+; RV32I-SW-SR-NEXT:addi s0, sp, 16
+; RV32I-SW-SR-NEXT:addi a0, a0, 15
+; RV32I-SW-SR-NEXT:andi a0, a0, -16
+; RV32I-SW-SR-NEXT:sub a0, sp, a0
+; RV32I-SW-SR-NEXT:mv sp, a0
+; RV32I-SW-SR-NEXT:call notdead
+; RV32I-SW-SR-NEXT:addi sp, s0, -16
+; RV32I-SW-SR-NEXT:tail __riscv_restore_1
+; RV32I-SW-SR-NEXT:  .LBB1_2: # %if.end
+; RV32I-SW-SR-NEXT:ret
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
Index: llvm/test/CodeGen/RISCV/saverestore.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/saverestore.ll
@@ -0,0 +1,299 @@
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s -check-prefix=RV32I
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s -check-prefix=RV64I
+; RUN: llc -mtriple=riscv32 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV32I-SR
+; RUN: llc -mtriple=riscv64 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV64I-SR
+; RUN: llc -mtriple=riscv32 -mattr=+f,+save-restore -target-abi=ilp32f < %s | FileCheck %s -check-prefix=RV32I-FP-SR
+; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+save-restore -target-abi=lp64d < %s | FileCheck %s -check-prefix=RV64I-FP-SR
+
+; Check that the correct save/restore libcalls are generated.
+
+@var0 = global [18 x i32] zeroinitializer
+@var1 = global [24 x i32] zeroinitializer
+@var2 = global [30 x i32] zeroinitializer
+
+define void @callee_saved0() nounwind {
+; RV32I-LABEL: callee_saved0:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved0:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail __riscv_restore
+;
+; RV32I-SR-LABEL: callee_saved0:
+; RV32I-SR: call t0, __riscv_save_5
+; RV32I-SR: tail __riscv_restore_5
+;
+; RV64I-SR-LABEL: callee_saved0:
+; RV64I-SR: call t0, __riscv_save_5
+; RV64I-SR: tail __riscv_restore_5
+;
+; RV32I-FP-SR-LABEL: callee_saved0:
+; RV32I-FP-SR: call t0, __riscv_save_5
+; RV32I-FP-SR: tail __riscv_restore_5
+;
+; RV64I-FP-SR-LABEL: callee_saved0:
+; RV64I-FP-SR: call t0, __riscv_save_5
+; RV64I-FP-SR: tail __riscv_restore_5
+  %val = load [18 x i32], [18 x i32]* @var0
+  store volatile [18 x i32] %val, [18 x i32]* @var0
+  ret void
+}
+
+define void @callee_saved1() nounwind {
+; RV32I-LABEL: callee_saved1:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved1:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail __riscv_restore
+;
+; RV32I-SR-LABEL: callee_saved1:
+; RV32I-SR: call t0, __riscv_save_11
+; RV32I-SR: tail __riscv_restore_11
+;
+; 

[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D72498#1813989 , @ilya-biryukov 
wrote:

> In D72498#1813962 , @sammccall wrote:
>
> > It's particularly unclear to me why typeprinter descends into auto but 
> > prints decltype, but Kadir says that seems to be intentional.
>
>
> Also don't see why they choose to have this inconsistency and I haven't seen 
> any indication it's not a coincidence.
>  @kadircet, why do you think it's intentional? Should we put some comments 
> there?


I was saying that because `TypePrinter` deliberately prints `decltype(` and 
then the expression.
I suppose we could make this a printing policy option to print either the 
underlying expr or type.

> I tend to disagree here. decltype is normally the last resort, so whatever it 
> produces is probably super-obscure, would even expect it to be not 
> representable in C++ in many cases.

I was rather talking about the obscurity of the expression inside decltype vs 
the typedef alias. I believe it is a lot harder to make any assumptions on 
`decltype(callback)` compared to `IntMap` without seeing the underlying type.

> Would definitely be helpful. If you feel we have some room in hover, I would 
> love to have that. But there's a balance to be made, see Sam's comments about 
> canonical types being obscure. I agree on 50% of the cases :-)

I think this should be OK to spend some space, as it will only show up when 
needed. I believe `better` printing of canonical types is a different problem 
we should definitely solve.

@sammccall wrote:

> It's a contrived example that makes clangd look silly (why decltype(a) 
> instead of int?) but also the user look silly (why hover the variable rather 
> than the decltype?).


Right, the user can definitely hover over the decltype, but this goes against 
our objectives. I believe with hover we are trying to reduce number of jumps a 
user needs to take for acquiring some info,
and requiring them to jump to the definition of symbol for figuring out the 
type doesn't seem right.

> But note that this patch doesn't handle the important use case of decltype as 
> return type, really!
>  imagine cout << sum('c', 4), and you want to know what type the function 
> call has.
>  The natural thing is to hover over the function call, you'll see "function 
> sum -> decltype(t1 + t2)" which is indeed pretty useless.
>  But this patch doesn't fix that behaviour, it only handles types of 
> declarations.

Yes, but this was an oversight rather than an explicit decision. I believe we 
should definitely do the same for return type and even parameter types.

> @ilya-biryukov @kadircet what do you think about unwrapping decltype only 
> when it's a return value (optional: of a function whose leading return type 
> is auto) to narrowly catch this idiom?

I wouldn't special case that behavior as it is equally useful for ValueDecls, 
since we are trying to get rid of the extra jump as mentioned above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72498/new/

https://reviews.llvm.org/D72498



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2020-01-13 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added a comment.

In D62686#1815158 , @pzheng wrote:

> I see the following .cfi_offset directives generated using @shiva0217's test 
> case. Any idea why the offset for ra is 536870908?
>
>   callt0, __riscv_save_0
>   .cfi_def_cfa_offset 16
>   .cfi_offset ra, 536870908
>   


Hmm I see this too I'll look into it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62686/new/

https://reviews.llvm.org/D62686



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2020-01-13 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX added a comment.

Thanks @sammccall ,  for the test case. Seems like, this implementation doesn't 
address the lambda functions returning "auto".  We're looking into this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70524/new/

https://reviews.llvm.org/D70524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72395: [clangd] Publish xref for macros from Index and AST.

2020-01-13 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 237596.
usaxena95 marked 3 inline comments as done.
usaxena95 added a comment.

Removed repeated check from the test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72395/new/

https://reviews.llvm.org/D72395

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -937,6 +937,13 @@
   [[CAT]](Fo, o) foo4;
 }
   )cpp",
+
+  R"cpp(// Macros
+#define [[MA^CRO]](X) (X+1)
+void test() {
+  int x = [[MACRO]]([[MACRO]](1));
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
@@ -1011,7 +1018,7 @@
   }
 }
 
-TEST(FindReferences, NeedsIndex) {
+TEST(FindReferences, NeedsIndexForSymbols) {
   const char *Header = "int foo();";
   Annotations Main("int main() { [[f^oo]](); }");
   TestTU TU;
@@ -1040,13 +1047,49 @@
   EXPECT_EQ(1u, LimitRefs.References.size());
   EXPECT_TRUE(LimitRefs.HasMore);
 
-  // If the main file is in the index, we don't return duplicates.
-  // (even if the references are in a different location)
+  // Avoid indexed results for the main file. Use AST for the mainfile.
   TU.Code = ("\n\n" + Main.code()).str();
   EXPECT_THAT(findReferences(AST, Main.point(), 0, TU.index().get()).References,
   ElementsAre(RangeIs(Main.range(;
 }
 
+TEST(FindReferences, NeedsIndexForMacro) {
+  const char *Header = "#define MACRO(X) (X+1)";
+  Annotations Main(R"cpp(
+int main() {
+  int a = [[MA^CRO]](1);
+}
+  )cpp");
+  TestTU TU;
+  TU.Code = Main.code();
+  TU.HeaderCode = Header;
+  auto AST = TU.build();
+
+  // References in main file are returned without index.
+  EXPECT_THAT(
+  findReferences(AST, Main.point(), 0, /*Index=*/nullptr).References,
+  ElementsAre(RangeIs(Main.range(;
+
+  Annotations IndexedMain(R"cpp(
+int indexed_main() {
+  int a = [[MACRO]](1);
+}
+  )cpp");
+
+  // References from indexed files are included.
+  TestTU IndexedTU;
+  IndexedTU.Code = IndexedMain.code();
+  IndexedTU.Filename = "Indexed.cpp";
+  IndexedTU.HeaderCode = Header;
+  EXPECT_THAT(
+  findReferences(AST, Main.point(), 0, IndexedTU.index().get()).References,
+  ElementsAre(RangeIs(Main.range()), RangeIs(IndexedMain.range(;
+  auto LimitRefs =
+  findReferences(AST, Main.point(), /*Limit*/ 1, IndexedTU.index().get());
+  EXPECT_EQ(1u, LimitRefs.References.size());
+  EXPECT_TRUE(LimitRefs.HasMore);
+}
+
 TEST(FindReferences, NoQueryForLocalSymbols) {
   struct RecordingIndex : public MemIndex {
 mutable Optional> RefIDs;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -432,52 +432,73 @@
 elog("Failed to get a path for the main file, so no references");
 return Results;
   }
+  auto URIMainFile = URIForFile::canonicalize(*MainFilePath, *MainFilePath);
   auto Loc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, SM, AST.getLangOpts()));
-  // TODO: should we handle macros, too?
-  // We also show references to the targets of using-decls, so we include
-  // DeclRelation::Underlying.
-  DeclRelationSet Relations = DeclRelation::TemplatePattern |
-  DeclRelation::Alias | DeclRelation::Underlying;
-  auto Decls = getDeclAtPosition(AST, Loc, Relations);
-
-  // We traverse the AST to find references in the main file.
-  auto MainFileRefs = findRefs(Decls, AST);
-  // We may get multiple refs with the same location and different Roles, as
-  // cross-reference is only interested in locations, we deduplicate them
-  // by the location to avoid emitting duplicated locations.
-  MainFileRefs.erase(std::unique(MainFileRefs.begin(), MainFileRefs.end(),
- [](const ReferenceFinder::Reference ,
-const ReferenceFinder::Reference ) {
-   return L.Loc == R.Loc;
- }),
- MainFileRefs.end());
-  for (const auto  : MainFileRefs) {
-if (auto Range = getTokenRange(SM, AST.getLangOpts(), Ref.Loc)) {
-  Location Result;
-  Result.range = *Range;
-  Result.uri = URIForFile::canonicalize(*MainFilePath, *MainFilePath);
-  Results.References.push_back(std::move(Result));
+  RefsRequest Req;
+
+  if (auto Macro = locateMacroAt(Loc, AST.getPreprocessor())) {
+// Handle references to macro.
+if (auto MacroSID = getSymbolID(Macro->Name, Macro->Info, SM)) {
+  // Collect macro references from main file.
+  const auto  = 

[PATCH] D72395: [clangd] Publish xref for macros from Index and AST.

2020-01-13 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:1093
+
+  // If the main file is in the index, we don't return duplicates.
+  // (even if the references are in a different location)

kadircet wrote:
> i know the comment is copied over, but it doesn't reflect what's going on.
> 
> as this check makes sure we prever results from AST rather than index for 
> main file, not the duplicate handling(which actually de-dups references on 
> the *same* location).
> 
> since this is handled in the common code path, it is OK to check only in one 
> of the tests(up to you though). but please update the comments.
Updated the old comment to show the correct intent.
Also removed the check from the macros test since this was on the common code 
path.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72395/new/

https://reviews.llvm.org/D72395



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e45fcfc - Revert "[DWARF5][clang]: Added support for DebugInfo generation for auto return type for C++ member functions."

2020-01-13 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-01-13T11:13:16+01:00
New Revision: e45fcfc3aa57bb237fd4fd694d0c257be66d5482

URL: 
https://github.com/llvm/llvm-project/commit/e45fcfc3aa57bb237fd4fd694d0c257be66d5482
DIFF: 
https://github.com/llvm/llvm-project/commit/e45fcfc3aa57bb237fd4fd694d0c257be66d5482.diff

LOG: Revert "[DWARF5][clang]: Added support for DebugInfo generation for auto 
return type for C++ member functions."

This reverts commit 6d6a4590c5d4c7fc7445d72fe685f966b0a8cafb, which
introduces a crash.

See https://reviews.llvm.org/D70524 for details.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h

Removed: 
clang/test/CodeGenCXX/debug-info-auto-return.cpp



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 6d2123a7b0e1..675df309e3f0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -810,10 +810,6 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType 
*BT) {
   return DBuilder.createBasicType(BTName, Size, Encoding);
 }
 
-llvm::DIType *CGDebugInfo::CreateType(const AutoType *Ty) {
-  return DBuilder.createUnspecifiedType("auto");
-}
-
 llvm::DIType *CGDebugInfo::CreateType(const ComplexType *Ty) {
   // Bit size and offset of the type.
   llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float;
@@ -1461,18 +1457,16 @@ void CGDebugInfo::CollectRecordFields(
 
 llvm::DISubroutineType *
 CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
-   llvm::DIFile *Unit, bool decl) {
+   llvm::DIFile *Unit) {
   const FunctionProtoType *Func = 
Method->getType()->getAs();
   if (Method->isStatic())
 return cast_or_null(
 getOrCreateType(QualType(Func, 0), Unit));
-  return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit, 
decl);
+  return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit);
 }
 
-llvm::DISubroutineType *
-CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,
-   const FunctionProtoType *Func,
-   llvm::DIFile *Unit, bool decl) {
+llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
+QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
   // Add "this" pointer.
   llvm::DITypeRefArray Args(
   cast(getOrCreateType(QualType(Func, 0), Unit))
@@ -1480,12 +1474,9 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
   assert(Args.size() && "Invalid number of arguments!");
 
   SmallVector Elts;
+
   // First element is always return type. For 'void' functions it is NULL.
-  QualType temp = Func->getReturnType();
-  if (temp->getTypeClass() == Type::Auto && decl)
-Elts.push_back(CreateType(cast(temp)));
-  else
-Elts.push_back(Args[0]);
+  Elts.push_back(Args[0]);
 
   // "this" pointer is always first argument.
   const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl();
@@ -1544,7 +1535,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
   isa(Method) || isa(Method);
 
   StringRef MethodName = getFunctionName(Method);
-  llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit, true);
+  llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit);
 
   // Since a single ctor/dtor corresponds to multiple functions, it doesn't
   // make sense to give a single ctor/dtor a linkage name.
@@ -2763,7 +2754,7 @@ llvm::DIType *CGDebugInfo::CreateType(const 
MemberPointerType *Ty,
   return DBuilder.createMemberPointerType(
   getOrCreateInstanceMethodType(
   CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()),
-  FPT, U, false),
+  FPT, U),
   ClassType, Size, /*Align=*/0, Flags);
 }
 
@@ -3538,7 +3529,7 @@ llvm::DISubroutineType 
*CGDebugInfo::getOrCreateFunctionType(const Decl *D,
 return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));
 
   if (const auto *Method = dyn_cast(D))
-return getOrCreateMethodType(Method, F, false);
+return getOrCreateMethodType(Method, F);
 
   const auto *FTy = FnType->getAs();
   CallingConv CC = FTy ? FTy->getCallConv() : CallingConv::CC_C;

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index d9c6b4d79097..90e9a61ebe96 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -165,7 +165,6 @@ class CGDebugInfo {
   /// ivars and property accessors.
   llvm::DIType *CreateType(const BuiltinType *Ty);
   llvm::DIType *CreateType(const ComplexType *Ty);
-  llvm::DIType *CreateType(const AutoType *Ty);
   llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
   llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg);
   llvm::DIType *CreateType(const TemplateSpecializationType *Ty,
@@ -215,10 

[clang] 10c11e4 - This option allows selecting the TLS size in the local exec TLS model,

2020-01-13 Thread Peter Smith via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2020-01-13T10:16:53Z
New Revision: 10c11e4e2d05cf0e8f8251f50d84ce77eb1e9b8d

URL: 
https://github.com/llvm/llvm-project/commit/10c11e4e2d05cf0e8f8251f50d84ce77eb1e9b8d
DIFF: 
https://github.com/llvm/llvm-project/commit/10c11e4e2d05cf0e8f8251f50d84ce77eb1e9b8d.diff

LOG: This option allows selecting the TLS size in the local exec TLS model,
which is the default TLS model for non-PIC objects. This allows large/
many thread local variables or a compact/fast code in an executable.

Specification is same as that of GCC. For example, the code model
option precedes the TLS size option.

TLS access models other than local-exec are not changed. It means
supoort of the large code model is only in the local exec TLS model.

Patch By KAWASHIMA Takahiro (kawashima-fj )
Reviewers: dmgreen, mstorsjo, t.p.northover, peter.smith, ostannard
Reviewd By: peter.smith
Committed by: peter.smith

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

Added: 
clang/test/Driver/tls-size.c
llvm/test/CodeGen/AArch64/arm64-tls-initial-exec.ll
llvm/test/CodeGen/AArch64/arm64-tls-local-exec.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp

Removed: 
llvm/test/CodeGen/AArch64/arm64-tls-execs.ll



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index cf8fbe251b35..50fc1836282f 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -333,6 +333,9 @@ ENUM_CODEGENOPT(VecLib, VectorLibrary, 2, NoLibrary)
 /// The default TLS model to use.
 ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
 
+/// Bit size of immediate TLS offsets (0 == use the default).
+VALUE_CODEGENOPT(TLSSize, 8, 0)
+
 /// Number of path components to strip when emitting checks. (0 == full
 /// filename)
 VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0)

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0fee90707d40..71b257094a98 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2178,6 +2178,9 @@ def mwatchsimulator_version_min_EQ : Joined<["-"], 
"mwatchsimulator-version-min=
 def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
+def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group, 
Flags<[DriverOption, CC1Option]>,
+  HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): "
+   "12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 
256TB, needs -mcmodel=large)">;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
 def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, 
Group;
 def mno_default_build_attributes : Joined<["-"], 
"mno-default-build-attributes">, Group;

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index d58bcf5a7905..0bfcab88a3a9 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -474,6 +474,7 @@ static void initTargetOptions(llvm::TargetOptions ,
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
+  Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.ExplicitEmulatedTLS = CodeGenOpts.ExplicitEmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4ef40e974cd6..4d924e072f57 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4531,6 +4531,19 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 CmdArgs.push_back(A->getValue());
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_mtls_size_EQ)) {
+StringRef Value = A->getValue();
+unsigned TLSSize = 0;
+Value.getAsInteger(10, TLSSize);
+if (!Triple.isAArch64() || !Triple.isOSBinFormatELF())
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getOption().getName() << TripleStr;
+if (TLSSize != 12 && TLSSize != 24 && TLSSize != 32 && TLSSize != 48)
+  D.Diag(diag::err_drv_invalid_int_value)
+  << A->getOption().getName() << Value;
+

[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2020-01-13 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added a comment.

In D62686#1808041 , @apazos wrote:

> Lewis, is the patch final? It would be good to merge it before the 10.0 
> release branch creation on Jan 15th


I would say so now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62686/new/

https://reviews.llvm.org/D62686



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This seems to have introduced a crash compiling libcxx. I'm currently reducing 
the crashing code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70524/new/

https://reviews.llvm.org/D70524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71688: [AArch64] Add -mtls-size option for ELF targets

2020-01-13 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

Committed as 10c11e4e2d05cf0e8f8251f50d84ce77eb1e9b8d 
 , I've 
used the new attribution process https://llvm.org/docs/DeveloperPolicy.html so 
you should show up as the author of the patch in the commit log. I'll comment 
here if there are any problems with buildbots.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71688/new/

https://reviews.llvm.org/D71688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-01-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good to me (with a minor comment). Thanks!




Comment at: clang/tools/driver/driver.cpp:271
+unsigned long long Enable;
+if (getAsUnsignedInteger(SpawnCC1Str, 10, Enable) || Enable > 1) {
+  llvm::errs() << "error: the value of the environment variable "

I think just checking SpawnCC1Str == "0" or == "1" would be easier.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69825/new/

https://reviews.llvm.org/D69825



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-13 Thread liu hui via Phabricator via cfe-commits
lh123 added a comment.

In D72498#1816339 , @sammccall wrote:

> In D72498#1816244 , @ilya-biryukov 
> wrote:
>
> > In D72498#1815500 , @lh123 wrote:
> >
> > > - hover over the `front` , you'll see "instance-method `front` → 
> > > `std::vector >::reference`".
> > > - hover over the `push_back`, you'll see "`std::vector > > std::allocator >::value_type && __x`".
> >
> >
> > These look terrible and are the great examples where showing canonical 
> > types results in better output than canonical types.
> >  I wonder why we add `std::vector>::` in the 
> > first place, I believe the standard library uses `value_type` in the 
> > declaration. Showing `value_type` is not great, but at least that doesn't 
> > uglify what was written in the code in the first place.
> >  FWIW, I think the perfect output in those cases would be `int (aka 
> > value_type)`
>
>
> Indeed. Another illustrative example, the return type of 
> `vector::at()` - we'd probably want `int64&` here, rather than 
> `vector<...>::reference` or `unsigned long long`/`unsigned long` depending on 
> platform.


Currently, I think that in most cases, showing both expanded (canonical) and 
spelled types is sufficient.

> This has been used in ycmd for ~4 years without complaint. 
> https://github.com/clangd/clangd/issues/58#issuecomment-507800970




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72498/new/

https://reviews.llvm.org/D72498



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72591: [clang] [test] Fix riscv-toolchain-extra to be less picky about paths

2020-01-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: edward-jones, MaskRay.
Herald added subscribers: luismarques, apazos, sameer.abuasal, pzheng, 
s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, zzheng, shiva0217, kito-cheng, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb.

Fix riscv-toolchain-extra tests to pass when CLANG_RESOURCE_DIR is set
to another value than the default.


https://reviews.llvm.org/D72591

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -25,8 +25,8 @@
 // C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
 // C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
 // C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -25,8 +25,8 @@
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
 // C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
 // C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib/crt0.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv32.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv32.o"
 // C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib"
 // C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv32.a"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv32.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv32.a"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv32.o"


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -25,8 +25,8 @@
 // C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: 

[PATCH] D72594: [clangd] Include expression in DecltypeTypeLoc sourcerange while building SelectionTree

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Currently AST only contains the location for `decltype` keyword,
therefore we were skipping expressions inside decltype while building selection
tree.

This patch extends source range in such cases to contain the expression as well.
A proper fix would require changes to Sema and DecltypeTypeLoc to contain these
location information.

Fixes https://github.com/clangd/clangd/issues/250.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72594

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -323,6 +323,12 @@
 Foo x = [[^12_ud]];
   )cpp",
   "UserDefinedLiteral"},
+  {
+  R"cpp(
+int a;
+decltype([[^a]] + a) b;
+)cpp",
+  "DeclRefExpr"},
   };
   for (const Case  : Cases) {
 Annotations Test(C.Code);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -527,6 +527,16 @@
   // don't intersect the selection may be recursively skipped.
   bool canSafelySkipNode(const DynTypedNode ) {
 SourceRange S = N.getSourceRange();
+if (auto *TL = N.get()) {
+  // DecltypeTypeLoc only contains the SourceRange for `decltype` keyword.
+  // We are extending the SourceRange up until the end of the expression
+  // inside decltype. Note that this will not include the closing
+  // parenthese.
+  // FIXME: Alter DecltypeTypeLoc to contain parentheses locations and get
+  // rid of this patch.
+  if (auto DT = TL->getAs())
+S.setEnd(DT.getUnderlyingExpr()->getEndLoc());
+}
 if (!SelChecker.mayHit(S)) {
   dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy), indent());
   dlog("{1}skipped range = {0}", S.printToString(SM), indent(1));


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -323,6 +323,12 @@
 Foo x = [[^12_ud]];
   )cpp",
   "UserDefinedLiteral"},
+  {
+  R"cpp(
+int a;
+decltype([[^a]] + a) b;
+)cpp",
+  "DeclRefExpr"},
   };
   for (const Case  : Cases) {
 Annotations Test(C.Code);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -527,6 +527,16 @@
   // don't intersect the selection may be recursively skipped.
   bool canSafelySkipNode(const DynTypedNode ) {
 SourceRange S = N.getSourceRange();
+if (auto *TL = N.get()) {
+  // DecltypeTypeLoc only contains the SourceRange for `decltype` keyword.
+  // We are extending the SourceRange up until the end of the expression
+  // inside decltype. Note that this will not include the closing
+  // parenthese.
+  // FIXME: Alter DecltypeTypeLoc to contain parentheses locations and get
+  // rid of this patch.
+  if (auto DT = TL->getAs())
+S.setEnd(DT.getUnderlyingExpr()->getEndLoc());
+}
 if (!SelChecker.mayHit(S)) {
   dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy), indent());
   dlog("{1}skipped range = {0}", S.printToString(SM), indent(1));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Following crashes for me with `clang++ -g2`:

  struct Thing {
void crash(Thing ) {
  auto Lambda = [&] {
Other.external();
  };
  Lambda();
}
void external();
  };
  
  void test(Thing , Thing ) {
A.crash(B);
  }

Haven't yet verified that it's this commit, but certainly looks related. Will 
revert once this is confirmed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70524/new/

https://reviews.llvm.org/D70524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D70524#1816492 , @sammccall wrote:

> Following crashes for me with `clang++ -g2`:


This crashes at 6d6a4590c5d4 
 but not 
at c958639098a8 
. Reverted 
in e45fcfc3aa57bb237fd4fd694d0c257be66d5482 
, up to 
you whether the prev patch should be reverted too.

Stack trace:

  1. parser at end of file
  2.Code generation
   #0 0x0263ea84 PrintStackTrace 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/Support/Unix/Signals.inc:564:13
   #1 0x0263ea84 PrintStackTraceSignalHandler(void*) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/Support/Unix/Signals.inc:624:0
   #2 0x0263c61e llvm::sys::RunSignalHandlers() 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/Support/Signals.cpp:69:18
   #3 0x0263ee9c SignalHandler(int) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/Support/Unix/Signals.inc:396:3
   #4 0x7fc9c4fad3a0 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x123a0)
   #5 0x7fc9c424ecfb raise (/lib/x86_64-linux-gnu/libc.so.6+0x36cfb)
   #6 0x7fc9c42398ad abort (/lib/x86_64-linux-gnu/libc.so.6+0x218ad)
   #7 0x7fc9c423977f (/lib/x86_64-linux-gnu/libc.so.6+0x2177f)
   #8 0x7fc9c4247542 (/lib/x86_64-linux-gnu/libc.so.6+0x2f542)
   #9 0x030c08a6 
(/usr/local/google/home/sammccall/llvmbuild-mono/bin/clang-10+0x30c08a6)
  #10 0x030c5b7e 
llvm::DwarfUnit::applySubprogramDefinitionAttributes(llvm::DISubprogram const*, 
llvm::DIE&) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1176:15
  #11 0x030c4e46 
llvm::DwarfUnit::applySubprogramAttributes(llvm::DISubprogram const*, 
llvm::DIE&, bool) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1221:9
  #12 0x03106a0f getOperand 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/include/llvm/IR/Metadata.h:1078:5
  #13 0x03106a0f getOperandAs 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/include/llvm/IR/DebugInfoMetadata.h:132:0
  #14 0x03106a0f getStringOperand 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/include/llvm/IR/DebugInfoMetadata.h:136:0
  #15 0x03106a0f getName 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/include/llvm/IR/DebugInfoMetadata.h:1793:0
  #16 0x03106a0f 
llvm::DwarfCompileUnit::applySubprogramAttributesToDefinition(llvm::DISubprogram
 const*, llvm::DIE&) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1299:0
  #17 0x030a01d2 getSkeleton 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h:116:12
  #18 0x030a01d2 forBothCUs<(lambda at 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1090:9)>
 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:509:0
  #19 0x030a01d2 llvm::DwarfDebug::finishSubprogramDefinitions() 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1088:0
  #20 0x030a029a llvm::DwarfDebug::finalizeModuleInfo() 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1099:3
  #21 0x030a0978 llvm::DwarfDebug::endModule() 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1238:3
  #22 0x03084da3 ~TimeRegion 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/include/llvm/Support/Timer.h:152:9
  #23 0x03084da3 llvm::AsmPrinter::doFinalization(llvm::Module&) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1485:0
  #24 0x01fc9fa5 llvm::FPPassManager::doFinalization(llvm::Module&) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/IR/LegacyPassManager.cpp:1535:13
  #25 0x01fca5f6 runOnModule 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/IR/LegacyPassManager.cpp:1611:41
  #26 0x01fca5f6 llvm::legacy::PassManagerImpl::run(llvm::Module&) 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/lib/IR/LegacyPassManager.cpp:1694:0
  #27 0x02824eb9 ~TimeTraceScope 
/usr/local/google/home/sammccall/src/llvm-mono/llvm/include/llvm/Support/TimeProfiler.h:74:35
  #28 0x02824eb9 EmitAssembly 
/usr/local/google/home/sammccall/src/llvm-mono/clang/lib/CodeGen/BackendUtil.cpp:912:0
  #29 0x02824eb9 clang::EmitBackendOutput(clang::DiagnosticsEngine&, 
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, 
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout 
const&, llvm::Module*, clang::BackendAction, 
std::unique_ptr >) 

[PATCH] D69868: Allow "callbr" to return non-void values

2020-01-13 Thread Bill Wendling via Phabricator via cfe-commits
void marked 2 inline comments as done.
void added inline comments.



Comment at: llvm/lib/CodeGen/MachineVerifier.cpp:701
+  } else if (MBB->succ_size() == LandingPadSuccs.size() ||
+ MBB->succ_size() == IndirectPadSuccs.size()) {
 // It's possible that the block legitimately ends with a noreturn

jyknight wrote:
> void wrote:
> > jyknight wrote:
> > > This isn't correct.
> > > 
> > > This line here, is looking at a block which doesn't end in a jump to a 
> > > successor. So, it's trying to verify that the successor list makes sense 
> > > in that context.
> > > 
> > > The unstated assumption in the code is that the only successors will be 
> > > landing pads. Instead of actually checking each one, instead it just 
> > > checks that the count is the number of landing pads, with the assumption 
> > > that all the successors should be landing pads, and that all the landing 
> > > pads should be successors.
> > > 
> > > The next clause is then checking for the case where there's a fallthrough 
> > > to the next block. In that case, the successors should've been all the 
> > > landing pads, and the single fallthrough block.
> > > 
> > > Adding similar code to check for the number of callbr targets doesn't 
> > > really make sense. It's certainly not the case that all callbr targets 
> > > are targets of all 
> > > callbr instructions. And even if it was, this still wouldn't be counting 
> > > things correctly.
> > > 
> > > 
> > > However -- I think i'd expect analyzeBranch to error out (returning true) 
> > > when confronted by a callbr instruction, because it cannot actually tell 
> > > what's going on there. If that were the case, nothing in this block 
> > > should even be invoked. But I guess that's probably not happening, due to 
> > > the terminator being followed by non-terminators.
> > > 
> > > That seems likely to be a problem that needs to be fixed. (And if that is 
> > > fixed, I think the changes here aren't needed anymore)
> > > 
> > > 
> > Your comment is very confusing. Could you please give an example of where 
> > this fails?
> Sorry about that, I should've delimited the parts of that message better...
> Basically:
> - Paragraphs 2-4 are describing why the code before this patch appears to be 
> correct for landing pad, even though it's taking some shortcuts and making 
> some non-obvious assumptions.
> - Paragraph 5 ("Adding similar code"...) is why it's not correct for callbr.
> - Paragraph 6-7 are how I'd suggest to resolve it.
> 
> 
> I believe the code as of your patch will fail validation if you have a callbr 
> instruction which has a normal-successor block which is an indirect target of 
> a *different* callbr in the function.
> 
> I believe it'll also fail if you have any landing-pad successors, since those 
> aren't being added to the count of expected successors, but rather checked 
> separately.
> 
> But more seriously than these potential verifier failures, I expect that 
> analyzeBranch returning wrong answers (in that it may report that a block 
> unconditionally-jumps to a successor, while it really has both a callbr and 
> jump, separated by the non-terminator copies) will cause miscompilation. I'm 
> not sure exactly how that will exhibit, but I'm pretty sure it's not going to 
> be good.
> 
> And, if analyzeBranch properly said "no idea" when confronted by callbr 
> control flow, then this code in the verifier wouldn't be reached.
I didn't need a delineation of the parts of the comment. I needed a clearer 
description of what your concern is, and to give an example of code that fails 
here.

This bit of code is simply saying that if the block containing the 
`INLINEASM_BR` doesn't end with a `BR` instruction, then the number of its 
successors should be equal to the number of indirect successors. This is 
correct, as it's not valid to have a duplicate label used in a `callbr` 
instruction:

```
$ llc -o /dev/null x.ll
Duplicate callbr destination!
  %3 = callbr i32 asm sideeffect "testl $0, $0; testl $1, $1; jne ${2:l}", 
"={si},r,X,0,~{dirflag},~{fpsr},~{flags}"(i32 %2, i8* blockaddress(@test1, 
%asm.fallthrough), i32 %1) #2
  to label %asm.fallthrough [label %asm.fallthrough], !srcloc !6
./bin/llc: x.ll: error: input module is broken!
```

A `callbr` with a normal successor block that is the indirect target of a 
different `callbr` isn't really relevant here, unless I'm misunderstanding what 
`analyzeBranch` returns. There would be two situations:

1. The MBB ends in a fallthrough, which is the case I mentioned above, or

2. The MBB ends in a `BR` instruction, in which case it won't be in this block 
of code, but the block below.

If `analyzeBranch` is not taking into account potential `COPY` instructions 
between `INLINEASM_BR` and `BR`, then it needs to be addressed there (I'll 
verify that it is). I *do* know that this code is reached by the verifier, so 
it handles it to some degree. :-)



[PATCH] D72594: [clangd] Include expression in DecltypeTypeLoc sourcerange while building SelectionTree

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61742 tests passed, 0 failed 
and 780 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72594/new/

https://reviews.llvm.org/D72594



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] b96ec49 - [clangd] Remove raw string literals in macros

2020-01-13 Thread Oliver Stannard via cfe-commits

Author: Oliver Stannard
Date: 2020-01-13T11:45:05Z
New Revision: b96ec492d34ecf31fd2c8d2f0033f00e36cc2b9c

URL: 
https://github.com/llvm/llvm-project/commit/b96ec492d34ecf31fd2c8d2f0033f00e36cc2b9c
DIFF: 
https://github.com/llvm/llvm-project/commit/b96ec492d34ecf31fd2c8d2f0033f00e36cc2b9c.diff

LOG: [clangd] Remove raw string literals in macros

Older (but still supported) versions of GCC don't handle C++11 raw
string literals in macro parameters correctly.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/FormattedStringTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp 
b/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
index 825bf5bbd866..80d0934bed3e 100644
--- a/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -194,10 +194,10 @@ TEST(BulletList, Render) {
   EXPECT_EQ(L.asPlainText(), "- foo");
 
   L.addItem().addParagraph().appendText("bar");
-  EXPECT_EQ(L.asMarkdown(), R"md(- foo
-- bar)md");
-  EXPECT_EQ(L.asPlainText(), R"pt(- foo
-- bar)pt");
+  llvm::StringRef Expected = R"md(- foo
+- bar)md";
+  EXPECT_EQ(L.asMarkdown(), Expected);
+  EXPECT_EQ(L.asPlainText(), Expected);
 
   // Nested list, with a single item.
   Document  = L.addItem();
@@ -215,24 +215,26 @@ TEST(BulletList, Render) {
   Document  = InnerList.addItem();
   DeepDoc.addParagraph().appendText("baz");
   DeepDoc.addParagraph().appendText("baz");
-  EXPECT_EQ(L.asMarkdown(), R"md(- foo
+  StringRef ExpectedMarkdown = R"md(- foo
 - bar
 - foo  
   baz  
   - foo  
 - baz  
-  baz)md");
-  EXPECT_EQ(L.asPlainText(), R"pt(- foo
+  baz)md";
+  EXPECT_EQ(L.asMarkdown(), ExpectedMarkdown);
+  StringRef ExpectedPlainText = R"pt(- foo
 - bar
 - foo
   baz
   - foo
 - baz
-  baz)pt");
+  baz)pt";
+  EXPECT_EQ(L.asPlainText(), ExpectedPlainText);
 
   // Termination
   Inner.addParagraph().appendText("after");
-  EXPECT_EQ(L.asMarkdown(), R"md(- foo
+  ExpectedMarkdown = R"md(- foo
 - bar
 - foo  
   baz  
@@ -240,15 +242,17 @@ TEST(BulletList, Render) {
 - baz  
   baz
 
-after)md");
-  EXPECT_EQ(L.asPlainText(), R"pt(- foo
+after)md";
+  EXPECT_EQ(L.asMarkdown(), ExpectedMarkdown);
+  ExpectedPlainText = R"pt(- foo
 - bar
 - foo
   baz
   - foo
 - baz
   baz
-after)pt");
+after)pt";
+  EXPECT_EQ(L.asPlainText(), ExpectedPlainText);
 }
 
 } // namespace



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72245: [PoC][RISCV][LTO] Pass target-abi via module flag metadata

2020-01-13 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:151
 
+  TargetMachine::initTargetOptions(M, Conf.Options);
+

tejohnson wrote:
> lenary wrote:
> > tejohnson wrote:
> > > This is going to be problematic. The Conf is a reference to the Config 
> > > object saved on the LTO class instance shared by all backend invocations 
> > > (the regular LTO module if one exists and any ThinLTO modules). They will 
> > > end up clobbering each other's values here - although from the assert in 
> > > initTargetOptions I see they are required to all have the same value 
> > > anyway. Still, it is not good as the assert may actually be missed with 
> > > unlucky interference between the threads. The Config object here should 
> > > really be marked const, let me see if I can change that.
> > > 
> > > You could make a copy of the Config here, but that essentially misses the 
> > > assertion completely. 
> > > 
> > > A better way to do this would be in LTO::addModule, which is invoked 
> > > serially to add each Module to the LTO object.
> > > 
> > > However - this misses other places that invoke createTargetMachine - 
> > > should other places be looking at this new module flag as well? One 
> > > example I can think of is the old LTO API (*LTOCodeGenerator.cpp files), 
> > > used by linkers such as ld64 and some other proprietary linkers and the 
> > > llvm-lto testing tool. But I have no idea about other invocations of 
> > > createTargetMachine.
> > > 
> > > Note that changes to LTO.cpp/LTOBackend.cpp (the new LTO API) needs some 
> > > kind of llvm-lto2 based test.
> > Thank you for this feedback. 
> > 
> > I've been looking at how to add an overridable TargetMachine hook which is 
> > not dissimilar to this static function, but is overridable by TargetMachine 
> > subclasses. It sounds like this approach will also not work (unless the 
> > TargetMachine is allowed to update its (Default)Options in LTO without 
> > issue). 
> > 
> > I am hoping to get a patch out today for review (which does not include the 
> > RISC-V specific parts of this patch, and only includes a default empty 
> > implementation), but I imagine it will remain unsatisfactory for LTO for 
> > the same reasons this is.
> Presumably you could still do the same thing I'm suggesting here - validate 
> and aggregate the value across modules in LTO::addModule. Then your hook 
> would just check the aggregated setting on the Config.
D72624 is the patch I have prepared, noting I haven't had time to implement the 
aggregation yet, which suggests that patch's approach is too general.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72245/new/

https://reviews.llvm.org/D72245



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-13 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In D71451#1816269 , @Jac1494 wrote:

> ping


I'd be curious to the answer to David's questions. If the size increase is 
because of unused extern variables coming in from libc or something then it 
doesn't seem worth the cost.




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4598
+  if (!(DebugKind == clang::codegenoptions::FullDebugInfo))
+return;
 

nit: 

```
if (DebugKind < clang::codegenoptions::FullDebugInfo)
  return

```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71451/new/

https://reviews.llvm.org/D71451



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71365: expand printf when compiling HIP to AMDGPU

2020-01-13 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGenHIP/printf.cpp:18
+}
+
+// CHECK: [[BEGIN:%.*]]   = call i64 @__ockl_printf_begin(i64 0)

sameerds wrote:
> sameerds wrote:
> > arsenm wrote:
> > > This could use a lot more testcases. Can you add some half, float, and 
> > > double as well as pointers (including different address spaces) and 
> > > vectors?
> > I am not sure what exactly should be tested. The validity of this expansion 
> > depends on the signature of the builtin printf function. Since printf is 
> > variadic, the "default argument promotions" in the C/C++ spec guarantee 
> > that the arguments are 32/64 bit integers or doubles if they are not 
> > pointers. The printf signature as well as the device library functions are 
> > defined using only generic pointers, so the address space does not matter. 
> > Non-scalar arguments are not supported, which is checked by another test 
> > using a struct. I could add a vector there, but that doesn't seem to be 
> > adding any value.
> Bump!
The address space shouldn't matter, but it's good to make sure it doesn't. 

Vector arguments are 100% supported in OpenCL printf, and are not subject to 
argument promotion. You have to use a width modifier for them though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71365/new/

https://reviews.llvm.org/D71365



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Hover.cpp:552
+// For functions we display signature in a list form, e.g.:
+// Generates `x` from:
+// - `bool param1`

Comment needs updating



Comment at: clang-tools-extra/clangd/Hover.cpp:567
+  } else if (Type) {
+Output.addParagraph().appendText("Type: ").appendCode(*Type);
   }

consider **`∈`**, which would be short and symmetrical with the arrow for 
return type...

Too obscure?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72623/new/

https://reviews.llvm.org/D72623



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72527: [clang-tidy] adjust scripts to subsubsections in Release Notes

2020-01-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D72527#1817518 , @Eugene.Zelenko 
wrote:

> Both scripts works fine. However rename script should also sort entries 
> alphabetically, but probably this should be separate patch.


Yep, sorting of the list on rename is a separate issue.
The patch LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72527/new/

https://reviews.llvm.org/D72527



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72612: [AArch64][SVE] Add ImmArg property to intrinsics with immediates

2020-01-13 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1099
+class AsmVectorIndexOpnd
+: Operand, ComplexPattern", []> 
{
   let ParserMatchClass = mc;

@efriedma  @rengolin The idea here is to use a ComplexPattern to match either a 
TargetConstant or a Constant (as at this point in selectiondag, it probably no 
longer matters what kind of constant it is, as we want to match an 
instruction). This avoids having to duplicate patternfragments for TImmLeaf and 
ImmLeaf for all the operands deriving from AsmVectorIndexOpnd.

Any thoughts on this approach?



Comment at: llvm/lib/Target/AArch64/SVEInstrFormats.td:4386
 
-  def : SVE_3_Op_Imm_Pat(NAME # _B)>;
-  def : SVE_3_Op_Imm_Pat(NAME # _H)>;
-  def : SVE_3_Op_Imm_Pat(NAME # _S)>;
-  def : SVE_3_Op_Imm_Pat(NAME # _D)>;
+  def : SVE_3_Op_Cpx_Imm_Pat(NAME # _B)>;
+  def : SVE_3_Op_Cpx_Imm_Pat(NAME # _H)>;

I think these can just as well use `tvecshiftR8`, `tvecshiftR16`, (etc) as 
those already exist.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72612/new/

https://reviews.llvm.org/D72612



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69970: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood (reland with fixes)

2020-01-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk closed this revision.
vsk added a comment.

Yes, this landed in 568db780bb7267651a902da8e85bc59fc89aea70 
.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69970/new/

https://reviews.llvm.org/D69970



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2020-01-13 Thread Stella Stamenova via Phabricator via cfe-commits
stella.stamenova added a comment.

This also broke a number of the tests on the Windows LLDB bot, so when you get 
around to resubmitting the change with a fix, please make sure the bot doesn't 
get broken again: 
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/12551


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70524/new/

https://reviews.llvm.org/D70524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72500/new/

https://reviews.llvm.org/D72500



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72579: Evaluate __{c11_,}atomic_is_lock_free to 0 (avoid libcall) if larger than MaxAtomicPromoteWidth

2020-01-13 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

If I understand this correctly, this just evaluates the query for lock free 
atomics at compile time if the size is larger than the maximum possible size 
for an atomic on the target. If that's the case, this looks fine to me. But of 
course, some of the other target maintainers might feel otherwise.
The incompatibility with GCC might be an issue for some, but I don't expect 
this to be an issue at least on PPC.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72579/new/

https://reviews.llvm.org/D72579



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72245: [PoC][RISCV][LTO] Pass target-abi via module flag metadata

2020-01-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:151
 
+  TargetMachine::initTargetOptions(M, Conf.Options);
+

This is going to be problematic. The Conf is a reference to the Config object 
saved on the LTO class instance shared by all backend invocations (the regular 
LTO module if one exists and any ThinLTO modules). They will end up clobbering 
each other's values here - although from the assert in initTargetOptions I see 
they are required to all have the same value anyway. Still, it is not good as 
the assert may actually be missed with unlucky interference between the 
threads. The Config object here should really be marked const, let me see if I 
can change that.

You could make a copy of the Config here, but that essentially misses the 
assertion completely. 

A better way to do this would be in LTO::addModule, which is invoked serially 
to add each Module to the LTO object.

However - this misses other places that invoke createTargetMachine - should 
other places be looking at this new module flag as well? One example I can 
think of is the old LTO API (*LTOCodeGenerator.cpp files), used by linkers such 
as ld64 and some other proprietary linkers and the llvm-lto testing tool. But I 
have no idea about other invocations of createTargetMachine.

Note that changes to LTO.cpp/LTOBackend.cpp (the new LTO API) needs some kind 
of llvm-lto2 based test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72245/new/

https://reviews.llvm.org/D72245



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72121: [clang-tidy] Fix readability-identifier-naming missing member variables

2020-01-13 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added a comment.

Is anyone able to commit on my behalf?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72121/new/

https://reviews.llvm.org/D72121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72634: [clangd] Improve ObjC property handling in SelectionTree.

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: dgoldman.
Herald added subscribers: cfe-commits, usaxena95, kadircet, jfb, arphaman, 
jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72634

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -323,6 +323,29 @@
 Foo x = [[^12_ud]];
   )cpp",
   "UserDefinedLiteral"},
+
+  // Objective-C OpaqueValueExpr/PseudoObjectExpr has weird ASTs.
+  // Need to traverse the contents of the OpaqueValueExpr to the POE,
+  // and ensure we traverse only the syntactic form of the 
PseudoObjectExpr.
+  {
+  R"cpp(
+@interface I{}
+@property(retain) I*x;
+@property(retain) I*y;
+@end
+void test(I *f) { [[^f]].x.y = 0; }
+  )cpp",
+  "DeclRefExpr"},
+  {
+  R"cpp(
+@interface I{}
+@property(retain) I*x;
+@property(retain) I*y;
+@end
+void test(I *f) { [[f.^x]].y = 0; }
+  )cpp",
+  "ObjCPropertyRefExpr"},
+
   };
   for (const Case  : Cases) {
 Annotations Test(C.Code);
@@ -333,6 +356,7 @@
 // FIXME: Auto-completion in a template requires disabling delayed template
 // parsing.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+TU.ExtraArgs.push_back("-xobjective-c++");
 
 auto AST = TU.build();
 auto T = makeSelectionTree(C.Code, AST);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -511,7 +511,8 @@
   [[f.x]].y = 0;
 }
   )cpp";
-  EXPECT_DECLS("OpaqueValueExpr", "@property(atomic, retain, readwrite) I *x");
+  EXPECT_DECLS("ObjCPropertyRefExpr",
+   "@property(atomic, retain, readwrite) I *x");
 
   Code = R"cpp(
 @protocol Foo
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -462,6 +462,14 @@
  TraverseStmt(S->getRangeInit()) && TraverseStmt(S->getBody());
 });
   }
+  // OpaqueValueExpr blocks traversal, we must explicitly traverse it.
+  bool TraverseOpaqueValueExpr(OpaqueValueExpr *E) {
+return traverseNode(E, [&] { return TraverseStmt(E->getSourceExpr()); });
+  }
+  // We only want to traverse the *syntactic form* to understand the selection.
+  bool TraversePseudoObjectExpr(PseudoObjectExpr *E) {
+return traverseNode(E, [&] { return TraverseStmt(E->getSyntacticForm()); 
});
+  }
 
 private:
   using Base = RecursiveASTVisitor;


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -323,6 +323,29 @@
 Foo x = [[^12_ud]];
   )cpp",
   "UserDefinedLiteral"},
+
+  // Objective-C OpaqueValueExpr/PseudoObjectExpr has weird ASTs.
+  // Need to traverse the contents of the OpaqueValueExpr to the POE,
+  // and ensure we traverse only the syntactic form of the PseudoObjectExpr.
+  {
+  R"cpp(
+@interface I{}
+@property(retain) I*x;
+@property(retain) I*y;
+@end
+void test(I *f) { [[^f]].x.y = 0; }
+  )cpp",
+  "DeclRefExpr"},
+  {
+  R"cpp(
+@interface I{}
+@property(retain) I*x;
+@property(retain) I*y;
+@end
+void test(I *f) { [[f.^x]].y = 0; }
+  )cpp",
+  "ObjCPropertyRefExpr"},
+
   };
   for (const Case  : Cases) {
 Annotations Test(C.Code);
@@ -333,6 +356,7 @@
 // FIXME: Auto-completion in a template requires disabling delayed template
 // parsing.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+TU.ExtraArgs.push_back("-xobjective-c++");
 
 auto AST = TU.build();
 auto T = makeSelectionTree(C.Code, AST);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -511,7 +511,8 @@
   [[f.x]].y = 0;
 }
   )cpp";
-  EXPECT_DECLS("OpaqueValueExpr", 

[PATCH] D72634: [clangd] Improve ObjC property handling in SelectionTree.

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61796 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72634/new/

https://reviews.llvm.org/D72634



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72362: [clang-tidy] misc-no-recursion: a new check

2020-01-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked 3 inline comments as done.
lebedev.ri added a comment.

In D72362#1817599 , @bader wrote:

> Does it make sense to implement such diagnostics in clang Sema, considering 
> that OpenCL does not allow recursion?
>  We implemented similar diagnostics for SYCL programming model and would be 
> like to upstream it to clang later 
> (https://github.com/intel/llvm/commit/4efe9fcf2dc6f6150b5b477b0f8320ea13a7f596).
>  Can we somehow leverage this work for the compiler?


Implementing it elsewhere will be more restrictive in the future - somehow i 
suspect
it will be easier to make clang-tidy CTU-aware rather than clang sema.

That being said, is SYCL inherently single-TU, does it not support
linking multiple separately compiled object files together?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72362/new/

https://reviews.llvm.org/D72362



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72624: [WIP] TargetMachine Hook for Module Metadata

2020-01-13 Thread Sam Elliott via Phabricator via cfe-commits
lenary created this revision.
lenary added reviewers: tejohnson, dblaikie, khchen, dsanders, echristo.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, liufengdb, 
herhut, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, 
shauheen, burmako, jpienaar, rriddle, mehdi_amini, dang, dexonsmith, steven_wu, 
hiraditya.
Herald added projects: clang, LLDB, LLVM.

This patch attempts to add a target-overridable hook for allowing module 
metadata
to override TargetMachine options, especially during LTO.

The new hook is called `TargetMachine::resetTargetDefaultOptions` and takes the
`llvm::Module` so that the module metadata can be read with the API provided
by `llvm::Module`.

It is not clear that this patch handles LTO correctly at the moment.

This patch relates to D72245  and D72246 
 and the discussion in
http://lists.llvm.org/pipermail/llvm-dev/2020-January/138151.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72624

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
  llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.rst
  llvm/examples/Kaleidoscope/Chapter8/toy.cpp
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/lib/Target/TargetMachineC.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/opt/opt.cpp
  mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
  mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -110,8 +110,9 @@
   }
   std::unique_ptr machine(
   target->createTargetMachine(targetTriple, "generic", "", {}, {}));
-  llvmModule->setDataLayout(machine->createDataLayout());
   llvmModule->setTargetTriple(targetTriple);
+  machine->resetTargetDefaultOptions(*llvmModule);
+  llvmModule->setDataLayout(machine->createDataLayout());
   return false;
 }
 
Index: mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
===
--- mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -142,6 +142,7 @@
   }
 
   // Set the data layout of the llvm module to match what the ptx target needs.
+  targetMachine->resetTargetDefaultOptions(llvmModule);
   llvmModule.setDataLayout(targetMachine->createDataLayout());
 
   auto ptx = translateModuleToPtx(llvmModule, *targetMachine);
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -674,6 +674,8 @@
 
   std::unique_ptr TM(Machine);
 
+  TM->resetTargetDefaultOptions(*M);
+
   // Override function attributes based on CPUStr, FeaturesStr, and command line
   // flags.
   setFunctionAttributes(CPUStr, FeaturesStr, *M);
Index: llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
===
--- llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
+++ llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
@@ -123,6 +123,7 @@
   //
 
   M->setTargetTriple(TM->getTargetTriple().normalize());
+  TM->resetTargetDefaultOptions(*M);
   M->setDataLayout(TM->createDataLayout());
   setFunctionAttributes(TM->getTargetCPU(), TM->getTargetFeatureString(), *M);
 
Index: llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
===
--- llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
+++ llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
@@ -91,6 +91,7 @@
 
   // Set up the module to build for our target.
   M->setTargetTriple(TM->getTargetTriple().normalize());
+  TM->resetTargetDefaultOptions(*M);
   M->setDataLayout(TM->createDataLayout());
 
   // Build up a PM to do instruction selection.
Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -504,6 +504,9 @@
 TLII.disableAllFunctions();
   PM.add(new TargetLibraryInfoWrapperPass(TLII));
 
+  // Initialise target default options from module metadata
+  Target->resetTargetDefaultOptions(*M);
+
   // Add the target data from the target machine, if it exists, or the module.
   M->setDataLayout(Target->createDataLayout());
 
Index: llvm/lib/Target/TargetMachineC.cpp
===
--- llvm/lib/Target/TargetMachineC.cpp
+++ llvm/lib/Target/TargetMachineC.cpp
@@ -193,6 +193,7 @@
 
   std::string error;

[PATCH] D72625: [clangd] Render header of hover card as a heading

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72625

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1631,6 +1631,7 @@
 }
   }
 }
+
 TEST(Hover, Present) {
   struct {
 const std::function Builder;
@@ -1720,6 +1721,17 @@
   }
 }
 
+// This is a separate test as headings don't create any differences in plaintext
+// mode.
+TEST(Hover, PresentHeadings) {
+  HoverInfo HI;
+  HI.Kind = index::SymbolKind::Variable;
+  HI.Name = "foo";
+  HI.Type = "type";
+
+  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -145,6 +145,15 @@
   EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
 }
 
+TEST(Document, Heading) {
+  Document D;
+  D.addHeading(1).appendText("foo");
+  D.addHeading(2).appendText("bar");
+  D.addParagraph().appendText("baz");
+  EXPECT_EQ(D.asMarkdown(), "# foo  \n## bar  \nbaz");
+  EXPECT_EQ(D.asPlainText(), "foo\nbar\nbaz");
+}
+
 TEST(CodeBlock, Render) {
   Document D;
   // Code blocks preserves any extra spaces.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -469,7 +469,10 @@
   // class `X`
   //
   // function `foo` → `int`
-  markup::Paragraph  = Output.addParagraph();
+  // Note that we are making use of a level-3 heading because VSCode renders
+  // level 1 and 2 headers in a huge font, see
+  // https://github.com/microsoft/vscode/issues/88417 for details.
+  markup::Paragraph  = Output.addHeading(3);
   Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FORMATTEDSTRING_H
 
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 #include 
 #include 
@@ -86,6 +87,9 @@
   /// Adds a block of code. This translates to a ``` block in markdown. In plain
   /// text representation, the code block will be surrounded by newlines.
   void addCodeBlock(std::string Code, std::string Language = "cpp");
+  /// Heading is a special type of paragraph that will be prepended with \p
+  /// Level many '#'s in markdown.
+  Paragraph (size_t Level);
 
   BulletList ();
 
Index: clang-tools-extra/clangd/FormattedString.cpp
===
--- clang-tools-extra/clangd/FormattedString.cpp
+++ clang-tools-extra/clangd/FormattedString.cpp
@@ -164,6 +164,19 @@
   }
   return IndentedR;
 }
+
+class Heading : public Paragraph {
+public:
+  Heading(size_t Level) : Level(Level) {}
+  void renderMarkdown(llvm::raw_ostream ) const override {
+OS << std::string(Level, '#') << ' ';
+Paragraph::renderMarkdown(OS);
+  }
+
+private:
+  size_t Level;
+};
+
 } // namespace
 
 std::string Block::asMarkdown() const {
@@ -278,6 +291,12 @@
   Children.emplace_back(std::make_unique());
   return *static_cast(Children.back().get());
 }
+
+Paragraph ::addHeading(size_t Level) {
+  assert(Level > 0);
+  Children.emplace_back(std::make_unique(Level));
+  return *static_cast(Children.back().get());
+}
 } // namespace markup
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72523: [remark][diagnostics] Using clang diagnostic handler for IR input files

2020-01-13 Thread Rong Xu via Phabricator via cfe-commits
xur marked 3 inline comments as done.
xur added inline comments.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:594
+  // SourceLoc.
+  if (Context == nullptr) {
+return FullSourceLoc();

tejohnson wrote:
> Does this only happen with IR input? Does it always happen with IR input? If 
> not, what happens when we have a non-null Context but IR input? It sounds 
> like it should still always return an invalid Loc since there is no 
> SourceManager? In that case can you set a flag on the BackendConsumer so we 
> can bail out directly in the IR input case, instead of going through the 
> motions only to get an invalid Loc back anyway? It would also be more clear.
Before this patch, IR input does not called to this function. IR input has a 
null Context (so it will seg-fault at the dereference at line 598). Context == 
nullptr should be only happening with the empty BackendConsume that installed 
in this patch. 
I tried to set Context but the whole point was to get SrouceManager which was 
not available for IR input.





Comment at: clang/lib/CodeGen/CodeGenAction.cpp:650
+  if (!Loc.isValid()) {
+MsgStream << D.getLocationStr() << ": in function "
+  << D.getFunction().getName() << ' '

tejohnson wrote:
> Can you add a test for this one?
> 
> Also, what determines the format of the message when Loc is valid? I was 
> trying to figure out where that got determined, but couldn't easily track it 
> down. 
Do you mean adding a test to test the path of branch starting line 650?
(For the case of valid Loc, I don't think we need to test as it's not changed.)

If so, there is already a test for this:
clang/test/CodeGen/backend-unsupported-error.ll
I think this calls to llvm's diagnostic handler for IR input files (before this 
patch). The format is here:
DiagnosticInfoUnsupported::print(...) in  llvm/lib/IR/DiagnosticInfo.cpp

For the case of input other than IR files, the Diags should go to clang 
diagnostic handler.  This patch might change the behavior. 

I think I will check Context == nullptr directly (rather Loc.isValid). This way 
we don't need to call into getBestLocationFromDebugLoc(), and it will not 
affect non-IR input files.




Comment at: clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c:8
+// RUN: llvm-lto -thinlto -o %t %t1.bo
+// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo 
-fthinlto-index=%t.thinlto.bc -emit-obj -Rpass-analysis=info 2>&1 | FileCheck 
%s -check-prefix=CHECK-REMARK
+// RUN: llvm-profdata merge -o %t2.profdata %S/Inputs/thinlto_expect2.proftext

tejohnson wrote:
> In this case (since no -Wmisexpect), presumably we should not be getting the 
> warning, whereas without your fix we were, correct? In that case, please add 
> a NOT check to confirm that we don't get the message anymore.
Yes. You are right. 
I will add a NOT check to confirm this.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72523/new/

https://reviews.llvm.org/D72523



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72630: [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

2020-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh, JonasToth.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Initialising a pointer from nullptr involves an implicit cast.
Ignore it after getting initialiser from InitListExpr.

Fixes: PR4440


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72630

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -291,7 +291,7 @@
   int e1{};
   int e2 = 0;
   int e3 = {5};
-  int e4 = 5;
+  int e4{5};
   int e5 = -5;
   int e6 = +5;
 };
@@ -315,7 +315,7 @@
   double e1{};
   double e2 = 0.0;
   double e3 = 5.0;
-  double e4 = -5.0;
+  double e4{-5.0};
   double e5 = +5.0;
 };
 
@@ -333,7 +333,7 @@
   // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
   bool e1{};
   bool e2 = false;
-  bool e3 = true;
+  bool e3{true};
 };
 
 struct ExistingEnum {
@@ -365,7 +365,7 @@
   // CHECK-FIXES: ExistingPointer(long) :  e4() {}
   int *e1{};
   int *e2 = 0;
-  int *e3 = nullptr;
+  int *e3{nullptr};
   int **e4 = 
 };
 
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -137,7 +137,7 @@
 static const Expr *getInitializer(const Expr *E) {
   auto *InitList = dyn_cast(E);
   if (InitList && InitList->getNumInits() == 1)
-return InitList->getInit(0);
+return InitList->getInit(0)->IgnoreParenImpCasts();
   return E;
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -291,7 +291,7 @@
   int e1{};
   int e2 = 0;
   int e3 = {5};
-  int e4 = 5;
+  int e4{5};
   int e5 = -5;
   int e6 = +5;
 };
@@ -315,7 +315,7 @@
   double e1{};
   double e2 = 0.0;
   double e3 = 5.0;
-  double e4 = -5.0;
+  double e4{-5.0};
   double e5 = +5.0;
 };
 
@@ -333,7 +333,7 @@
   // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
   bool e1{};
   bool e2 = false;
-  bool e3 = true;
+  bool e3{true};
 };
 
 struct ExistingEnum {
@@ -365,7 +365,7 @@
   // CHECK-FIXES: ExistingPointer(long) :  e4() {}
   int *e1{};
   int *e2 = 0;
-  int *e3 = nullptr;
+  int *e3{nullptr};
   int **e4 = 
 };
 
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -137,7 +137,7 @@
 static const Expr *getInitializer(const Expr *E) {
   auto *InitList = dyn_cast(E);
   if (InitList && InitList->getNumInits() == 1)
-return InitList->getInit(0);
+return InitList->getInit(0)->IgnoreParenImpCasts();
   return E;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 292562c - Try number 2 for fixing bot failures

2020-01-13 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-13T10:12:35-08:00
New Revision: 292562c0046c72ea1ed229dbe13a89dca73e5b89

URL: 
https://github.com/llvm/llvm-project/commit/292562c0046c72ea1ed229dbe13a89dca73e5b89
DIFF: 
https://github.com/llvm/llvm-project/commit/292562c0046c72ea1ed229dbe13a89dca73e5b89.diff

LOG: Try number 2 for fixing bot failures

Additional fixes for bot failures from 2af97be8027a0823b88d4b6a07fc5eedb440bc1f.
Remove more exact matching on AnalyisManagers, as they can vary.
Also allow different orders between LoopAnalysis and
BranchProbabilityAnalysis as that can vary due to both being accessed in
the parameter list of a call.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 666b9444b326..ce80ff744ed1 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -70,11 +70,11 @@
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Finished llvm::Function pass manager run.
-; CHECK-O: Running pass: RequireAnalysisPass>
+; CHECK-O: Running pass: RequireAnalysisPass>
-; CHECK-O: Running pass: 
ModuleToPostOrderCGSCCPassAdaptor 
> >
+; CHECK-O: Running pass: RequireAnalysisPass> on main
-; CHECK-O: Running pass: 
FunctionToLoopPassAdaptor > on main
+; CHECK-O: Running pass: 
RequireAnalysisPass > on main
+; CHECK-O: Running pass: FunctionToLoopPassAdaptor>
+; CHECK-O: Running pass: RequireAnalysisPass >
 ; CHECK-O: Starting llvm::Function pass manager run.
@@ -208,7 +208,7 @@
 ; CHECK-O: Running pass: LoopUnrollPass on main
 ; CHECK-O: Running pass: WarnMissedTransformationsPass on main
 ; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running pass: 
RequireAnalysisPass> on main
+; CHECK-O: Running pass: 
RequireAnalysisPass on main
 ; CHECK-O: Starting llvm::Function pass manager run.
 ; CHECK-O: Running pass: LoopSimplifyPass on main

diff  --git a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
index bb5bbebd8570..efdcc946cf47 100644
--- a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
@@ -59,8 +59,10 @@
 ; CHECK-O-NEXT: Running analysis: AAManager
 ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O-NEXT: Running analysis: BlockFrequencyAnalysis on foo
-; CHECK-O-NEXT: Running analysis: BranchProbabilityAnalysis on foo
-; CHECK-O-NEXT: Running analysis: LoopAnalysis on foo
+; These next two can appear in any order since they are accessed as parameters
+; on the same call to BlockFrequencyInfo::calculate.
+; CHECK-O-DAG: Running analysis: BranchProbabilityAnalysis on foo
+; CHECK-O-DAG: Running analysis: LoopAnalysis on foo
 ; CHECK-O-NEXT: Running pass: SimplifyCFGPass
 ; CHECK-O-NEXT: Finished llvm::Function pass manager run.
 ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA

diff  --git a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
index 1b90fb3a2f55..d8ea6b6d7207 100644
--- a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
@@ -57,7 +57,7 @@
 ; CHECK-O-NEXT: Running pass: SampleProfileLoaderPass
 ; CHECK-O-NEXT: Running analysis: ProfileSummaryAnalysis
 ; CHECK-O-NEXT: Running analysis: CallGraphAnalysis
-; CHECK-O-NEXT: Running pass: 
RequireAnalysisPass>
+; CHECK-O-NEXT: Running pass: RequireAnalysisPass >
+; CHECK-O123-NEXT: Running pass: 
ModuleToPostOrderCGSCCPassAdaptor> on
+; CHECK-O-NEXT: Running pass: RequireAnalysisPass>
+; CHECK-O-NEXT: Running pass: RequireAnalysisPasshttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7aed43b - Hopefully last fix for bot failures

2020-01-13 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-13T10:34:54-08:00
New Revision: 7aed43b60739653b13b8503f9df4c958c44feed8

URL: 
https://github.com/llvm/llvm-project/commit/7aed43b60739653b13b8503f9df4c958c44feed8
DIFF: 
https://github.com/llvm/llvm-project/commit/7aed43b60739653b13b8503f9df4c958c44feed8.diff

LOG: Hopefully last fix for bot failures

Hopefully final bot fix for last few failures from
2af97be8027a0823b88d4b6a07fc5eedb440bc1f.

Looks like sometimes the "llvm::" preceeding objects get printed in the
debug pass manager output and sometimes they don't. Replace with
wildcard matching.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index ce80ff744ed1..9a83a71b3e07 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -19,23 +19,23 @@
 ; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O3 %s
 
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis
-; CHECK-O: Starting llvm::Module pass manager run.
+; CHECK-O: Starting {{.*}}Module pass manager run.
 ; CHECK-O: Running pass: WholeProgramDevirtPass
 ; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running pass: LowerTypeTestsPass
 ; CHECK-O: Invalidating all non-preserved analyses for:
 ; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-O: Running pass: PassManager
-; CHECK-O: Starting llvm::Module pass manager run.
+; CHECK-O: Running pass: PassManager<{{.*}}Module>
+; CHECK-O: Starting {{.*}}Module pass manager run.
 ; CHECK-O: Running pass: PGOIndirectCallPromotion
 ; CHECK-O: Running analysis: ProfileSummaryAnalysis
 ; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
 ; CHECK-O: Running pass: InferFunctionAttrsPass
-; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor >
-; CHECK-O: Starting llvm::Function pass manager run.
+; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> >
+; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: AssumptionAnalysis on main
@@ -45,20 +45,20 @@
 ; CHECK-O: Running analysis: TargetLibraryAnalysis on main
 ; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
 ; CHECK-O3: Running pass: CallSiteSplittingPass on main
-; CHECK-O: Finished llvm::Function pass manager run.
+; CHECK-O: Finished {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: IPSCCPPass
 ; CHECK-O: Running pass: CalledValuePropagationPass
 ; CHECK-O: Running pass: GlobalOptPass
 ; CHECK-O: Invalidating all non-preserved analyses for:
 ; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
-; CHECK-O: Running pass: ModuleToFunctionPassAdaptor
+; CHECK-O: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PromotePass>
 ; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running analysis: DominatorTreeAnalysis on main
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
 ; CHECK-O: Running analysis: AssumptionAnalysis on main
 ; CHECK-O: Running pass: DeadArgumentEliminationPass
-; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor >
-; CHECK-O: Starting llvm::Function pass manager run.
+; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> >
+; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: InstCombinePass on main
 ; CHECK-O: Running analysis: TargetLibraryAnalysis on main
 ; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
@@ -69,12 +69,12 @@
 ; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Running analysis: TargetIRAnalysis on main
-; CHECK-O: Finished llvm::Function pass manager run.
-; CHECK-O: Running pass: RequireAnalysisPass > on (main)
+; CHECK-O2: Running pass: 
CGSCCToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> > on (main)
 ; CHECK-O: Running analysis: FunctionAnalysisManagerCGSCCProxy on (main)
 ; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
-; CHECK-O3: Running pass: 
CGSCCToFunctionPassAdaptor > on (main)
-; CHECK-O: Starting llvm::Function pass manager run.
+; CHECK-O3: Running pass: 

[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

2020-01-13 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

@rsmith friendly reminder


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63960/new/

https://reviews.llvm.org/D63960



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Hover.cpp:553
 
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();

(When merging with D72623, I'm assuming return type will go below this line?)



Comment at: clang-tools-extra/clangd/Hover.cpp:576
 Output.addParagraph().appendText(Documentation);
 
   if (!Definition.empty()) {

seems to me we'd likely want one above definition too



Comment at: clang-tools-extra/clangd/test/hover.test:12
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "function foo → void\n\nvoid foo()"
+# CHECK-NEXT:  "value": "function foo → void\n\n\nvoid foo()"
 # CHECK-NEXT:},

Why are we getting two blank lines here?

(I understand why this patch increases it by one, but don't understand why it 
was two before. Ideally I think we never want \n\n\n in plaintext)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72622/new/

https://reviews.llvm.org/D72622



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72121: [clang-tidy] Fix readability-identifier-naming missing member variables

2020-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D72121#1817170 , @njames93 wrote:

> Is anyone able to commit on my behalf?


Happy to do so. I've committed for you in 
fb79ef524171c96a9f3df025ac7a8a3e00fdc0b4 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72121/new/

https://reviews.llvm.org/D72121



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72245: [PoC][RISCV][LTO] Pass target-abi via module flag metadata

2020-01-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:151
 
+  TargetMachine::initTargetOptions(M, Conf.Options);
+

lenary wrote:
> tejohnson wrote:
> > This is going to be problematic. The Conf is a reference to the Config 
> > object saved on the LTO class instance shared by all backend invocations 
> > (the regular LTO module if one exists and any ThinLTO modules). They will 
> > end up clobbering each other's values here - although from the assert in 
> > initTargetOptions I see they are required to all have the same value 
> > anyway. Still, it is not good as the assert may actually be missed with 
> > unlucky interference between the threads. The Config object here should 
> > really be marked const, let me see if I can change that.
> > 
> > You could make a copy of the Config here, but that essentially misses the 
> > assertion completely. 
> > 
> > A better way to do this would be in LTO::addModule, which is invoked 
> > serially to add each Module to the LTO object.
> > 
> > However - this misses other places that invoke createTargetMachine - should 
> > other places be looking at this new module flag as well? One example I can 
> > think of is the old LTO API (*LTOCodeGenerator.cpp files), used by linkers 
> > such as ld64 and some other proprietary linkers and the llvm-lto testing 
> > tool. But I have no idea about other invocations of createTargetMachine.
> > 
> > Note that changes to LTO.cpp/LTOBackend.cpp (the new LTO API) needs some 
> > kind of llvm-lto2 based test.
> Thank you for this feedback. 
> 
> I've been looking at how to add an overridable TargetMachine hook which is 
> not dissimilar to this static function, but is overridable by TargetMachine 
> subclasses. It sounds like this approach will also not work (unless the 
> TargetMachine is allowed to update its (Default)Options in LTO without 
> issue). 
> 
> I am hoping to get a patch out today for review (which does not include the 
> RISC-V specific parts of this patch, and only includes a default empty 
> implementation), but I imagine it will remain unsatisfactory for LTO for the 
> same reasons this is.
Presumably you could still do the same thing I'm suggesting here - validate and 
aggregate the value across modules in LTO::addModule. Then your hook would just 
check the aggregated setting on the Config.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72245/new/

https://reviews.llvm.org/D72245



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72484: [clang-tidy] Fix check for Abseil internal namespace access

2020-01-13 Thread Gennadiy Rozental via Phabricator via cfe-commits
rogeeff marked 2 inline comments as done.
rogeeff added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp:43-44
+
+  if (!LocAtFault.isValid())
+return;
+

lebedev.ri wrote:
> Is there test coverage for this? When does/can this happen?
At the time when I wrote this internally the test cases in 
abseil-no-internal-dependencies.cpp were reproducing this failure. I'm not sure 
this is still the case. It is possible compiler was fixed since then.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72484/new/

https://reviews.llvm.org/D72484



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bb2e5f5 - Fix tests for builtbot failures

2020-01-13 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-13T09:28:13-08:00
New Revision: bb2e5f5e454245c8e7e9e4c9bf7a463c64604292

URL: 
https://github.com/llvm/llvm-project/commit/bb2e5f5e454245c8e7e9e4c9bf7a463c64604292
DIFF: 
https://github.com/llvm/llvm-project/commit/bb2e5f5e454245c8e7e9e4c9bf7a463c64604292.diff

LOG: Fix tests for builtbot failures

Should fix most of the buildbot failures from
2af97be8027a0823b88d4b6a07fc5eedb440bc1f, by loosening up the matching
on the AnalysisProxy output.

Added in --dump-input=fail on the one test that appears to be something
different, so I can hopefully debug it better.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 664b260a549b..666b9444b326 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -21,16 +21,16 @@
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis
 ; CHECK-O: Starting llvm::Module pass manager run.
 ; CHECK-O: Running pass: WholeProgramDevirtPass
-; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running pass: LowerTypeTestsPass
 ; CHECK-O: Invalidating all non-preserved analyses for:
-; CHECK-O: Invalidating analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running pass: ForceFunctionAttrsPass
 ; CHECK-O: Running pass: PassManager
 ; CHECK-O: Starting llvm::Module pass manager run.
 ; CHECK-O: Running pass: PGOIndirectCallPromotion
 ; CHECK-O: Running analysis: ProfileSummaryAnalysis
-; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
 ; CHECK-O: Running pass: InferFunctionAttrsPass
@@ -50,9 +50,9 @@
 ; CHECK-O: Running pass: CalledValuePropagationPass
 ; CHECK-O: Running pass: GlobalOptPass
 ; CHECK-O: Invalidating all non-preserved analyses for:
-; CHECK-O: Invalidating analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running pass: ModuleToFunctionPassAdaptor
-; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running analysis: DominatorTreeAnalysis on main
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
 ; CHECK-O: Running analysis: AssumptionAnalysis on main
@@ -66,7 +66,7 @@
 ; CHECK-O: Running analysis: BasicAA on main
 ; CHECK-O: Running analysis: ScopedNoAliasAA on main
 ; CHECK-O: Running analysis: TypeBasedAA on main
-; CHECK-O: Running analysis: 
OuterAnalysisManagerProxy on main
+; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Finished llvm::Function pass manager run.
@@ -75,11 +75,11 @@
 ; CHECK-O: Running analysis: CallGraphAnalysis
 ; CHECK-O: Running pass: RequireAnalysisPass>
 ; CHECK-O: Running pass: 
ModuleToPostOrderCGSCCPassAdaptor 
> >
-; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running analysis: LazyCallGraphAnalysis
 ; CHECK-O: Running analysis: FunctionAnalysisManagerCGSCCProxy on (main)
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis on (main)
-; CHECK-O: Running analysis: 
OuterAnalysisManagerProxy on (main)
+; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
@@ -104,7 +104,7 @@
 ; CHECK-O: Running analysis: BasicAA on main
 ; CHECK-O: Running analysis: ScopedNoAliasAA on main
 ; CHECK-O: Running analysis: TypeBasedAA on main
-; CHECK-O: Running analysis: 
OuterAnalysisManagerProxy on main
+; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SpeculativeExecutionPass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main
 ; CHECK-O: Running analysis: LazyValueAnalysis on main
@@ -194,7 +194,7 @@
 ; CHECK-O: Running analysis: ScalarEvolutionAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
-; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy on main
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running pass: 

[PATCH] D72527: [clang-tidy] adjust scripts to subsubsections in Release Notes

2020-01-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko marked an inline comment as done.
Eugene.Zelenko added a comment.

Both scripts works fine. However rename script should also sort entries 
alphabetically, but probably this should be separate patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72527/new/

https://reviews.llvm.org/D72527



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72594: [clangd] Include expression in DecltypeTypeLoc sourcerange while building SelectionTree

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang-tools-extra/clangd/Selection.cpp:530
 SourceRange S = N.getSourceRange();
+if (auto *TL = N.get()) {
+  // DecltypeTypeLoc only contains the SourceRange for `decltype` keyword.

Alternately, we could just always return false if it's a DecltypeTypeLoc.



Comment at: clang-tools-extra/clangd/Selection.cpp:531
+if (auto *TL = N.get()) {
+  // DecltypeTypeLoc only contains the SourceRange for `decltype` keyword.
+  // We are extending the SourceRange up until the end of the expression

I think this comment could be a little clearer on the three ranges, and that 
the AST one is just incorrect.

e.g.
```
// DeclTypeTypeLoc::getSourceRange() is incomplete, which would lead to failing
// to descend into the child expression.
// decltype(2+2);
// X <-- correct range
//   <-- range reported by getSourceRange()
//   <-- range with this hack
```



Comment at: clang-tools-extra/clangd/Selection.cpp:534
+  // inside decltype. Note that this will not include the closing
+  // parenthese.
+  // FIXME: Alter DecltypeTypeLoc to contain parentheses locations and get

nit: parenthesis


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72594/new/

https://reviews.llvm.org/D72594



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-01-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D71600#1816834 , @adalava wrote:

> In D71600#1816160 , @MaskRay wrote:
>
> > I am still confused why you need the special rule for 
> > `__atomic_is_lock_free` (GCC/clang) and `__c11_atomic_is_lock_free` (clang).
> >
> > https://github.com/gcc-mirror/gcc/blob/master/gcc/builtins.c#L7300-L7314 
> > GCC `__atomic_is_lock_free` expands to either 1 or a library call to 
> > `__atomic_is_lock_free`, never 0. How did FreeBSD get around libatomic when 
> > it was still using GCC? In clang, We can probably extend the semantics of 
> > `__c11_atomic_is_lock_free` and use 
> > `clang::TargetInfo::getMaxAtomicPromoteWidth`, but I'll make more research 
> > in this area.
> >
> > Can you be elaborate how do 
> > `__atomic_is_lock_free`/`__c11_atomic_is_lock_free` pull in 
> > libatomic.{a,so} dependency on FreeBSD powerpc?
>
>
> On FreeBSD 11.x/12.x (GCC4), libatomic can be installed by user through 
> "gcc9" ports package. The library is not shipped with the base system and 
> it's not required to compile the base system (world + kernel) since nothing 
> depends on 64 bit atomics an external call so `__atomic_is_lock_free` is 
> never made.
>
> The problem appeared when I switched to clang in a new ISO, this added an 
> undesired external libatomic dependency to build FreeBSD base sources 
> (world): clang was emitting a call to external `__atomic_is_lock_free` 
> implementation when building clang itself from base sources. (user would need 
> to install gcc9 to be able to build FreeBSD base source using clang, it's not 
> acceptable.


I'm curious about this: what part of clang makes it emit a call to 
`is_lock_free`? clang itself probably shouldn't be doing this, so maybe we 
should fix that issue as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71600/new/

https://reviews.llvm.org/D71600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72579: Evaluate __{c11_,}atomic_is_lock_free to 0 (avoid libcall) if larger than MaxAtomicPromoteWidth

2020-01-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a subscriber: jwakely.
jfb added a comment.

This changes the expression to a constant expression as well, right? You should 
point this out in the commit message.

The divergence with GCC is unfortunate, @jwakely do you think you'd be able to 
get GCC to match this behavior as well? It's technically a breaking change, but 
I doubt it matters in practice. It might also break code when newer 
architectures come in (if they have larger atomics) but again I think that's 
fine.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72579/new/

https://reviews.llvm.org/D72579



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71365: expand printf when compiling HIP to AMDGPU

2020-01-13 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Mostly looks fine, except vectors are supposed to work




Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:52
+  } else if (Ty->getTypeID() == Type::DoubleTyID) {
+return Builder.CreateBitCast(Arg, Int64Ty);
+  } else if (auto PtrTy = dyn_cast(Ty)) {

No else after return



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:57-58
+
+  llvm_unreachable("unexpected type");
+  return Builder.getInt64(0);
+}

Dead code


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71365/new/

https://reviews.llvm.org/D71365



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72527: [clang-tidy] adjust scripts to subsubsections in Release Notes

2020-01-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko updated this revision to Diff 237720.
Eugene.Zelenko added a comment.

Renamed "New aliases" to "New check aliases".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72527/new/

https://reviews.llvm.org/D72527

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -171,8 +171,8 @@
   Finds classes, structs, and unions that contain redundant member
   access specifiers.
 
-New aliases
-^^^
+New check aliases
+^
 
 - New alias :doc:`cert-pos44-c
   ` to
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -176,11 +176,11 @@
 
 for line in lines:
   if not note_added:
-match = re.search('Improvements to clang-tidy', line)
+match = re.search('Renamed checks', line)
 if match:
   header_found = True
 elif header_found:
-  if not line.startswith(''):
+  if not line.startswith(''):
 f.write("""
 - The '%s' check was renamed to :doc:`%s
   `
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -219,8 +219,8 @@
   with open(filename, 'r') as f:
 lines = f.readlines()
 
-  lineMatcher = re.compile('Improvements to clang-tidy')
-  nextSectionMatcher = re.compile('Improvements to clang-include-fixer')
+  lineMatcher = re.compile('New checks')
+  nextSectionMatcher = re.compile('New check aliases')
   checkerMatcher = re.compile('- New :doc:`(.*)')
 
   print('Updating %s...' % filename)
@@ -249,12 +249,12 @@
   f.write(line)
   continue
 
-if line.startswith(''):
+if line.startswith(''):
   f.write(line)
   continue
 
 if header_found and add_note_here:
-  if not line.startswith(''):
+  if not line.startswith(''):
 f.write("""- New :doc:`%s
   ` check.
 


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -171,8 +171,8 @@
   Finds classes, structs, and unions that contain redundant member
   access specifiers.
 
-New aliases
-^^^
+New check aliases
+^
 
 - New alias :doc:`cert-pos44-c
   ` to
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -176,11 +176,11 @@
 
 for line in lines:
   if not note_added:
-match = re.search('Improvements to clang-tidy', line)
+match = re.search('Renamed checks', line)
 if match:
   header_found = True
 elif header_found:
-  if not line.startswith(''):
+  if not line.startswith(''):
 f.write("""
 - The '%s' check was renamed to :doc:`%s
   `
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -219,8 +219,8 @@
   with open(filename, 'r') as f:
 lines = f.readlines()
 
-  lineMatcher = re.compile('Improvements to clang-tidy')
-  nextSectionMatcher = re.compile('Improvements to clang-include-fixer')
+  lineMatcher = re.compile('New checks')
+  nextSectionMatcher = re.compile('New check aliases')
   checkerMatcher = re.compile('- New :doc:`(.*)')
 
   print('Updating %s...' % filename)
@@ -249,12 +249,12 @@
   f.write(line)
   continue
 
-if line.startswith(''):
+if line.startswith(''):
   f.write(line)
   continue
 
 if header_found and add_note_here:
-  if not line.startswith(''):
+  if not line.startswith(''):
 f.write("""- New :doc:`%s
   ` check.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] fb79ef5 - Fix readability-identifier-naming missing member variables

2020-01-13 Thread Aaron Ballman via cfe-commits

Author: Nathan James
Date: 2020-01-13T13:28:55-05:00
New Revision: fb79ef524171c96a9f3df025ac7a8a3e00fdc0b4

URL: 
https://github.com/llvm/llvm-project/commit/fb79ef524171c96a9f3df025ac7a8a3e00fdc0b4
DIFF: 
https://github.com/llvm/llvm-project/commit/fb79ef524171c96a9f3df025ac7a8a3e00fdc0b4.diff

LOG: Fix readability-identifier-naming missing member variables

Fixes PR41122 (missing fixes for member variables in a destructor) and
PR29005 (does not rename class members in all locations).

Added: 

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index bd736743ae1c..8146cb36cf21 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -237,10 +237,26 @@ void IdentifierNamingCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(namedDecl().bind("decl"), this);
   Finder->addMatcher(usingDecl().bind("using"), this);
   Finder->addMatcher(declRefExpr().bind("declRef"), this);
-  Finder->addMatcher(cxxConstructorDecl().bind("classRef"), this);
-  Finder->addMatcher(cxxDestructorDecl().bind("classRef"), this);
+  Finder->addMatcher(cxxConstructorDecl(unless(isImplicit())).bind("classRef"),
+ this);
+  Finder->addMatcher(cxxDestructorDecl(unless(isImplicit())).bind("classRef"),
+ this);
   Finder->addMatcher(typeLoc().bind("typeLoc"), this);
   Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this);
+  Finder->addMatcher(
+  functionDecl(unless(cxxMethodDecl(isImplicit())),
+   
hasBody(forEachDescendant(memberExpr().bind("memberExpr",
+  this);
+  Finder->addMatcher(
+  cxxConstructorDecl(
+  unless(isImplicit()),
+  forEachConstructorInitializer(
+  allOf(isWritten(), withInitializer(forEachDescendant(
+ memberExpr().bind("memberExpr")),
+  this);
+  Finder->addMatcher(fieldDecl(hasInClassInitializer(
+ forEachDescendant(memberExpr().bind("memberExpr",
+ this);
 }
 
 void IdentifierNamingCheck::registerPPCallbacks(
@@ -710,8 +726,6 @@ static void 
addUsage(IdentifierNamingCheck::NamingCheckFailureMap ,
 void IdentifierNamingCheck::check(const MatchFinder::MatchResult ) {
   if (const auto *Decl =
   Result.Nodes.getNodeAs("classRef")) {
-if (Decl->isImplicit())
-  return;
 
 addUsage(NamingCheckFailures, Decl->getParent(),
  Decl->getNameInfo().getSourceRange());
@@ -730,8 +744,6 @@ void IdentifierNamingCheck::check(const 
MatchFinder::MatchResult ) {
 
   if (const auto *Decl =
   Result.Nodes.getNodeAs("classRef")) {
-if (Decl->isImplicit())
-  return;
 
 SourceRange Range = Decl->getNameInfo().getSourceRange();
 if (Range.getBegin().isInvalid())
@@ -806,6 +818,14 @@ void IdentifierNamingCheck::check(const 
MatchFinder::MatchResult ) {
 return;
   }
 
+  if (const auto *MemberRef =
+  Result.Nodes.getNodeAs("memberExpr")) {
+SourceRange Range = MemberRef->getMemberNameInfo().getSourceRange();
+addUsage(NamingCheckFailures, MemberRef->getMemberDecl(), Range,
+ Result.SourceManager);
+return;
+  }
+
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
 if (!Decl->getIdentifier() || Decl->getName().empty() || 
Decl->isImplicit())
   return;

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
new file mode 100644
index ..caffc3283ca2
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -0,0 +1,137 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.MemberCase, value: CamelCase}, 
\
+// RUN: {key: readability-identifier-naming.ParameterCase, value: 
CamelCase} \
+// RUN:  ]}'
+
+int set_up(int);
+int clear(int);
+
+class Foo {
+public:
+  const int bar_baz; // comment-0
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for member 
'bar_baz'
+  // CHECK-FIXES: {{^}}  const int BarBaz; // comment-0
+
+  Foo(int Val) : bar_baz(Val) { // comment-1
+// CHECK-FIXES: {{^}}  Foo(int Val) : BarBaz(Val) { // comment-1
+set_up(bar_baz); // comment-2
+// CHECK-FIXES: {{^}}set_up(BarBaz); // comment-2
+  }
+
+  Foo() : Foo(0) {}
+
+  ~Foo() {
+

[clang] cb988a8 - Add a couple of missed wildcards in debug-pass-manager output checking

2020-01-13 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-13T10:49:40-08:00
New Revision: cb988a858abbaf1a1ae0fe03f2a1dae692131ea9

URL: 
https://github.com/llvm/llvm-project/commit/cb988a858abbaf1a1ae0fe03f2a1dae692131ea9
DIFF: 
https://github.com/llvm/llvm-project/commit/cb988a858abbaf1a1ae0fe03f2a1dae692131ea9.diff

LOG: Add a couple of missed wildcards in debug-pass-manager output checking

Along with the previous fix for bot failures from
2af97be8027a0823b88d4b6a07fc5eedb440bc1f, need to add a wildcard in a
couple of places where my local output did not print "llvm::" but the
bot is.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 9a83a71b3e07..01e840c4bd22 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -74,7 +74,7 @@
 ; CHECK-O: Running analysis: GlobalsAA
 ; CHECK-O: Running analysis: CallGraphAnalysis
 ; CHECK-O: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis
-; CHECK-O: Running pass: 
ModuleToPostOrderCGSCCPassAdaptor<{{.*}}DevirtSCCRepeatedPass<{{.*}}PassManagerhttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72625: [clangd] Render header of hover card as a heading

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61781 tests passed, 0 failed 
and 780 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72625/new/

https://reviews.llvm.org/D72625



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72523: [remark][diagnostics] Using clang diagnostic handler for IR input files

2020-01-13 Thread Rong Xu via Phabricator via cfe-commits
xur updated this revision to Diff 237716.
xur added a comment.

Integrated Teresa's review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72523/new/

https://reviews.llvm.org/D72523

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
  clang/test/CodeGen/thinlto-diagnostic-handler-remarks-with-hotness.ll

Index: clang/test/CodeGen/thinlto-diagnostic-handler-remarks-with-hotness.ll
===
--- clang/test/CodeGen/thinlto-diagnostic-handler-remarks-with-hotness.ll
+++ clang/test/CodeGen/thinlto-diagnostic-handler-remarks-with-hotness.ll
@@ -28,7 +28,7 @@
 ; YAML-NEXT: ...
 
 ; Next try with pass remarks to stderr
-; RUN: %clang -target x86_64-scei-ps4 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -mllvm -pass-remarks=inline -fdiagnostics-show-hotness -o %t2.o -c 2>&1 | FileCheck %s
+; RUN: %clang -target x86_64-scei-ps4 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -Rpass=inline -fdiagnostics-show-hotness -o %t2.o -c 2>&1 | FileCheck %s
 
 ; CHECK: tinkywinky inlined into main with (cost=0, threshold=337) (hotness: 300)
 
Index: clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
===
--- /dev/null
+++ clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
@@ -0,0 +1,24 @@
+// Test clang diagnositic handler works in IR file compilaiton.
+
+// REQUIRES: x86-registered-target
+
+// RUN: llvm-profdata merge -o %t1.profdata %S/Inputs/thinlto_expect1.proftext
+// RUN: %clang -O2 -fexperimental-new-pass-manager -flto=thin -g -fprofile-use=%t1.profdata -c -o %t1.bo %s
+// RUN: llvm-lto -thinlto -o %t %t1.bo
+// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -emit-obj -Rpass-analysis=info 2>&1 | FileCheck %s -check-prefix=CHECK-REMARK
+// RUN: llvm-profdata merge -o %t2.profdata %S/Inputs/thinlto_expect2.proftext
+// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata -emit-obj -Wmisexpect 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata -emit-obj 2>&1 | FileCheck %s -allow-empty -check-prefix=CHECK-NOWARNING
+
+int sum;
+__attribute__((noinline)) void bar() {
+  sum = 1234;
+}
+
+__attribute__((noinline)) void foo(int m) {
+  if (__builtin_expect(m > 9, 1))
+bar();
+}
+// CHECK-REMARK: remark: In {{.*}}.c:
+// CHECK-WARNING: warning: Potential performance regression from use of __builtin_expect(): Annotation was correct on {{.*}}.c:{{[0-9]*}}:26: 50.00% (12 / 24) of profiled executions.
+// CHECK-NOWARNING-NOT: warning: {{.*}}.c:{{[0-9]*}}:26: 50.00% (12 / 24)
Index: clang/test/CodeGen/Inputs/thinlto_expect2.proftext
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/thinlto_expect2.proftext
@@ -0,0 +1,20 @@
+# CSIR level Instrumentation Flag
+:csir
+foo
+# Func Hash:
+25571299074
+# Num Counters:
+2
+# Counter Values:
+12
+24
+
+foo
+# Func Hash:
+1152921530178146050
+# Num Counters:
+2
+# Counter Values:
+24
+12
+
Index: clang/test/CodeGen/Inputs/thinlto_expect1.proftext
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/thinlto_expect1.proftext
@@ -0,0 +1,11 @@
+# IR level Instrumentation Flag
+:ir
+foo
+# Func Hash:
+25571299074
+# Num Counters:
+2
+# Counter Values:
+12
+24
+
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -151,6 +151,25 @@
   FrontendTimesIsEnabled = TimePasses;
   llvm::TimePassesIsEnabled = TimePasses;
 }
+BackendConsumer(BackendAction Action, DiagnosticsEngine ,
+const HeaderSearchOptions ,
+const PreprocessorOptions ,
+const CodeGenOptions ,
+const TargetOptions ,
+const LangOptions , bool TimePasses,
+SmallVector LinkModules, LLVMContext ,
+CoverageSourceInfo *CoverageInfo = nullptr)
+: Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
+  CodeGenOpts(CodeGenOpts), TargetOpts(TargetOpts), LangOpts(LangOpts),
+  Context(nullptr),
+  LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
+  LLVMIRGenerationRefCount(0),
+  Gen(CreateLLVMCodeGen(Diags, "", HeaderSearchOpts, PPOpts,
+CodeGenOpts, C, CoverageInfo)),
+  LinkModules(std::move(LinkModules)) {
+  FrontendTimesIsEnabled = 

[PATCH] D72624: [WIP] TargetMachine Hook for Module Metadata

2020-01-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

I'm not sure if ThinLTOCodeGenerator.cpp and LTOBackend.cpp were intentionally 
left out due to the LTO concerns mentioned in the description?

Note if we are just passing in the Module and updating the TM based on that, it 
wouldn't hit the threading issue I mentioned in D72245 
, but neither would you get the proper 
aggregation/checking across ThinLTO'ed modules.




Comment at: llvm/include/llvm/Target/TargetMachine.h:188
+  // `M.setTargetTriple(TM->getTargetTriple())` and before
+  // `M.setDataLayout(createDataLayout())`.
+  virtual void resetTargetDefaultOptions(const Module ) const;

Is there a way to enforce this? Otherwise I foresee fragility. E.g. what if 
this method set a flag on the TM indicating that we have updated it properly 
from the Module, and TargetMachine::createDataLayout() asserted that this flag 
was set?



Comment at: llvm/lib/Target/TargetMachine.cpp:51
+//
+// Override methods should only change DefaultOptions, and use this super
+// method to copy the default options into the current options.


Looks like DefaultOptions is const, so override methods wouldn't be able to 
change it.



Comment at: llvm/lib/Target/TargetMachine.cpp:53
+// method to copy the default options into the current options.
+void TargetMachine::resetTargetDefaultOptions(const Module ) const {
+  Options = DefaultOptions;

Can you clarify how M will be used - will a follow on patch set the 
MCOptions.ABIName from the Module? Note in the meantime you will likely need to 
mark this with an LLVM_ATTRIBUTE_UNUSED.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72624/new/

https://reviews.llvm.org/D72624



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72362: [clang-tidy] misc-no-recursion: a new check

2020-01-13 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

Does it make sense to implement such diagnostics in clang Sema, considering 
that OpenCL does not allow recursion?
We implemented similar diagnostics for SYCL programming model and would be like 
to upstream it to clang later 
(https://github.com/intel/llvm/commit/4efe9fcf2dc6f6150b5b477b0f8320ea13a7f596).
 Can we somehow leverage this work for the compiler?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72362/new/

https://reviews.llvm.org/D72362



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72566: [clang-tidy] Clang tidy is now alias aware

2020-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72566#1816109 , @lebedev.ri wrote:

> I think the fact that this is a fourth (?) different incarnation of a patch
>  trying to solve the same *major* *ugly* problem, it may be an evidence that
>  perhaps this problem should not be approached from the 'let's hack it 
> together'
>  approach, but with a concrete plan sent as an RFC to cfe-dev :/


+1

This is a pretty big part of the user interface for clang-tidy, so I think we 
need community buy-in on how to proceed. It's not that we think the current 
interface is perfect, it's more that there are complexities we need to better 
understand before deciding on a solution. I'd rather get a big picture idea of 
the design for aliases, how they interact with the command line, documentation, 
diagnostics, etc to make sure we're hitting all of the important bits. Also, we 
should make sure that whatever we do is at least someone comparable with the 
clang static analyzer (I don't know if they have aliases there or not) so that 
we don't design two totally different approaches to solving the same problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72566/new/

https://reviews.llvm.org/D72566



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72634: [clangd] Improve ObjC property handling in SelectionTree.

2020-01-13 Thread David Goldman via Phabricator via cfe-commits
dgoldman requested changes to this revision.
dgoldman added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:347
+  )cpp",
+  "ObjCPropertyRefExpr"},
+

Please add a test for the case mentioned in 
https://github.com/clangd/clangd/issues/253 as well (for implicit property 
refs) even though it should also be a ObjCPropertyRefExpr


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72634/new/

https://reviews.llvm.org/D72634



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6288f86 - Revert "[ThinLTO] Add additional ThinLTO pipeline testing with new PM"

2020-01-13 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-13T11:01:48-08:00
New Revision: 6288f86e870c7bb7fe47cc138320b9eb34c93941

URL: 
https://github.com/llvm/llvm-project/commit/6288f86e870c7bb7fe47cc138320b9eb34c93941
DIFF: 
https://github.com/llvm/llvm-project/commit/6288f86e870c7bb7fe47cc138320b9eb34c93941.diff

LOG: Revert "[ThinLTO] Add additional ThinLTO pipeline testing with new PM"

This reverts commit 2af97be8027a0823b88d4b6a07fc5eedb440bc1f.

After attempting to fix bot failures from matching issues (mostly due to
inconsistent printing of "llvm::" prefixes on objects, and
AnalysisManager objects being printed differntly, I am now seeing some
differences I don't understand (real differences in the passes being
printed). Giving up at this point to allow the bots to recover. Will
revisit later.

Added: 


Modified: 
llvm/test/Other/new-pm-pgo.ll

Removed: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/Inputs/new-pm-thinlto-prelink-pgo-defaults.proftext
llvm/test/Other/Inputs/new-pm-thinlto-samplepgo-defaults.prof
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll



diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
deleted file mode 100644
index 01e840c4bd22..
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ /dev/null
@@ -1,236 +0,0 @@
-; REQUIRES: x86-registered-target
-
-; Validate ThinLTO post link pipeline at O2 and O3
-
-; RUN: opt -thinlto-bc -o %t.o %s
-
-; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
-; RUN:   -o %t2.index \
-; RUN:   -r=%t.o,main,px
-
-; RUN: %clang -target x86_64-grtev4-linux-gnu \
-; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
-; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s
-
-; RUN: %clang -target x86_64-grtev4-linux-gnu \
-; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
-; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O3 %s
-
-; CHECK-O: Running analysis: PassInstrumentationAnalysis
-; CHECK-O: Starting {{.*}}Module pass manager run.
-; CHECK-O: Running pass: WholeProgramDevirtPass
-; CHECK-O: Running analysis: InnerAnalysisManagerProxy
-; CHECK-O: Running pass: LowerTypeTestsPass
-; CHECK-O: Invalidating all non-preserved analyses for:
-; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
-; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-O: Running pass: PassManager<{{.*}}Module>
-; CHECK-O: Starting {{.*}}Module pass manager run.
-; CHECK-O: Running pass: PGOIndirectCallPromotion
-; CHECK-O: Running analysis: ProfileSummaryAnalysis
-; CHECK-O: Running analysis: InnerAnalysisManagerProxy
-; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
-; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
-; CHECK-O: Running pass: InferFunctionAttrsPass
-; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> >
-; CHECK-O: Starting {{.*}}Function pass manager run.
-; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running analysis: TargetIRAnalysis on main
-; CHECK-O: Running analysis: AssumptionAnalysis on main
-; CHECK-O: Running pass: SROA on main
-; CHECK-O: Running analysis: DominatorTreeAnalysis on main
-; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
-; CHECK-O3: Running pass: CallSiteSplittingPass on main
-; CHECK-O: Finished {{.*}}Function pass manager run.
-; CHECK-O: Running pass: IPSCCPPass
-; CHECK-O: Running pass: CalledValuePropagationPass
-; CHECK-O: Running pass: GlobalOptPass
-; CHECK-O: Invalidating all non-preserved analyses for:
-; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
-; CHECK-O: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PromotePass>
-; CHECK-O: Running analysis: InnerAnalysisManagerProxy
-; CHECK-O: Running analysis: DominatorTreeAnalysis on main
-; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
-; CHECK-O: Running analysis: AssumptionAnalysis on main
-; CHECK-O: Running pass: DeadArgumentEliminationPass
-; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> >
-; CHECK-O: Starting {{.*}}Function pass manager run.
-; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
-; CHECK-O: Running analysis: AAManager on main
-; CHECK-O: Running analysis: 

[PATCH] D72245: [PoC][RISCV][LTO] Pass target-abi via module flag metadata

2020-01-13 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:151
 
+  TargetMachine::initTargetOptions(M, Conf.Options);
+

tejohnson wrote:
> This is going to be problematic. The Conf is a reference to the Config object 
> saved on the LTO class instance shared by all backend invocations (the 
> regular LTO module if one exists and any ThinLTO modules). They will end up 
> clobbering each other's values here - although from the assert in 
> initTargetOptions I see they are required to all have the same value anyway. 
> Still, it is not good as the assert may actually be missed with unlucky 
> interference between the threads. The Config object here should really be 
> marked const, let me see if I can change that.
> 
> You could make a copy of the Config here, but that essentially misses the 
> assertion completely. 
> 
> A better way to do this would be in LTO::addModule, which is invoked serially 
> to add each Module to the LTO object.
> 
> However - this misses other places that invoke createTargetMachine - should 
> other places be looking at this new module flag as well? One example I can 
> think of is the old LTO API (*LTOCodeGenerator.cpp files), used by linkers 
> such as ld64 and some other proprietary linkers and the llvm-lto testing 
> tool. But I have no idea about other invocations of createTargetMachine.
> 
> Note that changes to LTO.cpp/LTOBackend.cpp (the new LTO API) needs some kind 
> of llvm-lto2 based test.
Thank you for this feedback. 

I've been looking at how to add an overridable TargetMachine hook which is not 
dissimilar to this static function, but is overridable by TargetMachine 
subclasses. It sounds like this approach will also not work (unless the 
TargetMachine is allowed to update its (Default)Options in LTO without issue). 

I am hoping to get a patch out today for review (which does not include the 
RISC-V specific parts of this patch, and only includes a default empty 
implementation), but I imagine it will remain unsatisfactory for LTO for the 
same reasons this is.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72245/new/

https://reviews.llvm.org/D72245



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72622

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/test/hover.test
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1746,6 +1746,7 @@
 HI.NamespaceScope.emplace();
   },
   R"(class foo
+
 documentation
 
 template  class Foo {})",
@@ -1769,6 +1770,7 @@
 HI.Definition = "ret_type foo(params) {}";
   },
   R"(function foo → ret_type
+
 - 
 - type
 - type foo
@@ -1787,6 +1789,7 @@
 HI.Definition = "def";
   },
   R"(variable foo : type
+
 Value = value
 
 // In test::bar
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -136,12 +136,12 @@
   EXPECT_EQ(D.asPlainText(), ExpectedText);
 }
 
-TEST(Document, Spacer) {
+TEST(Document, Ruler) {
   Document D;
   D.addParagraph().appendText("foo");
-  D.addSpacer();
+  D.addRuler();
   D.addParagraph().appendText("bar");
-  EXPECT_EQ(D.asMarkdown(), "foo  \n\nbar");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nbar");
   EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
 }
 
Index: clang-tools-extra/clangd/test/hover.test
===
--- clang-tools-extra/clangd/test/hover.test
+++ clang-tools-extra/clangd/test/hover.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"contents": {
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "function foo → void\n\nvoid foo()"
+# CHECK-NEXT:  "value": "function foo → void\n\n\nvoid foo()"
 # CHECK-NEXT:},
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
@@ -37,7 +37,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"contents": {
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "enum foo\n\nenum foo {}"
+# CHECK-NEXT:  "value": "enum foo\n\n\nenum foo {}"
 # CHECK-NEXT:},
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -550,6 +550,8 @@
 Header.appendCode(*Type);
   }
 
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();
   // For functions we display signature in a list form, e.g.:
   // - `bool param1`
   // - `int param2 = 5`
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -81,8 +81,8 @@
 public:
   /// Adds a semantical block that will be separate from others.
   Paragraph ();
-  /// Inserts a vertical space into the document.
-  void addSpacer();
+  /// Inserts a horizontal separator to the document.
+  void addRuler();
   /// Adds a block of code. This translates to a ``` block in markdown. In plain
   /// text representation, the code block will be surrounded by newlines.
   void addCodeBlock(std::string Code, std::string Language = "cpp");
Index: clang-tools-extra/clangd/FormattedString.cpp
===
--- clang-tools-extra/clangd/FormattedString.cpp
+++ clang-tools-extra/clangd/FormattedString.cpp
@@ -122,10 +122,16 @@
   return llvm::StringRef(OS.str()).trim().str();
 }
 
-// Puts a vertical space between blocks inside a document.
-class Spacer : public Block {
+// Seperates two blocks with extra spacing. Note that it might render strangely
+// in vscode if the trailing block is a codeblock, see
+// https://github.com/microsoft/vscode/issues/88416 for details.
+class Ruler : public Block {
 public:
-  void renderMarkdown(llvm::raw_ostream ) const override { OS << '\n'; }
+  void renderMarkdown(llvm::raw_ostream ) const override {
+// Note that we need an extra new line before the ruler, otherwise we might
+// make previous block a title instead of introducing a ruler.
+OS << "\n---\n";
+  }
   void renderPlainText(llvm::raw_ostream ) const override { OS << '\n'; }
 };
 
@@ -259,7 +265,7 @@
   return *static_cast(Children.back().get());
 }
 
-void Document::addSpacer() 

[PATCH] D72621: PR44514: Fix recovery from noexcept with non-convertible expressions

2020-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added a reviewer: aaron.ballman.
Herald added a project: clang.

We currently treat noexcept(not-convertible-to-bool) as 'none', which
results in the typeloc info being a different size, and causing an
assert later on in the process.  In order to make recovery less
destructive, replace this with noexcept(false) and a constructed 'false'
expression.


Repository:
  rC Clang

https://reviews.llvm.org/D72621

Files:
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/SemaCXX/cxx0x-noexcept-expression.cpp


Index: clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
===
--- clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
+++ clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
@@ -75,3 +75,8 @@
   static_assert(!noexcept((int(*)[b ? throw : 42])0), "");
   static_assert(!noexcept((int(*)[b ? throw : 42]){0}), "");
 }
+
+struct pr_44514 {
+  // expected-error@+1{{value of type 'void' is not contextually convertible 
to 'bool'}}
+  void foo(void) const (f());
+};
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -81,8 +81,16 @@
ExceptionSpecificationType ) {
   // FIXME: This is bogus, a noexcept expression is not a condition.
   ExprResult Converted = CheckBooleanCondition(NoexceptLoc, NoexceptExpr);
-  if (Converted.isInvalid())
-return Converted;
+  if (Converted.isInvalid()) {
+EST = EST_NoexceptFalse;
+
+// Fill in an expression of 'false' as a fixup.
+auto *BoolExpr = new (Context)
+CXXBoolLiteralExpr(false, Context.BoolTy, NoexceptExpr->getBeginLoc());
+llvm::APSInt Value{1};
+Value = 0;
+return ConstantExpr::Create(Context, BoolExpr, APValue{Value});
+  }
 
   if (Converted.get()->isValueDependent()) {
 EST = EST_DependentNoexcept;


Index: clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
===
--- clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
+++ clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
@@ -75,3 +75,8 @@
   static_assert(!noexcept((int(*)[b ? throw : 42])0), "");
   static_assert(!noexcept((int(*)[b ? throw : 42]){0}), "");
 }
+
+struct pr_44514 {
+  // expected-error@+1{{value of type 'void' is not contextually convertible to 'bool'}}
+  void foo(void) const (f());
+};
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -81,8 +81,16 @@
ExceptionSpecificationType ) {
   // FIXME: This is bogus, a noexcept expression is not a condition.
   ExprResult Converted = CheckBooleanCondition(NoexceptLoc, NoexceptExpr);
-  if (Converted.isInvalid())
-return Converted;
+  if (Converted.isInvalid()) {
+EST = EST_NoexceptFalse;
+
+// Fill in an expression of 'false' as a fixup.
+auto *BoolExpr = new (Context)
+CXXBoolLiteralExpr(false, Context.BoolTy, NoexceptExpr->getBeginLoc());
+llvm::APSInt Value{1};
+Value = 0;
+return ConstantExpr::Create(Context, BoolExpr, APValue{Value});
+  }
 
   if (Converted.get()->isValueDependent()) {
 EST = EST_DependentNoexcept;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72500/new/

https://reviews.llvm.org/D72500



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69878: Consoldiate internal denormal flushing controls

2020-01-13 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 237665.
arsenm added a comment.

Mention support in langref


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69878/new/

https://reviews.llvm.org/D69878

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCUDA/propagate-metadata.cu
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/CodeGenOpenCL/denorms-are-zero.cl
  clang/test/CodeGenOpenCL/gfx9-fp32-denorms.cl
  clang/test/Driver/cl-denorms-are-zero.cl
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/denormal-fp-math.c
  clang/test/Driver/opencl.cl
  llvm/docs/LangRef.rst
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/CodeGen/NVPTX/fast-math.ll
  llvm/test/CodeGen/NVPTX/math-intrins.ll
  llvm/test/CodeGen/NVPTX/sqrt-approx.ll
  llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll

Index: llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll
===
--- llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll
+++ llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll
@@ -5,11 +5,11 @@
 ; hackery:
 
 ; RUN: cat %s > %t.ftz
-; RUN: echo 'attributes #0 = { "nvptx-f32ftz" = "true" }' >> %t.ftz
+; RUN: echo 'attributes #0 = { "denormal-fp-math-f32" = "preserve-sign" }' >> %t.ftz
 ; RUN: opt < %t.ftz -instcombine -S | FileCheck %s --check-prefix=CHECK --check-prefix=FTZ
 
 ; RUN: cat %s > %t.noftz
-; RUN: echo 'attributes #0 = { "nvptx-f32ftz" = "false" }' >> %t.noftz
+; RUN: echo 'attributes #0 = { "denormal-fp-math-f32" = "ieee" }' >> %t.noftz
 ; RUN: opt < %t.noftz -instcombine -S | FileCheck %s --check-prefix=CHECK --check-prefix=NOFTZ
 
 ; We handle nvvm intrinsics with ftz variants as follows:
Index: llvm/test/CodeGen/NVPTX/sqrt-approx.ll
===
--- llvm/test/CodeGen/NVPTX/sqrt-approx.ll
+++ llvm/test/CodeGen/NVPTX/sqrt-approx.ll
@@ -146,5 +146,5 @@
 }
 
 attributes #0 = { "unsafe-fp-math" = "true" }
-attributes #1 = { "nvptx-f32ftz" = "true" }
+attributes #1 = { "denormal-fp-math-f32" = "preserve-sign" }
 attributes #2 = { "reciprocal-estimates" = "rsqrtf:1,rsqrtd:1,sqrtf:1,sqrtd:1" }
Index: llvm/test/CodeGen/NVPTX/math-intrins.ll
===
--- llvm/test/CodeGen/NVPTX/math-intrins.ll
+++ llvm/test/CodeGen/NVPTX/math-intrins.ll
@@ -289,4 +289,4 @@
 }
 
 attributes #0 = { nounwind readnone }
-attributes #1 = { "nvptx-f32ftz" = "true" }
+attributes #1 = { "denormal-fp-math-f32" = "preserve-sign" }
Index: llvm/test/CodeGen/NVPTX/fast-math.ll
===
--- llvm/test/CodeGen/NVPTX/fast-math.ll
+++ llvm/test/CodeGen/NVPTX/fast-math.ll
@@ -162,4 +162,4 @@
 }
 
 attributes #0 = { "unsafe-fp-math" = "true" }
-attributes #1 = { "nvptx-f32ftz" = "true" }
+attributes #1 = { "denormal-fp-math-f32" = "preserve-sign" }
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -1709,9 +1710,10 @@
   // intrinsic, we don't have to look up any module metadata, as
   // FtzRequirementTy will be FTZ_Any.)
   if (Action.FtzRequirement != FTZ_Any) {
-bool FtzEnabled =
-II->getFunction()->getFnAttribute("nvptx-f32ftz").getValueAsString() ==
-"true";
+StringRef Attr = II->getFunction()
+ ->getFnAttribute("denormal-fp-math-f32")
+ .getValueAsString();
+bool FtzEnabled = parseDenormalFPAttribute(Attr) != DenormalMode::IEEE;
 
 if (FtzEnabled != (Action.FtzRequirement == FTZ_MustBeOn))
   return nullptr;
Index: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -121,14 +121,10 @@
   if 

[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D72498#1816957 , @kadircet wrote:

> In D72498#1816785 , @ilya-biryukov 
> wrote:
>
> > In D72498#1816424 , @lh123 wrote:
> >
> > > Currently, I think that in most cases, showing both expanded (canonical) 
> > > and spelled types is sufficient.
> > >
> > > > This has been used in ycmd for ~4 years without complaint. 
> > > > https://github.com/clangd/clangd/issues/58#issuecomment-507800970
> >
> >
> > That actually doesn't look bad. Maybe let's try doing that and see whether 
> > we'll get negative feedback?
> >  That seems to give useful information in **all** cases, so at least it'll 
> > cover all use-cases even it's more verbose.
> >
> > What do others think?
>
>
> SGTM, happy to update all types in `HoverInfo` to contain both a 
> `pretty-printed` and `canonical` version. Where pretty-printed would just 
> means desugared, so keywords like auto/decltype would've
>  been stripped away and it would be the type as written in all other cases, 
> while canonical would refer to `clang canonical` with all of the type aliases 
> etc. resolved. Ofc.
>  Does that SG to you as well @sammccall ?


No, I think printing *both* is at least somewhat likely to be too verbose, 
especially since the previous release showed no types at all.
And we're out of time to iterate on the behavior and presentation for this 
cycle. I think we should do something more conservative and then experiment in 
the next release cycle.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72498/new/

https://reviews.llvm.org/D72498



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-01-13 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
aganea marked an inline comment as done.
Closed by commit rGb4a99a061f51: [Clang][Driver] Re-use the calling process 
instead of creating a new process… (authored by aganea).

Changed prior to commit:
  https://reviews.llvm.org/D69825?vs=237465=237677#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69825/new/

https://reviews.llvm.org/D69825

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Job.h
  clang/lib/Driver/Job.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CMakeLists.txt
  clang/test/Driver/cc1-spawnprocess.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fsanitize-blacklist.c
  clang/test/Driver/unknown-arg.c
  clang/test/Driver/warning-options_pedantic.cpp
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -14,6 +14,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/Stack.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -30,6 +31,7 @@
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -239,6 +241,8 @@
   *NumberSignPtr = '=';
 }
 
+static int ExecuteCC1Tool(ArrayRef argv);
+
 static void SetBackdoorDriverOutputsFromEnvVars(Driver ) {
   // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
   TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
@@ -254,6 +258,27 @@
   TheDriver.CCLogDiagnostics = !!::getenv("CC_LOG_DIAGNOSTICS");
   if (TheDriver.CCLogDiagnostics)
 TheDriver.CCLogDiagnosticsFilename = ::getenv("CC_LOG_DIAGNOSTICS_FILE");
+
+  // Whether the cc1 tool should be called inside the current process, or if we
+  // should spawn a new clang process (old behavior).
+  // Not having an additional process saves some execution time of Windows,
+  // and makes debugging easier.
+  bool UseNewCC1Process = CLANG_SPAWN_CC1;
+
+  StringRef SpawnCC1Str = ::getenv("CLANG_SPAWN_CC1");
+  if (!SpawnCC1Str.empty()) {
+if (SpawnCC1Str != "0" && SpawnCC1Str != "1") {
+  llvm::errs() << "error: the value of the environment variable "
+  "CLANG_SPAWN_CC1 must be either 0 or 1.\n";
+  ::exit(1);
+}
+UseNewCC1Process = SpawnCC1Str[0] - '0';
+  }
+  if (!UseNewCC1Process) {
+TheDriver.CC1Main = 
+// Ensure the CC1Command actually catches cc1 crashes
+llvm::CrashRecoveryContext::Enable();
+  }
 }
 
 static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
@@ -303,13 +328,19 @@
 TheDriver.setInstalledDir(InstalledPathParent);
 }
 
-static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
+static int ExecuteCC1Tool(ArrayRef argv) {
+  // If we call the cc1 tool from the clangDriver library (through
+  // Driver::CC1Main), we need to cleanup the options usage count. The options
+  // are currently global, and they might have been used previously by the
+  // driver.
+  llvm::cl::ResetAllOptionOccurrences();
+  StringRef Tool = argv[1];
   void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
-  if (Tool == "")
+  if (Tool == "-cc1")
 return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
-  if (Tool == "as")
+  if (Tool == "-cc1as")
 return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
-  if (Tool == "gen-reproducer")
+  if (Tool == "-cc1gen-reproducer")
 return cc1gen_reproducer_main(argv.slice(2), argv[0], GetExecutablePathVP);
 
   // Reject unknown tools.
@@ -379,7 +410,7 @@
   auto newEnd = std::remove(argv.begin(), argv.end(), nullptr);
   argv.resize(newEnd - argv.begin());
 }
-return ExecuteCC1Tool(argv, argv[1] + 4);
+return ExecuteCC1Tool(argv);
   }
 
   bool CanonicalPrefixes = true;
@@ -503,7 +534,7 @@
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.
-  // Once abnormal termiation was caught, negative status should not be
+  // Once abnormal termination was caught, negative status should not be
   // propagated.
   if (Res < 0)
 Res = 1;
Index: clang/test/Driver/warning-options_pedantic.cpp
===
--- clang/test/Driver/warning-options_pedantic.cpp
+++ clang/test/Driver/warning-options_pedantic.cpp
@@ -1,6 +1,6 @@
 // Make sure we don't match the -NOT lines with the linker invocation.
 // Delimiters match the start of the cc1 and the start of the linker lines
-// DELIMITERS: {{^ *"}}

[PATCH] D72484: [clang-tidy] Fix check for Abseil internal namespace access

2020-01-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In D72484#1817187 , @rogeeff wrote:

> It is my first time submitting clang-tidy change. So I'm not sure of the 
> procedure exactly. Do we wait for something from me?


Reviewers should make comments and finally approve patch when everything would 
be fine. Please keep in mind that people may be busy in real life.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72484/new/

https://reviews.llvm.org/D72484



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72484: [clang-tidy] Fix check for Abseil internal namespace access

2020-01-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp:43-44
+
+  if (!LocAtFault.isValid())
+return;
+

Is there test coverage for this? When does/can this happen?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72484/new/

https://reviews.llvm.org/D72484



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6c20314 - [clang] Remove raw string literals in macros

2020-01-13 Thread Oliver Stannard via cfe-commits

Author: Oliver Stannard
Date: 2020-01-13T12:38:58Z
New Revision: 6c203149b60e92e802df0c7a431744c337830a09

URL: 
https://github.com/llvm/llvm-project/commit/6c203149b60e92e802df0c7a431744c337830a09
DIFF: 
https://github.com/llvm/llvm-project/commit/6c203149b60e92e802df0c7a431744c337830a09.diff

LOG: [clang] Remove raw string literals in macros

Older (but still supported) versions of GCC don't handle C++11 raw
string literals in macro parameters correctly.

Added: 


Modified: 
clang/unittests/AST/ASTTraverserTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index 4b982431297c..88921a002053 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -342,9 +342,7 @@ B func12() {
 
   {
 auto FN = getFunctionNode("func1");
-
-EXPECT_EQ(dumpASTString(ast_type_traits::TK_AsIs, FN),
-  R"cpp(
+llvm::StringRef Expected = R"cpp(
 FunctionDecl 'func1'
 `-CompoundStmt
   `-ReturnStmt
@@ -354,97 +352,106 @@ FunctionDecl 'func1'
   `-ImplicitCastExpr
 `-CXXConstructExpr
   `-IntegerLiteral
-)cpp");
+)cpp";
 
-EXPECT_EQ(
-dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, FN),
-R"cpp(
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_AsIs, FN), Expected);
+
+Expected = R"cpp(
 FunctionDecl 'func1'
 `-CompoundStmt
   `-ReturnStmt
 `-IntegerLiteral
-)cpp");
+)cpp";
+EXPECT_EQ(
+dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, FN),
+Expected);
   }
 
-  EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func2")),
-R"cpp(
+  llvm::StringRef Expected = R"cpp(
 FunctionDecl 'func2'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXTemporaryObjectExpr
   `-IntegerLiteral
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func3")),
-R"cpp(
+  getFunctionNode("func2")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func3'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXFunctionalCastExpr
   `-IntegerLiteral
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func4")),
-R"cpp(
+  getFunctionNode("func3")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func4'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXTemporaryObjectExpr
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func5")),
-R"cpp(
+  getFunctionNode("func4")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func5'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXTemporaryObjectExpr
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func6")),
-R"cpp(
+  getFunctionNode("func5")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func6'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXTemporaryObjectExpr
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func7")),
-R"cpp(
+  getFunctionNode("func6")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func7'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXTemporaryObjectExpr
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func8")),
-R"cpp(
+  getFunctionNode("func7")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func8'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXFunctionalCastExpr
   `-InitListExpr
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func9")),
-R"cpp(
+  getFunctionNode("func8")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func9'
 `-CompoundStmt
   `-ReturnStmt
 `-CXXFunctionalCastExpr
   `-InitListExpr
-)cpp");
-
+)cpp";
   EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-  getFunctionNode("func10")),
-R"cpp(
+  getFunctionNode("func9")),
+Expected);
+
+  Expected = R"cpp(
 FunctionDecl 'func10'
 `-CompoundStmt
   |-DeclStmt
@@ -452,11 +459,12 @@ FunctionDecl 'func10'
   |   `-CXXConstructExpr
   

[PATCH] D72538: [ThinLTO] Add additional ThinLTO pipeline testing with new PM

2020-01-13 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2af97be8027a: [ThinLTO] Add additional ThinLTO pipeline 
testing with new PM (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72538/new/

https://reviews.llvm.org/D72538

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/test/Other/Inputs/new-pm-thinlto-prelink-pgo-defaults.proftext
  llvm/test/Other/Inputs/new-pm-thinlto-samplepgo-defaults.prof
  llvm/test/Other/new-pm-pgo.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- /dev/null
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -0,0 +1,213 @@
+; Validate ThinLTO prelink pipeline when we have Sample PGO
+;
+; RUN: opt -disable-verify -debug-pass-manager \
+; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
+; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1,CHECK-O-NODIS,CHECK-O123
+; RUN: opt -disable-verify -debug-pass-manager \
+; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
+; RUN: -passes='thinlto-pre-link,name-anon-globals' -S  %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ,CHECK-O-NODIS,CHECK-O123
+; RUN: opt -disable-verify -debug-pass-manager \
+; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
+; RUN: -passes='thinlto-pre-link,name-anon-globals' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O3,CHECK-O23SZ,CHECK-O-NODIS,CHECK-O123,CHECK-EP-PIPELINE-START
+; RUN: opt -disable-verify -debug-pass-manager \
+; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
+; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Os,CHECK-O23SZ,CHECK-O-NODIS
+; RUN: opt -disable-verify -debug-pass-manager \
+; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
+; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Oz,CHECK-O23SZ,CHECK-O-NODIS
+; RUN: opt -disable-verify -debug-pass-manager -new-pm-debug-info-for-profiling \
+; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
+; RUN: -passes='thinlto-pre-link,name-anon-globals' -S  %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK-DIS,CHECK-O,CHECK-O2,CHECK-O23SZ,CHECK-O123
+;
+; CHECK-O: Running analysis: PassInstrumentationAnalysis
+; CHECK-O-NEXT: Starting llvm::Module pass manager run.
+; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
+; CHECK-O-NEXT: Starting llvm::Module pass manager run.
+; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
+; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor
+; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
+; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
+; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
+; CHECK-O-NEXT: Starting llvm::Module pass manager run.
+; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass
+; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
+; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
+; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
+; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
+; CHECK-O-NEXT: Starting llvm::Function pass manager run.
+; CHECK-O-NEXT: Running pass: SimplifyCFGPass
+; CHECK-O-NEXT: Running analysis: TargetIRAnalysis
+; CHECK-O-NEXT: Running analysis: AssumptionAnalysis
+; CHECK-O-NEXT: Running pass: SROA
+; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis
+; CHECK-O-NEXT: Running pass: EarlyCSEPass
+; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
+; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass
+; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass
+; CHECK-O-NEXT: Running pass: InstCombinePass on foo
+; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on foo
+; CHECK-O-NEXT: Running analysis: AAManager on foo
+; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy on foo
+; CHECK-O-NEXT: Finished llvm::Function pass manager run.
+; CHECK-O-NEXT: Running pass: SampleProfileLoaderPass
+; CHECK-O-NEXT: Running analysis: ProfileSummaryAnalysis

[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72623/new/

https://reviews.llvm.org/D72623



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Moves type/returntype into its own line as it is more readable in cases
where the type is long.

Also gives parameter lists a heading, `Parameters:` to make them stand out.

Leaves the `right arrow` instead of `Returns: ` before Return Type to make
output more symmetric.

  function foo
  
  Returns: ret_type
  Parameters:
  - int x

vs

  function foo
  
   ret_type
  Parameters:
  - int x


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72623

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/test/hover.test
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1769,8 +1769,10 @@
 HI.NamespaceScope = "ns::";
 HI.Definition = "ret_type foo(params) {}";
   },
-  R"(function foo → ret_type
+  R"(function foo
 
+ ret_type
+Parameters:
 - 
 - type
 - type foo
@@ -1788,8 +1790,9 @@
 HI.Type = "type";
 HI.Definition = "def";
   },
-  R"(variable foo : type
+  R"(variable foo
 
+Type: type
 Value = value
 
 // In test::bar
Index: clang-tools-extra/clangd/test/hover.test
===
--- clang-tools-extra/clangd/test/hover.test
+++ clang-tools-extra/clangd/test/hover.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"contents": {
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "function foo → void\n\n\nvoid foo()"
+# CHECK-NEXT:  "value": "function foo\n\n void\n\nvoid foo()"
 # CHECK-NEXT:},
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -518,11 +518,11 @@
 markup::Document HoverInfo::present() const {
   markup::Document Output;
   // Header contains a text of the form:
-  // variable `var` : `int`
+  // variable `var`
   //
   // class `X`
   //
-  // function `foo` → `int`
+  // function `foo`
   markup::Paragraph  = Output.addParagraph();
   if (Name.empty()) {
 // User is hovering over an expression, we only have Type and Value set.
@@ -542,27 +542,29 @@
 
   Header.appendText(index::getSymbolKindString(Kind));
   Header.appendCode(Name);
-  if (ReturnType) {
-Header.appendText("→");
-Header.appendCode(*ReturnType);
-  } else if (Type) {
-Header.appendText(":");
-Header.appendCode(*Type);
-  }
 
   // Put a linebreak after header to increase readability.
   Output.addRuler();
-  // For functions we display signature in a list form, e.g.:
-  // - `bool param1`
-  // - `int param2 = 5`
-  if (Parameters && !Parameters->empty()) {
-markup::BulletList  = Output.addBulletList();
-for (const auto  : *Parameters) {
-  std::string Buffer;
-  llvm::raw_string_ostream OS(Buffer);
-  OS << Param;
-  L.addItem().addParagraph().appendCode(std::move(OS.str()));
+  // Print Types on their own lines to reduce chances of getting line-wrapped by
+  // editor, as they might be long.
+  if (ReturnType) {
+// For functions we display signature in a list form, e.g.:
+// Generates `x` from:
+// - `bool param1`
+// - `int param2 = 5`
+Output.addParagraph().appendText("").appendCode(*ReturnType);
+if (Parameters && !Parameters->empty()) {
+  Output.addParagraph().appendText("Parameters:");
+  markup::BulletList  = Output.addBulletList();
+  for (const auto  : *Parameters) {
+std::string Buffer;
+llvm::raw_string_ostream OS(Buffer);
+OS << Param;
+L.addItem().addParagraph().appendCode(std::move(OS.str()));
+  }
 }
+  } else if (Type) {
+Output.addParagraph().appendText("Type: ").appendCode(*Type);
   }
 
   if (Value) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-13 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72622/new/

https://reviews.llvm.org/D72622



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71848: Allow the discovery of Android NDK's triple-prefixed binaries.

2020-01-13 Thread Brian Ledger via Phabricator via cfe-commits
brianpl updated this revision to Diff 237691.
brianpl added a comment.

- Search for tools prefixed with GNU target triples.
- Merge branch 'master' of https://github.com/llvm/llvm-project


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71848/new/

https://reviews.llvm.org/D71848

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/android-triple-version.c

Index: clang/test/Driver/android-triple-version.c
===
--- /dev/null
+++ clang/test/Driver/android-triple-version.c
@@ -0,0 +1,172 @@
+// Android's target triples can contain a version number in the environment
+// field (e.g. arm-linux-androideabi9).
+// Make sure that any version is stripped when finding toolchain binaries.
+
+// Ensure no execute permissions on .../bin/{target-triple}/ld.
+// RUN: chmod -x %S/Inputs/basic_android_ndk_tree/arm-linux-androideabi/bin/ld
+// RUN: chmod -x %S/Inputs/basic_android_ndk_tree/aarch64-linux-android/bin/ld
+// RUN: chmod -x %S/Inputs/basic_android_ndk_tree/i686-linux-android/bin/ld
+// RUN: chmod -x %S/Inputs/basic_android_ndk_tree/mipsel-linux-android/bin/ld
+
+// Ensure execute permissions on .../bin/{target-triple}-ld
+// RUN: chmod +x  %S/Inputs/basic_android_ndk_tree/bin/arm-linux-androideabi-ld
+// RUN: chmod +x  %S/Inputs/basic_android_ndk_tree/bin/aarch64-linux-android-ld
+// RUN: chmod +x %S/Inputs/basic_android_ndk_tree/bin/i686-linux-android-ld
+// RUN: chmod +x %S/Inputs/basic_android_ndk_tree/bin/mipsel-linux-android-ld
+
+// Link clang into the mock NDK.
+// RUN: rm -f %S/Inputs/basic_android_ndk_tree/bin/clang
+// RUN: ln -s %clang %S/Inputs/basic_android_ndk_tree/bin/clang
+
+// Test target arm-linux-androideabi
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target arm-linux-androideabi %s |& \
+// RUN: grep arm-linux-androideabi-ld
+
+// Test target arm-unknown-linux-androideabi
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target arm-unknown-linux-androideabi %s |& \
+// RUN: grep arm-linux-androideabi-ld
+
+// Test target arm-linux-androideabi14
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target arm-linux-androideabi14 %s |& \
+// RUN: grep arm-linux-androideabi-ld
+
+// Test target arm-linux-androideabi29
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target arm-linux-androideabi29 %s |& \
+// RUN: grep arm-linux-androideabi-ld
+
+// Test target arm-unknown-linux-androideabi14
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target arm-unknown-linux-androideabi14 %s |& \
+// RUN: grep arm-linux-androideabi-ld
+
+// Test target arm-unknown-linux-androideabi29
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target arm-unknown-linux-androideabi29 %s |& \
+// RUN: grep arm-linux-androideabi-ld
+
+// Test target aarch64-linux-android
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target aarch64-linux-android %s |& \
+// RUN: grep aarch64-linux-android-ld
+
+// Test target aarch64-unknown-linux-android
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target aarch64-unknown-linux-android %s |& \
+// RUN: grep aarch64-linux-android-ld
+
+// Test target aarch64-linux-android14
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target aarch64-linux-android14 %s |& \
+// RUN: grep aarch64-linux-android-ld
+
+// Test target aarch64-linux-android29
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target aarch64-linux-android29 %s |& \
+// RUN: grep aarch64-linux-android-ld
+
+// Test target aarch64-unknown-linux-android14
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target aarch64-unknown-linux-android14 %s |& \
+// RUN: grep aarch64-linux-android-ld
+
+// Test target aarch64-unknown-linux-android29
+// RUN: env "PATH=%S/Inputs/basic_android_ndk_tree/bin" \
+// RUN: %S/Inputs/basic_android_ndk_tree/bin/clang \
+// RUN: -### -target aarch64-unknown-linux-android29 %s |& \
+// RUN: grep aarch64-linux-android-ld
+

[PATCH] D72500: [clangd] Show hower info for expressions

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D72500#1813975 , @sammccall wrote:

> Basing this on the hover for the type doesn't seem right. e.g. `int` should 
> be the `Type` rather than the `Name`.
>
> Rather than printing the value if evaluable, I think we should only show the 
> hover if evaluable. There's a cost to showing it and the value of just the 
> type doesn't seem clearly high enough.
>
> I think we should avoid triggering for literals. Maybe some exceptions, but a 
> hover saying that 0 is an int with value 0 seems silly.


agreed.

In D72500#1815780 , @lh123 wrote:

> In D72500#1813975 , @sammccall wrote:
>
> > I think we should avoid triggering for literals. Maybe some exceptions, but 
> > a hover saying that 0 is an int with value 0 seems silly.
>
>
> Hovering over `IntegerLiteral/FloatingLiteral` may be useless, but I think 
> it's useful when hovering over 
> `StringLiteral/UserDefinedLiteral/CXXNullPtrLiteralExpr ...`.
>
> - `"hello"` -> `char [6]`.
> - `nullptr` -> `std::nullptr_t`.
> - `1i` -> `std::complex`.


I believe all but the first case seems redundant. So I am only keeping the 
StringLiterals and dropping the rest.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72500/new/

https://reviews.llvm.org/D72500



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72500: [clangd] Show hower info for expressions

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 237649.
kadircet added a comment.

- Ignore literals


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72500/new/

https://reviews.llvm.org/D72500

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -601,6 +601,18 @@
   R"cpp(// non-named decls don't get hover. Don't crash!
 ^static_assert(1, "");
   )cpp",
+  R"cpp(// non-evaluatable expr
+  template  void foo() {
+(void)[[size^of]](T);
+  })cpp",
+  // literals
+  "auto x = t^rue;",
+  "auto x = '^A';",
+  "auto x = ^(int){42};",
+  "auto x = ^42.;",
+  "auto x = ^42.0i;",
+  "auto x = ^42;",
+  "auto x = ^nullptr;",
   };
 
   for (const auto  : Tests) {
@@ -1548,6 +1560,28 @@
 HI.ReturnType = "int";
 HI.Parameters.emplace();
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo ) {
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo ) {
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// string literals
+  auto x = [[^"asdf"]];)cpp",
+  [](HoverInfo ) { HI.Type = "const char [5]"; }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -13,6 +13,7 @@
 #include "FindTarget.h"
 #include "FormattedString.h"
 #include "Logger.h"
+#include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
 #include "index/SymbolCollector.h"
@@ -21,13 +22,18 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -421,6 +427,43 @@
   }
   return HI;
 }
+
+// Generates hover info for string literals and evaluatable expressions.
+//  FIXME: Support hover for user-defined literals.
+llvm::Optional getHoverContents(const Expr *E, ParsedAST ) {
+  // There's not much value in hovering over "42" and getting a hover card
+  // saying "42 is an int", similar for other literals.
+  // Unfortunately there's no common base Literal classes inherits from
+  // (apart from Expr), therefore this is a nasty blacklist.
+  if (llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E))
+return llvm::None;
+
+  HoverInfo HI;
+  // For string literals we choose to show the type, which contains the
+  // length.
+  if (auto *SL = llvm::dyn_cast(E)) {
+HI.Type = E->getType().getAsString();
+// Not much value in repeating the literal's value, as user is
+// directly hovering over it.
+return HI;
+  }
+
+  // For expressions we currently print the type and the value, iff it is
+  // evaluatable.
+  if (auto Val = printExprValue(E, AST.getASTContext())) {
+auto Policy =
+printingPolicyForDecls(AST.getASTContext().getPrintingPolicy());
+Policy.SuppressTagKeyword = true;
+HI.Type = E->getType().getAsString(Policy);
+HI.Value = *Val;
+return HI;
+  }
+  return llvm::None;
+}
 } // namespace
 
 llvm::Optional getHover(ParsedAST , Position Pos,
@@ -450,11 +493,11 @@
 // Look for a close enclosing expression to show the value of.
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext());
+  } else if (const Expr *E = N->ASTNode.get()) {
+HI = getHoverContents(E, AST);
   }
   // FIXME: support hovers for other nodes?
-  //  - certain expressions (sizeof etc)
   //  - built-in types
-  //  - literals (esp user-defined)
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2020-01-13 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:559
+  if (!CodeGenOpts.ThinLTOIndexFile.empty())
+MPM.add(createLowerTypeTestsPass(/*ExportSummary=*/nullptr,
+ /*ImportSummary=*/nullptr,

Test case?



Comment at: clang/test/CodeGenCXX/lto-visibility-inference.cpp:73
   c1->f();
-  // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C2"
+  // ITANIUM: type.test{{.*}}!"_ZTS2C2"
   // MS: type.test{{.*}}!"?AUC2@@"

What caused this and other changes in this file?



Comment at: llvm/include/llvm/Transforms/IPO.h:245
+ const ModuleSummaryIndex *ImportSummary,
+ bool StripAll = false);
 

s/StripAll/DropTypeTests/g ?



Comment at: llvm/lib/LTO/LTOCodeGenerator.cpp:550
+  // pipeline run below.
+  updateVCallVisibilityInModule(*MergedModule);
+

I'd rather use
```
updateVCallVisibilityInModule(*MergedModule,  /* 
WholeProgramVisibilityEnabledInLTO */ false)
```
and remove default value for second parameter



Comment at: llvm/lib/LTO/ThinLTOCodeGenerator.cpp:976
+  // via the internal option. Must be done before WPD below.
+  updateVCallVisibilityInIndex(*Index);
+

ditto



Comment at: llvm/lib/Transforms/IPO/LowerTypeTests.cpp:1775
+if (TypeTestFunc) {
+  for (auto UI = TypeTestFunc->use_begin(), UE = TypeTestFunc->use_end();
+   UI != UE;) {

Fold identical code blocks



Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:145
+/// when enabled via the linker.
+cl::opt DisableWholeProgramVisibility(
+"disable-whole-program-visibility", cl::init(false), cl::Hidden,

Is this tested?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71913/new/

https://reviews.llvm.org/D71913



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b4a99a0 - [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-01-13 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-01-13T10:40:18-05:00
New Revision: b4a99a061f517e60985667e39519f60186cbb469

URL: 
https://github.com/llvm/llvm-project/commit/b4a99a061f517e60985667e39519f60186cbb469
DIFF: 
https://github.com/llvm/llvm-project/commit/b4a99a061f517e60985667e39519f60186cbb469.diff

LOG: [Clang][Driver] Re-use the calling process instead of creating a new 
process for the cc1 invocation

With this patch, the clang tool will now call the -cc1 invocation directly 
inside the same process. Previously, the -cc1 invocation was creating, and 
waiting for, a new process.
This patch therefore reduces the number of created processes during a build, 
thus it reduces build times on platforms where process creation can be costly 
(Windows) and/or impacted by a antivirus.
It also makes debugging a bit easier, as there's no need to attach to the 
secondary -cc1 process anymore, breakpoints will be hit inside the same process.

Crashes or signaling inside the -cc1 invocation will have the same side-effect 
as before, and will be reported through the same means.

This behavior can be controlled at compile-time through the CLANG_SPAWN_CC1 
cmake flag, which defaults to OFF. Setting it to ON will revert to the previous 
behavior, where any -cc1 invocation will create/fork a secondary process.
At run-time, it is also possible to tweak the CLANG_SPAWN_CC1 environment 
variable. Setting it and will override the compile-time setting. A value of 0 
calls -cc1 inside the calling process; a value of 1 will create a secondary 
process, as before.

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

Added: 
clang/test/Driver/cc1-spawnprocess.c

Modified: 
clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Job.h
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CMakeLists.txt
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fsanitize-blacklist.c
clang/test/Driver/unknown-arg.c
clang/test/Driver/warning-options_pedantic.cpp
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index bc172b468512..781c3eb7f2f2 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -237,6 +237,9 @@ set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
   "Enable the experimental new pass manager by default.")
 
+set(CLANG_SPAWN_CC1 OFF CACHE BOOL
+"Whether clang should use a new process for the CC1 invocation")
+
 # TODO: verify the values against LangStandards.def?
 set(CLANG_DEFAULT_STD_C "" CACHE STRING
   "Default standard to use for C/ObjC code (IDENT from LangStandards.def, 
empty for platform default)")

diff  --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 68125dbc6d4b..261b3841b86f 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -80,4 +80,7 @@
 #cmakedefine01 CLANG_ENABLE_OBJC_REWRITER
 #cmakedefine01 CLANG_ENABLE_STATIC_ANALYZER
 
+/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */
+#cmakedefine01 CLANG_SPAWN_CC1
+
 #endif

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index d667fcb1efef..fd25663bd358 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -204,6 +204,13 @@ class Driver {
   /// Whether the driver is generating diagnostics for debugging purposes.
   unsigned CCGenDiagnostics : 1;
 
+  /// Pointer to the ExecuteCC1Tool function, if available.
+  /// When the clangDriver lib is used through clang.exe, this provides a
+  /// shortcut for executing the -cc1 command-line directly, in the same
+  /// process.
+  typedef int (*CC1ToolFunc)(ArrayRef argv);
+  CC1ToolFunc CC1Main = nullptr;
+
 private:
   /// Raw target triple.
   std::string TargetTriple;

diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index 41d972280852..0765b3c67d4e 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -119,7 +119,7 @@ class Command {
   /// \param NewEnvironment An array of environment variables.
   /// \remark If the environment remains unset, then the environment
   /// from the parent process will be used.
-  void setEnvironment(llvm::ArrayRef NewEnvironment);
+  virtual void setEnvironment(llvm::ArrayRef NewEnvironment);
 
   const char *getExecutable() const { return Executable; }
 
@@ -130,6 +130,24 @@ class Command {
 
   /// Set whether to print the input filenames when executing.
   void setPrintInputFilenames(bool P) { PrintInputFilenames = P; }
+
+protected:
+  /// Optionally print the filenames to be compiled
+  void PrintFileNames() const;
+};
+
+/// Use the CC1 tool 

[PATCH] D72427: [DebugInfo] Add option to clang to limit debug info that is emitted for classes.

2020-01-13 Thread Orlando Cazalet-Hyams via Phabricator via cfe-commits
Orlando added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:2225
+  !CXXDecl->isLambda() && !isClassOrMethodDLLImport(CXXDecl)) {
+for (const auto *ctor : CXXDecl->ctors()) {
+  if (ctor->isUserProvided())

Nit: Should `ctor` be `Ctor` here?

I'm just passing by, please don't wait on any approval from me for this patch.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72427/new/

https://reviews.llvm.org/D72427



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69590: [RISCV] Fix ILP32D lowering for double+double/double+int return types

2020-01-13 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luismarques.

This looks good to me, thanks James. I had a closer step through of the logic 
here to convince myself.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69590/new/

https://reviews.llvm.org/D69590



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72612: [AArch64][SVE] Add ImmArg property to intrinsics with immediates

2020-01-13 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: efriedma, sdesmalen, andwar.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Several SVE intrinsics with immediate arguments (including those
added by D70253  & D70437 
) do not use the ImmArg property.
This patch adds ImmArg where required and changes
the appropriate patterns which match the immediates.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72612

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td

Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -354,6 +354,12 @@
 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, (vt3 ImmTy:$Op3))),
   (inst $Op1, $Op2, ImmTy:$Op3)>;
 
+class SVE_3_Op_Cpx_Imm_Pat
+: Pat<(vtd (op vt1:$Op1, vt2:$Op2, (cpx ImmTy:$Op3))),
+  (inst $Op1, $Op2, ImmTy:$Op3)>;
+
 class SVE_4_Op_Imm_Pat
@@ -4377,10 +4383,10 @@
 let Inst{9-8} = imm{4-3};
   }
 
-  def : SVE_3_Op_Imm_Pat(NAME # _B)>;
-  def : SVE_3_Op_Imm_Pat(NAME # _H)>;
-  def : SVE_3_Op_Imm_Pat(NAME # _S)>;
-  def : SVE_3_Op_Imm_Pat(NAME # _D)>;
+  def : SVE_3_Op_Cpx_Imm_Pat(NAME # _B)>;
+  def : SVE_3_Op_Cpx_Imm_Pat(NAME # _H)>;
+  def : SVE_3_Op_Cpx_Imm_Pat(NAME # _S)>;
+  def : SVE_3_Op_Cpx_Imm_Pat(NAME # _D)>;
 }
 
 class sve_int_bin_pred_shift sz8_64, bit wide, bits<3> opc,
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -5023,6 +5023,7 @@
 defm : Neon_INS_elt_pattern;
 
 
+let AddedComplexity = 1 in {
 // Floating point vector extractions are codegen'd as either a sequence of
 // subregister extractions, or a MOV (aka CPY here, alias for DUP) if
 // the lane number is anything other than zero.
@@ -5032,6 +5033,7 @@
   (f32 (EXTRACT_SUBREG V128:$Rn, ssub))>;
 def : Pat<(vector_extract (v8f16 V128:$Rn), 0),
   (f16 (EXTRACT_SUBREG V128:$Rn, hsub))>;
+}
 
 def : Pat<(vector_extract (v2f64 V128:$Rn), VectorIndexD:$idx),
   (f64 (CPYi64 V128:$Rn, VectorIndexD:$idx))>;
Index: llvm/lib/Target/AArch64/AArch64InstrFormats.td
===
--- llvm/lib/Target/AArch64/AArch64InstrFormats.td
+++ llvm/lib/Target/AArch64/AArch64InstrFormats.td
@@ -683,6 +683,10 @@
   let ParserMatchClass = Imm0_63Operand;
 }
 
+def shiftimm8  : ComplexPattern",  []>;
+def shiftimm16 : ComplexPattern", []>;
+def shiftimm32 : ComplexPattern", []>;
+def shiftimm64 : ComplexPattern", []>;
 
 // Crazy immediate formats used by 32-bit and 64-bit logical immediate
 // instructions for splatting repeating bit patterns across the immediate.
@@ -832,7 +836,7 @@
 }
 
 // imm32_0_7 predicate - True if the 32-bit immediate is in the range [0,7]
-def imm32_0_7 : Operand, ImmLeaf, TImmLeaf {
   let ParserMatchClass = Imm0_7Operand;
@@ -1091,8 +1095,8 @@
   let RenderMethod = "addVectorIndexOperands";
 }
 
-class AsmVectorIndexOpnd
-: Operand, ImmLeaf {
+class AsmVectorIndexOpnd
+: Operand, ComplexPattern", []> {
   let ParserMatchClass = mc;
   let PrintMethod = "printVectorIndex";
 }
@@ -1103,17 +1107,17 @@
 def VectorIndexSOperand : AsmVectorIndex<0, 3>;
 def VectorIndexDOperand : AsmVectorIndex<0, 1>;
 
-def VectorIndex1 : AsmVectorIndexOpnd;
-def VectorIndexB : AsmVectorIndexOpnd;
-def VectorIndexH : AsmVectorIndexOpnd;
-def VectorIndexS : AsmVectorIndexOpnd;
-def VectorIndexD : AsmVectorIndexOpnd;
+def VectorIndex1 : AsmVectorIndexOpnd;
+def VectorIndexB : AsmVectorIndexOpnd;
+def VectorIndexH : AsmVectorIndexOpnd;
+def VectorIndexS : AsmVectorIndexOpnd;
+def VectorIndexD : AsmVectorIndexOpnd;
 
-def VectorIndex132b : AsmVectorIndexOpnd;
-def VectorIndexB32b : AsmVectorIndexOpnd;
-def VectorIndexH32b : AsmVectorIndexOpnd;
-def VectorIndexS32b : AsmVectorIndexOpnd;
-def VectorIndexD32b : AsmVectorIndexOpnd;
+def VectorIndex132b : AsmVectorIndexOpnd;
+def VectorIndexB32b : AsmVectorIndexOpnd;
+def VectorIndexH32b : AsmVectorIndexOpnd;
+def VectorIndexS32b : AsmVectorIndexOpnd;
+def VectorIndexD32b : AsmVectorIndexOpnd;
 
 def SVEVectorIndexExtDupBOperand : AsmVectorIndex<0, 63, "SVE">;
 def SVEVectorIndexExtDupHOperand : AsmVectorIndex<0, 31, "SVE">;
@@ -1122,15 +1126,15 @@
 def SVEVectorIndexExtDupQOperand : AsmVectorIndex<0, 3, "SVE">;
 
 def sve_elm_idx_extdup_b
-  : AsmVectorIndexOpnd;
+  : AsmVectorIndexOpnd;
 def sve_elm_idx_extdup_h
-  : AsmVectorIndexOpnd;
+  : AsmVectorIndexOpnd;
 def sve_elm_idx_extdup_s
- 

[PATCH] D69590: [RISCV] Fix ILP32D lowering for double+double/double+int return types

2020-01-13 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.

@jrtc27 It would be good to get this in for LLVM 10.0.

Having gone through the logic with @asb, we are both confident this is the 
right fix, and this patch does not require any additions at the moment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69590/new/

https://reviews.llvm.org/D69590



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72527: [clang-tidy] adjust scripts to subsubsections in Release Notes

2020-01-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

LG with a nit, if this works.




Comment at: clang-tools-extra/clang-tidy/add_new_check.py:223
+  lineMatcher = re.compile('New checks')
+  nextSectionMatcher = re.compile('New aliases')
   checkerMatcher = re.compile('- New :doc:`(.*)')

"New check aliases" would be less ambiguous.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72527/new/

https://reviews.llvm.org/D72527



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 237660.
kadircet added a comment.

- Update presentation for expressions, which doesn't have `Name` field set.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72500/new/

https://reviews.llvm.org/D72500

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -601,6 +601,18 @@
   R"cpp(// non-named decls don't get hover. Don't crash!
 ^static_assert(1, "");
   )cpp",
+  R"cpp(// non-evaluatable expr
+  template  void foo() {
+(void)[[size^of]](T);
+  })cpp",
+  // literals
+  "auto x = t^rue;",
+  "auto x = '^A';",
+  "auto x = ^(int){42};",
+  "auto x = ^42.;",
+  "auto x = ^42.0i;",
+  "auto x = ^42;",
+  "auto x = ^nullptr;",
   };
 
   for (const auto  : Tests) {
@@ -1548,6 +1560,28 @@
 HI.ReturnType = "int";
 HI.Parameters.emplace();
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo ) {
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo ) {
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// string literals
+  auto x = [[^"asdf"]];)cpp",
+  [](HoverInfo ) { HI.Type = "const char [5]"; }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -1758,6 +1792,17 @@
 // In test::bar
 def)",
   },
+  {
+  [](HoverInfo ) {
+HI.Type = "type";
+HI.Value = "val";
+  },
+  R"(type = val)",
+  },
+  {
+  [](HoverInfo ) { HI.Type = "type"; },
+  R"(type)",
+  },
   };
 
   for (const auto  : Cases) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -13,6 +13,7 @@
 #include "FindTarget.h"
 #include "FormattedString.h"
 #include "Logger.h"
+#include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
 #include "index/SymbolCollector.h"
@@ -21,13 +22,18 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -421,6 +427,43 @@
   }
   return HI;
 }
+
+// Generates hover info for string literals and evaluatable expressions.
+//  FIXME: Support hover for user-defined literals.
+llvm::Optional getHoverContents(const Expr *E, ParsedAST ) {
+  // There's not much value in hovering over "42" and getting a hover card
+  // saying "42 is an int", similar for other literals.
+  // Unfortunately there's no common base Literal classes inherits from
+  // (apart from Expr), therefore this is a nasty blacklist.
+  if (llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E))
+return llvm::None;
+
+  HoverInfo HI;
+  // For string literals we choose to show the type, which contains the
+  // length.
+  if (auto *SL = llvm::dyn_cast(E)) {
+HI.Type = E->getType().getAsString();
+// Not much value in repeating the literal's value, as user is
+// directly hovering over it.
+return HI;
+  }
+
+  // For expressions we currently print the type and the value, iff it is
+  // evaluatable.
+  if (auto Val = printExprValue(E, AST.getASTContext())) {
+auto Policy =
+printingPolicyForDecls(AST.getASTContext().getPrintingPolicy());
+Policy.SuppressTagKeyword = true;
+HI.Type = E->getType().getAsString(Policy);
+HI.Value = *Val;
+return HI;
+  }
+  return llvm::None;
+}
 } // namespace
 
 llvm::Optional getHover(ParsedAST , Position Pos,
@@ -450,11 +493,11 @@
 // Look for a close enclosing expression to show the value of.
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext());
+  } else if (const Expr *E = N->ASTNode.get()) {
+HI = getHoverContents(E, 

[PATCH] D71510: [clang][checkers] Added new checker 'error-return-checker'.

2020-01-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 237680.
balazske added a comment.

- Improved function list format in documentation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71510/new/

https://reviews.llvm.org/D71510

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/error-return.c

Index: clang/test/Analysis/error-return.c
===
--- /dev/null
+++ clang/test/Analysis/error-return.c
@@ -0,0 +1,625 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.ErrorReturn -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+/*
+Functions from CERT ERR33-C that should be checked for error:
+
+void *aligned_alloc( size_t alignment, size_t size );
+errno_t asctime_s(char *buf, rsize_t bufsz, const struct tm *time_ptr);
+int at_quick_exit( void (*func)(void) );
+int atexit( void (*func)(void) );
+void* bsearch( const void *key, const void *ptr, size_t count, size_t size,
+   int (*comp)(const void*, const void*) );
+void* bsearch_s( const void *key, const void *ptr, rsize_t count, rsize_t size,
+ int (*comp)(const void *, const void *, void *),
+ void *context );
+wint_t btowc( int c );
+size_t c16rtomb( char * restrict s, char16_t c16, mbstate_t * restrict ps );
+size_t c32rtomb( char * restrict s, char32_t c32, mbstate_t * restrict ps );
+void* calloc( size_t num, size_t size );
+clock_t clock(void);
+int cnd_broadcast( cnd_t *cond );
+int cnd_init( cnd_t* cond );
+int cnd_signal( cnd_t *cond );
+int cnd_timedwait( cnd_t* restrict cond, mtx_t* restrict mutex,
+   const struct timespec* restrict time_point );
+int cnd_wait( cnd_t* cond, mtx_t* mutex );
+errno_t ctime_s(char *buffer, rsize_t bufsz, const time_t *time);
+int fclose( FILE *stream );
+int fflush( FILE *stream );
+int fgetc( FILE *stream );
+int fgetpos( FILE *restrict stream, fpos_t *restrict pos );
+char *fgets( char *restrict str, int count, FILE *restrict stream );
+wint_t fgetwc( FILE *stream );
+FILE *fopen( const char *restrict filename, const char *restrict mode );
+errno_t fopen_s(FILE *restrict *restrict streamptr,
+const char *restrict filename,
+const char *restrict mode);
+int fprintf( FILE *restrict stream, const char *restrict format, ... );
+int fprintf_s(FILE *restrict stream, const char *restrict format, ...);
+int fputc( int ch, FILE *stream );
+int fputs( const char *restrict str, FILE *restrict stream );
+wint_t fputwc( wchar_t ch, FILE *stream );
+int fputws( const wchar_t * restrict str, FILE * restrict stream );
+size_t fread( void *restrict buffer, size_t size, size_t count,
+  FILE *restrict stream );
+FILE *freopen( const char *restrict filename, const char *restrict mode,
+   FILE *restrict stream );
+errno_t freopen_s(FILE *restrict *restrict newstreamptr,
+  const char *restrict filename, const char *restrict mode,
+  FILE *restrict stream);
+int fscanf( FILE *restrict stream, const char *restrict format, ... );
+int fscanf_s(FILE *restrict stream, const char *restrict format, ...);
+int fseek( FILE *stream, long offset, int origin );
+int fsetpos( FILE *stream, const fpos_t *pos );
+long ftell( FILE *stream );
+int fwprintf( FILE *restrict stream,
+  const wchar_t *restrict format, ... );
+int fwprintf_s( FILE *restrict stream,
+const wchar_t *restrict format, ...);
+size_t fwrite( const void *restrict buffer, size_t size, size_t count,
+   FILE *restrict stream ); // more exact error return: < count
+int fwscanf( FILE *restrict stream,
+ const wchar_t *restrict format, ... );
+int fwscanf_s( FILE *restrict stream,
+   const wchar_t *restrict format, ...);
+int getc( FILE *stream );
+int getchar(void);
+char *getenv( const char *name );
+errno_t getenv_s( size_t *restrict len, char *restrict value,
+  rsize_t valuesz, const char *restrict name );
+char *gets_s( char *str, rsize_t n );
+wint_t getwc( FILE *stream );
+wint_t getwchar(void);
+struct tm *gmtime( const time_t *time );
+struct tm *gmtime_s(const time_t *restrict time, struct tm *restrict result);
+struct tm *localtime( const time_t *time );
+struct tm *localtime_s(const time_t *restrict time, struct tm *restrict result);
+void* malloc( size_t size );
+int mblen( const char* s, size_t n );
+size_t mbrlen( const char *restrict s, size_t n, mbstate_t *restrict ps );
+size_t mbrtoc16( char16_t * restrict pc16, const char * restrict s,
+ size_t n, mbstate_t * restrict ps );
+size_t mbrtoc32( char32_t restrict * pc32, const char * restrict s,
+ size_t n, mbstate_t 

[PATCH] D72484: [clang-tidy] Fix check for Abseil internal namespace access

2020-01-13 Thread Gennadiy Rozental via Phabricator via cfe-commits
rogeeff added a comment.

It is my first time submitting clang-tidy change. So I'm not sure of the 
procedure exactly. Do we wait for something from me?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72484/new/

https://reviews.llvm.org/D72484



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2af97be - [ThinLTO] Add additional ThinLTO pipeline testing with new PM

2020-01-13 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-13T08:29:56-08:00
New Revision: 2af97be8027a0823b88d4b6a07fc5eedb440bc1f

URL: 
https://github.com/llvm/llvm-project/commit/2af97be8027a0823b88d4b6a07fc5eedb440bc1f
DIFF: 
https://github.com/llvm/llvm-project/commit/2af97be8027a0823b88d4b6a07fc5eedb440bc1f.diff

LOG: [ThinLTO] Add additional ThinLTO pipeline testing with new PM

Summary:
I've added some more extensive ThinLTO pipeline testing with the new PM,
motivated by the bug fixed in D72386.

I beefed up llvm/test/Other/new-pm-pgo.ll a little so that it tests
ThinLTO pre and post link with PGO, similar to the testing for the
default pipelines with PGO.

Added new pre and post link PGO tests for both instrumentation and
sample PGO that exhaustively test the pipelines at different
optimization levels via opt.

Added a clang test to exhaustively test the post link pipeline invoked for
distributed builds. I am currently only testing O2 and O3 since these
are the most important for performance.

It would be nice to add similar exhaustive testing for full LTO, and for
the old PM, but I don't have the bandwidth now and this is a start to
cover some of the situations that are not currently default and were
under tested.

Reviewers: wmi

Subscribers: mehdi_amini, inglorion, hiraditya, steven_wu, dexonsmith, jfb, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/Inputs/new-pm-thinlto-prelink-pgo-defaults.proftext
llvm/test/Other/Inputs/new-pm-thinlto-samplepgo-defaults.prof
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Modified: 
llvm/test/Other/new-pm-pgo.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
new file mode 100644
index ..664b260a549b
--- /dev/null
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -0,0 +1,236 @@
+; REQUIRES: x86-registered-target
+
+; Validate ThinLTO post link pipeline at O2 and O3
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,main,px
+
+; RUN: %clang -target x86_64-grtev4-linux-gnu \
+; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
+; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s
+
+; RUN: %clang -target x86_64-grtev4-linux-gnu \
+; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
+; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O3 %s
+
+; CHECK-O: Running analysis: PassInstrumentationAnalysis
+; CHECK-O: Starting llvm::Module pass manager run.
+; CHECK-O: Running pass: WholeProgramDevirtPass
+; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running pass: LowerTypeTestsPass
+; CHECK-O: Invalidating all non-preserved analyses for:
+; CHECK-O: Invalidating analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running pass: ForceFunctionAttrsPass
+; CHECK-O: Running pass: PassManager
+; CHECK-O: Starting llvm::Module pass manager run.
+; CHECK-O: Running pass: PGOIndirectCallPromotion
+; CHECK-O: Running analysis: ProfileSummaryAnalysis
+; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
+; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
+; CHECK-O: Running pass: InferFunctionAttrsPass
+; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor >
+; CHECK-O: Starting llvm::Function pass manager run.
+; CHECK-O: Running pass: SimplifyCFGPass on main
+; CHECK-O: Running analysis: TargetIRAnalysis on main
+; CHECK-O: Running analysis: AssumptionAnalysis on main
+; CHECK-O: Running pass: SROA on main
+; CHECK-O: Running analysis: DominatorTreeAnalysis on main
+; CHECK-O: Running pass: EarlyCSEPass on main
+; CHECK-O: Running analysis: TargetLibraryAnalysis on main
+; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
+; CHECK-O3: Running pass: CallSiteSplittingPass on main
+; CHECK-O: Finished llvm::Function pass manager run.
+; CHECK-O: Running pass: IPSCCPPass
+; CHECK-O: Running pass: CalledValuePropagationPass
+; CHECK-O: Running pass: GlobalOptPass
+; CHECK-O: Invalidating all non-preserved analyses for:
+; CHECK-O: Invalidating analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running pass: ModuleToFunctionPassAdaptor
+; CHECK-O: Running analysis: 
InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: DominatorTreeAnalysis on main
+; CHECK-O: Running 

[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D72498#1816424 , @lh123 wrote:

> Currently, I think that in most cases, showing both expanded (canonical) and 
> spelled types is sufficient.
>
> > This has been used in ycmd for ~4 years without complaint. 
> > https://github.com/clangd/clangd/issues/58#issuecomment-507800970


That actually doesn't look bad. Maybe let's try doing that and see whether 
we'll get negative feedback?
That seems to give useful information in **all** cases, so at least it'll cover 
all use-cases even it's more verbose.

What do others think?

In D72498#1816668 , @kadircet wrote:

> In D72498#1813989 , @ilya-biryukov 
> wrote:
>
> > In D72498#1813962 , @sammccall 
> > wrote:
> >
> > >
> >
> >
> > I tend to disagree here. decltype is normally the last resort, so whatever 
> > it produces is probably super-obscure, would even expect it to be not 
> > representable in C++ in many cases.
>
>
> I was rather talking about the obscurity of the expression inside decltype vs 
> the typedef alias. I believe it is a lot harder to make any assumptions on 
> `decltype(callback)` compared to `IntMap` without seeing the underlying type.


Point taken, although I bet we could come up with examples of obscure results 
in both cases.

>> Would definitely be helpful. If you feel we have some room in hover, I would 
>> love to have that. But there's a balance to be made, see Sam's comments 
>> about canonical types being obscure. I agree on 50% of the cases :-)
> 
> I think this should be OK to spend some space, as it will only show up when 
> needed. I believe `better` printing of canonical types is a different problem 
> we should definitely solve.

Totally agree, improving printing of STL types would be huge, no matter whether 
they're canonical or not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72498/new/

https://reviews.llvm.org/D72498



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-01-13 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava added a comment.

In D71600#1816160 , @MaskRay wrote:

> I am still confused why you need the special rule for `__atomic_is_lock_free` 
> (GCC/clang) and `__c11_atomic_is_lock_free` (clang).
>
> https://github.com/gcc-mirror/gcc/blob/master/gcc/builtins.c#L7300-L7314 GCC 
> `__atomic_is_lock_free` expands to either 1 or a library call to 
> `__atomic_is_lock_free`, never 0. How did FreeBSD get around libatomic when 
> it was still using GCC? In clang, We can probably extend the semantics of 
> `__c11_atomic_is_lock_free` and use 
> `clang::TargetInfo::getMaxAtomicPromoteWidth`, but I'll make more research in 
> this area.
>
> Can you be elaborate how do 
> `__atomic_is_lock_free`/`__c11_atomic_is_lock_free` pull in libatomic.{a,so} 
> dependency on FreeBSD powerpc?


On FreeBSD 11.x/12.x (GCC4), libatomic can be installed by user through "gcc9" 
ports package. The library is not shipped with the base system and it's not 
required to compile the base system (world + kernel) since nothing depends on 
64 bit atomics an external call so `__atomic_is_lock_free` is never made.

The problem appeared when I switched to clang in a new ISO, this added an 
undesired external libatomic dependency to build FreeBSD base sources (world): 
clang was emitting a call to external `__atomic_is_lock_free` implementation 
when building clang itself from base sources. (user would need to install gcc9 
to be able to build FreeBSD base source using clang, it's not acceptable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71600/new/

https://reviews.llvm.org/D71600



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D72498#1816785 , @ilya-biryukov 
wrote:

> In D72498#1816424 , @lh123 wrote:
>
> > Currently, I think that in most cases, showing both expanded (canonical) 
> > and spelled types is sufficient.
> >
> > > This has been used in ycmd for ~4 years without complaint. 
> > > https://github.com/clangd/clangd/issues/58#issuecomment-507800970
>
>
> That actually doesn't look bad. Maybe let's try doing that and see whether 
> we'll get negative feedback?
>  That seems to give useful information in **all** cases, so at least it'll 
> cover all use-cases even it's more verbose.
>
> What do others think?


SGTM, happy to update all types in `HoverInfo` to contain both a 
`pretty-printed` and `canonical` version. Where pretty-printed would just means 
desugared, so keywords like auto/decltype would've
been stripped away and it would be the type as written in all other cases, 
while canonical would refer to `clang canonical` with all of the type aliases 
etc. resolved. Ofc.
Does that SG to you as well @sammccall ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72498/new/

https://reviews.llvm.org/D72498



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >