[PATCH] D97753: [clang-tidy] Add a check for enforcing minimum length for variable names

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Please can you upload diffs with full context 

 or using arcanist 
.

It may be worth adding a case where if the `MinimumNameLength` is set to 
0, it won't check that type, or even bother registering its matchers.

It may be worth adding `unless(isImplicit())` to each `varDecl()` matcher, save 
any nasties from compiler generated decls.




Comment at: clang-tools-extra/clang-tidy/readability/VariableLengthCheck.cpp:23
+const unsigned DefaultMinimumExceptionNameLength = 2;
+const char DefaultIgnoredLoopCounterNames[] = "i;j;k;";
+

If you make this regex this could be changed to `"^[ijk]$"`.



Comment at: clang-tools-extra/clang-tidy/readability/VariableLengthCheck.cpp:30
+ DefaultMinimumVariableNameLength)},
+  MinimumLoopCounterNameLength{Options.get(
+  "MinimumLoopCounterNameLength", 
DefaultMinimumLoopCounterNameLength)},

For better or worse, we typically use parentheses instead of braced 
initialization for the member init list.



Comment at: 
clang-tools-extra/clang-tidy/readability/VariableLengthCheck.cpp:43-50
+  Options.store(Opts, "MinimumVariableNameLength",
+DefaultMinimumVariableNameLength);
+  Options.store(Opts, "MinimumLoopCounterNameLength",
+DefaultMinimumLoopCounterNameLength);
+  Options.store(Opts, "MinimumExceptionNameLength",
+DefaultMinimumExceptionNameLength);
+  Options.store(Opts, "IgnoredLoopCounterNames",

You shouldn't be storing the default value, you should be storing the value 
read from config.



Comment at: 
clang-tools-extra/clang-tidy/readability/VariableLengthCheck.cpp:54-55
+void VariableLengthCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  varDecl(hasParent(declStmt(hasParent(forStmt().bind("loopVar"), 
this);
+  Finder->addMatcher(varDecl(hasParent(cxxCatchStmt())).bind("exceptionVar"),

This code will match i, j and k in this example
```lang=c
  for (int i = 4, j = 5;;)
int k = 5;
```

It may be better to use this:
```lang=c++
// To match both i and j
forStmt(hasLoopInit(declStmt(forEach(varDecl().bind("loopVar")
// To only match i
forStmt(hasLoopInit(declStmt(containsDeclaration(0, 
varDecl().bind("loopVar")
```



Comment at: 
clang-tools-extra/clang-tidy/readability/VariableLengthCheck.cpp:58-62
+  Finder->addMatcher(
+  varDecl(unless(anyOf(hasParent(declStmt(hasParent(forStmt(,
+   hasParent(cxxCatchStmt()
+  .bind("standaloneVar"),
+  this);

This will miss the match for `k` in the same example:
```lang=c
for (int i = 4, j = 5;;)
  int k = 5;
```
Gotta scratch my head for this one though. Though like the case before its 
rather unlikely to show up in code so not the end of the world.

Also varDecl will match parameters, is this intended can you add tests and 
explain in documentation.
If its unintended putting `unless(parmVarDecl())` in the matcher disable that.



Comment at: 
clang-tools-extra/clang-tidy/readability/VariableLengthCheck.cpp:72-74
+diag(StandaloneVar->getLocation(),
+ "variable name %0 is too short, expected at least %1 characters")
+<< StandaloneVar << MinimumVariableNameLength;

This message can(should) be reused for all warnings with select.
 Obviously you'd put that in a char arrray and the reference it for the next 2 
diags.



Comment at: clang-tools-extra/clang-tidy/readability/VariableLengthCheck.h:20
+
+/// Warns about variable names whose length is too short
+///

Full-stop/period at the end of comments.



Comment at: clang-tools-extra/clang-tidy/readability/VariableLengthCheck.h:36
+
+  std::unordered_set IgnoredLoopCounterNames;
+};

I feel like regex is better suited for this purpose and just ignore any loop 
variables that match the regex.
Doing this will require storing a string as well as the regex for the purpose 
of `storeOptions`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97753

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-01 Thread Bing Yu via Phabricator via cfe-commits
yubing marked 15 inline comments as done.
yubing added inline comments.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:311
+  Value *ResElt = B.CreateAdd(EltC, SubVecR);
+  Value *NewVecC = B.CreateInsertElement(VecCPhi, ResElt, IdxC);
+  Value *NewVecD = B.CreateInsertElement(VecDPhi, ResElt, IdxC);

pengfei wrote:
> yubing wrote:
> > pengfei wrote:
> > > Is it necessary to insert the ResElt to VecC?
> > Yes, it is necessary since you should use updated eltC(aka, Cij) when you 
> > are doing matrix dotproduct:
> > Cij =Cij+Ai1.*B1j
> > Cij =Cij+Ai2.*B2j
> > 
> > Cij =Cij+AiK.*BKj
> But you don't need to update both C and D. Something like the psudo code 
> should enough:
> ```
> for (k : K)
>   Dij += Aik * Bkj;
> Dij += Cij
> ```
I change code into the following style, and it can also reduce inner loop's 
size:
```
for (k : K)
  Cij += Aik * Bkj;
Dij = Cij
```
Besides, I hoist the procedure of calculating (i,j)'s linear index above inner 
loops.



Comment at: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-bitcast.ll:13
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tileload.scalarize.rows.body:
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_HEADER:%.*]]

pengfei wrote:
> It seems the body block is not necessary
In fact, ISEL PASS can merge basicblocks together.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D97577: [clang-tidy] performance-for-range-copy: Don't trigger on implicit type conversions.

2021-03-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D97577#2596458 , @hokein wrote:

> In D97577#2592827 , @flx wrote:
>
>> In D97577#2592093 , @lebedev.ri 
>> wrote:
>>
>>> It is best not to change existing tests, but add new ones.
>>
>> Could elaborate on this, Roman?
>>
>> In this case the tests use special auto convertible types with the intention 
>> to test that the check doesn't trigger because the loop variable needs to be 
>> constructed. But the reason they don't trigger is that the loop variable 
>> erroneously is already a reference type.
>>
>> If we keep the tests as is we should rename the test functions and use 
>> different types or document that the real reason they don't trigger is that 
>> they already are const reference types, but we already have a test for that 
>> as well.
>
> The explanation sounds plausible, thanks.

Yep, no further comments from me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97577

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


[PATCH] D97577: [clang-tidy] performance-for-range-copy: Don't trigger on implicit type conversions.

2021-03-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

In D97577#2592827 , @flx wrote:

> In D97577#2592093 , @lebedev.ri 
> wrote:
>
>> It is best not to change existing tests, but add new ones.
>
> Could elaborate on this, Roman?
>
> In this case the tests use special auto convertible types with the intention 
> to test that the check doesn't trigger because the loop variable needs to be 
> constructed. But the reason they don't trigger is that the loop variable 
> erroneously is already a reference type.
>
> If we keep the tests as is we should rename the test functions and use 
> different types or document that the real reason they don't trigger is that 
> they already are const reference types, but we already have a test for that 
> as well.

The explanation sounds plausible, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97577

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-01 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 327362.
yubing edited the summary of this revision.
yubing added a comment.

address comments above


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

Files:
  llvm/include/llvm/CodeGen/Passes.h
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-amx-bitcast.ll
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -497,7 +497,7 @@
   "expand-reductions","indirectbr-expand",
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
-  "polyhedral-info"};
+  "lower-amx-intrinsics", "polyhedral-info"};
   for (const auto  : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -24,11 +24,12 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
-; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Basic Alias Analysis (stateless AA impl)
-; CHECK-NEXT:   Natural Loop Information
 ; CHECK-NEXT:   Canonicalize natural loops
 ; CHECK-NEXT:   Scalar Evolution Analysis
 ; CHECK-NEXT:   Loop Pass Manager
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -18,6 +18,9 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -lower-amx-type %s -S | FileCheck %s
+; RUN: opt --codegen-opt-level=2 -mtriple=x86_64 -lower-amx-type %s -S | FileCheck %s
 
 %struct.__tile_str = type { i16, i16, <256 x i32> }
 
Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -0,0 +1,237 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -mtriple=x86_64 -lower-amx-intrinsics %s -S | FileCheck %s
+
+define dso_local void @test_amx_load_non_O0(i16 signext %row, i16 signext %col, i8 *%ptr, i64 %stride, <256 x i32>* %vptr) {
+; CHECK-LABEL: @test_amx_load_non_O0(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i64 [[STRIDE:%.*]], 2
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.rows.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TILELOAD_SCALARIZE_ROWS_STEP:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP11:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tileload.scalarize.rows.body:
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.cols.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TILELOAD_SCALARIZE_ROWS_BODY]] ], [ [[TILELOAD_SCALARIZE_COLS_STEP:%.*]], [[TILELOAD_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI:%.*]] = phi <256 x i32> [ [[VEC_PHI_ROW]], [[TILELOAD_SCALARIZE_ROWS_BODY]] ], [ [[TMP11]], [[TILELOAD_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_BODY:%.*]]
+; CHECK:   tileload.scalarize.cols.body:

[PATCH] D96853: [clang][AVR] Support variable decorator '__flash'

2021-03-01 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 327361.

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

https://reviews.llvm.org/D96853

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/avr-flash.c


Index: clang/test/CodeGen/avr-flash.c
===
--- /dev/null
+++ clang/test/CodeGen/avr-flash.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+
+int foo(int i, int j) {
+  static __flash int b[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 
'const' needed for variables in address space '__flash'}}
+  return b[j] + b[i];
+}
Index: clang/test/CodeGen/address-space-avr.c
===
--- clang/test/CodeGen/address-space-avr.c
+++ clang/test/CodeGen/address-space-avr.c
@@ -1,12 +1,21 @@
 // RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
 
-// Test that function declarations in nonzero address spaces without prototype
-// are called correctly.
+// CHECK: @var0 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @bar.var2 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @var1 {{.*}} addrspace(1) constant [3 x i16]
 
 // CHECK: define{{.*}} void @bar() addrspace(1)
-// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to 
void (i16) addrspace(1)*)(i16 3)
+// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to 
void (i16) addrspace(1)*)
 // CHECK: declare void @foo(...) addrspace(1)
+
+__flash const int var0[] = {999, 888, 777};
+__flash static const int var1[] = {111, 222, 333};
+
+int i;
+
 void foo();
-void bar(void) {
-   foo(3);
+
+void bar() {
+  static __flash const int var2[] = {555, 666, 777};
+  foo(var1[i]);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/DiagnosticFrontend.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/CodeGen/SwiftCallingConv.h"
 #include "llvm/ADT/SmallBitVector.h"
@@ -8032,6 +8033,19 @@
   AVRTargetCodeGenInfo(CodeGenTypes )
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
+  LangAS getGlobalVarAddressSpace(CodeGenModule ,
+  const VarDecl *D) const override {
+// Check if a global/static variable is defined within address space 1
+// but not constant.
+LangAS AS = D->getType().getAddressSpace();
+if (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 1 &&
+!D->getType().isConstQualified())
+  CGM.getDiags().Report(D->getLocation(),
+diag::err_qualifier_with_address_space)
+  << 0 << 0 << "__flash";
+return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
+  }
+
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override {
 if (GV->isDeclaration())
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -308,6 +308,7 @@
   Builder.defineMacro("__AVR");
   Builder.defineMacro("__AVR__");
   Builder.defineMacro("__ELF__");
+  Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
 
   if (!this->CPU.empty()) {
 auto It = llvm::find_if(
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2991,6 +2991,9 @@
   "parameter may not be qualified with an address space">;
 def err_field_with_address_space : Error<
   "field may not be qualified with an address space">;
+def err_qualifier_with_address_space : Error<
+  "qualifier '%select{const|volatile}0' %select{needed|invalid}1 "
+  "for variables in address space '%2'">;
 def err_compound_literal_with_address_space : Error<
   "compound literal in function scope may not be qualified with an address 
space">;
 def err_address_space_mismatch_templ_inst : Error<


Index: clang/test/CodeGen/avr-flash.c
===
--- /dev/null
+++ clang/test/CodeGen/avr-flash.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+
+int foo(int i, int j) {
+  static __flash int b[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 'const' needed for variables in address space '__flash'}}
+  return b[j] + b[i];
+}
Index: clang/test/CodeGen/address-space-avr.c
===

[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

We should never silently accept and ignore an attribute unless (1) that's 
allowable semantics for the attribute or (2) we have to for source 
compatibility.  That test is specifically checking that we allow 
`__attribute__((nomerge))` before `@try` statements.  Are we just dropping the 
attribute, or are we correctly applying it to calls within the statement?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97371

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


[PATCH] D97535: [clangd] Use URIs instead of paths in the index file list

2021-03-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:292
+for (const auto  : *Slab) {
+  if (Sym.Definition)
+Files.insert(Sym.Definition.FileURI);

ArcsinX wrote:
> kadircet wrote:
> > it feels weird to choose one or the other here, why not just insert both 
> > (after checking if definition exists, ofc).
> > 
> > We are likely to have a merged symbol information anyway, and the logic 
> > here will likely result in no index owning the header files, unless there 
> > are some symbols *defined* (not just declared) in it.
> > 
> > This will likely result in some overshooting as knowing about a symbols 
> > declaration location doesn't mean indexing that particular file. But so 
> > does the current version, as knowing about definition location might be 
> > because of a merged symbol, rather than indexing of particular file.
> I will try to explain on example:
> 
> - **test.h**
> ```
> void f();
> ```
> - **test.c**
> ```
> #include "test.h"
> void f() { }
> ```
> - compile_commands.json contains a command for **test.c** compilation.
> 
> Scenario:
> - open **test.c**
> - try to find all references for `f()`
> 
> For that scenario result for `find all references` will be incorrect if both 
> (decl and def) files are in the file list because:
> - decl location is inside **test.h**
> - def location is inside **test.c**
> - the file list for the main file index contains **test.h** and **test.c**
> - the main file index does not contain references from **test.h**
> - the background (static) index contains references from **test.c**, but 
> results from the background index will be skipped, because **test.h** is in 
> the main file (dynamic) index file list.
Ah i see. This all seems really fragile :/ We might as well have something like:

a.h:
```
struct Bar;
```

a.cc:
```
#include "a.h"
struct Bar;
```

and now as soon as you open a.cc, all the results from a.h will be gone, 
because canonical declaration location for `Bar` will be in `a.h` and there is 
no definition. (and i believe this kind of forward-decl madness is quite common 
in at least LLVM). 
Even worse, the same will also happen even if you have definition in the 
header, but a forward decl in the main file, so even accepting the file for 
definition wouldn't be enough.

It is currently (i.e. without this patch) working as expected, as main file 
index only owns the information for the "main file" indexing was initiated for. 
This feels like a big regression to me (that I didn't notice initially, sorry 
for that), but I am ready to be convinced otherwise :D

As Sam mentioned what you do here and partitioning logic in FileShardedIndex is 
quite similar (yours undershoot, sharding logic overshoots) but in the sharding 
process we split indexing result of a full TU/preamble, and later on those 
shards will always be used in a merged fashion (e.g. when a.cc and b.cc, both 
including a.h gets indexed, the shard produced for a.h from b.cc won't contain 
any definition locations, but the shard produced for a.cc will know about those 
symbols definition locations and in a merged view those symbols will have all 
the necessary information.), whereas in here the resulting information is used 
in isolation (main file isn't merged with preamble symbols, but mixes Files 
view). Hence causing such regressions.

I think the proper thing to do here is to propagate relevant files with slabs 
on `FileSymbols::update`. What you do here and sharding isn't very different. 
The question is should we have a:
- string File
- optional File
- vector Files

Currently we always have exactly one File associated with all of those slabs as 
we either:
- always do sharding (preamble and background idx)
- even though symbol informations tell otherwise, we've only processed a single 
file (main file idx)

We would need 3rd option if we were to use filesymbols with a monolithic index, 
but we don't. And even if we need such a thing in future it shouldn't be a huge 
change hopefully.


Sorry for the wall of text, I hope I do make sense, but please tell me if I 
misunderstood/missing something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97535

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


[PATCH] D97733: Fix infinite recursion during IR emission if a constant-initialized lifetime-extended temporary object's initializer refers back to the same object.

2021-03-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e2579dbf434: Fix infinite recursion during IR emission if a 
constant-initialized lifetime… (authored by rsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97733

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/temporaries.cpp


Index: clang/test/CodeGenCXX/temporaries.cpp
===
--- clang/test/CodeGenCXX/temporaries.cpp
+++ clang/test/CodeGenCXX/temporaries.cpp
@@ -53,6 +53,17 @@
   // CHECK: @_ZN9BraceInit1xE ={{.*}} constant i32* @_ZGRN9BraceInit1xE_
 }
 
+namespace RefTempSubobject {
+  struct SelfReferential {
+int *p = ints;
+int ints[3] = {1, 2, 3};
+  };
+
+  // CHECK: @_ZGRN16RefTempSubobject2srE_ = internal global { i32*, [3 x i32] 
} { {{.*}} getelementptr {{.*}} @_ZGRN16RefTempSubobject2srE_ {{.*}}, [3 x i32] 
[i32 1, i32 2, i32 3] }
+  // CHECK: @_ZN16RefTempSubobject2srE = {{.*}} constant {{.*}} 
@_ZGRN16RefTempSubobject2srE_
+  constexpr const SelfReferential  = SelfReferential();
+}
+
 struct A {
   A();
   ~A();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5325,8 +5325,21 @@
 
   CharUnits Align = getContext().getTypeAlignInChars(MaterializedType);
 
-  if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E])
-return ConstantAddress(Slot, Align);
+  auto InsertResult = MaterializedGlobalTemporaryMap.insert({E, nullptr});
+  if (!InsertResult.second) {
+// We've seen this before: either we already created it or we're in the
+// process of doing so.
+if (!InsertResult.first->second) {
+  // We recursively re-entered this function, probably during emission of
+  // the initializer. Create a placeholder. We'll clean this up in the
+  // outer call, at the end of this function.
+  llvm::Type *Type = getTypes().ConvertTypeForMem(MaterializedType);
+  InsertResult.first->second = new llvm::GlobalVariable(
+  getModule(), Type, false, llvm::GlobalVariable::InternalLinkage,
+  nullptr);
+}
+return ConstantAddress(InsertResult.first->second, Align);
+  }
 
   // FIXME: If an externally-visible declaration extends multiple temporaries,
   // we need to give each temporary the same name in every translation unit 
(and
@@ -5405,7 +5418,17 @@
 *this, GV, AddrSpace, LangAS::Default,
 Type->getPointerTo(
 getContext().getTargetAddressSpace(LangAS::Default)));
-  MaterializedGlobalTemporaryMap[E] = CV;
+
+  // Update the map with the new temporary. If we created a placeholder above,
+  // replace it with the new global now.
+  llvm::Constant * = MaterializedGlobalTemporaryMap[E];
+  if (Entry) {
+Entry->replaceAllUsesWith(
+llvm::ConstantExpr::getBitCast(CV, Entry->getType()));
+llvm::cast(Entry)->eraseFromParent();
+  }
+  Entry = CV;
+
   return ConstantAddress(CV, Align);
 }
 


Index: clang/test/CodeGenCXX/temporaries.cpp
===
--- clang/test/CodeGenCXX/temporaries.cpp
+++ clang/test/CodeGenCXX/temporaries.cpp
@@ -53,6 +53,17 @@
   // CHECK: @_ZN9BraceInit1xE ={{.*}} constant i32* @_ZGRN9BraceInit1xE_
 }
 
+namespace RefTempSubobject {
+  struct SelfReferential {
+int *p = ints;
+int ints[3] = {1, 2, 3};
+  };
+
+  // CHECK: @_ZGRN16RefTempSubobject2srE_ = internal global { i32*, [3 x i32] } { {{.*}} getelementptr {{.*}} @_ZGRN16RefTempSubobject2srE_ {{.*}}, [3 x i32] [i32 1, i32 2, i32 3] }
+  // CHECK: @_ZN16RefTempSubobject2srE = {{.*}} constant {{.*}} @_ZGRN16RefTempSubobject2srE_
+  constexpr const SelfReferential  = SelfReferential();
+}
+
 struct A {
   A();
   ~A();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5325,8 +5325,21 @@
 
   CharUnits Align = getContext().getTypeAlignInChars(MaterializedType);
 
-  if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E])
-return ConstantAddress(Slot, Align);
+  auto InsertResult = MaterializedGlobalTemporaryMap.insert({E, nullptr});
+  if (!InsertResult.second) {
+// We've seen this before: either we already created it or we're in the
+// process of doing so.
+if (!InsertResult.first->second) {
+  // We recursively re-entered this function, probably during emission of
+  // the initializer. Create a placeholder. We'll clean this up in the
+  // outer call, at the end of this function.
+  llvm::Type *Type = getTypes().ConvertTypeForMem(MaterializedType);
+  InsertResult.first->second = new llvm::GlobalVariable(
+  getModule(), Type, false, 

[clang] 9e2579d - Fix infinite recursion during IR emission if a constant-initialized lifetime-extended temporary object's initializer refers back to the same object.

2021-03-01 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-03-01T22:19:21-08:00
New Revision: 9e2579dbf434e996b3d35f27b5a1762019cf27bb

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

LOG: Fix infinite recursion during IR emission if a constant-initialized 
lifetime-extended temporary object's initializer refers back to the same object.

`GetAddrOfGlobalTemporary` previously tried to emit the initializer of
a global temporary before updating the global temporary map. Emitting the
initializer could recurse back into `GetAddrOfGlobalTemporary` for the same
temporary, resulting in an infinite recursion.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/temporaries.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 750439dd6844..765138bc798f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5325,8 +5325,21 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
 
   CharUnits Align = getContext().getTypeAlignInChars(MaterializedType);
 
-  if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E])
-return ConstantAddress(Slot, Align);
+  auto InsertResult = MaterializedGlobalTemporaryMap.insert({E, nullptr});
+  if (!InsertResult.second) {
+// We've seen this before: either we already created it or we're in the
+// process of doing so.
+if (!InsertResult.first->second) {
+  // We recursively re-entered this function, probably during emission of
+  // the initializer. Create a placeholder. We'll clean this up in the
+  // outer call, at the end of this function.
+  llvm::Type *Type = getTypes().ConvertTypeForMem(MaterializedType);
+  InsertResult.first->second = new llvm::GlobalVariable(
+  getModule(), Type, false, llvm::GlobalVariable::InternalLinkage,
+  nullptr);
+}
+return ConstantAddress(InsertResult.first->second, Align);
+  }
 
   // FIXME: If an externally-visible declaration extends multiple temporaries,
   // we need to give each temporary the same name in every translation unit 
(and
@@ -5405,7 +5418,17 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
 *this, GV, AddrSpace, LangAS::Default,
 Type->getPointerTo(
 getContext().getTargetAddressSpace(LangAS::Default)));
-  MaterializedGlobalTemporaryMap[E] = CV;
+
+  // Update the map with the new temporary. If we created a placeholder above,
+  // replace it with the new global now.
+  llvm::Constant * = MaterializedGlobalTemporaryMap[E];
+  if (Entry) {
+Entry->replaceAllUsesWith(
+llvm::ConstantExpr::getBitCast(CV, Entry->getType()));
+llvm::cast(Entry)->eraseFromParent();
+  }
+  Entry = CV;
+
   return ConstantAddress(CV, Align);
 }
 

diff  --git a/clang/test/CodeGenCXX/temporaries.cpp 
b/clang/test/CodeGenCXX/temporaries.cpp
index edbaa7619221..3ce350d03f48 100644
--- a/clang/test/CodeGenCXX/temporaries.cpp
+++ b/clang/test/CodeGenCXX/temporaries.cpp
@@ -53,6 +53,17 @@ namespace BraceInit {
   // CHECK: @_ZN9BraceInit1xE ={{.*}} constant i32* @_ZGRN9BraceInit1xE_
 }
 
+namespace RefTempSubobject {
+  struct SelfReferential {
+int *p = ints;
+int ints[3] = {1, 2, 3};
+  };
+
+  // CHECK: @_ZGRN16RefTempSubobject2srE_ = internal global { i32*, [3 x i32] 
} { {{.*}} getelementptr {{.*}} @_ZGRN16RefTempSubobject2srE_ {{.*}}, [3 x i32] 
[i32 1, i32 2, i32 3] }
+  // CHECK: @_ZN16RefTempSubobject2srE = {{.*}} constant {{.*}} 
@_ZGRN16RefTempSubobject2srE_
+  constexpr const SelfReferential  = SelfReferential();
+}
+
 struct A {
   A();
   ~A();



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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-03-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Well we test them on `@try` in `tests/Parser/stmt-attributes.m`, but they are 
not being diagnosed as invalid. Should I instead keep the 
`ProhibitAttributes()` call and change the test to make sure they //are// being 
diagnosed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97371

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


[PATCH] D97224: Use Address for CGBuilder's CreateAtomicRMW and CreateAtomicCmpXchg.

2021-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Do we really consider the existing atomic intrinsics to not impose added 
alignment restrictions?  I'm somewhat concerned that we're going to produce IR 
here that's either really suboptimal or, worse, unimplementable, just because 
we over-interpreted some cue about alignment.  I guess it would only be a 
significant problem on a target where types are frequently under-aligned for 
what atomics need, which is not typical, or when the user is doing atomics on a 
field of something like a packed struct.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:354
   llvm::Type *Int128PtrTy = Int128Ty->getPointerTo();
-  Destination = CGF.Builder.CreateBitCast(Destination, Int128PtrTy);
-  Address ComparandResult(CGF.Builder.CreateBitCast(ComparandPtr, Int128PtrTy),
-  CGF.getContext().toCharUnitsFromBits(128));
+  DestAddr = CGF.Builder.CreateBitCast(DestAddr, Int128PtrTy);
+  ComparandAddr = CGF.Builder.CreateBitCast(ComparandAddr, Int128PtrTy);

Since you're changing this code anyway, please make this do 
`CreateElementBitCast(DestAddr, Int128Ty)` so that it's address-space-correct.

There are a lot of other lines in the patch that would benefit from the same 
thing.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3765
 Ptr = Builder.CreateBitCast(Ptr, Int8Ty->getPointerTo(AddrSpace));
+Address PtrAddr(Ptr, CharUnits::One());
 Value *NewVal = Builder.getInt8(1);

This should be using `EmitPointerWithAlignment` instead of assuming an 
alignment of 1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97224

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


[PATCH] D97116: Reduce the number of attributes attached to each function

2021-03-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D97116#2596275 , @crownyanguan 
wrote:

> However, this commit will cause performance regression.

More details?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97116

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

We don't have any reason to allow attributes on any of the `@` statements, but 
there's no reason to disallow them grammatically, as long as we still diagnose 
them as invalid (which I assume is tested somewhere?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97371

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


[PATCH] D95691: Implement P2173 for attributes on lambdas

2021-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Sorry.  I have no problem with continuing the existing pattern, I guess.


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

https://reviews.llvm.org/D95691

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


[PATCH] D97733: Fix infinite recursion during IR emission if a constant-initialized lifetime-extended temporary object's initializer refers back to the same object.

2021-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

No, I like this approach, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97733

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


[PATCH] D95984: [CodeGen] Fix codegen for __attribute__((swiftasynccall)).

2021-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95984

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


[clang] 1ff9361 - [PowerPC] Add missing overloads of vec_promote to altivec.h

2021-03-01 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-03-01T21:40:30-06:00
New Revision: 1ff93618e58df210def48d26878c20a1b414d900

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

LOG: [PowerPC] Add missing overloads of vec_promote to altivec.h

The VSX-only overloads (for 8-byte element vectors) are missing.
Add the missing overloads and convert element numbering to
modulo arithmetic to match GCC and XLC.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 402f3b389496..935eac3c8672 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -14024,49 +14024,71 @@ static __inline__ void __ATTRS_o_ai vec_stvrxl(vector 
float __a, int __b,
 static __inline__ vector signed char __ATTRS_o_ai vec_promote(signed char __a,
   int __b) {
   vector signed char __res = (vector signed char)(0);
-  __res[__b] = __a;
+  __res[__b & 0x7] = __a;
   return __res;
 }
 
 static __inline__ vector unsigned char __ATTRS_o_ai
 vec_promote(unsigned char __a, int __b) {
   vector unsigned char __res = (vector unsigned char)(0);
-  __res[__b] = __a;
+  __res[__b & 0x7] = __a;
   return __res;
 }
 
 static __inline__ vector short __ATTRS_o_ai vec_promote(short __a, int __b) {
   vector short __res = (vector short)(0);
-  __res[__b] = __a;
+  __res[__b & 0x7] = __a;
   return __res;
 }
 
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_promote(unsigned short __a, int __b) {
   vector unsigned short __res = (vector unsigned short)(0);
-  __res[__b] = __a;
+  __res[__b & 0x7] = __a;
   return __res;
 }
 
 static __inline__ vector int __ATTRS_o_ai vec_promote(int __a, int __b) {
   vector int __res = (vector int)(0);
-  __res[__b] = __a;
+  __res[__b & 0x3] = __a;
   return __res;
 }
 
 static __inline__ vector unsigned int __ATTRS_o_ai vec_promote(unsigned int 
__a,
int __b) {
   vector unsigned int __res = (vector unsigned int)(0);
-  __res[__b] = __a;
+  __res[__b & 0x3] = __a;
   return __res;
 }
 
 static __inline__ vector float __ATTRS_o_ai vec_promote(float __a, int __b) {
   vector float __res = (vector float)(0);
-  __res[__b] = __a;
+  __res[__b & 0x3] = __a;
   return __res;
 }
 
+#ifdef __VSX__
+static __inline__ vector double __ATTRS_o_ai vec_promote(double __a, int __b) {
+  vector double __res = (vector double)(0);
+  __res[__b & 0x1] = __a;
+  return __res;
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_promote(signed long long __a, int __b) {
+  vector signed long long __res = (vector signed long long)(0);
+  __res[__b & 0x1] = __a;
+  return __res;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_promote(unsigned long long __a, int __b) {
+  vector unsigned long long __res = (vector unsigned long long)(0);
+  __res[__b & 0x1] = __a;
+  return __res;
+}
+#endif
+
 /* vec_splats */
 
 static __inline__ vector signed char __ATTRS_o_ai vec_splats(signed char __a) {

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index bd0e66e69800..53370cb3949e 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -22,6 +22,7 @@ vector signed long long vsll = { 255LL, -937LL };
 vector unsigned long long vull = { 1447LL, 2894LL };
 double d = 23.4;
 signed long long sll = 618LL;
+unsigned long long ull = 618ULL;
 float af[4] = {23.4f, 56.7f, 89.0f, 12.3f};
 double ad[2] = {23.4, 56.7};
 signed char asc[16] = { -8,  9, -10, 11, -12, 13, -14, 15,
@@ -1851,6 +1852,24 @@ res_vsc = vec_xxsldwi(vsc, vsc, 0);
 res_vuc = vec_xxsldwi(vuc, vuc, 1);
 // CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x 
i32> 
 // CHECK-LE: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x 
i32> 
+
+res_vd = vec_promote(d, 0);
+// CHECK: store <2 x double> zeroinitializer
+// CHECK: insertelement <2 x double>
+// CHECK-LE: store <2 x double> zeroinitializer
+// CHECK-LE: insertelement <2 x double>
+
+res_vsll = vec_promote(sll, 0);
+// CHECK: store <2 x i64> zeroinitializer
+// CHECK: insertelement <2 x i64>
+// CHECK-LE: store <2 x i64> zeroinitializer
+// CHECK-LE: insertelement <2 x i64>
+
+res_vull = vec_promote(ull, 0);
+// CHECK: store <2 x i64> zeroinitializer
+// CHECK: insertelement <2 x i64>
+// CHECK-LE: store <2 x i64> zeroinitializer
+// CHECK-LE: insertelement <2 x i64>
 }
 
 // The return type of the call expression may be 
diff erent from the return type of the shufflevector.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D97116: Reduce the number of attributes attached to each function

2021-03-01 Thread crownyanguan via Phabricator via cfe-commits
crownyanguan added a comment.

However, this commit will cause performance regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97116

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


[PATCH] D97561: [clang] Use CompilerInstance::createTarget to createTarget

2021-03-01 Thread Tommy Chiang via Phabricator via cfe-commits
oToToT added a comment.

Kindly ping.

Since the part I modified is quite... old (about 4 to 7 years ago?), I hope 
I've found the right person to review for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97561

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


[clang] 38a34e2 - [PowerPC] Use modulo arithmetic for vec_extract in altivec.h

2021-03-01 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-03-01T19:49:26-06:00
New Revision: 38a34e207f30747a4b0288d97ce67e422bf5f363

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

LOG: [PowerPC] Use modulo arithmetic for vec_extract in altivec.h

These interfaces are not covered in the ELFv2 ABI but are rather
implemented to emulate those available in GCC/XLC. However, the
ones in the other compilers are documented to perform modulo
arithmetic on the element number. This patch just brings clang
inline with the other compilers at -O0 (with optimization, clang
already does the right thing).

Added: 


Modified: 
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 4d50d47d51b5..402f3b389496 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -12915,73 +12915,75 @@ vec_vxor(vector bool long long __a, vector bool long 
long __b) {
 /* vec_extract */
 
 static __inline__ signed char __ATTRS_o_ai vec_extract(vector signed char __a,
-   int __b) {
-  return __a[__b];
+   unsigned int __b) {
+  return __a[__b & 0xf];
 }
 
 static __inline__ unsigned char __ATTRS_o_ai
-vec_extract(vector unsigned char __a, int __b) {
-  return __a[__b];
+vec_extract(vector unsigned char __a, unsigned int __b) {
+  return __a[__b & 0xf];
 }
 
 static __inline__ unsigned char __ATTRS_o_ai vec_extract(vector bool char __a,
- int __b) {
-  return __a[__b];
+ unsigned int __b) {
+  return __a[__b & 0xf];
 }
 
 static __inline__ signed short __ATTRS_o_ai vec_extract(vector signed short 
__a,
-int __b) {
-  return __a[__b];
+unsigned int __b) {
+  return __a[__b & 0x7];
 }
 
 static __inline__ unsigned short __ATTRS_o_ai
-vec_extract(vector unsigned short __a, int __b) {
-  return __a[__b];
+vec_extract(vector unsigned short __a, unsigned int __b) {
+  return __a[__b & 0x7];
 }
 
 static __inline__ unsigned short __ATTRS_o_ai vec_extract(vector bool short 
__a,
-  int __b) {
-  return __a[__b];
+  unsigned int __b) {
+  return __a[__b & 0x7];
 }
 
 static __inline__ signed int __ATTRS_o_ai vec_extract(vector signed int __a,
-  int __b) {
-  return __a[__b];
+  unsigned int __b) {
+  return __a[__b & 0x3];
 }
 
 static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector unsigned int 
__a,
-int __b) {
-  return __a[__b];
+unsigned int __b) {
+  return __a[__b & 0x3];
 }
 
 static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector bool int __a,
-int __b) {
-  return __a[__b];
+unsigned int __b) {
+  return __a[__b & 0x3];
 }
 
 #ifdef __VSX__
 static __inline__ signed long long __ATTRS_o_ai
-vec_extract(vector signed long long __a, int __b) {
-  return __a[__b];
+vec_extract(vector signed long long __a, unsigned int __b) {
+  return __a[__b & 0x1];
 }
 
 static __inline__ unsigned long long __ATTRS_o_ai
-vec_extract(vector unsigned long long __a, int __b) {
-  return __a[__b];
+vec_extract(vector unsigned long long __a, unsigned int __b) {
+  return __a[__b & 0x1];
 }
 
 static __inline__ unsigned long long __ATTRS_o_ai
-vec_extract(vector bool long long __a, int __b) {
-  return __a[__b];
+vec_extract(vector bool long long __a, unsigned int __b) {
+  return __a[__b & 0x1];
 }
 
-static __inline__ double __ATTRS_o_ai vec_extract(vector double __a, int __b) {
-  return __a[__b];
+static __inline__ double __ATTRS_o_ai vec_extract(vector double __a,
+  unsigned int __b) {
+  return __a[__b & 0x1];
 }
 #endif
 
-static __inline__ float __ATTRS_o_ai vec_extract(vector float __a, int __b) {
-  return __a[__b];
+static __inline__ float __ATTRS_o_ai vec_extract(vector float __a,
+ unsigned int __b) {
+  return __a[__b & 0x3];
 }
 
 #ifdef __POWER9_VECTOR__



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


[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths

2021-03-01 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

This patch

In D97669#2596073 , @aykevl wrote:

> Looks reasonable to me. But again, I would like this to be reviewed also by 
> someone familiar with the internals of Clang (I'm not).

Actually this patch is copied from msp430, with just a little change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97669

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


[libunwind] b17d464 - [libunwind] This adds support in libunwind for rv32 hard float

2021-03-01 Thread Kamlesh Kumar via cfe-commits

Author: Kamlesh Kumar
Date: 2021-03-02T06:58:24+05:30
New Revision: b17d46430fce665d23661e23ade3ca57c3791836

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

LOG: [libunwind] This adds support in libunwind for rv32 hard float
and soft-float for both rv32 and rv64.

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

Added: 


Modified: 
libunwind/include/__libunwind_config.h
libunwind/src/Registers.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/assembly.h
libunwind/src/libunwind.cpp

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 34ac6f717d6e..a50ba053884b 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -131,12 +131,19 @@
   #define _LIBUNWIND_CONTEXT_SIZE 16
   #define _LIBUNWIND_CURSOR_SIZE 23
 # elif defined(__riscv)
-#  if __riscv_xlen == 64
-#define _LIBUNWIND_TARGET_RISCV 1
-#define _LIBUNWIND_CONTEXT_SIZE 64
-#define _LIBUNWIND_CURSOR_SIZE 76
+#  define _LIBUNWIND_TARGET_RISCV 1
+#  if defined(__riscv_flen)
+#   define RISCV_FLEN __riscv_flen
 #  else
-#error "Unsupported RISC-V ABI"
+#   define RISCV_FLEN 0
+#  endif
+#  define _LIBUNWIND_CONTEXT_SIZE (32 * (__riscv_xlen + RISCV_FLEN) / 64)
+#  if __riscv_xlen == 32
+#   define _LIBUNWIND_CURSOR_SIZE (_LIBUNWIND_CONTEXT_SIZE + 7)
+#  elif __riscv_xlen == 64
+#   define _LIBUNWIND_CURSOR_SIZE (_LIBUNWIND_CONTEXT_SIZE + 12)
+#  else
+#   error "Unsupported RISC-V ABI"
 #  endif
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV
 # elif defined(__ve__)

diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index de8e067b9d0c..1d23f97aedfb 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -3728,19 +3728,42 @@ inline const char 
*Registers_hexagon::getRegisterName(int regNum) {
 
 
 #if defined(_LIBUNWIND_TARGET_RISCV)
-/// Registers_riscv holds the register state of a thread in a 64-bit RISC-V
+/// Registers_riscv holds the register state of a thread in a RISC-V
 /// process.
+
+# if __riscv_xlen == 32
+typedef uint32_t reg_t;
+# elif __riscv_xlen == 64
+typedef uint64_t reg_t;
+# else
+#  error "Unsupported __riscv_xlen"
+# endif
+
+# if defined(__riscv_flen)
+#  if __riscv_flen == 64
+typedef double fp_t;
+#  elif __riscv_flen == 32
+typedef float fp_t;
+#  else
+#   error "Unsupported __riscv_flen"
+#  endif
+# else
+// This is just for supressing undeclared error of fp_t.
+typedef double fp_t;
+# endif
+
+/// Registers_riscv holds the register state of a thread.
 class _LIBUNWIND_HIDDEN Registers_riscv {
 public:
   Registers_riscv();
   Registers_riscv(const void *registers);
 
   boolvalidRegister(int num) const;
-  uint64_tgetRegister(int num) const;
-  voidsetRegister(int num, uint64_t value);
+  reg_t   getRegister(int num) const;
+  voidsetRegister(int num, reg_t value);
   boolvalidFloatRegister(int num) const;
-  double  getFloatRegister(int num) const;
-  voidsetFloatRegister(int num, double value);
+  fp_tgetFloatRegister(int num) const;
+  voidsetFloatRegister(int num, fp_t value);
   boolvalidVectorRegister(int num) const;
   v128getVectorRegister(int num) const;
   voidsetVectorRegister(int num, v128 value);
@@ -3749,31 +3772,45 @@ class _LIBUNWIND_HIDDEN Registers_riscv {
   static int  lastDwarfRegNum() { return 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV; }
   static int  getArch() { return REGISTERS_RISCV; }
 
-  uint64_t  getSP() const { return _registers[2]; }
-  void  setSP(uint64_t value) { _registers[2] = value; }
-  uint64_t  getIP() const { return _registers[0]; }
-  void  setIP(uint64_t value) { _registers[0] = value; }
+  reg_t   getSP() const { return _registers[2]; }
+  voidsetSP(reg_t value) { _registers[2] = value; }
+  reg_t   getIP() const { return _registers[0]; }
+  voidsetIP(reg_t value) { _registers[0] = value; }
 
 private:
   // _registers[0] holds the pc
-  uint64_t _registers[32];
-  double   _floats[32];
+  reg_t _registers[32];
+# if defined(__riscv_flen)
+  fp_t _floats[32];
+# endif
 };
 
 inline Registers_riscv::Registers_riscv(const void *registers) {
   static_assert((check_fit::does_fit),
 "riscv registers do not fit into unw_context_t");
   memcpy(&_registers, registers, sizeof(_registers));
+# if __riscv_xlen == 32
+  static_assert(sizeof(_registers) == 0x80,
+"expected float registers to be at offset 128");
+# elif __riscv_xlen == 64
   static_assert(sizeof(_registers) == 0x100,
 "expected 

[PATCH] D97101: [Coverage] Emit zero count gap region between statements if first statements contains return, throw, goto, co_return

2021-03-01 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:942
 pushRegion(Counter::getZero());
-auto  = getRegion();
-ZeroRegion.setDeferred(true);
-LastTerminatedRegion = {EndLoc, RegionStack.size()};
+if (!HasTerminateStmt) {
+  auto  = getRegion();

vsk wrote:
> zequanwu wrote:
> > vsk wrote:
> > > What's supposed to be the difference between the zero region pushed after 
> > > a `return;` vs. after a `break;`?
> > What I think is `DeferredRegion` is only used for `break;` and `continue`. 
> > Other terminate statements like `return;`, `throw` etc will use the logic 
> > in `VisitStmt` to emit gap region. So, I added this condition to separate 
> > the two cases.
> What do you think of the notion of using the gaps inserted in VisitStmt to 
> replace the whole deferred region system? Is it something that might be 
> feasible (if perhaps out of scope for this patch), or do you see a 
> fundamental reason it can't/shouldn't be done?
I think it is feasible. For break and continue, they only affect the statements 
after them in the same block. For other terminate statements, they affect all 
the statements after them even outside the block, see example below. Also 
instead of emitting a zero gap region in VisitStmt, we need emit gap region 
with (previous counter - current statement counter).

```
while (cond) {
...
break; // This affects statements' count until the end of the while body.
...
}

while (cond) {
...
return; // This affects statements' count until the end of the function body.
...
}
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

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


[PATCH] D97741: [clang+lld] Pass -platform_version args to ld64.lld

2021-03-01 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

If I understand this right, the right patch description should be "fix 
regression where we didn't pass `-platform_version` to new ld64.lld after 
D95204 ", right? It's good to fix this :)

The test changes look like 
http://reviews.llvm.org/rGa9eaf8435d9204f5d71a08cfd7c574e92d434871 so I think 
they're right :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97741

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


[PATCH] D94500: [clang-format] Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-03-01 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj added a comment.

In D94500#2594394 , 
@HazardyKnusperkeks wrote:

> In D94500#2593229 , @timwoj wrote:
>
>> In D94500#2592448 , 
>> @HazardyKnusperkeks wrote:
>>
>>> Do you need someone to push this?
>>
>> Yes I do. I don't have committer access.
>
> Please state the name and mail for the commit.

Tim Wojtulewicz
tim...@gmail.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths

2021-03-01 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

Looks reasonable to me. But again, I would like this to be reviewed also by 
someone familiar with the internals of Clang (I'm not).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97669

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


[PATCH] D97743: Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

2021-03-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 327320.
MaskRay retitled this revision from "Define __GCC_HAVE_DWARF2_CFI_ASM to 1 on 
ELF/Mach-O if CC1 -munwind-tables is specified" to "Define 
__GCC_HAVE_DWARF2_CFI_ASM if applicable".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Check -g and exceptions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97743

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Preprocessor/unwind-tables.c


Index: clang/test/Preprocessor/unwind-tables.c
===
--- /dev/null
+++ clang/test/Preprocessor/unwind-tables.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows
+// RUN: %clang_cc1 %s -verify -triple x86_64-unknown-elf
+
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
aarch64-apple-darwin
+// RUN: %clang_cc1 %s -verify -debug-info-kind=line-tables-only -DCFI_ASM 
-triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -fexceptions -DCFI_ASM -triple x86_64-unknown-elf
+
+// expected-no-diagnostics
+
+#ifdef CFI_ASM
+  #if __GCC_HAVE_DWARF2_CFI_ASM != 1
+  #error "__GCC_HAVE_DWARF2_CFI_ASM not defined"
+  #endif
+#else
+  #ifdef __GCC_HAVE_DWARF2_CFI_ASM
+  #error "__GCC_HAVE_DWARF2_CFI_ASM defined"
+  #endif
+#endif
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4350,6 +4350,11 @@
   Res.getCodeGenOpts().Argv0 = Argv0;
   Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
 
+  if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) &&
+  (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables ||
+   Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo))
+Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
   Success &= FixupInvocation(Res, Diags, Args, DashX);
 
   return Success;


Index: clang/test/Preprocessor/unwind-tables.c
===
--- /dev/null
+++ clang/test/Preprocessor/unwind-tables.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows
+// RUN: %clang_cc1 %s -verify -triple x86_64-unknown-elf
+
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple aarch64-apple-darwin
+// RUN: %clang_cc1 %s -verify -debug-info-kind=line-tables-only -DCFI_ASM -triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -fexceptions -DCFI_ASM -triple x86_64-unknown-elf
+
+// expected-no-diagnostics
+
+#ifdef CFI_ASM
+  #if __GCC_HAVE_DWARF2_CFI_ASM != 1
+  #error "__GCC_HAVE_DWARF2_CFI_ASM not defined"
+  #endif
+#else
+  #ifdef __GCC_HAVE_DWARF2_CFI_ASM
+  #error "__GCC_HAVE_DWARF2_CFI_ASM defined"
+  #endif
+#endif
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4350,6 +4350,11 @@
   Res.getCodeGenOpts().Argv0 = Argv0;
   Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
 
+  if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) &&
+  (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables ||
+   Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo))
+Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
   Success &= FixupInvocation(Res, Diags, Args, DashX);
 
   return Success;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D94554#2595625 , @njames93 wrote:

> Address some comments, though I have a feeling @Sammccall, I may have to wait 
> until DraftStore has been refactored first before continuing on with this.

D97738  is an attempt at this. It is... 
sprawly, but it's an overdue cleanup that should fit together well with this 
patch, I think.

There may be some conflicts but I don't think it'll be terrible actually... I 
think we should keep going here, it looks really good.




Comment at: clang-tools-extra/clangd/DraftStore.cpp:148
+  static std::unique_ptr
+  create(IntrusiveRefCntPtr Data, StringRef Name) {
+// Allocate space for the FileContentMemBuffer and its name with null

njames93 wrote:
> sammccall wrote:
> > Is there any reason to think we need this micro-optimization? It's quite 
> > invasive.
> Its basically copied from llvm/support/MemoryBuffer.cpp
Sure, but this doesn't really answer the question! Can we keep this trivial 
until we have a reason to optimize it? (Clang typically holds tens of thousands 
of MemoryBuffers, but we're only likely to have a few hundred of these)



Comment at: clang-tools-extra/clangd/DraftStore.cpp:213
+
+class DraftStoreFileSystem : public llvm::vfs::FileSystem {
+public:

njames93 wrote:
> sammccall wrote:
> > can't we use InMemoryFileSystem for this?
> `InMemoryFileSystem` Would work in theory. However using that requires 
> building a lot of unnecessary nodes for thing like intermediate directories.
Probably, but it would keep this code simpler, supports directory iteration and 
status (used in code completion), and I'm fairly confident its path handling is 
solid.

It's certainly possible to add this optimization later if it seems important, 
but in this patch I think it distracts from the design questions.



Comment at: clang-tools-extra/clangd/DraftStore.cpp:287
+for (const auto  : DS.Drafts) {
+  // Query the base filesystem for file uniqueids.
+  auto BaseStatus = BaseView->status(KV.getKey());

njames93 wrote:
> sammccall wrote:
> > doing IO in view() doesn't seem obviously OK.
> > 
> > what's the practical consequence of the overlay's inodes not matching that 
> > of the underlying FS? (It seems reasonable to say that the files always 
> > have different identity, and may/may not have the same content)
> It's probably not necessary, but I know preambles use the UniqueID. It may 
> just be safer to create a uniqueID for each item in the DraftStore and leave 
> it at that.
The biggest risks I can see with this approach:
 - in build-preamble-from-dirty-FS mode, would opening a draft cause the 
preamble to be considered invalid and needing rebuilding? My read of 
PrecompiledPreamble::CanReuse is no (UniqueIDs are not stored)
 - when parsing, if the file can be read through the overlay *and* underlying 
via different paths (e.g. hardlinks), these won't be deduplicated. However 
giving them the same inode only changes the nature of the bug: the file would 
get whichever content was read first.

So I think it's as good as we can expect.



Comment at: clang-tools-extra/clangd/DraftStore.h:37
 
+  DraftStore(const ThreadsafeFS );
+

having DraftStore sit on top of TFS seems a bit inside-out, giving it bigger 
scope than necessary.

What about giving DraftStore an asVFS() method that returns an in-memory 
filesystem?

then separately we can have a separate DirtyFS : TFS, that has a `DraftStore&` 
and a `TFS ` and implements viewImpl() on top of their public interfaces. 
Having the dependency in that direction seems more natural to me.



Comment at: clang-tools-extra/clangd/DraftStore.h:71
 private:
+  struct MetadataDraft {
+Draft Draft;

alternatively you can define whichever internal struct you like, like
```
struct FileData {
  std::string Filename;
  std::string Contents;
  // and MTime and UID
}
```

and store `DenseMap>` (with the keys pointing 
into the values).

You can still hand out `shared_ptr` using the aliasing 
constructor of shared_ptr.

The advantages of this:
 - it avoids the internal representation from being too constrained by the 
public API
 - SharedStringBuffer can easily wrap the whole `shared_ptr`, and so 
you doesn't need a *copy* of the filename

this is a little bit of complexity though, up to you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

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


[clang] 1490f6b - Fix build 5de2d189e6ad4

2021-03-01 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2021-03-01T16:06:30-08:00
New Revision: 1490f6b72c30f690b18018ceefd499562b255efa

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

LOG: Fix build 5de2d189e6ad4

Remove source_mgr remark diagnose kind.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 831f906ffac8..3086e922d9ed 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -22,7 +22,6 @@ def note_fe_inline_asm_here : Note<"instantiated into 
assembly here">;
 def err_fe_source_mgr : Error<"%0">, CatSourceMgr;
 def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, 
InGroup;
 def note_fe_source_mgr : Note<"%0">, CatSourceMgr;
-def remark_fe_source_mgr: Remark<"%0">, CatSourceMgr, 
InGroup;
 def err_fe_cannot_link_module : Error<"cannot link module '%0': %1">,
   DefaultFatal;
 



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


[PATCH] D97743: Define __GCC_HAVE_DWARF2_CFI_ASM to 1 on ELF/Mach-O if CC1 -munwind-tables is specified

2021-03-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: dexonsmith, jansvoboda11.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  % diff <(gcc -fno-asynchronous-unwind-tables -dM -E a.c) <(gcc -dM -E a.c)
  130a131
  > #define __GCC_HAVE_DWARF2_CFI_ASM 1

This macro is useful because code can decide whether inline asm should include 
`.cfi_*` directives.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97743

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Preprocessor/unwind-tables.c


Index: clang/test/Preprocessor/unwind-tables.c
===
--- /dev/null
+++ clang/test/Preprocessor/unwind-tables.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
aarch64-apple-darwin
+// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows
+
+// expected-no-diagnostics
+
+#ifdef CFI_ASM
+  #if __GCC_HAVE_DWARF2_CFI_ASM != 1
+  #error "__GCC_HAVE_DWARF2_CFI_ASM not defined"
+  #endif
+#else
+  #ifdef __GCC_HAVE_DWARF2_CFI_ASM
+  #error "__GCC_HAVE_DWARF2_CFI_ASM defined"
+  #endif
+#endif
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4045,8 +4045,8 @@
 
 static bool ParsePreprocessorArgs(PreprocessorOptions , ArgList ,
   DiagnosticsEngine ,
-  frontend::ActionKind Action,
-  const FrontendOptions ) {
+  const FrontendOptions ,
+  const llvm::Triple ) {
   PreprocessorOptions *PreprocessorOpts = 
   bool Success = true;
 
@@ -4101,6 +4101,10 @@
   Opts.addMacroDef("__CET__=3");
   }
 
+  if (Args.hasArg(OPT_munwind_tables) &&
+  (T.isOSBinFormatELF() || T.isOSBinFormatMachO()))
+Opts.addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
   // Add macros from the command line.
   for (const auto *A : Args.filtered(OPT_D, OPT_U)) {
 if (A->getOption().matches(OPT_D))
@@ -4130,7 +4134,7 @@
   // Always avoid lexing editor placeholders when we're just running the
   // preprocessor as we never want to emit the
   // "editor placeholder in source file" error in PP only mode.
-  if (isStrictlyPreprocessorAction(Action))
+  if (isStrictlyPreprocessorAction(FrontendOpts.ProgramAction))
 Opts.LexEditorPlaceholders = false;
 
   return Success;
@@ -4325,8 +4329,7 @@
   !LangOpts.Sanitize.has(SanitizerKind::KernelMemory);
 
   ParsePreprocessorArgs(Res.getPreprocessorOpts(), Args, Diags,
-Res.getFrontendOpts().ProgramAction,
-Res.getFrontendOpts());
+Res.getFrontendOpts(), T);
   ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), Args, Diags,
   Res.getFrontendOpts().ProgramAction);
 


Index: clang/test/Preprocessor/unwind-tables.c
===
--- /dev/null
+++ clang/test/Preprocessor/unwind-tables.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple aarch64-apple-darwin
+// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows
+
+// expected-no-diagnostics
+
+#ifdef CFI_ASM
+  #if __GCC_HAVE_DWARF2_CFI_ASM != 1
+  #error "__GCC_HAVE_DWARF2_CFI_ASM not defined"
+  #endif
+#else
+  #ifdef __GCC_HAVE_DWARF2_CFI_ASM
+  #error "__GCC_HAVE_DWARF2_CFI_ASM defined"
+  #endif
+#endif
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4045,8 +4045,8 @@
 
 static bool ParsePreprocessorArgs(PreprocessorOptions , ArgList ,
   DiagnosticsEngine ,
-  frontend::ActionKind Action,
-  const FrontendOptions ) {
+  const FrontendOptions ,
+  const llvm::Triple ) {
   PreprocessorOptions *PreprocessorOpts = 
   bool Success = true;
 
@@ -4101,6 +4101,10 @@
   Opts.addMacroDef("__CET__=3");
   }
 
+  if (Args.hasArg(OPT_munwind_tables) &&
+  (T.isOSBinFormatELF() || T.isOSBinFormatMachO()))
+Opts.addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
   // Add macros from the command line.
   for (const auto *A : Args.filtered(OPT_D, OPT_U)) {
 if (A->getOption().matches(OPT_D))
@@ -4130,7 +4134,7 @@
   // Always avoid lexing editor placeholders when we're just running the
   // preprocessor as we never want to emit 

[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5de2d189e6ad: [Diagnose] Unify MCContext and LLVMContext 
diagnosing (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

Files:
  clang/include/clang/Basic/DiagnosticCategories.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/test/CodeGen/AMDGPU/lds-initializer.ll
  llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
  llvm/test/CodeGen/XCore/section-name.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -290,6 +290,22 @@
   bool *HasError;
   LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
   bool handleDiagnostics(const DiagnosticInfo ) override {
+if (DI.getKind() == llvm::DK_SrcMgr) {
+  const auto  = cast(DI);
+  const SMDiagnostic  = DISM.getSMDiag();
+
+  if (SMD.getKind() == SourceMgr::DK_Error)
+*HasError = true;
+
+  SMD.print(nullptr, errs());
+
+  // For testing purposes, we print the LocCookie here.
+  if (DISM.isInlineAsmDiag() && DISM.getLocCookie())
+WithColor::note() << "!srcloc = " << DISM.getLocCookie() << "\n";
+
+  return true;
+}
+
 if (DI.getSeverity() == DS_Error)
   *HasError = true;
 
@@ -305,19 +321,6 @@
   }
 };
 
-static void InlineAsmDiagHandler(const SMDiagnostic , void *Context,
- unsigned LocCookie) {
-  bool *HasError = static_cast(Context);
-  if (SMD.getKind() == SourceMgr::DK_Error)
-*HasError = true;
-
-  SMD.print(nullptr, errs());
-
-  // For testing purposes, we print the LocCookie here.
-  if (LocCookie)
-WithColor::note() << "!srcloc = " << LocCookie << "\n";
-}
-
 // main - Entry point for the llc compiler.
 //
 int main(int argc, char **argv) {
@@ -367,7 +370,6 @@
   bool HasError = false;
   Context.setDiagnosticHandler(
   std::make_unique());
-  Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, );
 
   Expected> RemarksFileOrErr =
   setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
Index: llvm/test/CodeGen/XCore/section-name.ll
===
--- llvm/test/CodeGen/XCore/section-name.ll
+++ llvm/test/CodeGen/XCore/section-name.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
 
 @bar = internal global i32 zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
@@ -1,7 +1,7 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti -filetype=null < %s 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga -filetype=null < %s 2>&1 | FileCheck %s
 
-; CHECK: lds: unsupported initializer for address space
+; CHECK: error: lds: unsupported initializer for address space
 
 @lds = addrspace(3) global [256 x i32] zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-initializer.ll
@@ -1,5 +1,5 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
 
 ; CHECK: lds: unsupported initializer for address space
 
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -2348,7 +2348,7 @@
 /// will use the last parsed cpp hash line filename comment
 /// for the Filename and LineNo if any in the diagnostic.
 void AsmParser::DiagHandler(const SMDiagnostic , void 

[clang] 5de2d18 - [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2021-03-01T15:58:37-08:00
New Revision: 5de2d189e6ad466a1f0616195e8c524a4eb3cbc0

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

LOG: [Diagnose] Unify MCContext and LLVMContext diagnosing

The situation with inline asm/MC error reporting is kind of messy at the
moment. The errors from MC layout are not reliably propagated and users
have to specify an inlineasm handler separately to get inlineasm
diagnose. The latter issue is not a correctness issue but could be improved.

* Kill LLVMContext inlineasm diagnose handler and migrate it to use
  DiagnoseInfo/DiagnoseHandler.
* Introduce `DiagnoseInfoSrcMgr` to diagnose SourceMgr backed errors. This
  covers use cases like inlineasm, MC, and any clients using SourceMgr.
* Move AsmPrinter::SrcMgrDiagInfo and its instance to MCContext. The next step
  is to combine MCContext::SrcMgr and MCContext::InlineSrcMgr because in all
  use cases, only one of them is used.
* If LLVMContext is available, let MCContext uses LLVMContext's diagnose
  handler; if LLVMContext is not available, MCContext uses its own default
  diagnose handler which just prints SMDiagnostic.
* Change a few clients(Clang, llc, lldb) to use the new way of reporting.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticCategories.td
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/CodeGen/CodeGenAction.cpp
lldb/source/Expression/IRExecutionUnit.cpp
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/include/llvm/IR/LLVMContext.h
llvm/include/llvm/MC/MCContext.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/lib/CodeGen/MachineModuleInfo.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/CodeGen/AMDGPU/lds-initializer.ll
llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
llvm/test/CodeGen/XCore/section-name.ll
llvm/tools/llc/llc.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCategories.td 
b/clang/include/clang/Basic/DiagnosticCategories.td
index d7203173790e..fb6bdd710741 100644
--- a/clang/include/clang/Basic/DiagnosticCategories.td
+++ b/clang/include/clang/Basic/DiagnosticCategories.td
@@ -7,4 +7,5 @@
 
//===--===//
 
 class CatInlineAsm : DiagCategory<"Inline Assembly Issue">;
+class CatSourceMgr : DiagCategory<"SourceMgr Reported Issue">;
 class CatBackend : DiagCategory<"Backend Issue">;

diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index b9f8c78e43da..831f906ffac8 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -19,6 +19,10 @@ def err_fe_inline_asm : Error<"%0">, CatInlineAsm;
 def warn_fe_inline_asm : Warning<"%0">, CatInlineAsm, 
InGroup;
 def note_fe_inline_asm : Note<"%0">, CatInlineAsm;
 def note_fe_inline_asm_here : Note<"instantiated into assembly here">;
+def err_fe_source_mgr : Error<"%0">, CatSourceMgr;
+def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, 
InGroup;
+def note_fe_source_mgr : Note<"%0">, CatSourceMgr;
+def remark_fe_source_mgr: Remark<"%0">, CatSourceMgr, 
InGroup;
 def err_fe_cannot_link_module : Error<"cannot link module '%0': %1">,
   DefaultFatal;
 

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 1a1ce66656f5..81d78c69cc44 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1145,6 +1145,7 @@ def OpenMP : DiagGroup<"openmp", [
 
 // Backend warnings.
 def BackendInlineAsm : DiagGroup<"inline-asm">;
+def BackendSourceMgr : DiagGroup<"source-mgr">;
 def BackendFrameLargerThanEQ : DiagGroup<"frame-larger-than=">;
 def BackendPlugin : DiagGroup<"backend-plugin">;
 def RemarkBackendPlugin : DiagGroup<"remark-backend-plugin">;

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 6853926f4362..ff56b2902c54 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -301,14 +301,7 @@ namespace clang {
   if (!getModule())
 return;
 
-  // Install an inline asm handler so that diagnostics get printed through
-  // our diagnostics hooks.
   LLVMContext  = getModule()->getContext();
-  LLVMContext::InlineAsmDiagHandlerTy OldHandler =
-Ctx.getInlineAsmDiagnosticHandler();

[PATCH] D97741: [clang+lld] Pass -platform_version args to ld64.lld

2021-03-01 Thread Jez Ng via Phabricator via cfe-commits
int3 created this revision.
int3 added reviewers: lld-macho, thakis.
Herald added subscribers: steven_wu, hiraditya.
int3 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Now that ld64.lld points to the new Darwin backend, we can pass it the newer
`-platform_version` flag.

Most of the changes were originally in D95204: [lld-macho] Switch default to 
new Darwin backend , but I backed them out due 
to
test failures on builds which have `CLANG_DEFAULT_LINKER=lld`. The tests are
properly updated in this diff. @thakis, want to have a second look to make sure
things make sense? I haven't worked with clang-driver code much.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97741

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/lld/ld64.lld.darwinnew
  clang/test/Driver/Inputs/lld/ld64.lld.darwinold
  clang/test/Driver/darwin-infer-simulator-sdkroot.c
  clang/test/Driver/darwin-ld-demangle-lld.c
  clang/test/Driver/darwin-ld-lto.c
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c
  clang/test/Driver/darwin-sdkroot.c
  clang/test/Driver/target-triple-deployment.c

Index: clang/test/Driver/target-triple-deployment.c
===
--- clang/test/Driver/target-triple-deployment.c
+++ clang/test/Driver/target-triple-deployment.c
@@ -1,16 +1,16 @@
 // RUN: touch %t.o
-// RUN: %clang -target x86_64-apple-macosx10.4 -mlinker-version=400 -### %t.o 2> %t.log
-// RUN: %clang -target x86_64-apple-darwin9 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target x86_64-apple-macosx10.4 -mlinker-version=400 -### %t.o 2> %t.log
+// RUN: %clang -fuse-ld= -target x86_64-apple-darwin9 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log
 //
-// RUN: %clang -target armv7-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios0.0 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios1.2.3 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios5.0 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios7.0 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target arm64-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target arm64e-apple-ios13.0 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target arm64e-apple-ios14.1 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target armv7-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target armv7-apple-ios0.0 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target armv7-apple-ios1.2.3 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target armv7-apple-ios5.0 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target armv7-apple-ios7.0 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target arm64-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target arm64e-apple-ios13.0 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -fuse-ld= -target arm64e-apple-ios14.1 -mlinker-version=400 -### %t.o 2>> %t.log
 //
 // RUN: FileCheck %s < %t.log
 
Index: clang/test/Driver/darwin-sdkroot.c
===
--- clang/test/Driver/darwin-sdkroot.c
+++ clang/test/Driver/darwin-sdkroot.c
@@ -43,7 +43,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -fuse-ld= -target arm64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-IPHONE %s
 //
 // CHECK-IPHONE: clang
@@ -55,7 +55,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -fuse-ld= -target x86_64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SIMULATOR %s
 //
 // CHECK-SIMULATOR: clang
@@ -66,7 +66,7 @@
 //
 // RUN: rm -rf %t/SDKs/MacOSX10.10.0.sdk
 // RUN: mkdir -p %t/SDKs/MacOSX10.10.0.sdk
-// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin 

[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 327304.
ychen added a comment.

- Remove dead code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

Files:
  clang/include/clang/Basic/DiagnosticCategories.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/test/CodeGen/AMDGPU/lds-initializer.ll
  llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
  llvm/test/CodeGen/XCore/section-name.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -290,6 +290,22 @@
   bool *HasError;
   LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
   bool handleDiagnostics(const DiagnosticInfo ) override {
+if (DI.getKind() == llvm::DK_SrcMgr) {
+  const auto  = cast(DI);
+  const SMDiagnostic  = DISM.getSMDiag();
+
+  if (SMD.getKind() == SourceMgr::DK_Error)
+*HasError = true;
+
+  SMD.print(nullptr, errs());
+
+  // For testing purposes, we print the LocCookie here.
+  if (DISM.isInlineAsmDiag() && DISM.getLocCookie())
+WithColor::note() << "!srcloc = " << DISM.getLocCookie() << "\n";
+
+  return true;
+}
+
 if (DI.getSeverity() == DS_Error)
   *HasError = true;
 
@@ -305,19 +321,6 @@
   }
 };
 
-static void InlineAsmDiagHandler(const SMDiagnostic , void *Context,
- unsigned LocCookie) {
-  bool *HasError = static_cast(Context);
-  if (SMD.getKind() == SourceMgr::DK_Error)
-*HasError = true;
-
-  SMD.print(nullptr, errs());
-
-  // For testing purposes, we print the LocCookie here.
-  if (LocCookie)
-WithColor::note() << "!srcloc = " << LocCookie << "\n";
-}
-
 // main - Entry point for the llc compiler.
 //
 int main(int argc, char **argv) {
@@ -367,7 +370,6 @@
   bool HasError = false;
   Context.setDiagnosticHandler(
   std::make_unique());
-  Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, );
 
   Expected> RemarksFileOrErr =
   setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
Index: llvm/test/CodeGen/XCore/section-name.ll
===
--- llvm/test/CodeGen/XCore/section-name.ll
+++ llvm/test/CodeGen/XCore/section-name.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
 
 @bar = internal global i32 zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
@@ -1,7 +1,7 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti -filetype=null < %s 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga -filetype=null < %s 2>&1 | FileCheck %s
 
-; CHECK: lds: unsupported initializer for address space
+; CHECK: error: lds: unsupported initializer for address space
 
 @lds = addrspace(3) global [256 x i32] zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-initializer.ll
@@ -1,5 +1,5 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
 
 ; CHECK: lds: unsupported initializer for address space
 
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -2348,7 +2348,7 @@
 /// will use the last parsed cpp hash line filename comment
 /// for the Filename and LineNo if any in the diagnostic.
 void AsmParser::DiagHandler(const SMDiagnostic , void *Context) {
-  const AsmParser *Parser = static_cast(Context);
+  auto *Parser = static_cast(Context);
   raw_ostream  = errs();
 
   const SourceMgr  = 

[PATCH] D97738: [clangd] Move DraftStore from ClangdLSPServer into ClangdServer.

2021-03-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: njames93, kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

ClangdServer already gets notified of every change, so it makes sense for it to
be the source of truth.
This is a step towards having ClangdServer expose a FS that includes dirty
buffers: D94554 

Related changes:

- version is now optional for ClangdServer, to preserve our existing fuzziness 
in this area (missing version ==> autoincrement)
- ClangdServer::format{File,Range} are now more regular ClangdServer functions 
that don't need the code passed in. While here, combine into one function.
- incremental content update logic is moved from DraftStore to ClangdLSPServer, 
with most of the implementation in SourceCode.cpp. DraftStore is now fairly 
trivial, and will probably ultimately be *replaced* by the dirty FS stuff.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97738

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/test/crash-non-added-files.test
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -50,7 +50,7 @@
  const clangd::RenameOptions );
 
 llvm::Expected
-runFormatFile(ClangdServer , PathRef File, StringRef Code);
+runFormatFile(ClangdServer , PathRef File, const Range *Rng);
 
 SymbolSlab runFuzzyFind(const SymbolIndex , StringRef Query);
 SymbolSlab runFuzzyFind(const SymbolIndex , const FuzzyFindRequest );
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -115,9 +115,9 @@
 }
 
 llvm::Expected
-runFormatFile(ClangdServer , PathRef File, StringRef Code) {
+runFormatFile(ClangdServer , PathRef File, const Range *Rng) {
   llvm::Optional> Result;
-  Server.formatFile(File, Code, capture(Result));
+  Server.formatFile(File, Rng, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -27,6 +27,7 @@
 namespace {
 
 using llvm::Failed;
+using llvm::FailedWithMessage;
 using llvm::HasValue;
 
 MATCHER_P2(Pos, Line, Col, "") {
@@ -802,6 +803,226 @@
   EXPECT_FALSE(isKeyword("override", LangOpts));
 }
 
+struct IncrementalTestStep {
+  llvm::StringRef Src;
+  llvm::StringRef Contents;
+};
+
+int rangeLength(llvm::StringRef Code, const Range ) {
+  llvm::Expected Start = positionToOffset(Code, Rng.start);
+  llvm::Expected End = positionToOffset(Code, Rng.end);
+  assert(Start);
+  assert(End);
+  return *End - *Start;
+}
+
+/// Send the changes one by one to updateDraft, verify the intermediate results.
+void stepByStep(llvm::ArrayRef Steps) {
+  std::string Code = Annotations(Steps.front().Src).code().str();
+
+  for (size_t I = 1; I < Steps.size(); I++) {
+Annotations SrcBefore(Steps[I - 1].Src);
+Annotations SrcAfter(Steps[I].Src);
+llvm::StringRef Contents = Steps[I - 1].Contents;
+TextDocumentContentChangeEvent Event{
+SrcBefore.range(),
+rangeLength(SrcBefore.code(), SrcBefore.range()),
+Contents.str(),
+};
+
+EXPECT_THAT_ERROR(applyChange(Code, Event), llvm::Succeeded());
+EXPECT_EQ(Code, SrcAfter.code());
+  }
+}
+
+TEST(ApplyEditsTest, Simple) {
+  // clang-format off
+  IncrementalTestStep Steps[] =
+{
+  // Replace a range
+  {
+R"cpp(static int
+hello[[World]]()
+{})cpp",
+"Universe"
+  },
+  // Delete a range
+  {
+R"cpp(static int
+hello[[Universe]]()
+{})cpp",
+""
+  },
+  // Add a range
+  {
+R"cpp(static int
+hello[[]]()
+{})cpp",
+"Monde"
+  },
+  {
+R"cpp(static int
+helloMonde()
+{})cpp",
+""
+  }
+};
+  // clang-format on
+
+  stepByStep(Steps);
+}
+
+TEST(ApplyEditsTest, MultiLine) {
+  // clang-format off
+  IncrementalTestStep Steps[] =
+{
+

[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: llvm/include/llvm/MC/MCContext.h:67
   class SourceMgr;
+  template  class function_ref;
 

With `std::function`, this can be dropped.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D97449#2595415 , @MaskRay wrote:

> LG. Can you attach an example triggering clang `InlineAsmDiagHandler2`? I 
> want to check what the diagnostics look like before and now.

`clang/test/CodeGen/asm-errors.c` should trigger it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 327300.
ychen added a comment.

- Revert to use std::function since MCContext needs to own the handler callback
- Fix a typo in BackendConsumer::SrcMgrDiagHandler: DI.getKind() -> 
DI.getSeverity()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

Files:
  clang/include/clang/Basic/DiagnosticCategories.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/test/CodeGen/AMDGPU/lds-initializer.ll
  llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
  llvm/test/CodeGen/XCore/section-name.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -290,6 +290,22 @@
   bool *HasError;
   LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
   bool handleDiagnostics(const DiagnosticInfo ) override {
+if (DI.getKind() == llvm::DK_SrcMgr) {
+  const auto  = cast(DI);
+  const SMDiagnostic  = DISM.getSMDiag();
+
+  if (SMD.getKind() == SourceMgr::DK_Error)
+*HasError = true;
+
+  SMD.print(nullptr, errs());
+
+  // For testing purposes, we print the LocCookie here.
+  if (DISM.isInlineAsmDiag() && DISM.getLocCookie())
+WithColor::note() << "!srcloc = " << DISM.getLocCookie() << "\n";
+
+  return true;
+}
+
 if (DI.getSeverity() == DS_Error)
   *HasError = true;
 
@@ -305,19 +321,6 @@
   }
 };
 
-static void InlineAsmDiagHandler(const SMDiagnostic , void *Context,
- unsigned LocCookie) {
-  bool *HasError = static_cast(Context);
-  if (SMD.getKind() == SourceMgr::DK_Error)
-*HasError = true;
-
-  SMD.print(nullptr, errs());
-
-  // For testing purposes, we print the LocCookie here.
-  if (LocCookie)
-WithColor::note() << "!srcloc = " << LocCookie << "\n";
-}
-
 // main - Entry point for the llc compiler.
 //
 int main(int argc, char **argv) {
@@ -367,7 +370,6 @@
   bool HasError = false;
   Context.setDiagnosticHandler(
   std::make_unique());
-  Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, );
 
   Expected> RemarksFileOrErr =
   setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
Index: llvm/test/CodeGen/XCore/section-name.ll
===
--- llvm/test/CodeGen/XCore/section-name.ll
+++ llvm/test/CodeGen/XCore/section-name.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
 
 @bar = internal global i32 zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
@@ -1,7 +1,7 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti -filetype=null < %s 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga -filetype=null < %s 2>&1 | FileCheck %s
 
-; CHECK: lds: unsupported initializer for address space
+; CHECK: error: lds: unsupported initializer for address space
 
 @lds = addrspace(3) global [256 x i32] zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-initializer.ll
@@ -1,5 +1,5 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
 
 ; CHECK: lds: unsupported initializer for address space
 
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -2348,7 +2348,7 @@
 /// will use the last parsed cpp hash line filename comment
 /// for the Filename and LineNo if any in the diagnostic.
 void AsmParser::DiagHandler(const SMDiagnostic , void 

[PATCH] D97736: [Driver] Add a experimental option to link to LLVM libc.

2021-03-01 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra created this revision.
sivachandra added a reviewer: phosek.
Herald added subscribers: jansvoboda11, dang.
sivachandra requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The experimental option is named -experimental-link-llvmlibc. Specifying
it will put -lllvmlibc before each system libc library component on the
link command line. This way, even if the user specifies -lm, functions
from LLVM libc will be picked instead of functions from the system libc
math library. Also, sanitizer and other options add -lm at few other
places. By putting -lllvmlibc right before each of them, we ensure that
functions available in LLVM libc are picked up by the linker.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97736

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -233,6 +233,26 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE-NOPIE %s
 // CHECK-CLANG-LD-STATIC-PIE-NOPIE: error: cannot specify 'nopie' along with 
'static-pie'
 //
+// RUN: %clang -experimental-link-llvmlibc -no-canonical-prefixes %s -### -o 
%t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-LD-LINK-LLVMLIBC %s
+// CHECK-CLANG-LD-LINK-LLVMLIBC: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-LD-LINK-LLVMLIBC: "-m" "elf_x86_64"
+// CHECK-CLANG-LD-LINK-LLVMLIBC: "-lllvmlibc" "-lc"
+//
+// RUN: %clang -experimental-link-llvmlibc -no-canonical-prefixes %s -### -o 
%t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: -lm \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-LD-LINK-LLVMLIBC-LM %s
+// CHECK-CLANG-LD-LINK-LLVMLIBC-LM: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-LD-LINK-LLVMLIBC-LM: "-m" "elf_x86_64"
+// CHECK-CLANG-LD-LINK-LLVMLIBC-LM: "-lllvmlibc" "-lm"
+// CHECK-CLANG-LD-LINK-LLVMLIBC-LM: "-lllvmlibc" "-lc"
+//
 // RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=x86_64-unknown-linux -rtlib=platform \
 // RUN: --gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -670,6 +670,25 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_T);
 
+  if (Args.hasArg(options::OPT_experimental_link_llvmlibc)) {
+// We should add -lllvmlibc after all other link args have been 
accumulated.
+// This way, we can iterate over all the link args and add -lllvmlibc 
before
+// each libc library. This will also ensure that we prepend -lllvmlibc
+// before any used listed -lm options.
+ArgStringList WithLLVMLibc;
+for (StringRef Arg : CmdArgs) {
+  if (Arg == "-lm" || Arg == "-lc") {
+// TODO: Add -lllvmlibc before -lpthread when LLVM libc has pthread
+// functions available.
+WithLLVMLibc.push_back("-lllvmlibc");
+WithLLVMLibc.push_back(Arg.data());
+  } else {
+WithLLVMLibc.push_back(Arg.data());
+  }
+}
+CmdArgs = WithLLVMLibc;
+  }
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3623,6 +3623,7 @@
 def single__module : Flag<["-"], "single_module">;
 def specs_EQ : Joined<["-", "--"], "specs=">, Group;
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
+def experimental_link_llvmlibc : Flag<["-"], "experimental-link-llvmlibc">;
 def static_libgcc : Flag<["-"], "static-libgcc">;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
 def static : Flag<["-", "--"], "static">, Group, 
Flags<[NoArgumentUnused]>;


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -233,6 +233,26 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE-NOPIE %s
 // CHECK-CLANG-LD-STATIC-PIE-NOPIE: error: cannot specify 'nopie' along with 'static-pie'
 //
+// RUN: %clang -experimental-link-llvmlibc -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: 

[clang] 9ecbb34 - Fix test cxx-call-kernel.cpp

2021-03-01 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-03-01T17:10:53-05:00
New Revision: 9ecbb34e1d2dc77e768638b6ecd94d63e451915d

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

LOG: Fix test cxx-call-kernel.cpp

Only test it with x86 since other target may have an ABI
making it difficult to test.

Change-Id: I85423c8bb8f24cb3ea4cb64a408069b4d61c

Added: 


Modified: 
clang/test/CodeGenCUDA/cxx-call-kernel.cpp

Removed: 




diff  --git a/clang/test/CodeGenCUDA/cxx-call-kernel.cpp 
b/clang/test/CodeGenCUDA/cxx-call-kernel.cpp
index ae58dcd348ce..66da3e0c9bbf 100644
--- a/clang/test/CodeGenCUDA/cxx-call-kernel.cpp
+++ b/clang/test/CodeGenCUDA/cxx-call-kernel.cpp
@@ -1,5 +1,8 @@
-// RUN: %clang_cc1 -x hip -emit-llvm-bc %s -o %t.hip.bc
-// RUN: %clang_cc1 -mlink-bitcode-file %t.hip.bc -DHIP_PLATFORM -emit-llvm \
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:   -x hip -emit-llvm-bc %s -o %t.hip.bc
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:   -mlink-bitcode-file %t.hip.bc -DHIP_PLATFORM -emit-llvm \
 // RUN:   %s -o - | FileCheck %s
 
 #include "Inputs/cuda.h"



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


[PATCH] D84924: [clang-tidy] Added command line option `fix-notes`

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabbe9e227ed3: [clang-tidy] Added command line option 
`fix-notes` (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84924

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidy.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls-cxx17.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-inconsistent-declaration-parameter-name.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/clean-up-code.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/clean-up-code.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/clean-up-code.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/clean-up-code.cpp
@@ -1,6 +1,6 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=none --
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=llvm --
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- --fix-notes
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- --fix-notes -format-style=none --
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- --fix-notes -format-style=llvm --
 namespace a { class A {}; }
 namespace b {
 using a::A;
Index: clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
@@ -1,9 +1,10 @@
-// RUN: %check_clang_tidy %s "llvm-namespace-comment,clang-diagnostic-*" %t
+// RUN: %check_clang_tidy %s "llvm-namespace-comment,clang-diagnostic-*" %t -- --fix-notes
 void foo(int a) {
   if (a = 1) {
-  // CHECK-NOTES: [[@LINE-1]]:9: warning: using the result of an assignment as a condition without parentheses [clang-diagnostic-parentheses]
-  // CHECK-NOTES: [[@LINE-2]]:9: note: place parentheses around the assignment to silence this warning
-  // CHECK-NOTES: [[@LINE-3]]:9: note: use '==' to turn this assignment into an equality comparison
-  // CHECK-FIXES: if ((a = 1)) {
+// CHECK-NOTES: [[@LINE-1]]:9: warning: using the result of an assignment as a condition without parentheses [clang-diagnostic-parentheses]
+// CHECK-NOTES: [[@LINE-2]]:9: note: place parentheses around the assignment to silence this warning
+// CHECK-NOTES: [[@LINE-3]]:9: note: use '==' to turn this assignment into an equality comparison
+// As we have 2 conflicting fixes in notes, don't apply any fix.
+// CHECK-FIXES: if (a = 1) {
   }
 }
Index: clang-tools-extra/test/clang-tidy/checkers/readability-inconsistent-declaration-parameter-name.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-inconsistent-declaration-parameter-name.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-inconsistent-declaration-parameter-name.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-inconsistent-declaration-parameter-name %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-inconsistent-declaration-parameter-name %t -- --fix-notes -- -fno-delayed-template-parsing
 
 void consistentFunction(int a, int b, int c);
 void consistentFunction(int a, int b, int c);
Index: clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- -fno-delayed-template-parsing -isystem %S/Inputs/
-
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- --fix-notes -- -fno-delayed-template-parsing -isystem %S/Inputs/
 
 // - Definitions -
 template  class vector {};
Index: clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls-cxx17.cpp
===
--- 

[clang-tools-extra] abbe9e2 - [clang-tidy] Added command line option `fix-notes`

2021-03-01 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-01T22:07:11Z
New Revision: abbe9e227ed31e5dde9bb7567bb9f0dd047689c6

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

LOG: [clang-tidy] Added command line option `fix-notes`

Added an option to control whether to apply the fixes found in notes attached 
to clang tidy errors or not.
Diagnostics may contain multiple notes each offering different ways to fix the 
issue, for that reason the default behaviour should be to not look at fixes 
found in notes.
Instead offer up all the available fix-its in the output but don't try to apply 
the first one unless `-fix-notes` is supplied.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidy.h
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/index.rst
clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls-cxx17.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-inconsistent-declaration-parameter-name.cpp
clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
clang-tools-extra/test/clang-tidy/infrastructure/clean-up-code.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index dc523d0731d5..f65e8ed216f2 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -95,7 +95,7 @@ class AnalyzerDiagnosticConsumer : public 
ento::PathDiagnosticConsumer {
 
 class ErrorReporter {
 public:
-  ErrorReporter(ClangTidyContext , bool ApplyFixes,
+  ErrorReporter(ClangTidyContext , FixBehaviour ApplyFixes,
 llvm::IntrusiveRefCntPtr BaseFS)
   : Files(FileSystemOptions(), std::move(BaseFS)),
 DiagOpts(new DiagnosticOptions()),
@@ -133,8 +133,9 @@ class ErrorReporter {
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   // FIXME: explore options to support interactive fix selection.
-  const llvm::StringMap *ChosenFix = selectFirstFix(Error);
-  if (ApplyFixes && ChosenFix) {
+  const llvm::StringMap *ChosenFix;
+  if (ApplyFixes != FB_NoFix &&
+  (ChosenFix = getFixIt(Error, ApplyFixes == FB_FixNotes))) {
 for (const auto  : *ChosenFix) {
   for (const auto  : FileAndReplacements.second) {
 ++TotalFixes;
@@ -187,7 +188,7 @@ class ErrorReporter {
   }
 
   void finish() {
-if (ApplyFixes && TotalFixes > 0) {
+if (TotalFixes > 0) {
   Rewriter Rewrite(SourceMgr, LangOpts);
   for (const auto  : FileReplacements) {
 StringRef File = FileAndReplacements.first();
@@ -287,7 +288,7 @@ class ErrorReporter {
   SourceManager SourceMgr;
   llvm::StringMap FileReplacements;
   ClangTidyContext 
-  bool ApplyFixes;
+  FixBehaviour ApplyFixes;
   unsigned TotalFixes;
   unsigned AppliedFixes;
   unsigned WarningsAsErrors;
@@ -500,7 +501,8 @@ runClangTidy(clang::tidy::ClangTidyContext ,
  const CompilationDatabase ,
  ArrayRef InputFiles,
  llvm::IntrusiveRefCntPtr BaseFS,
- bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
+ bool ApplyAnyFix, bool EnableCheckProfile,
+ llvm::StringRef StoreCheckProfile) {
   ClangTool Tool(Compilations, InputFiles,
  std::make_shared(), BaseFS);
 
@@ -527,7 +529,7 @@ runClangTidy(clang::tidy::ClangTidyContext ,
   Context.setEnableProfiling(EnableCheckProfile);
   Context.setProfileStoragePrefix(StoreCheckProfile);
 
-  ClangTidyDiagnosticConsumer DiagConsumer(Context);
+  ClangTidyDiagnosticConsumer DiagConsumer(Context, nullptr, true, 
ApplyAnyFix);
   DiagnosticsEngine DE(new DiagnosticIDs(), new DiagnosticOptions(),
, /*ShouldOwnClient=*/false);
   Context.setDiagnosticsEngine();
@@ -574,7 +576,7 @@ runClangTidy(clang::tidy::ClangTidyContext ,
 }
 
 void handleErrors(llvm::ArrayRef Errors,
-  ClangTidyContext , bool Fix,
+  ClangTidyContext , FixBehaviour Fix,
   unsigned ,
   llvm::IntrusiveRefCntPtr BaseFS) {
   ErrorReporter Reporter(Context, Fix, std::move(BaseFS));

diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.h 

[PATCH] D97733: Fix infinite recursion during IR emission if a constant-initialized lifetime-extended temporary object's initializer refers back to the same object.

2021-03-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

@rjmccall We could alternatively address this by creating and registering the 
global first, and only then building and adding its initializer, but either way 
we're going to need some special-case code to detect and handle this situation 
(because we might need to change the type of the global to match the emitted 
constant). Happy to switch to that approach if you prefer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97733

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


[PATCH] D97708: [CUDA] Remove `noreturn` attribute from __assertfail().

2021-03-01 Thread Artem Belevich via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32e064527623: [CUDA] Remove `noreturn` attribute from 
__assertfail(). (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97708

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -349,9 +349,14 @@
 __device__ int vprintf(const char *, const char *);
 __device__ void free(void *) __attribute((nothrow));
 __device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc));
+
+// __assertfail() used to have a `noreturn` attribute. Unfortunately that
+// contributed to triggering the longstanding bug in ptxas when assert was used
+// in sufficiently convoluted code. See
+// https://bugs.llvm.org/show_bug.cgi?id=27738 for the details.
 __device__ void __assertfail(const char *__message, const char *__file,
  unsigned __line, const char *__function,
- size_t __charSize) __attribute__((noreturn));
+ size_t __charSize);
 
 // In order for standard assert() macro on linux to work we need to
 // provide device-side __assert_fail()


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -349,9 +349,14 @@
 __device__ int vprintf(const char *, const char *);
 __device__ void free(void *) __attribute((nothrow));
 __device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc));
+
+// __assertfail() used to have a `noreturn` attribute. Unfortunately that
+// contributed to triggering the longstanding bug in ptxas when assert was used
+// in sufficiently convoluted code. See
+// https://bugs.llvm.org/show_bug.cgi?id=27738 for the details.
 __device__ void __assertfail(const char *__message, const char *__file,
  unsigned __line, const char *__function,
- size_t __charSize) __attribute__((noreturn));
+ size_t __charSize);
 
 // In order for standard assert() macro on linux to work we need to
 // provide device-side __assert_fail()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 32e0645 - [CUDA] Remove `noreturn` attribute from __assertfail().

2021-03-01 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2021-03-01T13:59:22-08:00
New Revision: 32e0645276230bb5b736e378860df3b92b1f4ba8

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

LOG: [CUDA] Remove `noreturn` attribute from __assertfail().

`noreturn` complicates control flow and tends to trigger a known bug in ptxas if
the assert is used within loops in sufficiently complicated code.
https://bugs.llvm.org/show_bug.cgi?id=27738

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

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h 
b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
index f88c39a9b6e5..f401964bd529 100644
--- a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -349,9 +349,14 @@ extern "C" {
 __device__ int vprintf(const char *, const char *);
 __device__ void free(void *) __attribute((nothrow));
 __device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc));
+
+// __assertfail() used to have a `noreturn` attribute. Unfortunately that
+// contributed to triggering the longstanding bug in ptxas when assert was used
+// in sufficiently convoluted code. See
+// https://bugs.llvm.org/show_bug.cgi?id=27738 for the details.
 __device__ void __assertfail(const char *__message, const char *__file,
  unsigned __line, const char *__function,
- size_t __charSize) __attribute__((noreturn));
+ size_t __charSize);
 
 // In order for standard assert() macro on linux to work we need to
 // provide device-side __assert_fail()



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


[PATCH] D97733: Fix infinite recursion during IR emission if a constant-initialized lifetime-extended temporary object's initializer refers back to the same object.

2021-03-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: rjmccall.
rsmith requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`GetAddrOfGlobalTemporary` previously tried to emit the initializer of
a global temporary before updating the global temporary map. Emitting the
initializer could recurse back into `GetAddrOfGlobalTemporary` for the same
temporary, resulting in an infinite recursion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97733

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/temporaries.cpp


Index: clang/test/CodeGenCXX/temporaries.cpp
===
--- clang/test/CodeGenCXX/temporaries.cpp
+++ clang/test/CodeGenCXX/temporaries.cpp
@@ -53,6 +53,17 @@
   // CHECK: @_ZN9BraceInit1xE ={{.*}} constant i32* @_ZGRN9BraceInit1xE_
 }
 
+namespace RefTempSubobject {
+  struct SelfReferential {
+int *p = ints;
+int ints[3] = {1, 2, 3};
+  };
+
+  // CHECK: @_ZGRN16RefTempSubobject2srE_ = internal global { i32*, [3 x i32] 
} { {{.*}} getelementptr {{.*}} @_ZGRN16RefTempSubobject2srE_ {{.*}}, [3 x i32] 
[i32 1, i32 2, i32 3] }
+  // CHECK: @_ZN16RefTempSubobject2srE = {{.*}} constant {{.*}} 
@_ZGRN16RefTempSubobject2srE_
+  constexpr const SelfReferential  = SelfReferential();
+}
+
 struct A {
   A();
   ~A();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5315,8 +5315,21 @@
 
   CharUnits Align = getContext().getTypeAlignInChars(MaterializedType);
 
-  if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E])
-return ConstantAddress(Slot, Align);
+  auto InsertResult = MaterializedGlobalTemporaryMap.insert({E, nullptr});
+  if (!InsertResult.second) {
+// We've seen this before: either we already created it or we're in the
+// process of doing so.
+if (!InsertResult.first->second) {
+  // We recursively re-entered this function, probably during emission of
+  // the initializer. Create a placeholder. We'll clean this up in the
+  // outer call, at the end of this function.
+  llvm::Type *Type = getTypes().ConvertTypeForMem(MaterializedType);
+  InsertResult.first->second = new llvm::GlobalVariable(
+  getModule(), Type, false, llvm::GlobalVariable::InternalLinkage,
+  nullptr);
+}
+return ConstantAddress(InsertResult.first->second, Align);
+  }
 
   // FIXME: If an externally-visible declaration extends multiple temporaries,
   // we need to give each temporary the same name in every translation unit 
(and
@@ -5395,7 +5408,17 @@
 *this, GV, AddrSpace, LangAS::Default,
 Type->getPointerTo(
 getContext().getTargetAddressSpace(LangAS::Default)));
-  MaterializedGlobalTemporaryMap[E] = CV;
+
+  // Update the map with the new temporary. If we created a placeholder above,
+  // replace it with the new global now.
+  llvm::Constant * = MaterializedGlobalTemporaryMap[E];
+  if (Entry) {
+Entry->replaceAllUsesWith(
+llvm::ConstantExpr::getBitCast(CV, Entry->getType()));
+llvm::cast(Entry)->eraseFromParent();
+  }
+  Entry = CV;
+
   return ConstantAddress(CV, Align);
 }
 


Index: clang/test/CodeGenCXX/temporaries.cpp
===
--- clang/test/CodeGenCXX/temporaries.cpp
+++ clang/test/CodeGenCXX/temporaries.cpp
@@ -53,6 +53,17 @@
   // CHECK: @_ZN9BraceInit1xE ={{.*}} constant i32* @_ZGRN9BraceInit1xE_
 }
 
+namespace RefTempSubobject {
+  struct SelfReferential {
+int *p = ints;
+int ints[3] = {1, 2, 3};
+  };
+
+  // CHECK: @_ZGRN16RefTempSubobject2srE_ = internal global { i32*, [3 x i32] } { {{.*}} getelementptr {{.*}} @_ZGRN16RefTempSubobject2srE_ {{.*}}, [3 x i32] [i32 1, i32 2, i32 3] }
+  // CHECK: @_ZN16RefTempSubobject2srE = {{.*}} constant {{.*}} @_ZGRN16RefTempSubobject2srE_
+  constexpr const SelfReferential  = SelfReferential();
+}
+
 struct A {
   A();
   ~A();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5315,8 +5315,21 @@
 
   CharUnits Align = getContext().getTypeAlignInChars(MaterializedType);
 
-  if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E])
-return ConstantAddress(Slot, Align);
+  auto InsertResult = MaterializedGlobalTemporaryMap.insert({E, nullptr});
+  if (!InsertResult.second) {
+// We've seen this before: either we already created it or we're in the
+// process of doing so.
+if (!InsertResult.first->second) {
+  // We recursively re-entered this function, probably during emission of
+  // the initializer. Create a placeholder. We'll clean this up in the
+  // outer call, at the end of this function.
+  llvm::Type *Type = 

[PATCH] D97457: [flang][driver] Add `-fdebug-dump-parsing-log`

2021-03-01 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97457

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


[PATCH] D97340: [HIP] Support Spack packages

2021-03-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3535-3536
   HelpText<"Print the registered targets">;
+def print_rocm_search_dirs : Flag<["-", "--"], "print-rocm-search-dirs">,
+  HelpText<"Print the paths used for finding ROCm installation">;
 def private__bundle : Flag<["-"], "private_bundle">;

Perhaps the existing `print-search-dirs` option would do the job?



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:180
   if (!RocmPathArg.empty()) {
-Candidates.emplace_back(RocmPathArg.str());
-return Candidates;
+ROCmSearchDirs.emplace_back(RocmPathArg.str());
+DoPrintROCmSearchDirs();

We call getInstallationPathCandidates() more more than one place, so we may end 
up with the same path added multiple times.

I think population of the candidate list should be separated from reading it 
back, and should be done only once.
E.g.
```
  if (!isCandidateListReady) 
 initCandidateList(); // populates ROCmSearchDirs, sets isCandidateListReady
  return ROCmSearchDirs;
```





Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:207
+// installation candidate for SPACK.
+if (ParentName.startswith("llvm-amdgpu-")) {
+  auto SPACKReleaseStr =

What would be a consequence of mistakingly detecting a non-SPACK installation 
as SPACK?

I'm still not quite comfortable with using a path name, which can be 
arbitrarily named by a user, as a way to detect particular installation method.
Do SPACK packages have something *inside* the package directory that we could 
use to tell that it is indeed an SPACK package? Some sort of metadata or 
version file, perhaps?

It's probably OK to rely on the path naming scheme, but there are still corner 
cases it can't handle.
I could have a setup when the path-name based detection would still fail 
despite considering both the reaolved and unresolved symlink names.
E.g. 
```
/pkg/llvm-amdgpu-hash -> /pkg/some-other-real-dir-name
/usr/local/bin/clang -> /pkg/llvm-amdgpu-hash/bin/clang
```
If I compile with `/usr/local/bin/clang` neither the realpath nor the 
unresolved symlink will have 'llvm-amdgpu'. 

Granted, it's a somewhat contrived setup. Using the name as the hint would work 
for the standard setups, so we can live with that, provided that we can always 
tell compiler where to find the files it needs, if the user has an unusual 
install.




Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:32
+static llvm::SmallString<0> findSPACKPackage(const Driver ,
+ const llvm::SmallString<0> ,
+ StringRef Prefix) {

yaxunl wrote:
> tra wrote:
> > Based on how the function is used, perhaps we should make it 
> > `static std::string findSPACKPackage(const Driver , StringRef Path, 
> > StringRef PackageName, StringRef RocmVersion)`  and fold the prefix 
> > construction (and possibly version non-emptiness check) into the function.
> Will use PackageName and RocmVersion as arguments.
> 
> However, we use llvm::sys::path to manipulate paths and llvm::sys::path is 
> using llvm::SmallString. If we return std::string or use StringRef for path 
> argument, we have to convert them back and force.
> 
> 
It should still work. The use cases below look like this:
```
auto SPACKPath = findSPACKPackage(D, Path, "rocm-device-libs",
  Candidate.SPACKReleaseStr);
if (!SPACKPath.empty())
  Path = SPACKPath;
  }
  for (auto SubDir : SubDirs)
llvm::sys::path::append(Path, SubDir);
```

It's the `Pack` that needs to be a `SmallString`. Assigning an `std::string` to 
it should work  -- it has `operator=(StringRef)` and `StringRef` can be created 
from a `std::string`.

I'll leave it up to you. If `std::string` is inconvenient to use, the 
`SmallString` is fine.




Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:354-372
+  CandidatesInfo CanInfo;
+  if (!HIPPathArg.empty())
+CanInfo.Candidates.emplace_back(HIPPathArg.str(), /*StrictChecking=*/true);
+  else
+CanInfo = getInstallationPathCandidates();
   auto  = D.getVFS();
 

yaxunl wrote:
> tra wrote:
> > So, normally `--hip-path` would point to the HIP package installation. 
> > However, is clang installation path contains `llvm-amdgpu` (and thus 
> > CanInfo.SPACKReleaseStr is set to whatever version may follow),
> > then `--hip-path` (and other candidate paths) directories will also be 
> > treated as an SPACK package directory and, if the `hip` package is found 
> > there, then *that* package directory will be used as the actual path to be 
> > used.
> > 
> > I see several potential issues with that.
> > 
> > - if clang path contains llvm-amdgpu, but it is *not* installed as an SPACK 
> > package We have no control over user's choice of the name for the 
> > 

[PATCH] D97630: [clang-tidy] Added option to uniqueptr delete release check

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bfc14193170: [clang-tidy] Added option to uniqueptr delete 
release check (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97630

Files:
  clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
  clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp
@@ -1,5 +1,6 @@
-// RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t
-
+// RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t -check-suffix=NULLPTR
+// RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t -check-suffix=RESET -config='{ \
+// RUN: CheckOptions: [{key: readability-uniqueptr-delete-release.PreferResetCall, value: true}]}'
 namespace std {
 template 
 struct default_delete {};
@@ -13,6 +14,9 @@
   template 
   unique_ptr(unique_ptr&&);
   T* release();
+  void reset(T *P = nullptr);
+  T *() const;
+  T *operator->() const;
 };
 }  // namespace std
 
@@ -21,22 +25,62 @@
 void Positives() {
   std::unique_ptr P;
   delete P.release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
-  // CHECK-FIXES: {{^}}  P = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr' to reset 'unique_ptr<>' objects
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()' to reset 'unique_ptr<>' objects
+  // CHECK-FIXES-NULLPTR: {{^}}  P = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P.reset();
 
   auto P2 = P;
   delete P2.release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
-  // CHECK-FIXES: {{^}}  P2 = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr' to reset 'unique_ptr<>' objects
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()' to reset 'unique_ptr<>' objects
+  // CHECK-FIXES-NULLPTR: {{^}}  P2 = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P2.reset();
+
+  delete (P2.release());
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  (P2 = nullptr);
+  // CHECK-FIXES-RESET: {{^}}  (P2.reset());
 
   std::unique_ptr Array[20];
   delete Array[4].release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete
-  // CHECK-FIXES: {{^}}  Array[4] = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  Array[4] = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  Array[4].reset();
 
   delete ReturnsAUnique().release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete
-  // CHECK-FIXES: {{^}}  ReturnsAUnique() = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  ReturnsAUnique() = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  ReturnsAUnique().reset();
+
+  std::unique_ptr *P3();
+  delete P3->release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  *P3 = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P3->reset();
+
+  std::unique_ptr> P4;
+  delete (*P4).release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  (*P4) = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  (*P4).reset();
+
+  delete P4->release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  *P4 = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P4->reset();
+
+  delete (P4)->release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // 

[clang-tools-extra] 8bfc141 - [clang-tidy] Added option to uniqueptr delete release check

2021-03-01 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-01T21:52:13Z
New Revision: 8bfc14193170c95a49fca3e66aa077203783a137

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

LOG: [clang-tidy] Added option to uniqueptr delete release check

Adds an option, `PreferResetCall`, currently defaulted to `false`, to the check.
When `true` the check will refactor by calling the `reset` member function.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst

clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
index 478a3f2f93ba..45194a8e3d97 100644
--- a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
@@ -9,6 +9,8 @@
 #include "UniqueptrDeleteReleaseCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -17,50 +19,69 @@ namespace clang {
 namespace tidy {
 namespace readability {
 
+void UniqueptrDeleteReleaseCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "PreferResetCall", PreferResetCall);
+}
+
+UniqueptrDeleteReleaseCheck::UniqueptrDeleteReleaseCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  PreferResetCall(Options.get("PreferResetCall", false)) {}
+
 void UniqueptrDeleteReleaseCheck::registerMatchers(MatchFinder *Finder) {
-  auto IsSusbstituted = qualType(anyOf(
-  substTemplateTypeParmType(), 
hasDescendant(substTemplateTypeParmType(;
 
   auto UniquePtrWithDefaultDelete = classTemplateSpecializationDecl(
-  hasName("std::unique_ptr"),
-  hasTemplateArgument(1, 
refersToType(qualType(hasDeclaration(cxxRecordDecl(
- hasName("std::default_delete")));
+  hasName("::std::unique_ptr"),
+  hasTemplateArgument(1, refersToType(hasDeclaration(cxxRecordDecl(
+ hasName("::std::default_delete"));
 
   Finder->addMatcher(
-  cxxDeleteExpr(has(ignoringParenImpCasts(cxxMemberCallExpr(
-on(expr(hasType(UniquePtrWithDefaultDelete),
-unless(hasType(IsSusbstituted)))
-   .bind("uptr")),
-callee(cxxMethodDecl(hasName("release")))
+  cxxDeleteExpr(
+  unless(isInTemplateInstantiation()),
+  has(expr(ignoringParenImpCasts(
+  cxxMemberCallExpr(
+  callee(
+  memberExpr(hasObjectExpression(allOf(
+ unless(isTypeDependent()),
+ anyOf(hasType(UniquePtrWithDefaultDelete),
+   hasType(pointsTo(
+   UniquePtrWithDefaultDelete),
+ member(cxxMethodDecl(hasName("release"
+  .bind("release_expr")))
+  .bind("release_call")
   .bind("delete"),
   this);
 }
 
 void UniqueptrDeleteReleaseCheck::check(
 const MatchFinder::MatchResult ) {
-  const auto *PtrExpr = Result.Nodes.getNodeAs("uptr");
-  const auto *DeleteExpr = Result.Nodes.getNodeAs("delete");
+  const auto *DeleteExpr = Result.Nodes.getNodeAs("delete");
+  const auto *ReleaseExpr = Result.Nodes.getNodeAs("release_expr");
+  const auto *ReleaseCallExpr =
+  Result.Nodes.getNodeAs("release_call");
 
-  if (PtrExpr->getBeginLoc().isMacroID())
+  if (ReleaseExpr->getBeginLoc().isMacroID())
 return;
 
-  // Ignore dependent types.
-  // It can give us false positives, so we go with false negatives instead to
-  // be safe.
-  if (PtrExpr->getType()->isDependentType())
-return;
-
-  SourceLocation AfterPtr = Lexer::getLocForEndOfToken(
-  PtrExpr->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
-
-  diag(DeleteExpr->getBeginLoc(),
-   "prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> "
-   "objects")
-  << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
- DeleteExpr->getBeginLoc(), 

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 327280.
njames93 marked an inline comment as done.
njames93 added a comment.

Address some comments, though I have a feeling @Sammccall, I may have to wait 
until DraftStore has been refactored first before continuing on with this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/unittests/DraftStoreTests.cpp

Index: clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
===
--- clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
+++ clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
@@ -52,8 +52,8 @@
 llvm::Expected Result =
 DS.updateDraft(Path, llvm::None, {Event});
 ASSERT_TRUE(!!Result);
-EXPECT_EQ(Result->Contents, SrcAfter.code());
-EXPECT_EQ(DS.getDraft(Path)->Contents, SrcAfter.code());
+EXPECT_EQ(*Result->Contents, SrcAfter.code());
+EXPECT_EQ(*DS.getDraft(Path)->Contents, SrcAfter.code());
 EXPECT_EQ(Result->Version, static_cast(i));
   }
 }
@@ -84,8 +84,8 @@
   DS.updateDraft(Path, llvm::None, Changes);
 
   ASSERT_TRUE(!!Result) << llvm::toString(Result.takeError());
-  EXPECT_EQ(Result->Contents, FinalSrc.code());
-  EXPECT_EQ(DS.getDraft(Path)->Contents, FinalSrc.code());
+  EXPECT_EQ(*Result->Contents, FinalSrc.code());
+  EXPECT_EQ(*DS.getDraft(Path)->Contents, FinalSrc.code());
   EXPECT_EQ(Result->Version, 1);
 }
 
@@ -345,7 +345,7 @@
 
   Optional Contents = DS.getDraft(File);
   EXPECT_TRUE(Contents);
-  EXPECT_EQ(Contents->Contents, OriginalContents);
+  EXPECT_EQ(*Contents->Contents, OriginalContents);
   EXPECT_EQ(Contents->Version, 0);
 }
 
Index: clang-tools-extra/clangd/DraftStore.h
===
--- clang-tools-extra/clangd/DraftStore.h
+++ clang-tools-extra/clangd/DraftStore.h
@@ -11,8 +11,10 @@
 
 #include "Protocol.h"
 #include "support/Path.h"
+#include "support/ThreadsafeFS.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/FileSystem/UniqueID.h"
 #include 
 #include 
 #include 
@@ -28,10 +30,14 @@
 class DraftStore {
 public:
   struct Draft {
-std::string Contents;
+std::shared_ptr Contents;
 int64_t Version = -1;
   };
 
+  DraftStore(const ThreadsafeFS );
+
+  DraftStore() = default;
+
   /// \return Contents of the stored document.
   /// For untracked files, a llvm::None is returned.
   llvm::Optional getDraft(PathRef File) const;
@@ -59,9 +65,18 @@
   /// Remove the draft from the store.
   void removeDraft(PathRef File);
 
+  const ThreadsafeFS () const;
+
 private:
+  struct MetadataDraft {
+Draft Draft;
+llvm::sys::TimePoint<> MTime;
+llvm::sys::fs::UniqueID UID;
+  };
+  class DraftstoreFS;
+  std::unique_ptr DraftFS;
   mutable std::mutex Mutex;
-  llvm::StringMap Drafts;
+  llvm::StringMap Drafts;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/DraftStore.cpp
===
--- clang-tools-extra/clangd/DraftStore.cpp
+++ clang-tools-extra/clangd/DraftStore.cpp
@@ -9,7 +9,13 @@
 #include "DraftStore.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/FileSystem/UniqueID.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -21,7 +27,7 @@
   if (It == Drafts.end())
 return None;
 
-  return It->second;
+  return It->second.Draft;
 }
 
 std::vector DraftStore::getActiveFiles() const {
@@ -47,14 +53,22 @@
   }
 }
 
+static void updateTime(llvm::sys::TimePoint<> ) {
+  Time = llvm::sys::TimePoint<>::clock::now();
+}
+
 int64_t DraftStore::addDraft(PathRef File, llvm::Optional Version,
  llvm::StringRef Contents) {
   std::lock_guard Lock(Mutex);
 
-  Draft  = Drafts[File];
-  updateVersion(D, Version);
-  D.Contents = Contents.str();
-  return D.Version;
+  auto Res = Drafts.try_emplace(File);
+  auto  = Res.first->getValue();
+  if (Res.second)
+D.UID = llvm::vfs::getNextVirtualUniqueID();
+  updateVersion(D.Draft, Version);
+  updateTime(D.MTime);
+  D.Draft.Contents = std::make_shared(Contents);
+  return D.Draft.Version;
 }
 
 llvm::Expected DraftStore::updateDraft(
@@ -68,8 +82,8 @@
  "Trying to do incremental update on non-added document: {0}",
  File);
   }
-  Draft  = EntryIt->second;
-  std::string Contents = EntryIt->second.Contents;
+  MetadataDraft  = EntryIt->second;
+  std::string Contents = *D.Draft.Contents;
 
   for (const TextDocumentContentChangeEvent  : 

[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-03-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I guess my only concern is, what happens if MSVC fixes assert.h? Do we need to 
make the implicit `#define static_assert _Static_assert` conditional on the 
absence of any `static_assert` definition?


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

https://reviews.llvm.org/D95396

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


[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 3 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:159
   ClangdServer(const GlobalCompilationDatabase , const ThreadsafeFS ,
-   const Options , Callbacks *Callbacks = nullptr);
+   const ThreadsafeFS , const Options ,
+   Callbacks *Callbacks = nullptr);

sammccall wrote:
> Passing in FS + DirtyFS doesn't seem quite right, because we also pass in all 
> the mutations that create the differences.
> 
> It seem rather that *ClangdServer* should maintain the overlay containing the 
> dirty buffers, and expose it (for use in the few places that ClangdLSPServer 
> currently uses DraftStore).
> 
> (the fact that DraftStore isn't accessible from ClangdServer did also come up 
> when trying to split the *Server classes into Modules, so this seems like a 
> helpful direction from that perspective too)
I was never a fan of this tbh. But moving DraftStore would result in this being 
too big,



Comment at: clang-tools-extra/clangd/DraftStore.cpp:148
+  static std::unique_ptr
+  create(IntrusiveRefCntPtr Data, StringRef Name) {
+// Allocate space for the FileContentMemBuffer and its name with null

sammccall wrote:
> Is there any reason to think we need this micro-optimization? It's quite 
> invasive.
Its basically copied from llvm/support/MemoryBuffer.cpp



Comment at: clang-tools-extra/clangd/DraftStore.cpp:213
+
+class DraftStoreFileSystem : public llvm::vfs::FileSystem {
+public:

sammccall wrote:
> can't we use InMemoryFileSystem for this?
`InMemoryFileSystem` Would work in theory. However using that requires building 
a lot of unnecessary nodes for thing like intermediate directories.



Comment at: clang-tools-extra/clangd/DraftStore.cpp:287
+for (const auto  : DS.Drafts) {
+  // Query the base filesystem for file uniqueids.
+  auto BaseStatus = BaseView->status(KV.getKey());

sammccall wrote:
> doing IO in view() doesn't seem obviously OK.
> 
> what's the practical consequence of the overlay's inodes not matching that of 
> the underlying FS? (It seems reasonable to say that the files always have 
> different identity, and may/may not have the same content)
It's probably not necessary, but I know preambles use the UniqueID. It may just 
be safer to create a uniqueID for each item in the DraftStore and leave it at 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

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


[clang] 53d3038 - Fix build failure due to dump()

2021-03-01 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-03-01T16:44:08-05:00
New Revision: 53d30381f54fbeef3e9ca7f9b52d29d235365f19

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

LOG: Fix build failure due to dump()

Change-Id: I86b534223d63bf8bb8f49af5a64b300efbeba77b

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index d57dd7f49d50..55e19313850c 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5278,7 +5278,6 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, 
const CGCallee 
   isa(E) &&
   (!TargetDecl || !isa(TargetDecl))) {
 llvm::Value *Handle = Callee.getFunctionPointer();
-Handle->dump();
 auto *Cast =
 Builder.CreateBitCast(Handle, Handle->getType()->getPointerTo());
 auto *Stub = Builder.CreateLoad(Address(Cast, CGM.getPointerAlign()));



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


[PATCH] D86376: [HIP] Emit kernel symbol

2021-03-01 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5cf2a37f1255: [HIP] Emit kernel symbol (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D86376?vs=322894=327268#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86376

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/cxx-call-kernel.cpp
  clang/test/CodeGenCUDA/kernel-dbg-info.cu
  clang/test/CodeGenCUDA/kernel-stub-name.cu
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- clang/test/CodeGenCUDA/unnamed-types.cu
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -54,7 +54,7 @@
   [] __device__ (float x) { return x + 5.f; });
 }
 // HOST: @__hip_register_globals
-// HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
-// HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k1IZ2f1PfEUlfE_Z2f1S0_EUlffE_Z2f1S0_EUlfE0_EvS0_T_T0_T1_{{.*}}@1
+// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
+// HOST: __hipRegisterFunction{{.*}}@_Z2k1IZ2f1PfEUlfE_Z2f1S0_EUlffE_Z2f1S0_EUlfE0_EvS0_T_T0_T1_{{.*}}@1
 // MSVC: __hipRegisterFunction{{.*}}@"??$k0@V@?0???R1?0??f1@@YAXPEAM@Z@QEBA@0@Z@@@YAXPEAMV@?0???R0?0??f1@@YAX0@Z@QEBA@0@Z@@Z{{.*}}@0
 // MSVC: __hipRegisterFunction{{.*}}@"??$k1@V@?0??f1@@YAXPEAM@Z@V@?0??2@YAX0@Z@V@?0??2@YAX0@Z@@@YAXPEAMV@?0??f1@@YAX0@Z@V@?0??1@YAX0@Z@V@?0??1@YAX0@Z@@Z{{.*}}@1
Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -2,10 +2,17 @@
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
-// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=CHECK
+// RUN:   | FileCheck %s
 
 #include "Inputs/cuda.h"
 
+// Kernel handles
+
+// CHECK: @[[HCKERN:ckernel]] = constant void ()* @__device_stub__ckernel, align 8
+// CHECK: @[[HNSKERN:_ZN2ns8nskernelEv]] = constant void ()* @_ZN2ns23__device_stub__nskernelEv, align 8
+// CHECK: @[[HTKERN:_Z10kernelfuncIiEvv]] = linkonce_odr constant void ()* @_Z25__device_stub__kernelfuncIiEvv, align 8
+// CHECK: @[[HDKERN:_Z11kernel_declv]] = external constant void ()*, align 8
+
 extern "C" __global__ void ckernel() {}
 
 namespace ns {
@@ -17,6 +24,11 @@
 
 __global__ void kernel_decl();
 
+void (*kernel_ptr)();
+void *void_ptr;
+
+void launch(void *kern);
+
 // Device side kernel names
 
 // CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
@@ -26,16 +38,20 @@
 // Non-template kernel stub functions
 
 // CHECK: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HCKERN]]
 // CHECK: define{{.*}}@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[NSSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HNSKERN]]
+
 
-// CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
+// Check kernel stub is used for triple chevron
+
+// CHECK-LABEL: define{{.*}}@_Z4fun1v()
 // CHECK: call void @[[CSTUB]]()
 // CHECK: call void @[[NSSTUB]]()
 // CHECK: call void @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]]()
 // CHECK: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
-void hostfunc(void) {
+
+void fun1(void) {
   ckernel<<<1, 1>>>();
   ns::nskernel<<<1, 1>>>();
   kernelfunc<<<1, 1>>>();
@@ -45,11 +61,69 @@
 // Template kernel stub functions
 
 // CHECK: define{{.*}}@[[TSTUB]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[TSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HTKERN]]
+
+// Check declaration of stub function for external kernel.
 
 // CHECK: declare{{.*}}@[[DSTUB]]
 
+// Check kernel handle is used for passing the kernel as a function pointer
+
+// CHECK-LABEL: define{{.*}}@_Z4fun2v()
+// CHECK: call void @_Z6launchPv({{.*}}[[HCKERN]]
+// CHECK: call void @_Z6launchPv({{.*}}[[HNSKERN]]
+// CHECK: call void @_Z6launchPv({{.*}}[[HTKERN]]
+// CHECK: call void @_Z6launchPv({{.*}}[[HDKERN]]
+void fun2() {
+  launch((void *)ckernel);
+  launch((void *)ns::nskernel);
+  launch((void *)kernelfunc);
+  launch((void *)kernel_decl);
+}
+
+// Check kernel handle is used for assigning a kernel to a function pointer
+
+// CHECK-LABEL: define{{.*}}@_Z4fun3v()
+// CHECK:  store void ()* bitcast (void ()** @[[HCKERN]] to void ()*), void ()** @kernel_ptr, align 8
+// CHECK:  store void ()* bitcast (void ()** @[[HCKERN]] to void ()*), void ()** @kernel_ptr, align 8
+// CHECK:  store i8* bitcast (void ()** @[[HCKERN]] to i8*), i8** 

[clang] 5cf2a37 - [HIP] Emit kernel symbol

2021-03-01 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-03-01T16:31:40-05:00
New Revision: 5cf2a37f1255700d4da9d5f45e82bdfff09aee8c

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

LOG: [HIP] Emit kernel symbol

Currently clang uses stub function to launch kernel. This is inconvenient
to interop with C++ programs since the stub function has different name
as kernel, which is required by ROCm debugger.

This patch emits a variable symbol which has the same name as the kernel
and uses it to register and launch the kernel. This allows C++ program to
launch a kernel by using the original kernel name.

Reviewed by: Artem Belevich

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

Added: 
clang/test/CodeGenCUDA/cxx-call-kernel.cpp

Modified: 
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGCUDARuntime.h
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCUDA/Inputs/cuda.h
clang/test/CodeGenCUDA/kernel-dbg-info.cu
clang/test/CodeGenCUDA/kernel-stub-name.cu
clang/test/CodeGenCUDA/unnamed-types.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 57e3b151bfd4..3a311ab395e4 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -42,12 +42,18 @@ class CGNVCUDARuntime : public CGCUDARuntime {
   llvm::LLVMContext 
   /// Convenience reference to the current module
   llvm::Module 
-  /// Keeps track of kernel launch stubs emitted in this module
+  /// Keeps track of kernel launch stubs and handles emitted in this module
   struct KernelInfo {
-llvm::Function *Kernel;
+llvm::Function *Kernel; // stub function to help launch kernel
 const Decl *D;
   };
   llvm::SmallVector EmittedKernels;
+  // Map a device stub function to a symbol for identifying kernel in host 
code.
+  // For CUDA, the symbol for identifying the kernel is the same as the device
+  // stub function. For HIP, they are 
diff erent.
+  llvm::DenseMap KernelHandles;
+  // Map a kernel handle to the kernel stub.
+  llvm::DenseMap KernelStubs;
   struct VarInfo {
 llvm::GlobalVariable *Var;
 const VarDecl *D;
@@ -154,6 +160,12 @@ class CGNVCUDARuntime : public CGCUDARuntime {
 public:
   CGNVCUDARuntime(CodeGenModule );
 
+  llvm::GlobalValue *getKernelHandle(llvm::Function *F, GlobalDecl GD) 
override;
+  llvm::Function *getKernelStub(llvm::GlobalValue *Handle) override {
+auto Loc = KernelStubs.find(Handle);
+assert(Loc != KernelStubs.end());
+return Loc->second;
+  }
   void emitDeviceStub(CodeGenFunction , FunctionArgList ) override;
   void handleVarRegistration(const VarDecl *VD,
  llvm::GlobalVariable ) override;
@@ -272,6 +284,10 @@ std::string CGNVCUDARuntime::getDeviceSideName(const 
NamedDecl *ND) {
 void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction ,
  FunctionArgList ) {
   EmittedKernels.push_back({CGF.CurFn, CGF.CurFuncDecl});
+  if (auto *GV = dyn_cast(KernelHandles[CGF.CurFn])) {
+GV->setLinkage(CGF.CurFn->getLinkage());
+GV->setInitializer(CGF.CurFn);
+  }
   if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
  CudaFeature::CUDA_USES_NEW_LAUNCH) ||
   (CGF.getLangOpts().HIP && CGF.getLangOpts().HIPUseNewLaunchAPI))
@@ -350,7 +366,8 @@ void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction 
,
ShmemSize.getPointer(), Stream.getPointer()});
 
   // Emit the call to cudaLaunch
-  llvm::Value *Kernel = CGF.Builder.CreatePointerCast(CGF.CurFn, VoidPtrTy);
+  llvm::Value *Kernel =
+  CGF.Builder.CreatePointerCast(KernelHandles[CGF.CurFn], VoidPtrTy);
   CallArgList LaunchKernelArgs;
   LaunchKernelArgs.add(RValue::get(Kernel),
cudaLaunchKernelFD->getParamDecl(0)->getType());
@@ -405,7 +422,8 @@ void 
CGNVCUDARuntime::emitDeviceStubBodyLegacy(CodeGenFunction ,
 
   // Emit the call to cudaLaunch
   llvm::FunctionCallee cudaLaunchFn = getLaunchFn();
-  llvm::Value *Arg = CGF.Builder.CreatePointerCast(CGF.CurFn, CharPtrTy);
+  llvm::Value *Arg =
+  CGF.Builder.CreatePointerCast(KernelHandles[CGF.CurFn], CharPtrTy);
   CGF.EmitRuntimeCallOrInvoke(cudaLaunchFn, Arg);
   CGF.EmitBranch(EndBlock);
 
@@ -499,7 +517,7 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
 llvm::Constant *NullPtr = llvm::ConstantPointerNull::get(VoidPtrTy);
 llvm::Value *Args[] = {
 ,
-Builder.CreateBitCast(I.Kernel, VoidPtrTy),
+Builder.CreateBitCast(KernelHandles[I.Kernel], VoidPtrTy),
 KernelName,
 KernelName,
 llvm::ConstantInt::get(IntTy, -1),
@@ -1070,3 +1088,28 @@ llvm::Function *CGNVCUDARuntime::finalizeModule() {
   }
   return 

[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:22
 def note_fe_inline_asm_here : Note<"instantiated into assembly here">;
+def err_fe_source_mgr : Error<"%0">, CatSourceMgr;
+def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, 
InGroup;

MaskRay wrote:
> These seem unused.
These `.td` file changes are used by `ComputeDiagID(DI.getKind(), source_mgr, 
DiagID);` down below. Basically it makes non-inlineasm SourceMgr error its own 
diagnose category.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97630: [clang-tidy] Added option to uniqueptr delete release check

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 327258.
njames93 added a comment.

Add test demonstrating we aren't detecting bound member functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97630

Files:
  clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
  clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp
@@ -1,5 +1,6 @@
-// RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t
-
+// RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t -check-suffix=NULLPTR
+// RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t -check-suffix=RESET -config='{ \
+// RUN: CheckOptions: [{key: readability-uniqueptr-delete-release.PreferResetCall, value: true}]}'
 namespace std {
 template 
 struct default_delete {};
@@ -13,6 +14,9 @@
   template 
   unique_ptr(unique_ptr&&);
   T* release();
+  void reset(T *P = nullptr);
+  T *() const;
+  T *operator->() const;
 };
 }  // namespace std
 
@@ -21,22 +25,62 @@
 void Positives() {
   std::unique_ptr P;
   delete P.release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
-  // CHECK-FIXES: {{^}}  P = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr' to reset 'unique_ptr<>' objects
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()' to reset 'unique_ptr<>' objects
+  // CHECK-FIXES-NULLPTR: {{^}}  P = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P.reset();
 
   auto P2 = P;
   delete P2.release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
-  // CHECK-FIXES: {{^}}  P2 = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr' to reset 'unique_ptr<>' objects
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()' to reset 'unique_ptr<>' objects
+  // CHECK-FIXES-NULLPTR: {{^}}  P2 = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P2.reset();
+
+  delete (P2.release());
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  (P2 = nullptr);
+  // CHECK-FIXES-RESET: {{^}}  (P2.reset());
 
   std::unique_ptr Array[20];
   delete Array[4].release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete
-  // CHECK-FIXES: {{^}}  Array[4] = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  Array[4] = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  Array[4].reset();
 
   delete ReturnsAUnique().release();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete
-  // CHECK-FIXES: {{^}}  ReturnsAUnique() = nullptr;
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  ReturnsAUnique() = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  ReturnsAUnique().reset();
+
+  std::unique_ptr *P3();
+  delete P3->release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  *P3 = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P3->reset();
+
+  std::unique_ptr> P4;
+  delete (*P4).release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  (*P4) = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  (*P4).reset();
+
+  delete P4->release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  *P4 = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  P4->reset();
+
+  delete (P4)->release();
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'
+  // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()'
+  // CHECK-FIXES-NULLPTR: {{^}}  *(P4) = nullptr;
+  // CHECK-FIXES-RESET: {{^}}  (P4)->reset();
 }
 
 struct 

[PATCH] D97630: [clang-tidy] Added option to uniqueptr delete release check

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp:40
+
+  delete (P2.release());
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'

aaron.ballman wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > Not that I expect this to come up particularly often, but, how about: 
> > > `delete (P2.release)();`
> > I don't think Im gonna worry about those given how infrequently bound 
> > member functions are used.
> I'm fine with that, but it does come up from people who loathe ADL 
> shenanigans. That said, if it comes up *here*, I'd be surprised.
In its current config it wont detect it at all. I got it to detect bound member 
functions but the fix-its never seemed to work properly. I've just left it as 
it. so no warning or (corrupted fix-it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97630

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


[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/lib/MC/MCContext.cpp:869
+SMLoc Loc,
+std::function GetMessage) {
+  SourceMgr SM;

MaskRay wrote:
> ychen wrote:
> > MaskRay wrote:
> > > Use lightweight function_ref since you don't need to store the callback.
> > I was hesitant to do this because it requires including `STLExtras.h` in 
> > MCContext.h which could be bad for compile-time. 
> You can forward declare `function_ref` (see 
> `mlir/include/mlir/Support/LLVM.h`).
Thanks. Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Parse/Parser.h:1586-1589
+  for (const ParsedAttr  : *this) {
+if (A.getSyntax() != ParsedAttr::Syntax::AS_GNU)
+  return false;
+  }





Comment at: clang/include/clang/Parse/Parser.h:1591-1593
+  // If the attr list is empty, but the range is still set, we did parse
+  // some attributes. Return false in this case, even though we might've
+  // parsed [[]].

I would argue that this function should return false in this case because it 
has no attributes and since it has no attributes, it does not contain *only* 
GNU attributes. There shouldn't be a need to check `Range.isInvalid()` at all 
but could instead `return !empty();` and this functionality could be moved to 
`ParsedAttributes` instead of requiring there to be a range.

However, I don't know that this function needs to exist at all (see below).



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1828-1830
+  // Allow only GNU attributes here.
+  if (!attrs.hasOnlyGNUAttributes())
+ProhibitAttributes(attrs);

We really should be using `ProhibitCXX11Attributes()` here, but that doesn't 
currently handle the case where it's an empty attribute list. However, we could 
use the valid source range information in that case to look at the tokens used 
to decide whether to diagnose or not.


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

https://reviews.llvm.org/D97362

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


[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 327256.
ychen added a comment.

- Use function_ref


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

Files:
  clang/include/clang/Basic/DiagnosticCategories.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/test/CodeGen/AMDGPU/lds-initializer.ll
  llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
  llvm/test/CodeGen/XCore/section-name.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -290,6 +290,22 @@
   bool *HasError;
   LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
   bool handleDiagnostics(const DiagnosticInfo ) override {
+if (DI.getKind() == llvm::DK_SrcMgr) {
+  const auto  = cast(DI);
+  const SMDiagnostic  = DISM.getSMDiag();
+
+  if (SMD.getKind() == SourceMgr::DK_Error)
+*HasError = true;
+
+  SMD.print(nullptr, errs());
+
+  // For testing purposes, we print the LocCookie here.
+  if (DISM.isInlineAsmDiag() && DISM.getLocCookie())
+WithColor::note() << "!srcloc = " << DISM.getLocCookie() << "\n";
+
+  return true;
+}
+
 if (DI.getSeverity() == DS_Error)
   *HasError = true;
 
@@ -305,19 +321,6 @@
   }
 };
 
-static void InlineAsmDiagHandler(const SMDiagnostic , void *Context,
- unsigned LocCookie) {
-  bool *HasError = static_cast(Context);
-  if (SMD.getKind() == SourceMgr::DK_Error)
-*HasError = true;
-
-  SMD.print(nullptr, errs());
-
-  // For testing purposes, we print the LocCookie here.
-  if (LocCookie)
-WithColor::note() << "!srcloc = " << LocCookie << "\n";
-}
-
 // main - Entry point for the llc compiler.
 //
 int main(int argc, char **argv) {
@@ -367,7 +370,6 @@
   bool HasError = false;
   Context.setDiagnosticHandler(
   std::make_unique());
-  Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, );
 
   Expected> RemarksFileOrErr =
   setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
Index: llvm/test/CodeGen/XCore/section-name.ll
===
--- llvm/test/CodeGen/XCore/section-name.ll
+++ llvm/test/CodeGen/XCore/section-name.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
 
 @bar = internal global i32 zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
@@ -1,7 +1,7 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti -filetype=null < %s 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga -filetype=null < %s 2>&1 | FileCheck %s
 
-; CHECK: lds: unsupported initializer for address space
+; CHECK: error: lds: unsupported initializer for address space
 
 @lds = addrspace(3) global [256 x i32] zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-initializer.ll
@@ -1,5 +1,5 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
 
 ; CHECK: lds: unsupported initializer for address space
 
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -2348,7 +2348,7 @@
 /// will use the last parsed cpp hash line filename comment
 /// for the Filename and LineNo if any in the diagnostic.
 void AsmParser::DiagHandler(const SMDiagnostic , void *Context) {
-  const AsmParser *Parser = static_cast(Context);
+  auto *Parser = static_cast(Context);
   raw_ostream  = errs();
 
   const SourceMgr  = 

[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LG. Can you attach an example triggering clang `InlineAsmDiagHandler2`? I want 
to check what the diagnostic looks like now.




Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:22
 def note_fe_inline_asm_here : Note<"instantiated into assembly here">;
+def err_fe_source_mgr : Error<"%0">, CatSourceMgr;
+def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, 
InGroup;

These seem unused.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:1148
 def BackendInlineAsm : DiagGroup<"inline-asm">;
+def BackendSourceMgr : DiagGroup<"source-mgr">;
 def BackendFrameLargerThanEQ : DiagGroup<"frame-larger-than=">;

Unused


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D97449#2595390 , @MaskRay wrote:

> Is the https://github.com/ClangBuiltLinux/linux/issues/1269 unreachable error 
> fixed?
>
> Reproduce:
>
>   git clone https://android.googlesource.com/kernel/common.git --branch 
> android-4.19-stable
>   cd common
>   # ninja -C path/yo/your/build clang lld check-llvm-tools
>   PATH=path/to/your/build/bin:$PATH make -s -j 30 LLVM=1 O=/tmp/out/android 
> gki_defconfig bzImage 
>   # very slow

I think so. `DiagnosticInfoSrcMgr::print` is now implemented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97630: [clang-tidy] Added option to uniqueptr delete release check

2021-03-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp:40
+
+  delete (P2.release());
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'

njames93 wrote:
> aaron.ballman wrote:
> > Not that I expect this to come up particularly often, but, how about: 
> > `delete (P2.release)();`
> I don't think Im gonna worry about those given how infrequently bound member 
> functions are used.
I'm fine with that, but it does come up from people who loathe ADL shenanigans. 
That said, if it comes up *here*, I'd be surprised.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97630

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


[clang] 564f5b0 - Revert "[c++20] Mark class type NTTPs as done and start defining the feature test macro."

2021-03-01 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-03-01T12:53:35-08:00
New Revision: 564f5b0734bd5d265a0046e5ca9d08ae5bc303eb

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

LOG: Revert "[c++20] Mark class type NTTPs as done and start defining the 
feature test macro."

Some of the parts of this work were reverted; stop defining the feature
test macro for now.

This reverts commit b4c63ef6dd90dba9af26a111c9a78b121c5284b1.

Added: 


Modified: 
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Lexer/cxx-features.cpp

Removed: 




diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index d47ad1b74649..c64a912ce919 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -565,7 +565,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions ,
 Builder.defineMacro("__cpp_aggregate_bases", "201603L");
 Builder.defineMacro("__cpp_structured_bindings", "201606L");
 Builder.defineMacro("__cpp_nontype_template_args",
-LangOpts.CPlusPlus20 ? "201911L" : "201411L");
+"201411L"); // (not latest)
 Builder.defineMacro("__cpp_fold_expressions", "201603L");
 Builder.defineMacro("__cpp_guaranteed_copy_elision", "201606L");
 Builder.defineMacro("__cpp_nontype_template_parameter_auto", "201606L");

diff  --git a/clang/test/Lexer/cxx-features.cpp 
b/clang/test/Lexer/cxx-features.cpp
index f57faed4ed90..2f46f354ee83 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -181,7 +181,8 @@
 #error "wrong value for __cpp_structured_bindings"
 #endif
 
-#if check(nontype_template_args, 0, 0, 0, 201411, 201911, 201911)
+#if check(nontype_template_args, 0, 0, 0, 201411, 201411, 201411)
+// FIXME: 201911 in C++20
 #error "wrong value for __cpp_nontype_template_args"
 #endif
 



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


[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-03-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Is the https://github.com/ClangBuiltLinux/linux/issues/1269 unreachable error 
fixed?

Reproduce:

  git clone https://android.googlesource.com/kernel/common.git --branch 
android-4.19-stable
  cd common
  PATH=path/to/your/clang/bin:$PATH make -s -j 30 LLVM=1 O=/tmp/out/android 
gki_defconfig bzImage 
  # very slow




Comment at: llvm/lib/MC/MCContext.cpp:869
+SMLoc Loc,
+std::function GetMessage) {
+  SourceMgr SM;

ychen wrote:
> MaskRay wrote:
> > Use lightweight function_ref since you don't need to store the callback.
> I was hesitant to do this because it requires including `STLExtras.h` in 
> MCContext.h which could be bad for compile-time. 
You can forward declare `function_ref` (see `mlir/include/mlir/Support/LLVM.h`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97449

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


[PATCH] D97630: [clang-tidy] Added option to uniqueptr delete release check

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp:40
+
+  delete (P2.release());
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'

aaron.ballman wrote:
> Not that I expect this to come up particularly often, but, how about: `delete 
> (P2.release)();`
I don't think Im gonna worry about those given how infrequently bound member 
functions are used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97630

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


[PATCH] D97340: [HIP] Support Spack packages

2021-03-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 327243.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

revised by Artem's comments


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

https://reviews.llvm.org/D97340

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/ROCm.h
  
clang/test/Driver/Inputs/rocm-spack/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/bin/.hipVersion
  
clang/test/Driver/Inputs/rocm-spack/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include/hip/hip_runtime.h
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/asanrtl.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/hip.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_daz_opt_off.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_finite_only_off.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_isa_version_908.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_unsafe_math_off.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/ocml.bc
  
clang/test/Driver/Inputs/rocm-spack/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/opencl.bc
  clang/test/Driver/rocm-detect.hip

Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -16,14 +16,75 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
 
-
 // RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nogpulib \
 // RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s
 
+// Test ROCm installation built by SPACK by invoke clang at %T/rocm-spack/llvm-amdgpu-*
+// directory through a soft link.
+
+// RUN: rm -rf %T/rocm-spack
+// RUN: cp -r %S/Inputs/rocm-spack %T
+// RUN: ln -fs %clang %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
+// RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
+// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=SPACK %s
+
+// Test SPACK installation with multiple hip and rocm-device-libs packages of the same
+// ROCm release. Clang cannot determine which one to use and emit diagnostics. --hip-path
+// and --rocm-device-lib-path can be used to specify them.
+
+// RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
+// RUN: cp -r %T/rocm-spack/rocm-device-libs-* %T/rocm-spack/rocm-device-libs-4.0.0-efgh
+// RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
+// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
+// RUN:   | 

[PATCH] D87587: [clang-format][PR47290] Add ShortNamespaceLines format option

2021-03-01 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ca52815fb3c: [clang-format][PR47290] Add 
ShortNamespaceLines format option (authored by kuzkry, committed by 
HazardyKnusperkeks).

Changed prior to commit:
  https://reviews.llvm.org/D87587?vs=323289=327246#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87587

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -816,7 +816,7 @@
 "}\n"));
 }
 
-TEST_F(NamespaceEndCommentsFixerTest, AddEndCommentForNamespacesAroundMacros) {
+TEST_F(NamespaceEndCommentsFixerTest, AddsEndCommentForNamespacesAroundMacros) {
   // Conditional blocks around are fine
   EXPECT_EQ("namespace A {\n"
 "#if 1\n"
@@ -1116,6 +1116,75 @@
 "}\n"
 "}\n"));
 }
+
+using ShortNamespaceLinesTest = NamespaceEndCommentsFixerTest;
+
+TEST_F(ShortNamespaceLinesTest, ZeroUnwrappedLines) {
+  auto Style = getLLVMStyle();
+  Style.ShortNamespaceLines = 0u;
+
+  EXPECT_EQ("namespace OneLinerNamespace {}\n",
+fixNamespaceEndComments("namespace OneLinerNamespace {}\n", Style));
+  EXPECT_EQ("namespace ShortNamespace {\n"
+"}\n",
+fixNamespaceEndComments("namespace ShortNamespace {\n"
+"}\n",
+Style));
+  EXPECT_EQ("namespace LongNamespace {\n"
+"int i;\n"
+"}// namespace LongNamespace\n",
+fixNamespaceEndComments("namespace LongNamespace {\n"
+"int i;\n"
+"}\n",
+Style));
+}
+
+TEST_F(ShortNamespaceLinesTest, OneUnwrappedLine) {
+  constexpr auto DefaultUnwrappedLines = 1u;
+  auto const Style = getLLVMStyle();
+
+  EXPECT_EQ(DefaultUnwrappedLines, Style.ShortNamespaceLines);
+  EXPECT_EQ("namespace ShortNamespace {\n"
+"int i;\n"
+"}\n",
+fixNamespaceEndComments("namespace ShortNamespace {\n"
+"int i;\n"
+"}\n"));
+  EXPECT_EQ("namespace LongNamespace {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace LongNamespace\n",
+fixNamespaceEndComments("namespace LongNamespace {\n"
+"int i;\n"
+"int j;\n"
+"}\n"));
+}
+
+TEST_F(ShortNamespaceLinesTest, MultipleUnwrappedLine) {
+  auto Style = getLLVMStyle();
+  Style.ShortNamespaceLines = 2u;
+
+  EXPECT_EQ("namespace ShortNamespace {\n"
+"int i;\n"
+"int j;\n"
+"}\n",
+fixNamespaceEndComments("namespace ShortNamespace {\n"
+"int i;\n"
+"int j;\n"
+"}\n",
+Style));
+  EXPECT_EQ("namespace LongNamespace {\n"
+"int i;\n"
+"int j;\n"
+"int k;\n"
+"}// namespace LongNamespace\n",
+fixNamespaceEndComments("namespace LongNamespace {\n"
+"int i;\n"
+"int j;\n"
+"int k;\n"
+"}\n",
+Style));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -22,10 +22,6 @@
 namespace format {
 
 namespace {
-// The maximal number of unwrapped lines that a short namespace spans.
-// Short namespaces don't need an end comment.
-static const int kShortNamespaceMaxLines = 1;
-
 // Computes the name of a namespace given the namespace token.
 // Returns "" for anonymous namespace.
 std::string computeName(const FormatToken *NamespaceTok) {
@@ -283,7 +279,7 @@
 computeEndCommentText(NamespaceName, AddNewline, NamespaceTok,
   Style.SpacesInLineCommentPrefix.Minimum);
 if 

[PATCH] D96896: [clang-format] Respect spaces in line comment section without an active column limit

2021-03-01 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG418b4a7b3158: [clang-format] Respect spaces in line comment 
section... (authored by HazardyKnusperkeks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96896

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -3793,6 +3793,189 @@
"int i;//  A Comment to be moved\n"
"  //   with indent\n",
Style));
+
+  Style = getLLVMStyleWithColumns(0);
+  EXPECT_EQ("// Free comment without space\n"
+"\n"
+"//   Free comment with 3 spaces\n"
+"\n"
+"/// Free Doxygen without space\n"
+"\n"
+"///   Free Doxygen with 3 spaces\n"
+"\n"
+"/// A Doxygen Comment with a nested list:\n"
+"/// - Foo\n"
+"/// - Bar\n"
+"///   - Baz\n"
+"///   - End\n"
+"/// of the inner list\n"
+"///   .\n"
+"/// .\n"
+"\n"
+"namespace Foo {\n"
+"bool bar(bool b) {\n"
+"  bool ret1 = true; ///< Doxygenstyle without space\n"
+"  bool ret2 = true; ///<   Doxygenstyle with 3 spaces\n"
+"  if (b) {\n"
+"// Foo\n"
+"\n"
+"//   In function comment\n"
+"ret2 = false;\n"
+"  } // End of if\n"
+"\n"
+"  //  if (ret1) {\n"
+"  //return ret2;\n"
+"  //  }\n"
+"\n"
+"  // if (ret1) {\n"
+"  //   return ret2;\n"
+"  // }\n"
+"\n"
+"  return ret1 && ret2;\n"
+"}\n"
+"} // namespace Foo\n"
+"\n"
+"namespace Bar {\n"
+"int foo();\n"
+"} //  namespace Bar\n"
+"//@Nothing added because of the non ascii char\n"
+"\n"
+"//@  Nothing removed because of the non ascii char\n"
+"\n"
+"//  Comment to move to the left\n"
+"// But not this?\n"
+"//  @but this\n"
+"\n"
+"// Comment to move to the right\n"
+"//@ this stays\n"
+"\n"
+"//} will not move\n"
+"\n"
+"// vv will only move\n"
+"// } if the line above does\n",
+format(Code, Style));
+
+  Style.SpacesInLineCommentPrefix = {0, 0};
+  EXPECT_EQ("//Free comment without space\n"
+"\n"
+"//Free comment with 3 spaces\n"
+"\n"
+"///Free Doxygen without space\n"
+"\n"
+"///Free Doxygen with 3 spaces\n"
+"\n"
+"///A Doxygen Comment with a nested list:\n"
+"///- Foo\n"
+"///- Bar\n"
+"///  - Baz\n" // Here we keep the relative indentation
+"///  - End\n"
+"///of the inner list\n"
+"///  .\n"
+"///.\n"
+"\n"
+"namespace Foo {\n"
+"bool bar(bool b) {\n"
+"  bool ret1 = true; /// SmallString.size();\n"
+  "}";
+  EXPECT_EQ(Code, format(Code, Style));
+}
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1993,6 +1993,11 @@
 // We don't insert backslashes when breaking line comments.
 ColumnLimit = Style.ColumnLimit;
   }
+  if (ColumnLimit == 0) {
+// To make the rest of the function easier set the column limit to the
+// maximum, if there should be no limit.
+ColumnLimit = std::numeric_limits::max();
+  }
   if (Current.UnbreakableTailLength >= ColumnLimit)
 return {0, false};
   // ColumnWidth was already accounted into State.Column before calling
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6ca5281 - [clang-format][PR47290] Add ShortNamespaceLines format option

2021-03-01 Thread Björn Schäpers via cfe-commits

Author: Krystian Kuzniarek
Date: 2021-03-01T21:28:14+01:00
New Revision: 6ca52815fb3cb32343b9a008fdf9f593da39f203

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

LOG: [clang-format][PR47290] Add ShortNamespaceLines format option

clang-format documentation states that having enabled
FixNamespaceComments one may expect below code:

c++
namespace a {
foo();
}

to be turned into:

c++
namespace a {
foo();
} // namespace a

In reality, no "// namespace a" was added. The problem was too high
value of kShortNamespaceMaxLines, which is used while deciding whether
a namespace is long enough to be formatted.

As with 9163fe2, clang-format idempotence is preserved.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/NamespaceEndCommentsFixer.cpp
clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 1dbf11987cd8..a0af61faa143 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2210,14 +2210,16 @@ the configuration (without a prefix: ``Auto``).
   not use this in config files, etc. Use at your own risk.
 
 **FixNamespaceComments** (``bool``)
-  If ``true``, clang-format adds missing namespace end comments and
-  fixes invalid existing ones.
+  If ``true``, clang-format adds missing namespace end comments for
+  short namespaces and fixes invalid existing ones. Short ones are
+  controlled by "ShortNamespaceLines".
 
   .. code-block:: c++
 
  true:  false:
  namespace a {  vs. namespace a {
  foo(); foo();
+ bar(); bar();
  } // namespace a   }
 
 **ForEachMacros** (``std::vector``)
@@ -2367,7 +2369,7 @@ the configuration (without a prefix: ``Auto``).
   the record members, respecting the ``AccessModifierOffset``. Record
   members are indented one level below the record.
   When ``true``, access modifiers get their own indentation level. As a
-  consequence, record members are indented 2 levels below the record,
+  consequence, record members are always indented 2 levels below the record,
   regardless of the access modifier presence. Value of the
   ``AccessModifierOffset`` is ignored.
 
@@ -3040,43 +3042,72 @@ the configuration (without a prefix: ``Auto``).
  /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of
   * information */
 
+**ShortNamespaceLines** (``unsigned``)
+  The maximal number of unwrapped lines that a short namespace spans.
+  Defaults to 1.
+
+  This determines the maximum length of short namespaces by counting
+  unwrapped lines (i.e. containing neither opening nor closing
+  namespace brace) and makes "FixNamespaceComments" omit adding
+  end comments for those.
+
+  .. code-block:: c++
+
+ ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
+ namespace a {  namespace a {
+   int foo;   int foo;
+ }  } // namespace a
+
+ ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
+ namespace b {  namespace b {
+   int foo;   int foo;
+   int bar;   int bar;
+ } // namespace b   } // namespace b
+
 **SortIncludes** (``SortIncludesOptions``)
   Controls if and how clang-format will sort ``#includes``.
+  If ``Never``, includes are never sorted.
+  If ``CaseInsensitive``, includes are sorted in an ASCIIbetical or case
+  insensitive fashion.
+  If ``CaseSensitive``, includes are sorted in an alphabetical or case
+  sensitive fashion.
 
-  Possible Values:
+  Possible values:
 
-  * ``SI_Never`` (in configuration ``Never``)
+  * ``SI_Never`` (in configuration: ``Never``)
 Includes are never sorted.
 
 .. code-block:: c++
 
-  #include "B/A.h"
-  #include "A/B.h"
-  #include "a/b.h"
-  #include "A/b.h"
-  #include "B/a.h"
+   #include "B/A.h"
+   #include "A/B.h"
+   #include "a/b.h"
+   #include "A/b.h"
+   #include "B/a.h"
 
-  * ``SI_CaseInsensitive`` (in configuration ``CaseInsensitive``)
+  * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
 Includes are sorted in an ASCIIbetical or case insensitive fashion.
 
 .. code-block:: c++
 
-  #include "A/B.h"
-  #include "A/b.h"
-  #include "B/A.h"
-  #include "B/a.h"
-  #include "a/b.h"
+   

[clang] 418b4a7 - [clang-format] Respect spaces in line comment section...

2021-03-01 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2021-03-01T21:28:14+01:00
New Revision: 418b4a7b3158b47043c4c8891eb2e27966a55fa2

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

LOG: [clang-format] Respect spaces in line comment section...

... without an active column limit.

Before line comments were not touched at all with ColumnLimit == 0.

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 7198671901f3..ffb328f7de13 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1993,6 +1993,11 @@ ContinuationIndenter::breakProtrudingToken(const 
FormatToken ,
 // We don't insert backslashes when breaking line comments.
 ColumnLimit = Style.ColumnLimit;
   }
+  if (ColumnLimit == 0) {
+// To make the rest of the function easier set the column limit to the
+// maximum, if there should be no limit.
+ColumnLimit = std::numeric_limits::max();
+  }
   if (Current.UnbreakableTailLength >= ColumnLimit)
 return {0, false};
   // ColumnWidth was already accounted into State.Column before calling

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 8bb90e0d6e61..d8bf3567e38e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -19253,6 +19253,33 @@ TEST_F(FormatTest, IndentAccessModifiers) {
"};\n",
Style);
 }
+
+TEST_F(FormatTest, LimitlessStringsAndComments) {
+  auto Style = getLLVMStyleWithColumns(0);
+  constexpr StringRef Code =
+  "/**\n"
+  " * This is a multiline comment with quite some long lines, at least for 
"
+  "the LLVM Style.\n"
+  " * We will redo this with strings and line comments. Just to  check if "
+  "everything is working.\n"
+  " */\n"
+  "bool foo() {\n"
+  "  /* Single line multi line comment. */\n"
+  "  const std::string String = \"This is a multiline string with quite "
+  "some long lines, at least for the LLVM Style.\"\n"
+  " \"We already did it with multi line "
+  "comments, and we will do it with line comments. Just to check if "
+  "everything is working.\";\n"
+  "  // This is a line comment (block) with quite some long lines, at "
+  "least for the LLVM Style.\n"
+  "  // We already did this with multi line comments and strings. Just to "
+  "check if everything is working.\n"
+  "  const std::string SmallString = \"Hello World\";\n"
+  "  // Small line comment\n"
+  "  return String.size() > SmallString.size();\n"
+  "}";
+  EXPECT_EQ(Code, format(Code, Style));
+}
 } // namespace
 } // namespace format
 } // namespace clang

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index 108028e396a1..2a7ead62ba5b 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -3793,6 +3793,189 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
"int i;//  A Comment to be moved\n"
"  //   with indent\n",
Style));
+
+  Style = getLLVMStyleWithColumns(0);
+  EXPECT_EQ("// Free comment without space\n"
+"\n"
+"//   Free comment with 3 spaces\n"
+"\n"
+"/// Free Doxygen without space\n"
+"\n"
+"///   Free Doxygen with 3 spaces\n"
+"\n"
+"/// A Doxygen Comment with a nested list:\n"
+"/// - Foo\n"
+"/// - Bar\n"
+"///   - Baz\n"
+"///   - End\n"
+"/// of the inner list\n"
+"///   .\n"
+"/// .\n"
+"\n"
+"namespace Foo {\n"
+"bool bar(bool b) {\n"
+"  bool ret1 = true; ///< Doxygenstyle without space\n"
+"  bool ret2 = true; ///<   Doxygenstyle with 3 spaces\n"
+"  if (b) {\n"
+"// Foo\n"
+"\n"
+"//   In function comment\n"
+"ret2 = false;\n"
+"  } // End of if\n"
+"\n"
+"  //  if (ret1) {\n"
+"  //return ret2;\n"
+"  //  }\n"
+"\n"
+"  // if (ret1) {\n"
+"  //   return ret2;\n"
+"  // }\n"
+"\n"
+"  return ret1 && ret2;\n"
+"}\n"
+"} // namespace 

[PATCH] D97340: [HIP] Support Spack packages

2021-03-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:32
+static llvm::SmallString<0> findSPACKPackage(const Driver ,
+ const llvm::SmallString<0> ,
+ StringRef Prefix) {

tra wrote:
> Based on how the function is used, perhaps we should make it 
> `static std::string findSPACKPackage(const Driver , StringRef Path, 
> StringRef PackageName, StringRef RocmVersion)`  and fold the prefix 
> construction (and possibly version non-emptiness check) into the function.
Will use PackageName and RocmVersion as arguments.

However, we use llvm::sys::path to manipulate paths and llvm::sys::path is 
using llvm::SmallString. If we return std::string or use StringRef for path 
argument, we have to convert them back and force.





Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:354-372
+  CandidatesInfo CanInfo;
+  if (!HIPPathArg.empty())
+CanInfo.Candidates.emplace_back(HIPPathArg.str(), /*StrictChecking=*/true);
+  else
+CanInfo = getInstallationPathCandidates();
   auto  = D.getVFS();
 

tra wrote:
> So, normally `--hip-path` would point to the HIP package installation. 
> However, is clang installation path contains `llvm-amdgpu` (and thus 
> CanInfo.SPACKReleaseStr is set to whatever version may follow),
> then `--hip-path` (and other candidate paths) directories will also be 
> treated as an SPACK package directory and, if the `hip` package is found 
> there, then *that* package directory will be used as the actual path to be 
> used.
> 
> I see several potential issues with that.
> 
> - if clang path contains llvm-amdgpu, but it is *not* installed as an SPACK 
> package We have no control over user's choice of the name for the 
> installation path.
> - what if clang is installed as an SPCAK, but is invoked via a symlink with 
> the name that does not contain `llvm-amdgpu`
> - the fact that `--hip-path`/`--rocm-path` behavior may change based on 
> clang's executable path is rather peculiar. User-supplied parameters should 
> not change their meaning depending on what you call the executable. 
> 
> I'd be OK to derive spack-based paths if user didn't provide the paths 
> explicitly, but I don't think we should add any magic to explicit overrides.
> 
> 
Will make SPACKReleaseStr a member of Candidate and allow mixed Spack 
candidates and non-Spack candidates. If clang path contains llvm-amdgpu but is 
not a Spack package, clang will still look for non-Spack ROCm candidates.

Also added parent of real path of clang as ROCm candidate. If clang is invoked 
through a sym link which is not under the real ROCm directory, clang will still 
be able to detect it. Also added --print-rocm-search-dirs for testing this.

When --hip-path/--rocm-path is set, the specified ROCm/HIP path is used. Spack 
detection is disabled, since the candidate specified by --rocm-path or 
--hip-path has empty SPACKReleaseStr.


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

https://reviews.llvm.org/D97340

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


[PATCH] D97630: [clang-tidy] Added option to uniqueptr delete release check

2021-03-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-uniqueptr-delete-release.cpp:40
+
+  delete (P2.release());
+  // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr'

Not that I expect this to come up particularly often, but, how about: `delete 
(P2.release)();`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97630

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


[PATCH] D95204: [lld-macho] Switch default to new Darwin backend

2021-03-01 Thread Jez Ng via Phabricator via cfe-commits
int3 added a comment.

I've reverted the clang driver changes for now in 
rG922de2574c17a755279358be928e5343dcf56c56 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95204

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2021-03-01 Thread Alex Orlov via Phabricator via cfe-commits
aorlov added a comment.

Ping! Please, review this patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


[PATCH] D95017: [clang-format] Add case aware include sorting.

2021-03-01 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D95017#2572578 , @PragmaNull wrote:

> In D95017#2572238 , @curdeius wrote:
>
>> Do you have an idea for better names?
>> I see that e.g. MS documentation uses ascending order and case-sensitive 
>> order.
>
> I'm okay with the names, it just seems to me that they are reversed, where 
> CaseSensitive should sort using ASCIIbetic order, and CaseInsensitive should 
> ignore case entirely in the same way that most case-insensitive string 
> compares would.

Do you make a change? Otherwise I will do, but that will take some time, 
because I'm rather busy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-03-01 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 327230.
arnamoy10 added a comment.

Minor changes as per comments, also updated commit message to include 
description of changes related to Setters.


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

https://reviews.llvm.org/D96875

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Semantics/mod-file-rewriter.f90

Index: flang/test/Semantics/mod-file-rewriter.f90
===
--- flang/test/Semantics/mod-file-rewriter.f90
+++ flang/test/Semantics/mod-file-rewriter.f90
@@ -1,8 +1,8 @@
 ! RUN: rm -fr %t && mkdir %t && cd %t
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-unchanged.f90 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-changed.f90 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-unchanged.f90 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-changed.f90 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
 
 module m
   real :: x(10)
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -59,6 +59,7 @@
 ! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
 ! HELP-FC1-NEXT: -fdebug-dump-provenance Dump provenance
 ! HELP-FC1-NEXT: -fdebug-dump-symbolsDump symbols after the semantic analysis
+! HELP-FC1-NEXT: -fdebug-module-writer   Enables showing debug messages while writing module files.
 ! HELP-FC1-NEXT: -fdebug-unparse-with-symbols
 ! HELP-FC1-NEXT:Unparse and stop.
 ! HELP-FC1-NEXT: -fdebug-unparseUnparse and stop.
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -116,7 +116,7 @@
   // Prepare semantics
   setSemantics(std::make_unique(
   ci.invocation().semanticsContext(), parseTree,
-  ci.parsing().cooked().AsCharBlock()));
+  ci.parsing().cooked().AsCharBlock(), ci.invocation().debugModuleDir()));
   auto  = this->semantics();
 
   // Run semantic checks
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -292,9 +292,10 @@
 
 /// Parses all semantic related arguments and populates the variables
 /// options accordingly.
-static void parseSemaArgs(std::string , llvm::opt::ArgList ,
+static void parseSemaArgs(CompilerInvocation , llvm::opt::ArgList ,
 clang::DiagnosticsEngine ) {
 
+  // -J/module-dir option
   auto moduleDirList =
   args.getAllArgValues(clang::driver::options::OPT_module_dir);
   // User can only specify -J/-module-dir once
@@ -306,7 +307,12 @@
 diags.Report(diagID);
   }
   if (moduleDirList.size() == 1)
-moduleDir = moduleDirList[0];
+res.SetModuleDir(moduleDirList[0]);
+
+  // -fdebug-module-writer option
+  if (args.hasArg(clang::driver::options::OPT_fdebug_module_writer)) {
+res.SetDebugModuleDir(true);
+  }
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
@@ -339,7 +345,7 @@
   // Parse the preprocessor args
   parsePreprocessorArgs(res.preprocessorOpts(), args);
   // Parse semantic args
-  parseSemaArgs(res.moduleDir(), args, diags);
+  parseSemaArgs(res, args, diags);
 
   return success;
 }
@@ -451,7 +457,6 @@
   *(new Fortran::common::IntrinsicTypeDefaultKinds()),
   fortranOptions.features, allCookedSources);
 
-  auto  = moduleDir();
-  semanticsContext_->set_moduleDirectory(moduleDirJ)
+  semanticsContext_->set_moduleDirectory(moduleDir())
   .set_searchDirectories(fortranOptions.searchDirectories);
 }
Index: flang/include/flang/Frontend/CompilerInvocation.h
===
--- flang/include/flang/Frontend/CompilerInvocation.h
+++ flang/include/flang/Frontend/CompilerInvocation.h
@@ -69,6 +69,8 @@
   // of options.
   std::string moduleDir_ = ".";
 
+  bool 

[PATCH] D97717: [SYCL] Rework the SYCL driver options

2021-03-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: erichkeane, bader.
Herald added subscribers: jansvoboda11, dexonsmith, dang, Anastasia, ebevhan, 
yaxunl.
aaron.ballman requested review of this revision.
Herald added a project: clang.

SYCL compilations initiated by the driver will spawn off one or more frontend 
compilation jobs (one for device and one for host). This patch reworks the 
driver options to make upstreaming this from the downstream SYCL fork easier.

This patch introduces a language option to identify host executions 
(`SYCLIsHost`) and a -cc1 frontend option to enable this mode. `-fsycl` and 
`-fno-sycl` become driver-only options that are rejected when passed to -cc1. 
This is because the frontend and beyond should be looking at whether the user 
is doing a device or host compilation specifically. Because the frontend should 
only ever be in one mode or the other, `-fsycl-is-device` and `-fsycl-is-host` 
are mutually exclusive options.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97717

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CodeGenSYCL/convergent.cpp
  clang/test/CodeGenSYCL/filescope_asm.c
  clang/test/Frontend/sycl-aux-triple.cpp
  clang/test/Preprocessor/sycl-macro.cpp
  clang/test/SemaSYCL/float128.cpp
  clang/test/SemaSYCL/int128.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp

Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- clang/test/SemaSYCL/prohibit-thread-local.cpp
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
 
 thread_local const int prohobit_ns_scope = 0;
 thread_local int prohobit_ns_scope2 = 0;
Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- clang/test/SemaSYCL/kernel-attribute.cpp
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
 
 // Only function templates
 [[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
Index: clang/test/SemaSYCL/int128.cpp
===
--- clang/test/SemaSYCL/int128.cpp
+++ clang/test/SemaSYCL/int128.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-unknown-linux-gnu \
-// RUN:-fsycl -fsycl-is-device -verify -fsyntax-only %s
+// RUN:-fsycl-is-device -verify -fsyntax-only %s
 
 typedef __uint128_t BIGTY;
 
Index: clang/test/SemaSYCL/float128.cpp
===
--- clang/test/SemaSYCL/float128.cpp
+++ clang/test/SemaSYCL/float128.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only %s
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl-is-device -fsyntax-only %s
 
 typedef __float128 BIGTY;
 
Index: clang/test/Preprocessor/sycl-macro.cpp
===
--- clang/test/Preprocessor/sycl-macro.cpp
+++ clang/test/Preprocessor/sycl-macro.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 %s -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
-// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
-// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -fsycl-is-device -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl-is-host -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s
 
 // CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
 // CHECK-NOT:#define CL_SYCL_LANGUAGE_VERSION 121
Index: clang/test/Frontend/sycl-aux-triple.cpp
===
--- clang/test/Frontend/sycl-aux-triple.cpp
+++ clang/test/Frontend/sycl-aux-triple.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s 

[PATCH] D96709: Add Windows ehcont section support (/guard:ehcont).

2021-03-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:499
   CmdArgs.push_back("-guard:cf-");
+} else if (GuardArgs.equals_lower("ehcont")) {
+  CmdArgs.push_back("/guard:ehcont");

This is gone now, btw


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96709

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


[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D97411#2595049 , @akhuang wrote:

> In D97411#2594345 , @ldionne wrote:
>
>> I don't have an opinion about the attribute itself. I do have an opinion 
>> about using that attribute in libc++ instead of fixing the underlying issue 
>> (I think we shouldn't do it). Can you confirm what the problematic types 
>> are? In another patch I saw `__hash_node`, `__hash_value_type`, 
>> `__tree_node` and `__value_type`. Is that it?
>
> Not entirely sure - those were pointed out as types with missing debug info, 
> but there might be more. I tried looking for types in libc++ that have a 
> `value_type` member, since those seem to follow a similar pattern. Possibly 
> `__forward_list_node`?

Since we'll need to identify this list of types either way (to attribute or to 
fix) might be worth making the list - I'd guess building all the libc++ tests 
with/without ctor homing and seeing which types go missing as a result might be 
informative?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D97158: [ASTMatchers] Make nullPointerConstant usable at top-level

2021-03-01 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D97158#2594973 , @njames93 wrote:

> Should we make `nullPtrConstant()` a top level mather? I feel like this 
> change would actually throw users off.

This would make this matcher a "convenience" matcher. 
https://reviews.llvm.org/D97713

Currently it's something in between.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97158

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


[PATCH] D97713: [ASTMatchers] Add documentation for convenience matchers

2021-03-01 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added reviewers: aaron.ballman, njames93.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97713

Files:
  clang/docs/LibASTMatchersReference.html


Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -542,6 +542,24 @@
 
 
 
+
+Convenience Matchers
+
+
+Several matchers are only for convenience, in that they allow matching of
+nodes which can be done in other, more verbose ways.
+
+
+  optionally(...)
+  Equivalent to anyOf(..., anything()).
+  mapAnyOf(...).with(...)
+  A builder type for convenience matchers.  Allows mapping matchers into 
specified node matchers without repetition. This makes mapAnyOf(ifStmt, 
forStmt).with(hasCondition(expr())) an equivalent to 
anyOf(ifStmt(hasCondition(expr())), 
forStmt(hasCondition(expr(.
+  binaryOperation(...)
+  Convenience for mapAnyOf(binaryOperator(...), 
cxxOperatorCallExpr(...), cxxRewrittenBinaryOperator(...)).
+  invocation(...)
+  Convenience for mapAnyOf(callExpr(...), 
cxxConstructorExpr(...)).  Primarily useful for matching arguments to 
either kind of node.
+
+
 
 Node Matchers
 


Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -542,6 +542,24 @@
 
 
 
+
+Convenience Matchers
+
+
+Several matchers are only for convenience, in that they allow matching of
+nodes which can be done in other, more verbose ways.
+
+
+  optionally(...)
+  Equivalent to anyOf(..., anything()).
+  mapAnyOf(...).with(...)
+  A builder type for convenience matchers.  Allows mapping matchers into specified node matchers without repetition. This makes mapAnyOf(ifStmt, forStmt).with(hasCondition(expr())) an equivalent to anyOf(ifStmt(hasCondition(expr())), forStmt(hasCondition(expr(.
+  binaryOperation(...)
+  Convenience for mapAnyOf(binaryOperator(...), cxxOperatorCallExpr(...), cxxRewrittenBinaryOperator(...)).
+  invocation(...)
+  Convenience for mapAnyOf(callExpr(...), cxxConstructorExpr(...)).  Primarily useful for matching arguments to either kind of node.
+
+
 
 Node Matchers
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 922de25 - [lld-macho] Partial revert of D95204

2021-03-01 Thread Jez Ng via cfe-commits

Author: Jez Ng
Date: 2021-03-01T11:29:42-08:00
New Revision: 922de2574c17a755279358be928e5343dcf56c56

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

LOG: [lld-macho] Partial revert of D95204

Trying to unbreak https://lab.llvm.org/buildbot/#/builders/57/builds/4753

I'm not able to repro the failures locally so... here's hoping

Added: 
clang/test/Driver/Inputs/lld/ld64.lld.darwinnew

Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/darwin-ld-demangle-lld.c
clang/test/Driver/darwin-ld-platform-version-ios.c
clang/test/Driver/darwin-ld-platform-version-macos.c
clang/test/Driver/darwin-ld-platform-version-tvos.c
clang/test/Driver/darwin-ld-platform-version-watchos.c

Removed: 
clang/test/Driver/Inputs/lld/ld64.lld.darwinold



diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index e6a6fe2cb062..f8b03b635dd7 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -620,11 +620,11 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
 if (llvm::sys::fs::can_execute(LinkerPath)) {
-  // FIXME: Remove LinkerIsLLDDarwinNew once there's only one MachO lld.
+  // FIXME: Remove lld.darwinnew here once it's the only MachO lld.
   if (LinkerIsLLD)
-*LinkerIsLLD = UseLinker == "lld" || UseLinker == "lld.darwinold";
+*LinkerIsLLD = UseLinker == "lld" || UseLinker == "lld.darwinnew";
   if (LinkerIsLLDDarwinNew)
-*LinkerIsLLDDarwinNew = UseLinker == "lld";
+*LinkerIsLLDDarwinNew = UseLinker == "lld.darwinnew";
   return LinkerPath;
 }
   }

diff  --git a/clang/test/Driver/Inputs/lld/ld64.lld.darwinold 
b/clang/test/Driver/Inputs/lld/ld64.lld.darwinnew
similarity index 100%
rename from clang/test/Driver/Inputs/lld/ld64.lld.darwinold
rename to clang/test/Driver/Inputs/lld/ld64.lld.darwinnew

diff  --git a/clang/test/Driver/darwin-ld-demangle-lld.c 
b/clang/test/Driver/darwin-ld-demangle-lld.c
index 9610f6bc1016..84facc8d1539 100644
--- a/clang/test/Driver/darwin-ld-demangle-lld.c
+++ b/clang/test/Driver/darwin-ld-demangle-lld.c
@@ -1,13 +1,12 @@
 // With -fuse-ld=lld, -demangle is always passed to the linker on Darwin.
 // REQUIRES: shell
 
-// FIXME: Remove this test case when we remove the lld.darwinold backend.
 // RUN: %clang --target=x86_64-apple-darwin -### \
-// RUN:   -fuse-ld=lld.darwinold -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
+// RUN:   -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
 // RUN:   | FileCheck %s
-
+// FIXME: Remove ld.darwinnew once it's the default (and only) mach-o lld.
 // RUN: %clang --target=x86_64-apple-darwin -### \
-// RUN:   -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
+// RUN:   -fuse-ld=lld.darwinnew -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: "-demangle"

diff  --git a/clang/test/Driver/darwin-ld-platform-version-ios.c 
b/clang/test/Driver/darwin-ld-platform-version-ios.c
index bd518c315149..d03e46b5776d 100644
--- a/clang/test/Driver/darwin-ld-platform-version-ios.c
+++ b/clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -1,6 +1,6 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld.darwinold \
+// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
@@ -12,7 +12,7 @@
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
-// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld \
+// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld.darwinnew \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW  %s
@@ -20,7 +20,7 @@
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
-// RUN: %clang -target x86_64-apple-ios13-simulator -fuse-ld=lld \
+// RUN: %clang -target x86_64-apple-ios13-simulator -fuse-ld=lld.darwinnew \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s

diff  --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index 5a2510acb646..1954deea7b93 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,10 +1,10 @@
 // RUN: touch %t.o
 
-// RUN: 

[PATCH] D97052: [OpenCL] Prevent adding extension pragma by default

2021-03-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97052#2587043 , @azabaznov wrote:

> I see the update regaring this functionality on github issue: 
> https://github.com/KhronosGroup/OpenCL-Docs/issues/82#issuecomment-785496025. 
> Is it a right way to reflect this information in`OpenCLExtensions.def`?

The update only suggests a possible route and I don't want to block on it until 
there is a final decision. But if that becomes final, it is unlikely we will do 
something different. All the legacy pragmas will need to be accepted anyway.




Comment at: clang/include/clang/Basic/OpenCLExtensions.def:71
+OPENCL_EXTENSION(cl_khr_int64_extended_atomics, true, 100)
+OPENCL_COREFEATURE(cl_khr_3d_image_writes, true, 100, OCL_C_20)
 

azabaznov wrote:
> Anastasia wrote:
> > azabaznov wrote:
> > > Anastasia wrote:
> > > > azabaznov wrote:
> > > > > I think core and optional core features do not require pragma too. So 
> > > > > for example 3d image writes or fp64 do not require pragma in OpenCL C 
> > > > > 2.0. Isn't that so?
> > > > Well to be honest nothing seems to need pragma but we have to accept it 
> > > > for the backward compatibility. :)
> > > > 
> > > > In case of the core features if pragma would have been useful we would 
> > > > have to still accept it for the backward compatibility even if the 
> > > > feature became core.
> > > I'm just wondering if this new field needed in the file to maintain 
> > > backward compatibility. Maybe we can highlight OpenCL C 3.0 features with 
> > > some other way? Is it seems that check for name starting with 
> > > "__opencl_c" is a bad idea?
> > Not sure I understand you here but I don't think that we should add 
> > extension pragmas any longer at all even for the new extensions. FYI I am 
> > planning to add guidelines for that in https://reviews.llvm.org/D97072. 
> > Maybe it helps to clarify the idea?
> I mean that you could modify `OpenCLOptions::isWithPragma` that it will check 
> if extension/feature was introduced in OpenCL C 3.0. If that's the case then 
> no pragma needed. This new field `pragma` looks redundant as it is set to 
> true only for OpenCL C 3.0 features. However, it may be more cosmetic 
> concern...
You are right that it is only set to `true` for the OpenCL 3.0 features right 
now but the idea is to provide flexibility to set the pragma for every new 
extension/feature being added in the future instead of always adding the pragma 
unconditionally. This is why (I presume) we ended up with pragma for every 
extension in the first place. No matter that half of them were not used at all. 

Also, there is nothing fundamentally different between extensions and features. 
The difference is purely wording in the spec. So I prefer us to use the same 
mechanisms for both.



Comment at: clang/lib/Parse/ParsePragma.cpp:785
+  // Therefore, it should never be added by default.
+  Opt.acceptsPragma(Name);
 }

azabaznov wrote:
> Anastasia wrote:
> > azabaznov wrote:
> > > Anastasia wrote:
> > > > svenvh wrote:
> > > > > I fail to understand why this is needed, so perhaps this needs a bit 
> > > > > more explanation.  Extensions that should continue to support pragmas 
> > > > > already have their `WithPragma` field set to `true` via 
> > > > > `OpenCLExtensions.def`.  Why do we need to dynamically modify the 
> > > > > field?
> > > > It is a bit twisty here to be honest. Because we have also introduced 
> > > > the pragma `begin` and `end` that would add pragma `enable`/`disable` 
> > > > by default. So any extension added dynamically using `begin`/`end` 
> > > > would have to accept the pragma `enable`/`disable`. 
> > > > 
> > > > https://clang.llvm.org/docs/UsersManual.html#opencl-extensions
> > > > 
> > > > But in the subsequent patches, I hope to remove this because I just 
> > > > don't see where it is useful but it is very confusing.
> > > Is it ok not to track this situation here:
> > > 
> > > ```
> > > #pragma OPENCL EXTENSION __opencl_c_feature : begin
> > > #pragma OPENCL EXTENSION __opencl_c_feature: end
> > > ```
> > > 
> > > This is some of a corner case, but still...
> > I see. I am not sure what should happen here - I guess we should give an 
> > error? Although for earlier versions than OpenCL 3.0 this should probably 
> > be accepted?
> > 
> > Perhaps we can create a PR for this for now...
> Oh, I think we can ignore this as double underscored identifiers are 
> reserved. It's not expected that users will declare new features.
Yes, I think this is mainly used by tool developers.


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

https://reviews.llvm.org/D97052

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


[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-01 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

In D97411#2594345 , @ldionne wrote:

> I don't have an opinion about the attribute itself. I do have an opinion 
> about using that attribute in libc++ instead of fixing the underlying issue 
> (I think we shouldn't do it). Can you confirm what the problematic types are? 
> In another patch I saw `__hash_node`, `__hash_value_type`, `__tree_node` and 
> `__value_type`. Is that it?

Not entirely sure - those were pointed out as types with missing debug info, 
but there might be more. I tried looking for types in libc++ that have a 
`value_type` member, since those seem to follow a similar pattern. Possibly 
`__forward_list_node`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D97052: [OpenCL] Prevent adding extension pragma by default

2021-03-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 327204.
Anastasia added a comment.

- Reorder fields,
- make constructor parameters explicit
- use `insert_or_assign` member of `StringMap`.


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

https://reviews.llvm.org/D97052

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -3,15 +3,13 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && !defined(TEST_CORE_FEATURES)
-// expected-no-diagnostics
-#endif
+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
 // Extensions in all versions
 #ifndef cl_clang_storage_class_specifiers
@@ -100,7 +98,7 @@
 #error "Missing cl_khr_3d_image_writes define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && defined TEST_CORE_FEATURES
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) && defined TEST_CORE_FEATURES
 // expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core feature or supported optional core feature - ignoring}}
 #endif
 
@@ -215,3 +213,55 @@
 // expected-warning@+2{{unsupported OpenCL extension 'cl_intel_device_side_avc_motion_estimation' - ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable
+
+// Check that pragmas for the OpenCL 3.0 features are rejected.
+
+#pragma OPENCL EXTENSION __opencl_c_int64 : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_3d_image_writes : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_3d_image_writes' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_atomic_order_acq_rel : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_acq_rel' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_atomic_order_seq_cst : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_seq_cst' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_device_enqueue : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_device_enqueue' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_fp64 : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_fp64' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_generic_address_space : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_generic_address_space' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_images : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_images' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_pipes : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_pipes' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_program_scope_global_variables : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_program_scope_global_variables' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_read_write_images : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_read_write_images' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_subgroups : disable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_subgroups' - ignoring}}
+
+#pragma OPENCL EXTENSION __opencl_c_int64 : enable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}}
+#pragma OPENCL EXTENSION __opencl_c_3d_image_writes : enable
+//expected-warning@-1{{unknown OpenCL extension '__opencl_c_3d_image_writes' - ignoring}}

[PATCH] D97072: [OpenCL][Docs] Add guidelines for adding new extensions and features

2021-03-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 13 inline comments as done.
Anastasia added inline comments.



Comment at: clang/docs/OpenCLSupport.rst:221
+triggers in the parsing) should not be added to clang. Moreover, the acceptable
+behavior of pragmas should provide useful functionality to the user.
+

svenvh wrote:
> Anastasia wrote:
> > svenvh wrote:
> > > Remove "acceptable behavior of".
> > > 
> > > How do you define "useful functionality"?
> > I think this is one of those situations that is hard to define 
> > unambiguously, so I am open to suggestions. However, I do want to prevent 
> > changes that are reinventing the wheel (i.e. C/C++ already had another way 
> > to do the same thing) or functionality that doesn't add any value (i.e. 
> > requiring pragma enable to use already added types or functions). This has 
> > happened in the past multiple times so I think it is good to be specific 
> > that when new functionality is added it should have a reason for it.
> > 
> > I think the other statement above:
> > 
> > > New functionality is accepted as soon as the documentation is detailed to 
> > > the level sufficient to be implemented.
> > 
> > is similar. It is not very easy to tell what is the detailed level of 
> > documentation. FYI it generally aligns with clang overall policy:
> > 
> > https://clang.llvm.org/get_involved.html
> > 
> > > A specification: The specification must be sufficient to understand the 
> > > design of the feature as well as interpret the meaning of specific 
> > > examples. The specification should be detailed enough that another 
> > > compiler vendor could implement the feature.
> > 
> > I am just emphasizing this item here.
> > 
> > Regarding 'usefulness' I would even suggest adding it as a general 
> > guideline for clang but I think this is not very common. So for now I want 
> > to make sure we have it in our guidelines at least since we have 
> > encountered this.
> I see, though I'm a bit hesitant to accept the word "useful" without any 
> further explanation. Would adding the following make sense?
> 
> ... should provide useful functionality //that cannot be achieved by other 
> means// to the user.
I think this wording doesn't cover the case with pragmas though... where the 
behavior was not possible to achieve without them but it was not clear why it 
was needed to achieve what was achieved with the pragmas.

I find //**useful**// pretty clear here even though it is not precisely 
defined. I would not be able to define it precisely at this point because I 
don't even know all the possible ways the pragmas can be misused. I think we 
might have to accept the fact that human language is not as precise as a 
programming language. As a matter of fact, we are not publishing an algorithm 
but only the guidelines. Although of course, we don't want to misguide, this 
might not always be avoidable. For the same reasons Clang contribution policy 
has never defined what is a sufficiently precise documentation format for the 
new features. This will be left for the community to assess on a case by case 
basis.


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

https://reviews.llvm.org/D97072

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


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-03-01 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: clang/include/clang/Driver/Options.td:4280-4281
   HelpText<"Dump provenance">;
+def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, 
+  HelpText<"Enables showing debug messages while writing module files.">;
 

[nit] The convention here seems to be: no `.` at the end
[nit] Perhaps a bit shorter: `Enable debug messages while writhing module 
files`?



Comment at: flang/include/flang/Frontend/CompilerInvocation.h:73-74
+  bool debugModuleDir_ = false;
+
+
 public:

[nit] One empty line instead of 2



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:297
 clang::DiagnosticsEngine ) {
-
+  
+  // -J/module-dir option

Unrelated change


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

https://reviews.llvm.org/D96875

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


[PATCH] D97072: [OpenCL][Docs] Add guidelines for adding new extensions and features

2021-03-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 327199.
Anastasia added a comment.

- Added suggestions from Sven and Marco.


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

https://reviews.llvm.org/D97072

Files:
  clang/docs/OpenCLSupport.rst


Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -111,6 +111,8 @@
 Note that this is a frontend-only flag and therefore it requires the use of
 flags that forward options to the frontend e.g. ``-cc1`` or ``-Xclang``.
 
+.. _opencl_builtins:
+
 OpenCL builtins
 ---
 
@@ -153,6 +155,80 @@
   inserted using ``InsertOCLBuiltinDeclarationsFromTable`` and overload
   resolution takes place.
 
+OpenCL Extensions and Features
+--
+
+Clang implements various extensions to OpenCL kernel languages.
+
+New functionality is accepted as soon as the documentation is detailed to the
+level sufficient to be implemented. There should be an evidence that the
+extension is designed with implementation feasibility in consideration and
+assessment of complexity for C/C++ based compilers. Alternatively, the
+documentation can be accepted in a format of a draft that can be further
+refined during the implementation.
+
+Implementation guidelines
+^
+
+This section explains how to extend clang with the new functionality.
+
+**Parsing functionality**
+
+If an extension modifies the standard parsing it needs to be added to
+the clang frontend source code. This also means that the associated macro
+indicating the presence of the extension should be added to clang.
+
+The default flow for adding a new extension into the frontend is to
+modify `OpenCLExtensions.def
+`_
+
+This will add the macro automatically and also add a field in the target
+options ``clang::TargetOptions::OpenCLFeaturesMap`` to control the exposure
+of the new extension during the compilation.
+
+Note that by default targets like `SPIR` or `X86` expose all the OpenCL
+extensions. For all other targets the configuration has to be made explicitly.
+
+Note that the target extension support performed by clang can be overridden
+with :ref:`-cl-ext ` command-line flags.
+
+**Library functionality**
+
+If an extension adds functionality that does not modify standard language
+parsing it should not require modifying anything other than header files or
+``OpenCLBuiltins.td`` detailed in :ref:``.
+Most commonly such extensions add functionality via libraries (by adding
+non-native types or functions) parsed regularly. Similar to other languages 
this
+is the most common way to add new functionality.
+
+Clang has standard headers where new types and functions are being added,
+for more details refer to
+:ref:`the section on the OpenCL Header `. The macros indicating
+the presence of such extensions can be added in the standard header files
+conditioned on target specific predefined macros or/and language version
+predefined macros.
+
+**Pragmas**
+
+Some extensions alter standard parsing dynamically via pragmas.
+
+Clang provides a mechanism to add the standard extension pragma
+``OPENCL EXTENSION`` by setting a dedicated flag in the extension list entry of
+``OpenCLExtensions.def``. Note that there is no default behavior for the
+standard extension pragmas as it is not specified (for the standards up to and
+including version 3.0) in a sufficient level of detail and, therefore,
+there is no default functionality provided by clang.
+
+Pragmas without detailed information of their behavior (e.g. an explanation of
+changes it triggers in the parsing) should not be added to clang. Moreover, the
+pragmas should provide useful functionality to the user.
+
+Note that some legacy extensions (published prior to OpenCL 3.0) still
+provide some non-conformant functionality for pragmas e.g. add diagnostics on
+the use of types or functions. This functionality is not guaranteed to remain 
in
+future releases. However, any future changes should not affect backward
+compatibility.
+
 .. _opencl_addrsp:
 
 Address spaces attribute


Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -111,6 +111,8 @@
 Note that this is a frontend-only flag and therefore it requires the use of
 flags that forward options to the frontend e.g. ``-cc1`` or ``-Xclang``.
 
+.. _opencl_builtins:
+
 OpenCL builtins
 ---
 
@@ -153,6 +155,80 @@
   inserted using ``InsertOCLBuiltinDeclarationsFromTable`` and overload
   resolution takes place.
 
+OpenCL Extensions and Features
+--
+
+Clang implements various extensions to OpenCL kernel languages.
+
+New functionality is accepted as soon as the documentation is detailed to the

[PATCH] D97708: [CUDA] Remove `noreturn` attribute from __assertfail().

2021-03-01 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 327197.
tra edited the summary of this revision.
tra added a comment.

Added a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97708

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -349,9 +349,14 @@
 __device__ int vprintf(const char *, const char *);
 __device__ void free(void *) __attribute((nothrow));
 __device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc));
+
+// __assertfail() used to have a `noreturn` attribute. Unfortunately that
+// contributed to triggering the longstanding bug in ptxas when assert was used
+// in sufficiently convoluted code. See
+// https://bugs.llvm.org/show_bug.cgi?id=27738 for the details.
 __device__ void __assertfail(const char *__message, const char *__file,
  unsigned __line, const char *__function,
- size_t __charSize) __attribute__((noreturn));
+ size_t __charSize);
 
 // In order for standard assert() macro on linux to work we need to
 // provide device-side __assert_fail()


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -349,9 +349,14 @@
 __device__ int vprintf(const char *, const char *);
 __device__ void free(void *) __attribute((nothrow));
 __device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc));
+
+// __assertfail() used to have a `noreturn` attribute. Unfortunately that
+// contributed to triggering the longstanding bug in ptxas when assert was used
+// in sufficiently convoluted code. See
+// https://bugs.llvm.org/show_bug.cgi?id=27738 for the details.
 __device__ void __assertfail(const char *__message, const char *__file,
  unsigned __line, const char *__function,
- size_t __charSize) __attribute__((noreturn));
+ size_t __charSize);
 
 // In order for standard assert() macro on linux to work we need to
 // provide device-side __assert_fail()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97158: [ASTMatchers] Make nullPointerConstant usable at top-level

2021-03-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Should we make `nullPtrConstant()` a top level mather? I feel like this change 
would actually throw users off.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97158

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


[PATCH] D97708: [CUDA] Remove `noreturn` attribute from __assertfail().

2021-03-01 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Maybe add a comment on assertfail that we don't want it to be noreturn because 
blah blah?  So someone doesn't come back and add it when we're not looking.  :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97708

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


[PATCH] D97708: [CUDA] Remove `noreturn` attribute from __assertfail().

2021-03-01 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added subscribers: bixia, yaxunl.
tra requested review of this revision.
Herald added a project: clang.

`noreturn` complicates control flow and tends to trigger a known bug in ptxas if
the assert is used within loops in sufficiently complicated code.
https://bugs.llvm.org/show_bug.cgi?id=27738


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97708

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -351,7 +351,7 @@
 __device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc));
 __device__ void __assertfail(const char *__message, const char *__file,
  unsigned __line, const char *__function,
- size_t __charSize) __attribute__((noreturn));
+ size_t __charSize);
 
 // In order for standard assert() macro on linux to work we need to
 // provide device-side __assert_fail()


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -351,7 +351,7 @@
 __device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc));
 __device__ void __assertfail(const char *__message, const char *__file,
  unsigned __line, const char *__function,
- size_t __charSize) __attribute__((noreturn));
+ size_t __charSize);
 
 // In order for standard assert() macro on linux to work we need to
 // provide device-side __assert_fail()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97706: Make -f[no-]split-dwarf-inlining CC1 default align with driver default (no inlining)

2021-03-01 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd942a82a076d: Make -f[no-]split-dwarf-inlining CC1 default 
align with driver default (no… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97706

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/split-debug-inlining.c
  clang/test/Driver/split-debug.c


Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -7,8 +7,8 @@
 /// -gsplit-dwarf=split is equivalent to -gsplit-dwarf.
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g %s 2>&1 | 
FileCheck %s --check-prefixes=NOINLINE,SPLIT
 
-// INLINE-NOT: "-fno-split-dwarf-inlining"
-// NOINLINE:   "-fno-split-dwarf-inlining"
+// INLINE: "-fsplit-dwarf-inlining"
+// NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT:  "-debug-info-kind=limited"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"
Index: clang/test/CodeGen/split-debug-inlining.c
===
--- clang/test/CodeGen/split-debug-inlining.c
+++ clang/test/CodeGen/split-debug-inlining.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -debug-info-kind=limited -fno-split-dwarf-inlining -S 
-emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck 
--check-prefix=ABSENT %s
+// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -debug-info-kind=limited -fsplit-dwarf-inlining -S 
-emit-llvm -o - %s | FileCheck --check-prefix=ABSENT %s
 void f(void) {}
 // Verify that disabling split debug inlining info is propagated to the debug
 // info metadata.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3979,8 +3979,8 @@
   }
 }
 
-  if (T.isOSBinFormatELF() && !SplitDWARFInlining)
-CmdArgs.push_back("-fno-split-dwarf-inlining");
+  if (T.isOSBinFormatELF() && SplitDWARFInlining)
+CmdArgs.push_back("-fsplit-dwarf-inlining");
 
   // After we've dealt with all combinations of things that could
   // make DebugInfoKind be other than None or DebugLineTablesOnly,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2669,9 +2669,9 @@
   PosFlag,
   NegFlag>;
 defm split_dwarf_inlining : BoolFOption<"split-dwarf-inlining",
-  CodeGenOpts<"SplitDwarfInlining">, DefaultTrue,
-  NegFlag,
-  PosFlag, DefaultFalse,
+  NegFlag,
+  PosFlag>;
 def fdebug_default_version: Joined<["-"], "fdebug-default-version=">, 
Group,


Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -7,8 +7,8 @@
 /// -gsplit-dwarf=split is equivalent to -gsplit-dwarf.
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
 
-// INLINE-NOT: "-fno-split-dwarf-inlining"
-// NOINLINE:   "-fno-split-dwarf-inlining"
+// INLINE: "-fsplit-dwarf-inlining"
+// NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT:  "-debug-info-kind=limited"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
Index: clang/test/CodeGen/split-debug-inlining.c
===
--- clang/test/CodeGen/split-debug-inlining.c
+++ clang/test/CodeGen/split-debug-inlining.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -debug-info-kind=limited -fno-split-dwarf-inlining -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck --check-prefix=ABSENT %s
+// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=limited -fsplit-dwarf-inlining -S -emit-llvm -o - %s | FileCheck --check-prefix=ABSENT %s
 void f(void) {}
 // Verify that disabling split debug inlining info is propagated to the debug
 // info metadata.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3979,8 +3979,8 @@
   }
 }
 
-  if (T.isOSBinFormatELF() && !SplitDWARFInlining)
-CmdArgs.push_back("-fno-split-dwarf-inlining");
+  if (T.isOSBinFormatELF() && 

[clang] d942a82 - Make -f[no-]split-dwarf-inlining CC1 default align with driver default (no inlining)

2021-03-01 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-01T10:55:19-08:00
New Revision: d942a82a076d35130376fa786adfc933c7db1c89

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

LOG: Make -f[no-]split-dwarf-inlining CC1 default align with driver default (no 
inlining)

This makes CC1 and driver defaults consistent.
In addition, for more common cases (-g is specified without -gsplit-dwarf), 
users will not see -fno-split-dwarf-inlining in CC1 options.

Verified that the below is still true:

* `clang -g` => `splitDebugInlining: false` in DICompileUnit
* `clang -g -gsplit-dwarf` => `splitDebugInlining: false` in DICompileUnit
* `clang -g -gsplit-dwarf -fsplit-dwarf-inlining` => no `splitDebugInlining: 
false`

Reviewed By: dblaikie

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/split-debug-inlining.c
clang/test/Driver/split-debug.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 75c4eff29f1c..20dcac5d08ad 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2669,9 +2669,9 @@ defm debug_ranges_base_address : 
BoolFOption<"debug-ranges-base-address",
   PosFlag,
   NegFlag>;
 defm split_dwarf_inlining : BoolFOption<"split-dwarf-inlining",
-  CodeGenOpts<"SplitDwarfInlining">, DefaultTrue,
-  NegFlag,
-  PosFlag, DefaultFalse,
+  NegFlag,
+  PosFlag>;
 def fdebug_default_version: Joined<["-"], "fdebug-default-version=">, 
Group,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 95e7c642478b..df2b20702efc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3979,8 +3979,8 @@ static void renderDebugOptions(const ToolChain , const 
Driver ,
   }
 }
 
-  if (T.isOSBinFormatELF() && !SplitDWARFInlining)
-CmdArgs.push_back("-fno-split-dwarf-inlining");
+  if (T.isOSBinFormatELF() && SplitDWARFInlining)
+CmdArgs.push_back("-fsplit-dwarf-inlining");
 
   // After we've dealt with all combinations of things that could
   // make DebugInfoKind be other than None or DebugLineTablesOnly,

diff  --git a/clang/test/CodeGen/split-debug-inlining.c 
b/clang/test/CodeGen/split-debug-inlining.c
index 4a306d43e952..4730891e8450 100644
--- a/clang/test/CodeGen/split-debug-inlining.c
+++ b/clang/test/CodeGen/split-debug-inlining.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -debug-info-kind=limited -fno-split-dwarf-inlining -S 
-emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck 
--check-prefix=ABSENT %s
+// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -debug-info-kind=limited -fsplit-dwarf-inlining -S 
-emit-llvm -o - %s | FileCheck --check-prefix=ABSENT %s
 void f(void) {}
 // Verify that disabling split debug inlining info is propagated to the debug
 // info metadata.

diff  --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index d4511574da4d..00173836bc23 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -7,8 +7,8 @@
 /// -gsplit-dwarf=split is equivalent to -gsplit-dwarf.
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g %s 2>&1 | 
FileCheck %s --check-prefixes=NOINLINE,SPLIT
 
-// INLINE-NOT: "-fno-split-dwarf-inlining"
-// NOINLINE:   "-fno-split-dwarf-inlining"
+// INLINE: "-fsplit-dwarf-inlining"
+// NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT:  "-debug-info-kind=limited"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"



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


[clang-tools-extra] 8f9f7d0 - [clang-tidy] Tweak misc-static-assert fix in c++17

2021-03-01 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-01T18:51:50Z
New Revision: 8f9f7d02aaac98f8539158e05975e7acbbb58fcc

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

LOG: [clang-tidy] Tweak misc-static-assert fix in c++17

If C++17 mode is enabled and the assert doesn't have a string literal, we can 
emit a static assert with no message in favour of one with an empty message.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
index 2d6504cae689..e9ea69aaeb32 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
@@ -107,17 +107,16 @@ void StaticAssertCheck::check(const 
MatchFinder::MatchResult ) {
 FixItHints.push_back(
 FixItHint::CreateReplacement(SourceRange(AssertLoc), "static_assert"));
 
-std::string StaticAssertMSG = ", \"\"";
 if (AssertExprRoot) {
   FixItHints.push_back(FixItHint::CreateRemoval(
   SourceRange(AssertExprRoot->getOperatorLoc(;
   FixItHints.push_back(FixItHint::CreateRemoval(
   SourceRange(AssertMSG->getBeginLoc(), AssertMSG->getEndLoc(;
-  StaticAssertMSG = (Twine(", \"") + AssertMSG->getString() + "\"").str();
+  FixItHints.push_back(FixItHint::CreateInsertion(
+  LastParenLoc, (Twine(", \"") + AssertMSG->getString() + 
"\"").str()));
+} else if (!Opts.CPlusPlus17) {
+  FixItHints.push_back(FixItHint::CreateInsertion(LastParenLoc, ", \"\""));
 }
-
-FixItHints.push_back(
-FixItHint::CreateInsertion(LastParenLoc, StaticAssertMSG));
   }
 
   diag(AssertLoc, "found assert() that could be replaced by static_assert()")

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.cpp
index 85ae053cffef..d4d083640d16 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s misc-static-assert %t
+// RUN: %check_clang_tidy -std=c++11 -check-suffixes=,CXX11 %s 
misc-static-assert %t
+// RUN: %check_clang_tidy -std=c++17 -check-suffixes=,CXX17 %s 
misc-static-assert %t
 
 void abort() {}
 #ifdef NDEBUG
@@ -37,7 +38,8 @@ class B {
 template  void doSomething(T t) {
   assert(myfunc(1, 2));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be 
replaced by static_assert() [misc-static-assert]
-  // CHECK-FIXES: {{^  }}static_assert(myfunc(1, 2), "");
+  // CHECK-FIXES-CXX11: {{^  }}static_assert(myfunc(1, 2), "");
+  // CHECK-FIXES-CXX17: {{^  }}static_assert(myfunc(1, 2));
 
   assert(t.method());
   // CHECK-FIXES: {{^  }}assert(t.method());
@@ -52,7 +54,8 @@ int main() {
 
   assert(myfunc(1, 2) && (3 == 4));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
-  // CHECK-FIXES: {{^  }}static_assert(myfunc(1, 2) && (3 == 4), "");
+  // CHECK-FIXES-CXX11: {{^  }}static_assert(myfunc(1, 2) && (3 == 4), "");
+  // CHECK-FIXES-CXX17: {{^  }}static_assert(myfunc(1, 2) && (3 == 4));
 
   int x = 1;
   assert(x == 0);
@@ -74,7 +77,8 @@ int main() {
 
   assert(ZERO_MACRO);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
-  // CHECK-FIXES: {{^  }}static_assert(ZERO_MACRO, "");
+  // CHECK-FIXES-CXX11: {{^  }}static_assert(ZERO_MACRO, "");
+  // CHECK-FIXES-CXX17: {{^  }}static_assert(ZERO_MACRO);
 
   assert(!"Don't report me!");
   // CHECK-FIXES: {{^  }}assert(!"Don't report me!");
@@ -136,7 +140,8 @@ int main() {
 
   assert(10 == 5 + 5);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
-  // CHECK-FIXES: {{^  }}static_assert(10 == 5 + 5, "");
+  // CHECK-FIXES-CXX11: {{^  }}static_assert(10 == 5 + 5, "");
+  // CHECK-FIXES-CXX17: {{^  }}static_assert(10 == 5 + 5);
 #undef assert
 
   return 0;



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


  1   2   3   >