[PATCH] D130964: Enable __bf16 for x86 targets.

2022-08-01 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added subscribers: luke957, pengfei, s.egerton, simoncook.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead.
Herald added projects: clang, LLVM.

X86 psABI has updated to support __bf16 type, the ABI of which is the
same as FP16. See 
https://discourse.llvm.org/t/patch-add-optional-bfloat16-support/63149


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130964

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/X86/bfloat-abi.c
  clang/test/CodeGen/X86/bfloat-half-abi.c
  clang/test/CodeGen/X86/bfloat-mangle.cpp
  clang/test/Sema/vector-decl-crash.c
  llvm/include/llvm/IR/Type.h

Index: llvm/include/llvm/IR/Type.h
===
--- llvm/include/llvm/IR/Type.h
+++ llvm/include/llvm/IR/Type.h
@@ -144,6 +144,11 @@
   /// Return true if this is 'bfloat', a 16-bit bfloat type.
   bool isBFloatTy() const { return getTypeID() == BFloatTyID; }
 
+  /// Return true if this is a 16-bit float type.
+  bool is16bitFPTy() const {
+return getTypeID() == BFloatTyID || getTypeID() == HalfTyID;
+  }
+
   /// Return true if this is 'float', a 32-bit IEEE fp type.
   bool isFloatTy() const { return getTypeID() == FloatTyID; }
 
Index: clang/test/Sema/vector-decl-crash.c
===
--- clang/test/Sema/vector-decl-crash.c
+++ clang/test/Sema/vector-decl-crash.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -triple x86_64-unknown-unknown
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple riscv64-unknown-unknown
 
 // GH50171
 // This would previously crash when __bf16 was not a supported type.
Index: clang/test/CodeGen/X86/bfloat-mangle.cpp
===
--- /dev/null
+++ clang/test/CodeGen/X86/bfloat-mangle.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define {{.*}}void @_Z3foou6__bf16(bfloat noundef %b)
+void foo(__bf16 b) {}
Index: clang/test/CodeGen/X86/bfloat-half-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/bfloat-half-abi.c
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-feature +sse2 < %s | FileCheck %s --check-prefixes=CHECK
+
+struct bfloat1 {
+  __bf16 a;
+};
+
+struct bfloat1 h1(__bf16 a) {
+  // CHECK: define{{.*}}bfloat @
+  struct bfloat1 x;
+  x.a = a;
+  return x;
+}
+
+struct bfloat2 {
+  __bf16 a;
+  __bf16 b;
+};
+
+struct bfloat2 h2(__bf16 a, __bf16 b) {
+  // CHECK: define{{.*}}<2 x bfloat> @
+  struct bfloat2 x;
+  x.a = a;
+  x.b = b;
+  return x;
+}
+
+struct bfloat3 {
+  __bf16 a;
+  __bf16 b;
+  __bf16 c;
+};
+
+struct bfloat3 h3(__bf16 a, __bf16 b, __bf16 c) {
+  // CHECK: define{{.*}}<4 x bfloat> @
+  struct bfloat3 x;
+  x.a = a;
+  x.b = b;
+  x.c = c;
+  return x;
+}
+
+struct bfloat4 {
+  __bf16 a;
+  __bf16 b;
+  __bf16 c;
+  __bf16 d;
+};
+
+struct bfloat4 h4(__bf16 a, __bf16 b, __bf16 c, __bf16 d) {
+  // CHECK: define{{.*}}<4 x bfloat> @
+  struct bfloat4 x;
+  x.a = a;
+  x.b = b;
+  x.c = c;
+  x.d = d;
+  return x;
+}
+
+struct floatbfloat {
+  float a;
+  __bf16 b;
+};
+
+struct floatbfloat fh(float a, __bf16 b) {
+  // CHECK: define{{.*}}<4 x half> @
+  struct floatbfloat x;
+  x.a = a;
+  x.b = b;
+  return x;
+}
+
+struct floatbfloat2 {
+  float a;
+  __bf16 b;
+  __bf16 c;
+};
+
+struct floatbfloat2 fh2(float a, __bf16 b, __bf16 c) {
+  // CHECK: define{{.*}}<4 x half> @
+  struct floatbfloat2 x;
+  x.a = a;
+  x.b = b;
+  x.c = c;
+  return x;
+}
+
+struct bfloatfloat {
+  __bf16 a;
+  float b;
+};
+
+struct bfloatfloat hf(__bf16 a, float b) {
+  // CHECK: define{{.*}}<4 x half> @
+  struct bfloatfloat x;
+  x.a = a;
+  x.b = b;
+  return x;
+}
+
+struct bfloat2float {
+  __bf16 a;
+  __bf16 b;
+  float c;
+};
+
+struct bfloat2float h2f(__bf16 a, __bf16 b, float c) {
+  // CHECK: define{{.*}}<4 x bfloat> @
+  struct bfloat2float x;
+  x.a = a;
+  x.b = b;
+  x.c = c;
+  return x;
+}
+
+struct floatbfloat3 {
+  float a;
+  __bf16 b;
+  __bf16 c;
+  __bf16 d;
+};
+
+struct floatbfloat3 fh3(float a, __bf16 b, __bf16 c, __bf16 d) {
+  // CHECK: define{{.*}}{ <4 x half>, bfloat } @
+  struct floatbfloat3 x;
+  x.a = a;
+  x.b = b;
+  x.c = c;
+  x.d = d;
+  return x;
+}
+
+struct bfloat5 {
+  __bf16 a;
+  __bf16 b;
+  __bf16 c;
+  __bf16 d;
+  __bf16 e;
+};
+
+struct bfloat5 h5(__bf16 a, __bf16 b, __bf16 c, __bf16 d, __bf16 e) {
+  // CHECK: define{{.*}}{ <4 x bfloat>, bfloat } @
+  struct bfloat5 x;
+  x.a = a;
+  x.b = b;
+  x.c = c;
+  x.d = d;
+  x.e 

[PATCH] D130791: [clang] Short-circuit trivial constexpr array constructors

2022-08-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 449182.

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

https://reviews.llvm.org/D130791

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10833,6 +10833,9 @@
 if (FinalSize == 0)
   return true;
 
+bool HasTrivialConstructor = CheckTrivialDefaultConstructor(
+Info, E->getExprLoc(), E->getConstructor(),
+E->requiresZeroInitialization());
 LValue ArrayElt = Subobject;
 ArrayElt.addArray(Info, E, CAT);
 // We do the whole initialization in two passes, first for just one 
element,
@@ -10856,19 +10859,26 @@
 for (unsigned I = OldElts; I < N; ++I)
   Value->getArrayInitializedElt(I) = Filler;
 
-  // Initialize the elements.
-  for (unsigned I = OldElts; I < N; ++I) {
-if (!VisitCXXConstructExpr(E, ArrayElt,
-   >getArrayInitializedElt(I),
-   CAT->getElementType()) ||
-!HandleLValueArrayAdjustment(Info, E, ArrayElt,
- CAT->getElementType(), 1))
-  return false;
-// When checking for const initilization any diagnostic is considered
-// an error.
-if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
-!Info.keepEvaluatingAfterFailure())
-  return false;
+  if (HasTrivialConstructor && N == FinalSize) {
+// If we have a trivial constructor, only evaluate it once and copy
+// the result into all the array elements.
+APValue  = Value->getArrayInitializedElt(0);
+for (unsigned I = OldElts; I < FinalSize; ++I)
+  Value->getArrayInitializedElt(I) = FirstResult;
+  } else {
+for (unsigned I = OldElts; I < N; ++I) {
+  if (!VisitCXXConstructExpr(E, ArrayElt,
+ >getArrayInitializedElt(I),
+ CAT->getElementType()) ||
+  !HandleLValueArrayAdjustment(Info, E, ArrayElt,
+   CAT->getElementType(), 1))
+return false;
+  // When checking for const initilization any diagnostic is considered
+  // an error.
+  if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
+  !Info.keepEvaluatingAfterFailure())
+return false;
+}
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -55,6 +55,9 @@
 - Fixes an accepts-invalid bug in C when using a ``_Noreturn`` function
   specifier on something other than a function declaration. This fixes
   `Issue 56800 `_.
+- Improve compile-times with large dynamic array allocations with trivial
+  constructors. This fixes
+  `Issue 56774`_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10833,6 +10833,9 @@
 if (FinalSize == 0)
   return true;
 
+bool HasTrivialConstructor = CheckTrivialDefaultConstructor(
+Info, E->getExprLoc(), E->getConstructor(),
+E->requiresZeroInitialization());
 LValue ArrayElt = Subobject;
 ArrayElt.addArray(Info, E, CAT);
 // We do the whole initialization in two passes, first for just one element,
@@ -10856,19 +10859,26 @@
 for (unsigned I = OldElts; I < N; ++I)
   Value->getArrayInitializedElt(I) = Filler;
 
-  // Initialize the elements.
-  for (unsigned I = OldElts; I < N; ++I) {
-if (!VisitCXXConstructExpr(E, ArrayElt,
-   >getArrayInitializedElt(I),
-   CAT->getElementType()) ||
-!HandleLValueArrayAdjustment(Info, E, ArrayElt,
- CAT->getElementType(), 1))
-  return false;
-// When checking for const initilization any diagnostic is considered
-// an error.
-if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
-!Info.keepEvaluatingAfterFailure())
-  return false;
+  if (HasTrivialConstructor && N == FinalSize) {
+// If we have a trivial constructor, only evaluate it once and copy
+// the result into all the array elements.
+APValue  = Value->getArrayInitializedElt(0);
+for (unsigned I = OldElts; I < FinalSize; ++I)
+  Value->getArrayInitializedElt(I) = FirstResult;
+  } else {
+

[PATCH] D130791: [clang] Short-circuit trivial constexpr array constructors

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

In D130791#3692071 , @dblaikie wrote:

> also: What about zero length arrays? (which are supported as an extension) - 
> this change would cause failures that wouldn't be emitted in the old code?

There's a `if (FinalSize == 0) return true;` case above, so this code will 
never be reached for zero-length arrays. That loop here is pretty confusing... 
`OldElts` is either zero (for the first iteration), or one (for the second 
iteration, where `N == FinalSize`). I tried to untangle this, but it doesn't 
work very well since the `APValue` we pass to `VisitCXXConstructExpr()` must be 
in an array `APValue`...

As for testing: I didn't include a test because of what you two mentioned, I 
can't really test that a test case finished in under X seconds...




Comment at: clang/lib/AST/ExprConstant.cpp:10836-10838
+bool HasTrivialConstructor = CheckTrivialDefaultConstructor(
+Info, E->getExprLoc(), E->getConstructor(),
+E->requiresZeroInitialization());

aaron.ballman wrote:
> The big question this raises for me is: will this cause constexpr to fail 
> because of the note diagnostics when the type does not have a trivial default 
> constructor? Or does this just bump the failure up a bit so that we fail 
> before we start walking over the array elements?
I can't come up with an example that would make this fail, or fail differently 
than it did before. For a constructor that is not marked `constexpr` and where 
`CheckTrivialDefaultConstructor` returns `false`, the first 
`VisitCXXConstructExpr` will return `false` and no diagnostic will be emitted. 
In the cases I tried, `Info.EvalStatus.Diag` is `nullptr` anyway, so yeah. If 
it did emit a diagnostic, I would assume that the failure just happens a little 
early, yes.

The alternative would be to try to integrate the 
`CheckTrivialDefaultConstructor` call into the loop, but I'm not a fan of that 
loop anyway :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130791

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


[PATCH] D130906: [clang] format string checking for conpile-time evaluated str literal

2022-08-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8504
 return SLCT_UncheckedLiteral;
+  Expr::EvalResult Result;
+  if (E->EvaluateAsRValue(Result, S.Context)) {

A comment above this line would be helpful. Would also visually separate it 
from the `return` above, which just confused me.



Comment at: clang/lib/Sema/SemaChecking.cpp:8507
+if (Result.Val.isLValue()) {
+  auto *LVE = Result.Val.getLValueBase().dyn_cast();
+  if (LVE && LVE->getStmtClass() == Stmt::StringLiteralClass) {

I think you should be able to unify the two `if` statements.

Can you not `dyn_cast_or_null(Result.Val.getLValueBase())` here 
instead of casting to `Expr*` and checking the `StmtClass`?



Comment at: clang/test/Sema/format-strings-scanf.c:235
   scanf(0 ? "%s" : "%d", i); // no warning
-  scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char 
*'}}
+  scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char 
*'}} \
+ // expected-note{{format string is defined here}}

inclyc wrote:
> These new notes are FixIt hints, looks much better than before.
Can you show some sample output?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130906

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


[clang] 6d10733 - [C++20] [Modules] Handle initializer for Header Units

2022-08-01 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-08-02T11:24:46+08:00
New Revision: 6d10733d445506c02ebec9faa54658431857bb49

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

LOG: [C++20] [Modules] Handle initializer for Header Units

Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

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

Added: 
clang/test/CodeGenCXX/module-initializer-header.cppm

Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 620af1e633b7..420141362f0e 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -650,8 +650,8 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 
   SmallVector ModuleInits;
   for (Module *M : AllImports) {
-// No Itanium initializer in module map modules.
-if (M->isModuleMapModule())
+// No Itanium initializer in header like modules.
+if (M->isHeaderLikeModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
@@ -779,8 +779,8 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
   SmallVector ModuleInits;
   if (CXX20ModuleInits)
 for (Module *M : ImportedModules) {
-  // No Itanium initializer in module map modules.
-  if (M->isModuleMapModule())
+  // No Itanium initializer in header like modules.
+  if (M->isHeaderLikeModule())
 continue;
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
   SmallString<256> FnName;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 579ebba7736d..dc1122f3ab67 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -521,7 +521,7 @@ static void setVisibilityFromDLLStorageClass(const 
clang::LangOptions ,
 
 void CodeGenModule::Release() {
   Module *Primary = getContext().getModuleForCodeGen();
-  if (CXX20ModuleInits && Primary && !Primary->isModuleMapModule())
+  if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
 EmitModuleInitializers(Primary);
   EmitDeferred();
   DeferredDecls.insert(EmittedDeferredDecls.begin(),
@@ -2521,21 +2521,23 @@ void 
CodeGenModule::EmitModuleInitializers(clang::Module *Primary) {
   // source, first Global Module Fragments, if present.
   if (auto GMF = Primary->getGlobalModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(GMF)) {
-  assert(D->getKind() == Decl::Var && "GMF initializer decl is not a 
var?");
+  if (isa(D))
+continue;
+  assert(isa(D) && "GMF initializer decl is not a var?");
   EmitTopLevelDecl(D);
 }
   }
   // Second any associated with the module, itself.
   for (Decl *D : getContext().getModuleInitializers(Primary)) {
 // Skip import decls, the inits for those are called explicitly.
-if (D->getKind() == Decl::Import)
+if (isa(D))
   continue;
 EmitTopLevelDecl(D);
   }
   // Third any associated with the Privat eMOdule Fragment, if present.
   if (auto PMF = Primary->getPrivateModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(PMF)) {
-  assert(D->getKind() == Decl::Var && "PMF initializer decl is not a 
var?");
+  assert(isa(D) && "PMF initializer decl is not a var?");
   EmitTopLevelDecl(D);
 }
   }

diff  --git a/clang/test/CodeGenCXX/module-initializer-header.cppm 
b/clang/test/CodeGenCXX/module-initializer-header.cppm
new file mode 100644
index ..253f096845b9
--- /dev/null
+++ b/clang/test/CodeGenCXX/module-initializer-header.cppm
@@ -0,0 +1,31 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -xc++-user-header 
-emit-header-unit %t/header.h -o %t/header.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple 
-fmodule-file=%t/header.pcm %t/M.cppm -S -emit-llvm -o - | FileCheck %t/M.cppm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple 
-fmodule-file=%t/header.pcm %t/Use.cpp -S -emit-llvm -o - | FileCheck %t/Use.cpp
+//
+//--- header.h
+int foo();
+int i = foo();
+
+//--- M.cppm
+module;
+import "header.h";
+export module M;
+
+// CHECK: @i = {{.*}}global i32 0
+// CHECK: void @__cxx_global_var_init()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:  %call = call noundef{{.*}} i32 @_Z3foov()
+// CHECK-NEXT:  store i32 %call, ptr @i  
+
+//--- Use.cpp
+import "header.h";
+

[clang] 39cfde2 - Revert "[C++20] [Modules] Handle initializer for Header Units"

2022-08-01 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-08-02T11:09:38+08:00
New Revision: 39cfde236693a928ff6594ddc321c4550237cfaa

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

LOG: Revert "[C++20] [Modules] Handle initializer for Header Units"

This reverts commit db6152ad66d7cf48f9f5c3eb28bf54c092978773.

This commit fails in ppc64. Since we want to backport it to 15.x. So
revert it now to keep the patch complete.

Added: 


Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
clang/test/CodeGenCXX/module-initializer-header.cppm



diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 420141362f0e..620af1e633b7 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -650,8 +650,8 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 
   SmallVector ModuleInits;
   for (Module *M : AllImports) {
-// No Itanium initializer in header like modules.
-if (M->isHeaderLikeModule())
+// No Itanium initializer in module map modules.
+if (M->isModuleMapModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
@@ -779,8 +779,8 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
   SmallVector ModuleInits;
   if (CXX20ModuleInits)
 for (Module *M : ImportedModules) {
-  // No Itanium initializer in header like modules.
-  if (M->isHeaderLikeModule())
+  // No Itanium initializer in module map modules.
+  if (M->isModuleMapModule())
 continue;
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
   SmallString<256> FnName;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index dc1122f3ab67..579ebba7736d 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -521,7 +521,7 @@ static void setVisibilityFromDLLStorageClass(const 
clang::LangOptions ,
 
 void CodeGenModule::Release() {
   Module *Primary = getContext().getModuleForCodeGen();
-  if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
+  if (CXX20ModuleInits && Primary && !Primary->isModuleMapModule())
 EmitModuleInitializers(Primary);
   EmitDeferred();
   DeferredDecls.insert(EmittedDeferredDecls.begin(),
@@ -2521,23 +2521,21 @@ void 
CodeGenModule::EmitModuleInitializers(clang::Module *Primary) {
   // source, first Global Module Fragments, if present.
   if (auto GMF = Primary->getGlobalModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(GMF)) {
-  if (isa(D))
-continue;
-  assert(isa(D) && "GMF initializer decl is not a var?");
+  assert(D->getKind() == Decl::Var && "GMF initializer decl is not a 
var?");
   EmitTopLevelDecl(D);
 }
   }
   // Second any associated with the module, itself.
   for (Decl *D : getContext().getModuleInitializers(Primary)) {
 // Skip import decls, the inits for those are called explicitly.
-if (isa(D))
+if (D->getKind() == Decl::Import)
   continue;
 EmitTopLevelDecl(D);
   }
   // Third any associated with the Privat eMOdule Fragment, if present.
   if (auto PMF = Primary->getPrivateModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(PMF)) {
-  assert(isa(D) && "PMF initializer decl is not a var?");
+  assert(D->getKind() == Decl::Var && "PMF initializer decl is not a 
var?");
   EmitTopLevelDecl(D);
 }
   }

diff  --git a/clang/test/CodeGenCXX/module-initializer-header.cppm 
b/clang/test/CodeGenCXX/module-initializer-header.cppm
deleted file mode 100644
index d60ad45a0ab3..
--- a/clang/test/CodeGenCXX/module-initializer-header.cppm
+++ /dev/null
@@ -1,31 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: rm -rf %t
-// RUN: split-file %s %t
-//
-// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -xc++-user-header 
-emit-header-unit %t/header.h -o %t/header.pcm
-// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple 
-fmodule-file=%t/header.pcm %t/M.cppm -S -emit-llvm -o - | FileCheck %t/M.cppm
-// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple 
-fmodule-file=%t/header.pcm %t/Use.cpp -S -emit-llvm -o - | FileCheck %t/Use.cpp
-//
-//--- header.h
-int foo();
-int i = foo();
-
-//--- M.cppm
-module;
-import "header.h";
-export module M;
-
-// CHECK: @i = {{.*}}global i32 0
-// CHECK: void @__cxx_global_var_init()
-// CHECK-NEXT: entry:
-// CHECK-NEXT:  %call = call noundef i32 @_Z3foov()
-// CHECK-NEXT:  store i32 %call, ptr @i  
-
-//--- Use.cpp
-import "header.h";
-
-// CHECK: @i = {{.*}}global i32 0
-// CHECK: void @__cxx_global_var_init()
-// 

[PATCH] D130864: [NFC] Introduce ASTContext::isInSameModule()

2022-08-01 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked 2 inline comments as done.
ChuanqiXu added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:6232
+
+  auto getHashValueForPrimaryModule = [this](const Module *M) {
+if (!PrimaryModuleHash.count(M))

erichkeane wrote:
> Doesn't `FindAndConstruct` do something pretty similar here?  This lambda is 
> incredibly inefficient as it requires two 3 separate lookups into the map.
> 
> Instead, I believe `FindAndConstruct` will create a new entry (which can be 
> 'set' if necessary', and then have its value returned.
On the one hand, `FindAndConstruct ` would construct an empty value, which is 
not we want. We want the value to be a hash_value of the name. On the other 
hand, your comments makes sense the implementation could be optimized. 
Currently, there would be at most 2 lookups and the number should be 1 at the 
hot path.


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

https://reviews.llvm.org/D130864

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


[PATCH] D130864: [NFC] Introduce ASTContext::isInSameModule()

2022-08-01 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 449173.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D130864

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp

Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1568,38 +1568,27 @@
 }
 
 /// Determine if we could use all the declarations in the module.
-bool Sema::isUsableModule(const Module *M) {
+bool Sema::isUsableModule(const Module *M) const {
   assert(M && "We shouldn't check nullness for module here");
-  // Return quickly if we cached the result.
-  if (UsableModuleUnitsCache.count(M))
-return true;
 
   // If M is the global module fragment of the current translation unit. So it
   // should be usable.
   // [module.global.frag]p1:
   //   The global module fragment can be used to provide declarations that are
   //   attached to the global module and usable within the module unit.
-  if (M == GlobalModuleFragment ||
-  // If M is the module we're parsing, it should be usable. This covers the
-  // private module fragment. The private module fragment is usable only if
-  // it is within the current module unit. And it must be the current
-  // parsing module unit if it is within the current module unit according
-  // to the grammar of the private module fragment. NOTE: This is covered by
-  // the following condition. The intention of the check is to avoid string
-  // comparison as much as possible.
-  M == getCurrentModule() ||
-  // The module unit which is in the same module with the current module
-  // unit is usable.
-  //
-  // FIXME: Here we judge if they are in the same module by comparing the
-  // string. Is there any better solution?
-  M->getPrimaryModuleInterfaceName() ==
-  llvm::StringRef(getLangOpts().CurrentModule).split(':').first) {
-UsableModuleUnitsCache.insert(M);
-return true;
-  }
-
-  return false;
+  //
+  // If M is the module we're parsing, it should be usable. This covers the
+  // private module fragment. The private module fragment is usable only if
+  // it is within the current module unit. And it must be the current
+  // parsing module unit if it is within the current module unit according
+  // to the grammar of the private module fragment. NOTE: This is covered by
+  // the following condition. The intention of the check is to avoid
+  // expensive comparison as much as possible.
+  //
+  // The module unit which is in the same module with the current module
+  // unit is usable.
+  return isModuleUnitOfCurrentTU(M) ||
+ getASTContext().isInSameModule(M, getCurrentModule());
 }
 
 bool Sema::hasVisibleMergedDefinition(NamedDecl *Def) {
@@ -1609,7 +1598,7 @@
   return false;
 }
 
-bool Sema::hasMergedDefinitionInCurrentModule(NamedDecl *Def) {
+bool Sema::hasMergedDefinitionInCurrentModule(NamedDecl *Def) const {
   for (const Module *Merged : Context.getModulesWithMergedDefinition(Def))
 if (isUsableModule(Merged))
   return true;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1644,8 +1644,7 @@
   // Partitions are part of the module, but a partition could import another
   // module, so verify that the PMIs agree.
   if (NewM && OldM && (NewM->isModulePartition() || OldM->isModulePartition()))
-return NewM->getPrimaryModuleInterfaceName() ==
-   OldM->getPrimaryModuleInterfaceName();
+return getASTContext().isInSameModule(NewM, OldM);
 
   bool NewIsModuleInterface = NewM && NewM->isModulePurview();
   bool OldIsModuleInterface = OldM && OldM->isModulePurview();
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1129,7 +1129,7 @@
 }
 
 ArrayRef
-ASTContext::getModulesWithMergedDefinition(const NamedDecl *Def) {
+ASTContext::getModulesWithMergedDefinition(const NamedDecl *Def) const {
   auto MergedIt =
   MergedDefModules.find(cast(Def->getCanonicalDecl()));
   if (MergedIt == MergedDefModules.end())
@@ -6212,6 +6212,31 @@
   llvm_unreachable("bad template name!");
 }
 
+bool ASTContext::isInSameModule(const Module *X, const Module *Y) const {
+  // If either one is not module unit, they must not be in the same module.
+  if (!X || !Y)
+return false;
+
+  if (X == Y)
+return true;
+
+  /// A header module won't be in the same module with a different address.
+  if (X->isHeaderLikeModule() || Y->isHeaderLikeModule())
+return false;
+
+  auto getHashValueForPrimaryModule = [this](const Module *M) {
+auto Iter 

[clang] 29f852a - [Driver] Remove deprecated -fsanitize-coverage-{black,white}list=

2022-08-01 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-08-01T19:39:25-07:00
New Revision: 29f852a1516bcd3928dad74835965f238de34409

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

LOG: [Driver] Remove deprecated -fsanitize-coverage-{black,white}list=

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 4d381374431a..da95d66a66e7 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1007,11 +1007,11 @@ Enable control flow integrity (CFI) checks for 
cross-DSO calls.
 
 Generalize pointers in CFI indirect call type signature checks
 
-.. option:: -fsanitize-coverage-allowlist=, 
-fsanitize-coverage-whitelist=
+.. option:: -fsanitize-coverage-allowlist=
 
 Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blocked ones
 
-.. option:: -fsanitize-coverage-ignorelist=, 
-fsanitize-coverage-blacklist=
+.. option:: -fsanitize-coverage-ignorelist=
 
 Disable sanitizer coverage instrumentation for modules and functions that 
match the provided special case list, even the allowed ones
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index bf73f12a5180..e37b461c95cb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1675,18 +1675,11 @@ def fsanitize_coverage_allowlist : Joined<["-"], 
"fsanitize-coverage-allowlist="
 Group, Flags<[CoreOption, NoXarchOption]>,
 HelpText<"Restrict sanitizer coverage instrumentation exclusively to 
modules and functions that match the provided special case list, except the 
blocked ones">,
 MarshallingInfoStringVector>;
-def : Joined<["-"], "fsanitize-coverage-whitelist=">,
-  Group, Flags<[CoreOption, HelpHidden]>, 
Alias,
-  HelpText<"Deprecated, use -fsanitize-coverage-allowlist= instead">;
 def fsanitize_coverage_ignorelist : Joined<["-"], 
"fsanitize-coverage-ignorelist=">,
 Group, Flags<[CoreOption, NoXarchOption]>,
 HelpText<"Disable sanitizer coverage instrumentation for modules and 
functions "
  "that match the provided special case list, even the allowed 
ones">,
 
MarshallingInfoStringVector>;
-def : Joined<["-"], "fsanitize-coverage-blacklist=">,
-  Group, Flags<[CoreOption, HelpHidden]>,
-  Alias,
-  HelpText<"Deprecated, use -fsanitize-coverage-ignorelist= instead">;
 def fsanitize_memory_track_origins_EQ : Joined<["-"], 
"fsanitize-memory-track-origins=">,
 Group,
 HelpText<"Enable origins tracking in 
MemorySanitizer">,



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


[clang] 0bb3aaf - [docs] Regenerate clang/docs/ClangCommandLineReference.rst

2022-08-01 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-08-01T19:31:25-07:00
New Revision: 0bb3aafbd5d59fdd3720c4ba9b995863bc3d2f45

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

LOG: [docs] Regenerate clang/docs/ClangCommandLineReference.rst

Also update -ftime-trace='s help to fix a recommonmark error.

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 6d1b6000484c..4d381374431a 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -893,6 +893,10 @@ Require member pointer base types to be complete if they 
would be significant un
 
 Put crash-report files in 
 
+.. option:: -fcrash-diagnostics=, -fcrash-diagnostics (equivalent to 
-fcrash-diagnostics=compiler)
+
+Set level of crash diagnostic reporting, (option: off, compiler, all)
+
 .. option:: -fdeclspec, -fno-declspec
 
 Allow \_\_declspec as a keyword
@@ -1145,7 +1149,9 @@ Include path management
 
 Flags controlling how ``#include``\s are resolved to files.
 
-.. option:: -I, --include-directory , --include-directory=
+.. program:: clang3
+.. option:: -I, /I, -I, --include-directory , 
--include-directory=
+.. program:: clang
 
 Add directory to include search path. For C++ inputs, if
 there are multiple -I options, these directories are searched
@@ -2301,6 +2307,10 @@ Instrument only functions from files where names don't 
match all the regexes sep
 
 Instrument only functions from files where names match any regex separated by 
a semi-colon
 
+.. option:: -fprofile-function-groups=
+
+Partition functions into N groups and select only functions in group i to be 
instrumented using -fprofile-selected-function-group
+
 .. option:: -fprofile-generate, -fno-profile-generate
 
 Generate instrumented code to collect execution counts into default.profraw 
(overridden by LLVM\_PROFILE\_FILE env var)
@@ -2333,10 +2343,6 @@ Use instrumentation data for profile-guided optimization
 
 Filename defining the list of functions/files to instrument
 
-.. option:: -fprofile-function-groups=, 
-fprofile-selected-function-group=
-
-Partition functions into  groups and select only functions in group  to 
be instrumented
-
 .. option:: -fprofile-remapping-file=
 
 Use the remappings described in  to match the profile data against names 
in the program
@@ -2356,6 +2362,10 @@ Specifies that the sample profile is accurate. If the 
sample
 
 Enable sample-based profile guided optimizations
 
+.. option:: -fprofile-selected-function-group=
+
+Partition functions into N groups using -fprofile-function-groups and select 
only functions in group i to be instrumented. The valid range is 0 to N-1 
inclusive
+
 .. option:: -fprofile-update=
 
 Set update method of profile counters.  must be 'atomic', 
'prefer-atomic' or 'single'.
@@ -2528,6 +2538,10 @@ Emit full debug info for all types used by the program
 
 Enable optimizations based on the strict definition of an enum's value range
 
+.. option:: -fstrict-flex-arrays=
+
+Enable optimizations based on the strict definition of flexible arrays.  
must be '0', '1' or '2'.
+
 .. option:: -fstrict-float-cast-overflow, -fno-strict-float-cast-overflow
 
 Assume that overflowing float-to-int casts are undefined (default)
@@ -2587,6 +2601,12 @@ can be analyzed with chrome://tracing or `Speedscope App
 
 Minimum time granularity (in microseconds) traced by time profiler
 
+.. program:: clang1
+.. option:: -ftime-trace=
+.. program:: clang
+
+Similar to -ftime-trace. Specify the JSON file or a directory which will 
contain the JSON file
+
 .. option:: -ftls-model=
 
   must be 'global-dynamic', 'local-dynamic', 'initial-exec' or 
'local-exec'.
@@ -2647,12 +2667,6 @@ Turn on loop unroller
 
 .. option:: -fuse-init-array, -fno-use-init-array
 
-.. option:: -fstrict-flex-arrays=, -fno-strict-flex-arrays
-
-Control which arrays are considered as flexible arrays members. 
-can be 1 (array of size 0, 1 and undefined are considered) or 2 (array of size 0
-and undefined are considered).
-
 .. option:: -fuse-ld=
 
 .. option:: -fuse-line-directives, -fno-use-line-directives
@@ -3040,12 +3054,18 @@ Set Fuchsia API level
 .. option:: -mabi=
 
 .. program:: clang1
+.. option:: -mabi=quadword-atomics
+.. program:: clang
+
+Enable quadword atomics ABI on AIX (AIX PPC64 only). Uses lqarx/stqcx. 
instructions.
+
+.. program:: clang2
 .. option:: -mabi=vec-default
 .. program:: clang
 
 Enable the default Altivec ABI on AIX (AIX only). Uses only volatile vector 
registers.
 
-.. program:: clang2
+.. program:: clang3
 .. option:: -mabi=vec-extabi
 .. program:: clang
 
@@ -3141,6 +3161,10 @@ Insert calls to fentry at function 

[PATCH] D130871: [C++20] [Modules] Handle initializer for Header Units

2022-08-01 Thread Chuanqi Xu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb6152ad66d7: [C++20] [Modules] Handle initializer for 
Header Units (authored by ChuanqiXu).

Changed prior to commit:
  https://reviews.llvm.org/D130871?vs=448931=449172#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130871

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/module-initializer-header.cppm

Index: clang/test/CodeGenCXX/module-initializer-header.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/module-initializer-header.cppm
@@ -0,0 +1,31 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -xc++-user-header -emit-header-unit %t/header.h -o %t/header.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -fmodule-file=%t/header.pcm %t/M.cppm -S -emit-llvm -o - | FileCheck %t/M.cppm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -fmodule-file=%t/header.pcm %t/Use.cpp -S -emit-llvm -o - | FileCheck %t/Use.cpp
+//
+//--- header.h
+int foo();
+int i = foo();
+
+//--- M.cppm
+module;
+import "header.h";
+export module M;
+
+// CHECK: @i = {{.*}}global i32 0
+// CHECK: void @__cxx_global_var_init()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:  %call = call noundef i32 @_Z3foov()
+// CHECK-NEXT:  store i32 %call, ptr @i  
+
+//--- Use.cpp
+import "header.h";
+
+// CHECK: @i = {{.*}}global i32 0
+// CHECK: void @__cxx_global_var_init()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:  %call = call noundef i32 @_Z3foov()
+// CHECK-NEXT:  store i32 %call, ptr @i  
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -521,7 +521,7 @@
 
 void CodeGenModule::Release() {
   Module *Primary = getContext().getModuleForCodeGen();
-  if (CXX20ModuleInits && Primary && !Primary->isModuleMapModule())
+  if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
 EmitModuleInitializers(Primary);
   EmitDeferred();
   DeferredDecls.insert(EmittedDeferredDecls.begin(),
@@ -2521,21 +2521,23 @@
   // source, first Global Module Fragments, if present.
   if (auto GMF = Primary->getGlobalModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(GMF)) {
-  assert(D->getKind() == Decl::Var && "GMF initializer decl is not a var?");
+  if (isa(D))
+continue;
+  assert(isa(D) && "GMF initializer decl is not a var?");
   EmitTopLevelDecl(D);
 }
   }
   // Second any associated with the module, itself.
   for (Decl *D : getContext().getModuleInitializers(Primary)) {
 // Skip import decls, the inits for those are called explicitly.
-if (D->getKind() == Decl::Import)
+if (isa(D))
   continue;
 EmitTopLevelDecl(D);
   }
   // Third any associated with the Privat eMOdule Fragment, if present.
   if (auto PMF = Primary->getPrivateModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(PMF)) {
-  assert(D->getKind() == Decl::Var && "PMF initializer decl is not a var?");
+  assert(isa(D) && "PMF initializer decl is not a var?");
   EmitTopLevelDecl(D);
 }
   }
Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -650,8 +650,8 @@
 
   SmallVector ModuleInits;
   for (Module *M : AllImports) {
-// No Itanium initializer in module map modules.
-if (M->isModuleMapModule())
+// No Itanium initializer in header like modules.
+if (M->isHeaderLikeModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
@@ -779,8 +779,8 @@
   SmallVector ModuleInits;
   if (CXX20ModuleInits)
 for (Module *M : ImportedModules) {
-  // No Itanium initializer in module map modules.
-  if (M->isModuleMapModule())
+  // No Itanium initializer in header like modules.
+  if (M->isHeaderLikeModule())
 continue;
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
   SmallString<256> FnName;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] db6152a - [C++20] [Modules] Handle initializer for Header Units

2022-08-01 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-08-02T10:27:02+08:00
New Revision: db6152ad66d7cf48f9f5c3eb28bf54c092978773

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

LOG: [C++20] [Modules] Handle initializer for Header Units

Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

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

Added: 
clang/test/CodeGenCXX/module-initializer-header.cppm

Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 620af1e633b7..420141362f0e 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -650,8 +650,8 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 
   SmallVector ModuleInits;
   for (Module *M : AllImports) {
-// No Itanium initializer in module map modules.
-if (M->isModuleMapModule())
+// No Itanium initializer in header like modules.
+if (M->isHeaderLikeModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
@@ -779,8 +779,8 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
   SmallVector ModuleInits;
   if (CXX20ModuleInits)
 for (Module *M : ImportedModules) {
-  // No Itanium initializer in module map modules.
-  if (M->isModuleMapModule())
+  // No Itanium initializer in header like modules.
+  if (M->isHeaderLikeModule())
 continue;
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
   SmallString<256> FnName;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 579ebba7736d..dc1122f3ab67 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -521,7 +521,7 @@ static void setVisibilityFromDLLStorageClass(const 
clang::LangOptions ,
 
 void CodeGenModule::Release() {
   Module *Primary = getContext().getModuleForCodeGen();
-  if (CXX20ModuleInits && Primary && !Primary->isModuleMapModule())
+  if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
 EmitModuleInitializers(Primary);
   EmitDeferred();
   DeferredDecls.insert(EmittedDeferredDecls.begin(),
@@ -2521,21 +2521,23 @@ void 
CodeGenModule::EmitModuleInitializers(clang::Module *Primary) {
   // source, first Global Module Fragments, if present.
   if (auto GMF = Primary->getGlobalModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(GMF)) {
-  assert(D->getKind() == Decl::Var && "GMF initializer decl is not a 
var?");
+  if (isa(D))
+continue;
+  assert(isa(D) && "GMF initializer decl is not a var?");
   EmitTopLevelDecl(D);
 }
   }
   // Second any associated with the module, itself.
   for (Decl *D : getContext().getModuleInitializers(Primary)) {
 // Skip import decls, the inits for those are called explicitly.
-if (D->getKind() == Decl::Import)
+if (isa(D))
   continue;
 EmitTopLevelDecl(D);
   }
   // Third any associated with the Privat eMOdule Fragment, if present.
   if (auto PMF = Primary->getPrivateModuleFragment()) {
 for (Decl *D : getContext().getModuleInitializers(PMF)) {
-  assert(D->getKind() == Decl::Var && "PMF initializer decl is not a 
var?");
+  assert(isa(D) && "PMF initializer decl is not a var?");
   EmitTopLevelDecl(D);
 }
   }

diff  --git a/clang/test/CodeGenCXX/module-initializer-header.cppm 
b/clang/test/CodeGenCXX/module-initializer-header.cppm
new file mode 100644
index ..d60ad45a0ab3
--- /dev/null
+++ b/clang/test/CodeGenCXX/module-initializer-header.cppm
@@ -0,0 +1,31 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -xc++-user-header 
-emit-header-unit %t/header.h -o %t/header.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple 
-fmodule-file=%t/header.pcm %t/M.cppm -S -emit-llvm -o - | FileCheck %t/M.cppm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple 
-fmodule-file=%t/header.pcm %t/Use.cpp -S -emit-llvm -o - | FileCheck %t/Use.cpp
+//
+//--- header.h
+int foo();
+int i = foo();
+
+//--- M.cppm
+module;
+import "header.h";
+export module M;
+
+// CHECK: @i = {{.*}}global i32 0
+// CHECK: void @__cxx_global_var_init()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:  %call = call noundef i32 @_Z3foov()
+// CHECK-NEXT:  store i32 %call, ptr @i  
+
+//--- Use.cpp
+import "header.h";
+
+// 

[PATCH] D130936: [SemaCXX] Validate destructor is valid for dependent classes

2022-08-01 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM but let's have Erich take a look.




Comment at: clang/lib/Sema/SemaDecl.cpp:11499
 
-  // FIXME: Shouldn't we be able to perform this check even when the class
-  // type is dependent? Both gcc and edg can handle that.

The FIXME goes back a while, I wonder how long ago we fixed this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130936

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


[clang] 9bf6ecc - [clang] Only run test on x86

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-02T00:56:05Z
New Revision: 9bf6eccae112476d953180e814781b99237bd0bb

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

LOG: [clang] Only run test on x86

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 7db0e2e188c2..65d562996e62 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,4 +1,4 @@
-// REQUIRES: lld
+// REQUIRES: lld, x86-registered-target
 
 // RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s



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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-08-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This change caused a ton of churn, for what I understand fix the diag in C mode 
when assert.h is not included.

IMHO, it would've been better to change the diag to say either `static_assert` 
as before in c++ mode or when assert.h is included (i.e. almost always), and 
`_Static_assert` else. You can use PP.getLastMacroWithSpelling() to 
(effectively) detect if assert.h was included.

Is this something y'all had considered?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D130863: [clangd] Make git ignore index directories

2022-08-01 Thread sums via Phabricator via cfe-commits
sums marked an inline comment as done.
sums added inline comments.



Comment at: clang-tools-extra/clangd/test/background-index.test:23
+# RUN: ls %/t/.cache/clangd/index/.gitignore
+# RUN: ls %/t/sub_dir/.cache/clangd/index/.gitignore
+

sammccall wrote:
> Bleh, ideally this would go in clangd/.gitignore but we'd have to break a 
> bunch of abstractions to do that. I think this is fine.
Doing it this way also ignores the `.gitignore` file itself :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130863

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


[PATCH] D130951: [HLSL] CodeGen hlsl resource binding.

2022-08-01 Thread Xiang Li via Phabricator via cfe-commits
python3kgae created this revision.
python3kgae added reviewers: aaron.ballman, Anastasia, kuhar, bogner, beanz, 
pow2clk.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

''register(ID, space)'' like register(t3, space1) will be translated into
i32 3, i32 1 as the last 2 operands for resource annotation metadata.

NamedMetadata for CBuffers and SRVs are added as "hlsl.srvs" and "hlsl.cbufs".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130951

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h
  clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
  clang/test/CodeGenHLSL/cbuf.hlsl

Index: clang/test/CodeGenHLSL/cbuf.hlsl
===
--- clang/test/CodeGenHLSL/cbuf.hlsl
+++ clang/test/CodeGenHLSL/cbuf.hlsl
@@ -1,7 +1,7 @@
 // RUN: %clang_dxc -Tlib_6_7 -fcgl  -Fo - %s | FileCheck %s
 
 // CHECK: @[[CB:.+]] = external addrspace(4) constant { float, i32, double }
-cbuffer A : register(b0, space1) {
+cbuffer A : register(b0, space2) {
   float a;
   double b;
 }
@@ -19,3 +19,8 @@
 // CHECK: load double, ptr addrspacecast (ptr addrspace(5) getelementptr inbounds ({ float, i32, double }, ptr addrspace(5) @[[TB]], i32 0, i32 2) to ptr), align 8
   return a + b + c*d;
 }
+
+// CHECK: !hlsl.cbufs = !{![[CBMD:[0-9]+]]}
+// CHECK: !hlsl.srvs = !{![[TBMD:[0-9]+]]}
+// CHECK: ![[CBMD]] = !{ptr addrspace(4) @[[CB]], !"A.cb.ty", i32 0, i32 0, i32 2}
+// CHECK: ![[TBMD]] = !{ptr addrspace(5) @[[TB]], !"A.tb.ty", i32 0, i32 2, i32 1}
\ No newline at end of file
Index: clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
===
--- clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
+++ clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
@@ -8,5 +8,5 @@
 }
 
 // CHECK: !hlsl.uavs = !{![[Single:[0-9]+]], ![[Array:[0-9]+]]}
-// CHECK-DAG: ![[Single]] = !{ptr @"?Buffer1@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer", i32 0}
-// CHECK-DAG: ![[Array]] = !{ptr @"?BufferArray@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer >", i32 1}
+// CHECK-DAG: ![[Single]] = !{ptr @"?Buffer1@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer", i32 0, i32 -1, i32 0}
+// CHECK-DAG: ![[Array]] = !{ptr @"?BufferArray@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer >", i32 1, i32 -1, i32 0}
Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -31,6 +31,7 @@
 
 namespace clang {
 class HLSLBufferDecl;
+class HLSLResourceBindingAttr;
 class CallExpr;
 class Type;
 class VarDecl;
@@ -42,13 +43,17 @@
 
 class CGHLSLRuntime {
 public:
+  struct ResBinding {
+llvm::Optional Reg;
+unsigned Space;
+ResBinding(HLSLResourceBindingAttr *Attr);
+  };
   struct Buffer {
 Buffer(HLSLBufferDecl *D);
 llvm::StringRef Name;
 // IsCBuffer - Whether the buffer is a cbuffer (and not a tbuffer).
 bool IsCBuffer;
-llvm::Optional Reg;
-unsigned Space;
+ResBinding Binding;
 // Global variable and offset for each constant.
 std::vector> Constants;
 llvm::StructType *LayoutStruct = nullptr;
@@ -69,6 +74,8 @@
   void finishCodeGen();
 
 private:
+  void addResourceAnnotation(llvm::GlobalVariable *GV, llvm::StringRef TyName,
+ hlsl::ResourceClass RC, ResBinding );
   void addConstant(VarDecl *D, Buffer );
   void addBufferDecls(DeclContext *DC, Buffer );
   llvm::SmallVector Buffers;
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -110,10 +110,6 @@
   return CBGV;
 }
 
-void addResourceBinding(GlobalVariable *GV, CGHLSLRuntime::Buffer ) {
-  // FIXME: add resource binding to GV.
-}
-
 } // namespace
 
 void CGHLSLRuntime::addConstant(VarDecl *D, Buffer ) {
@@ -191,19 +187,52 @@
 Buf.IsCBuffer ? CBufferAddressSpace : TBufferAddressSpace;
 GlobalVariable *GV = replaceBuffer(Buf, AddressSapce);
 M.getGlobalList().push_back(GV);
-addResourceBinding(GV, Buf);
+hlsl::ResourceClass RC =
+Buf.IsCBuffer ? hlsl::ResourceClass::CBuffer : hlsl::ResourceClass::SRV;
+std::string TyName =
+Buf.Name.str() + (Buf.IsCBuffer ? ".cb." : ".tb.") + "ty";
+addResourceAnnotation(GV, TyName, RC, Buf.Binding);
   }
 }
 
-CGHLSLRuntime::Buffer::Buffer(HLSLBufferDecl *D) {
-  Name = D->getName();
-  IsCBuffer = D->isCBuffer();
-  if (auto *Binding = D->getAttr()) {
-Reg = Binding->getID();
-Space = Binding->getSpace();
-  } else {
-Space = 0;
+CGHLSLRuntime::Buffer::Buffer(HLSLBufferDecl *D)
+: Name(D->getName()), IsCBuffer(D->isCBuffer()),
+  Binding(D->getAttr()) {}
+
+void 

[PATCH] D130800: [clang][Headers] Avoid compiler warnings in builtin headers

2022-08-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:37
 
-#if __cplusplus >= 201103L
+#if defined(__cplusplus) && __cplusplus >= 201103L
 #define __DELETE =delete

Are there actual use cases where CUDA headers are used from a non-C++ 
compilation? I do not think they will compile with non-C++ compilation at all.

I'm curious how we managed to run into a situation where CUDA headers may be 
used w/o C++. 

I think a better fix here and other CUDA headers may be to add 
```
#if !defined(__cplusplus)
#error CUDA headers must be used from a CUDA/C++ compilation.
#endif
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130800

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-08-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 449150.
craig.topper added a comment.

Add hasVInstructions to RISCVISAInfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/builtin_float_strictfp.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp


Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -929,6 +929,10 @@
 }
   }
 
+  // FIXME: Strict FP support is incomplete for vectors.
+  if (!Subtarget.hasVInstructions())
+IsStrictFPEnabled = true;
+
   // Function alignments.
   const Align FunctionAlignment(Subtarget.hasStdExtC() ? 2 : 4);
   setMinFunctionAlignment(FunctionAlignment);
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -228,6 +228,10 @@
  llvm::any_of(SupportedExperimentalExtensions, FindByNameAndVersion);
 }
 
+bool RISCVISAInfo::hasVInstructions() const {
+  return hasExtension("zve32x");
+}
+
 bool RISCVISAInfo::hasExtension(StringRef Ext) const {
   stripExperimentalPrefix(Ext);
 
@@ -702,7 +706,7 @@
   bool HasF = Exts.count("f") != 0;
   bool HasZfinx = Exts.count("zfinx") != 0;
   bool HasZdinx = Exts.count("zdinx") != 0;
-  bool HasVector = Exts.count("zve32x") != 0;
+  bool HasVector = hasVInstructions();
   bool HasZve32f = Exts.count("zve32f") != 0;
   bool HasZve64d = Exts.count("zve64d") != 0;
   bool HasZvl = MinVLen != 0;
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -62,6 +62,7 @@
   unsigned getMinVLen() const { return MinVLen; }
   unsigned getMaxELen() const { return MaxELen; }
   unsigned getMaxELenFp() const { return MaxELenFp; }
+  bool hasVInstructions() const;
 
   bool hasExtension(StringRef Ext) const;
   std::string toString() const;
Index: clang/test/CodeGen/builtin_float_strictfp.c
===
--- clang/test/CodeGen/builtin_float_strictfp.c
+++ clang/test/CodeGen/builtin_float_strictfp.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple x86_64-windows-pc 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,FP16
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple ppc64-be 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,NOFP16
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple riscv64 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,FP16
 
 // test to ensure that these builtins don't do the variadic promotion of 
float->double.
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -41,6 +41,7 @@
 HasRISCVVTypes = true;
 MCountName = "_mcount";
 HasFloat16 = true;
+HasStrictFP = true;
   }
 
   bool setCPU(const std::string ) override {
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -190,7 +190,7 @@
   if (ISAInfo->hasExtension("c"))
 Builder.defineMacro("__riscv_compressed");
 
-  if (ISAInfo->hasExtension("zve32x"))
+  if (ISAInfo->hasVInstructions())
 Builder.defineMacro("__riscv_vector");
 }
 
@@ -282,6 +282,10 @@
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasVInstructions())
+HasStrictFP = false;
+
   return true;
 }
 


Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -929,6 +929,10 @@
 }
   }
 
+  // FIXME: Strict FP support is incomplete for vectors.
+  if (!Subtarget.hasVInstructions())
+IsStrictFPEnabled = true;
+
   // Function alignments.
   const Align FunctionAlignment(Subtarget.hasStdExtC() ? 2 : 4);
   setMinFunctionAlignment(FunctionAlignment);
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -228,6 +228,10 @@
  llvm::any_of(SupportedExperimentalExtensions, FindByNameAndVersion);
 }
 
+bool RISCVISAInfo::hasVInstructions() const {
+ 

[PATCH] D130935: [clang] Only modify FileEntryRef names that are externally remapped

2022-08-01 Thread Ben Langmuir 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 rG98cf745a032e: [clang] Only modify FileEntryRef names that 
are externally remapped (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130935

Files:
  clang/lib/Basic/FileManager.cpp
  clang/unittests/Basic/FileManagerTest.cpp


Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -44,16 +44,16 @@
   }
 }
 
-if (!StatPath)
-  StatPath = Path;
-
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath ? StatPath : Path,
+ llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
+if (StatPath)
+  Status.ExposesExternalVFSPath = true;
 StatCalls[Path] = Status;
   }
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -274,8 +274,8 @@
   if (!UFE)
 UFE = new (FilesAlloc.Allocate()) FileEntry();
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (!Status.ExposesExternalVFSPath || Status.getName() == Filename) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
   } else {
 // Name mismatch. We need a redirect. First grab the actual entry we want
@@ -292,19 +292,7 @@
 // filesystems behave and confuses parts of clang expect to see the
 // name-as-accessed on the \a FileEntryRef.
 //
-// Further, it isn't *just* external names, but will also give back 
absolute
-// paths when a relative path was requested - the check is comparing the
-// name from the status, which is passed an absolute path resolved from the
-// current working directory. `clang-apply-replacements` appears to depend
-// on this behaviour, though it's adjusting the working directory, which is
-// definitely not supported. Once that's fixed this hack should be able to
-// be narrowed to only when there's an externally mapped name given back.
-//
 // A potential plan to remove this is as follows -
-//   - Add API to determine if the name has been rewritten by the VFS.
-//   - Fix `clang-apply-replacements` to pass down the absolute path rather
-// than changing the CWD. Narrow this hack down to just externally
-// mapped paths.
 //   - Expose the requested filename. One possibility would be to allow
 // redirection-FileEntryRefs to be returned, rather than returning
 // the pointed-at-FileEntryRef, and customizing `getName()` to look


Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -44,16 +44,16 @@
   }
 }
 
-if (!StatPath)
-  StatPath = Path;
-
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath ? StatPath : Path,
+ llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
+if (StatPath)
+  Status.ExposesExternalVFSPath = true;
 StatCalls[Path] = Status;
   }
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -274,8 +274,8 @@
   if (!UFE)
 UFE = new (FilesAlloc.Allocate()) FileEntry();
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (!Status.ExposesExternalVFSPath || Status.getName() == Filename) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
   } else {
 // Name mismatch. We need a redirect. First grab the actual entry we want
@@ -292,19 +292,7 @@
 // filesystems behave and confuses parts of clang expect to see the
 // name-as-accessed on the \a FileEntryRef.
 //
-// Further, it isn't 

[clang] 98cf745 - [clang] Only modify FileEntryRef names that are externally remapped

2022-08-01 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2022-08-01T15:45:51-07:00
New Revision: 98cf745a032ea0d29fbddaa204760d4e823c237f

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

LOG: [clang] Only modify FileEntryRef names that are externally remapped

As progress towards having FileEntryRef contain the requested name of
the file, this commit narrows the "remap" hack to only apply to paths
that were remapped to an external contents path by a VFS. That was
always the original intent of this code, and the fact it was making
relative paths absolute was an unintended side effect.

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

Added: 


Modified: 
clang/lib/Basic/FileManager.cpp
clang/unittests/Basic/FileManagerTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index b66780a1d1d1d..451c7c3b8a0dc 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -274,8 +274,8 @@ FileManager::getFileRef(StringRef Filename, bool openFile, 
bool CacheFailure) {
   if (!UFE)
 UFE = new (FilesAlloc.Allocate()) FileEntry();
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (!Status.ExposesExternalVFSPath || Status.getName() == Filename) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
   } else {
 // Name mismatch. We need a redirect. First grab the actual entry we want
@@ -292,19 +292,7 @@ FileManager::getFileRef(StringRef Filename, bool openFile, 
bool CacheFailure) {
 // filesystems behave and confuses parts of clang expect to see the
 // name-as-accessed on the \a FileEntryRef.
 //
-// Further, it isn't *just* external names, but will also give back 
absolute
-// paths when a relative path was requested - the check is comparing the
-// name from the status, which is passed an absolute path resolved from the
-// current working directory. `clang-apply-replacements` appears to depend
-// on this behaviour, though it's adjusting the working directory, which is
-// definitely not supported. Once that's fixed this hack should be able to
-// be narrowed to only when there's an externally mapped name given back.
-//
 // A potential plan to remove this is as follows -
-//   - Add API to determine if the name has been rewritten by the VFS.
-//   - Fix `clang-apply-replacements` to pass down the absolute path rather
-// than changing the CWD. Narrow this hack down to just externally
-// mapped paths.
 //   - Expose the requested filename. One possibility would be to allow
 // redirection-FileEntryRefs to be returned, rather than returning
 // the pointed-at-FileEntryRef, and customizing `getName()` to look

diff  --git a/clang/unittests/Basic/FileManagerTest.cpp 
b/clang/unittests/Basic/FileManagerTest.cpp
index 535d4d9e09c67..6e60bba9b2a99 100644
--- a/clang/unittests/Basic/FileManagerTest.cpp
+++ b/clang/unittests/Basic/FileManagerTest.cpp
@@ -44,16 +44,16 @@ class FakeStatCache : public FileSystemStatCache {
   }
 }
 
-if (!StatPath)
-  StatPath = Path;
-
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath ? StatPath : Path,
+ llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
+if (StatPath)
+  Status.ExposesExternalVFSPath = true;
 StatCalls[Path] = Status;
   }
 



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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-08-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:286
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasExtension("zve32x"))
+HasStrictFP = false;

reames wrote:
> craig.topper wrote:
> > reames wrote:
> > > craig.topper wrote:
> > > > reames wrote:
> > > > > asb wrote:
> > > > > > There's also code in RISCVISAInfo.cpp that does `HasVector = 
> > > > > > Exts.count("zve32x") != 0`. It's probably worth adding a helper 
> > > > > > (`hasVInstructions`?) that encapsulates this, and use it from both 
> > > > > > places.
> > > > > It's not clear to me why this condition is specific to embedded 
> > > > > vector variants.  Do we have strict FP with +V?  Either you need to 
> > > > > fix a comment here, or the condition.  One or the other.  
> > > > V implies Zve64d implies Zve64f implies Zve32f and Zve64x. Zve32f 
> > > > implies Zve32x. Zve32x is the root of the vector inheritance tree.
> > > So, I went digging.  I agree that our *implementation* treats V as 
> > > implying Zve64d, but I can find anything in the *specification* to that 
> > > effect.  The feature set seems like it might be identical between the 
> > > two, but I don't see anything in the spec which requires a +V 
> > > implementation to claim support for Zve64d.  Do you have particular 
> > > wording in mind I'm missing?  
> > > 
> > > (Regardless, the fact we assume this elsewhere means this is a 
> > > non-blocking comment for this review.  At the very least, this isn't 
> > > introducing a new problem.)
> > We removed the implication for a brief period but Krste and Andrew 
> > disagreed. I believe this is now covered by the note at the end of 
> > https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#183-v-vector-extension-for-application-processors
> > 
> > "As is the case with other RISC-V extensions, it is valid to include 
> > overlapping extensions in the same ISA string. For example, RV64GCV and 
> > RV64GCV_Zve64f are both valid and equivalent ISA strings, as is 
> > RV64GCV_Zve64f_Zve32x_Zvl128b."
> Er, yuck that's subtle.  Not quite sure I'd read it the way you do, but your 
> read is at least easily defensible.  We can wait until someone has a concrete 
> case where they aren't implied before figuring out if that case is disallowed 
> per the spec.  :)
Maybe their biggest issue with the split we had was that we made them mutex and 
issued an error.

I'm going to add the wrapper that Alex suggested so that this is more 
centralized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

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


[PATCH] D126097: [clang-tidy] Adds the NSDateFormatter checker to clang-tidy

2022-08-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Great, thanks! Unless there are other objections from other reviewers, I think 
this is good to go.


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

https://reviews.llvm.org/D126097

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


[PATCH] D126097: [clang-tidy] Adds the NSDateFormatter checker to clang-tidy

2022-08-01 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud updated this revision to Diff 449144.

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

https://reviews.llvm.org/D126097

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
  clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/objc/nsdate-formatter.rst
  clang-tools-extra/test/clang-tidy/checkers/objc/nsdate-formatter.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc/nsdate-formatter.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc/nsdate-formatter.m
@@ -0,0 +1,313 @@
+// RUN: %check_clang_tidy %s objc-nsdate-formatter %t
+@interface NSObject
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface TestClass : NSObject
++ (void)testMethod1;
++ (void)testMethod2;
++ (void)testMethod3;
++ (void)testAnotherClass;
+@end
+
+@interface NSString : NSObject
+@end
+
+void NSLog(NSString *format, ...);
+
+@interface NSDate : NSObject
+@end
+
+@interface NSDateFormatter : NSObject
+@property(copy) NSString *dateFormat;
+- (NSString *)stringFromDate:(NSDate *)date;
+@end
+
+@interface AnotherClass : NSObject
+@property(copy) NSString *dateFormat;
+@end
+
+@interface NSDateComponents : NSObject
+@property long year;
+@property long month;
+@property long day;
+@end
+
+@interface NSCalendar : NSObject
+@property(class, readonly, copy) NSCalendar *currentCalendar;
+- (nullable NSDate *)dateFromComponents:(NSDateComponents *)Comps;
+@end
+
+@implementation TestClass
++ (void)testMethod1 {
+  // Reproducing incorrect behavior from Radar
+  NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+  [formatter setDateFormat:@"_MM_dd_HH_mm_ss_SSS_ZZZ"];
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use of week year(Y) with month(M); did you mean to use calendar year(y) instead? [objc-nsdate-formatter]
+  NSDateComponents *comps = [[NSDateComponents alloc] init];
+  [comps setDay:29];
+  [comps setMonth:12];
+  [comps setYear:2014];
+  NSDate *date_radar = [[NSCalendar currentCalendar] dateFromComponents:comps];
+  NSLog(@"_MM_dd_HH_mm_ss_SSS_ZZZ %@", [formatter stringFromDate:date_radar]);
+
+  // Radar correct behavior
+  [formatter setDateFormat:@"_MM_dd_HH_mm_ss_SSS_ZZZ"];
+  NSLog(@"_MM_dd_HH_mm_ss_SSS_ZZZ %@", [formatter stringFromDate:date_radar]);
+
+  // Radar correct behavior - week year
+  [formatter setDateFormat:@"_ww_dd_HH_mm_ss_SSS_ZZZ"];
+  NSLog(@"_ww_dd_HH_mm_ss_SSS_ZZZ %@", [formatter stringFromDate:date_radar]);
+
+  // Radar incorrect behavior
+  [formatter setDateFormat:@"_ww_dd_HH_mm_ss_SSS_ZZZ"];
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use of calendar year(y) with week of the year(w); did you mean to use week-year(Y) instead? [objc-nsdate-formatter]
+  NSLog(@"_ww_dd_HH_mm_ss_SSS_ZZZ %@", [formatter stringFromDate:date_radar]);
+
+  NSLog(@"==");
+  // Correct
+  [formatter setDateFormat:@"_MM"];
+  NSLog(@"_MM %@", [formatter stringFromDate:date_radar]);
+
+  // Correct
+  [formatter setDateFormat:@"_dd"];
+  NSLog(@"_dd %@", [formatter stringFromDate:date_radar]);
+
+  // Correct
+  [formatter setDateFormat:@"_DD"];
+  NSLog(@"_DD %@", [formatter stringFromDate:date_radar]);
+
+  // Incorrect
+  [formatter setDateFormat:@"_ww"];
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use of calendar year(y) with week of the year(w); did you mean to use week-year(Y) instead? [objc-nsdate-formatter]
+  NSLog(@"_ww %@", [formatter stringFromDate:date_radar]);
+
+  // Incorrect
+  [formatter setDateFormat:@"_WW"];
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: Week of Month(W) used without the month(M); did you forget M in the format string? [objc-nsdate-formatter]
+  NSLog(@"_WW %@", [formatter stringFromDate:date_radar]);
+
+  NSLog(@"==");
+  // Correct
+  [formatter setDateFormat:@"_MM_dd"];
+  NSLog(@"_MM_dd %@", [formatter stringFromDate:date_radar]);
+
+  // Potentially Incorrect
+  [formatter setDateFormat:@"_MM_DD"];
+  NSLog(@"_MM_DD %@", [formatter stringFromDate:date_radar]);
+
+  // Incorrect
+  [formatter setDateFormat:@"_MM_ww"];
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use of calendar year(y) with week of the year(w); did you mean to use week-year(Y) instead? [objc-nsdate-formatter]
+  NSLog(@"_MM_ww %@", [formatter stringFromDate:date_radar]);
+
+  NSLog(@"===WEEK YEAR==");
+  // Incorrect
+  [formatter setDateFormat:@"_MM"];
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use of week year(Y) with month(M); did you mean to use calendar year(y) instead? [objc-nsdate-formatter]
+  NSLog(@"_MM 

[clang] 6b3fa58 - [clang] Make test agnostic to file seperator character

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T22:12:04Z
New Revision: 6b3fa58fde5962f00523e2a8f2498b1206345db2

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

LOG: [clang] Make test agnostic to file seperator character

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 733a6f9d1305..7db0e2e188c2 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -7,9 +7,9 @@
 // CHECK: error: undefined symbol: a
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.c
-// CHECK-NEXT: note: diagnostic msg: {{.*}}/linker-crash-{{.*}}.tar
-// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.sh
+// CHECK-NEXT: note: diagnostic msg: {{.*}}lld-repro-{{.*}}.c
+// CHECK-NEXT: note: diagnostic msg: {{.*}}linker-crash-{{.*}}.tar
+// CHECK-NEXT: note: diagnostic msg: {{.*}}lld-repro-{{.*}}.sh
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 



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


[clang] 71f2d5c - [clang] Re-enable test after marking it XFAIL

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T22:09:13Z
New Revision: 71f2d5c2d195256f27f293aefdc1d4f6c117065d

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

LOG: [clang] Re-enable test after marking it XFAIL

This test had to be disabled because ps4 targets don't support
-fuse-ld. Preferably, this should just be unsupported for ps4
targets. However no such lit feature exists so I have just gone
ahead and set the target explicitly. Moreover, this needs
to create a terminal link step, either an executable or shared
object to get the link error. With the change to the explicit
target I've had to also add -nostartfiles -nostdlib so that
clang doesn't pull crt files into the link which may not be
present. Again, this would likely be solved if this test
was unsupported for the one platform that disables -fuse-ld

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 2643ad871835..733a6f9d1305 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,7 +1,6 @@
 // REQUIRES: lld
-// XFAIL: *
 
-// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -14,9 +13,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 
2>&1 \
+// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=compiler 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:



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


[PATCH] D130871: [C++20] [Modules] Handle initializer for Header Units

2022-08-01 Thread Iain Sandoe via Phabricator via cfe-commits
iains accepted this revision.
iains added a comment.
This revision is now accepted and ready to land.

LGTM, one small point about the test,




Comment at: clang/test/CodeGenCXX/module-initializer-header.cppm:5-7
+// RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu 
-xc++-user-header -emit-header-unit %t/header.h -o %t/header.pcm
+// RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu 
-fmodule-file=%t/header.pcm %t/M.cppm -S -emit-llvm -o - | FileCheck %t/M.cppm
+// RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu 
-fmodule-file=%t/header.pcm %t/Use.cpp -S -emit-llvm -o - | FileCheck %t/Use.cpp

you could use `-triple %itanium_abi_triple` which would increase the test 
coverage to other titanium platforms.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130871

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


[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-08-01 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 449140.
steplong added a comment.
Herald added a subscriber: steakhal.

- Change unittest to match Num Args 1 or 2

I won't merge this. Just want to see if this passes the unittest


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-zc.cpp
  clang/unittests/StaticAnalyzer/CallEventTest.cpp

Index: clang/unittests/StaticAnalyzer/CallEventTest.cpp
===
--- clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -81,7 +81,7 @@
 }
   )",
  Diags));
-  EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n");
+  EXPECT_THAT(Diags, MatchesRegex("test.CXXDeallocator: NumArgs: (1|2)\n"));
 }
 
 } // namespace
Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF %s
+// SIZED-DEALLOC: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++20 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// ALIGNED-NEW-BEFORE-CPP17-NOT: "-faligned-allocation"
+// ALIGNED-NEW-CPP17ONWARDS: "-faligned-allocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
 // isn't explicitly passed.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6470,6 +6470,7 @@
 }
 CmdArgs.push_back(LanguageStandard.data());
   }
+  bool IsCPP17Onwards = false;
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
@@ -6493,6 +6494,9 @@
 }
 
 CmdArgs.push_back(LanguageStandard.data());
+
+IsCPP17Onwards =
+LanguageStandard != "-std=c++11" && LanguageStandard != "-std=c++14";
   }
 
   Args.addOptInFlag(CmdArgs, options::OPT_fborland_extensions,
@@ -6622,9 +6626,15 @@
 options::OPT_fno_relaxed_template_template_args);
 
   // -fsized-deallocation is off by default, as it is an ABI-breaking change for
-  // most platforms.
-  Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
-options::OPT_fno_sized_deallocation);
+  // most platforms. MSVC turns on /Zc:sizedDealloc by default, starting in
+  // MSVC 2015.
+  if (IsWindowsMSVC && IsMSVC2015Compatible &&
+  !Args.getLastArg(options::OPT_fsized_deallocation,
+   options::OPT_fno_sized_deallocation))
+CmdArgs.push_back("-fsized-deallocation");
+  else
+Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
+  options::OPT_fno_sized_deallocation);
 
   // -faligned-allocation is on by default in C++17 onwards and otherwise off
   // by default.
@@ -6635,6 +6645,8 @@
   CmdArgs.push_back("-fno-aligned-allocation");
 else
   CmdArgs.push_back("-faligned-allocation");
+  } else if (IsCPP17Onwards) {
+CmdArgs.push_back("-faligned-allocation");
   }
 
   // The default new alignment can be specified using a dedicated option or via
Index: clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
@@ -1,5 +1,10 @@
 // RUN: %check_clang_tidy %s misc-new-delete-overloads %t
 
+// MSVC turns on sized deallocations by default, so we unsupport this test
+// for windows.
+
+// UNSUPPORTED: system-windows
+
 typedef decltype(sizeof(int)) size_t;
 
 struct S {
___
cfe-commits mailing list

[PATCH] D130934: [clang] Update code that assumes FileEntry::getName is absolute NFC

2022-08-01 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4c6dc2e6637: [clang] Update code that assumes 
FileEntry::getName is absolute NFC (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130934

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -240,8 +240,7 @@
   // We do not want #line markers to affect dependency generation!
   if (Optional Filename =
   SM.getNonBuiltinFilenameForID(SM.getFileID(SM.getExpansionLoc(Loc
-MDC.FileDeps.push_back(
-std::string(llvm::sys::path::remove_leading_dotslash(*Filename)));
+MDC.addFileDep(llvm::sys::path::remove_leading_dotslash(*Filename));
 }
 
 void ModuleDepCollectorPP::InclusionDirective(
@@ -252,7 +251,7 @@
   if (!File && !Imported) {
 // This is a non-modular include that HeaderSearch failed to find. Add it
 // here as `FileChanged` will never see it.
-MDC.FileDeps.push_back(std::string(FileName));
+MDC.addFileDep(FileName);
   }
   handleImport(Imported);
 }
@@ -282,8 +281,7 @@
  ->getName());
 
   if (!MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
-MDC.FileDeps.push_back(
-MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
+MDC.addFileDep(MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
 
   for (const Module *M : DirectModularDeps) {
 // A top-level module might not be actually imported as a module when
@@ -346,10 +344,10 @@
 // handle it like normal. With explicitly built modules we don't need
 // to play VFS tricks, so replace it with the correct module map.
 if (IF.getFile()->getName().endswith("__inferred_module.map")) {
-  MD.FileDeps.insert(ModuleMap->getName());
+  MDC.addFileDep(MD, ModuleMap->getName());
   return;
 }
-MD.FileDeps.insert(IF.getFile()->getName());
+MDC.addFileDep(MD, IF.getFile()->getName());
   });
 
   // We usually don't need to list the module map files of our dependencies when
@@ -494,3 +492,24 @@
  PrebuiltModuleFileIt->second == M->getASTFile()->getName());
   return true;
 }
+
+static StringRef makeAbsolute(CompilerInstance , StringRef Path,
+  SmallVectorImpl ) {
+  if (llvm::sys::path::is_absolute(Path))
+return Path;
+  Storage.assign(Path.begin(), Path.end());
+  CI.getFileManager().makeAbsolutePath(Storage);
+  return StringRef(Storage.data(), Storage.size());
+}
+
+void ModuleDepCollector::addFileDep(StringRef Path) {
+  llvm::SmallString<256> Storage;
+  Path = makeAbsolute(ScanInstance, Path, Storage);
+  FileDeps.push_back(std::string(Path));
+}
+
+void ModuleDepCollector::addFileDep(ModuleDeps , StringRef Path) {
+  llvm::SmallString<256> Storage;
+  Path = makeAbsolute(ScanInstance, Path, Storage);
+  MD.FileDeps.insert(Path);
+}
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -28,8 +28,9 @@
 class DependencyConsumerForwarder : public DependencyFileGenerator {
 public:
   DependencyConsumerForwarder(std::unique_ptr Opts,
-  DependencyConsumer )
-  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), C(C) {}
+  StringRef WorkingDirectory, DependencyConsumer )
+  : DependencyFileGenerator(*Opts), WorkingDirectory(WorkingDirectory),
+Opts(std::move(Opts)), C(C) {}
 
   void finishedMainFile(DiagnosticsEngine ) override {
 C.handleDependencyOutputOpts(*Opts);
@@ -37,11 +38,13 @@
 for (const auto  : getDependencies()) {
   CanonPath = File;
   llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
+  llvm::sys::fs::make_absolute(WorkingDirectory, CanonPath);
   C.handleFileDependency(CanonPath);
 }
   }
 
 private:
+  StringRef WorkingDirectory;
   std::unique_ptr Opts;
   DependencyConsumer 
 };
@@ -221,8 +224,8 @@
 switch (Format) {
 case ScanningOutputFormat::Make:
   ScanInstance.addDependencyCollector(
-  std::make_shared(std::move(Opts),
-Consumer));
+  std::make_shared(
+  

[clang] b4c6dc2 - [clang] Update code that assumes FileEntry::getName is absolute NFC

2022-08-01 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2022-08-01T14:48:37-07:00
New Revision: b4c6dc2e66370d94ff52075c2710a674d8e1e0f8

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

LOG: [clang] Update code that assumes FileEntry::getName is absolute NFC

It's an accident that we started return asbolute paths from
FileEntry::getName for all relative paths. Prepare for getName to get
(closer to) return the requested path. Note: conceptually it might make
sense for the dependency scanner to allow relative paths and have the
DependencyConsumer decide if it wants to make them absolute, but we
currently document that it's absolute and I didn't want to change
behaviour here.

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

Added: 


Modified: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index cb5caf1ca92a1..9757d99cd789b 100644
--- 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -156,11 +156,15 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
 const tooling::TranslationUnitDiagnostics *SourceTU,
 const llvm::Optional BuildDir) {
 // Use the file manager to deduplicate paths. FileEntries are
-// automatically canonicalized.
-auto PrevWorkingDir = SM.getFileManager().getFileSystemOpts().WorkingDir;
+// automatically canonicalized. Since relative paths can come from 
diff erent
+// build directories, make them absolute immediately.
+SmallString<128> Path = R.getFilePath();
 if (BuildDir)
-  SM.getFileManager().getFileSystemOpts().WorkingDir = 
std::move(*BuildDir);
-if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
+  llvm::sys::fs::make_absolute(*BuildDir, Path);
+else
+  SM.getFileManager().makeAbsolutePath(Path);
+
+if (auto Entry = SM.getFileManager().getFile(Path)) {
   if (SourceTU) {
 auto  = DiagReplacements[*Entry];
 auto It = Replaces.find(R);
@@ -171,11 +175,10 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
   return;
   }
   GroupedReplacements[*Entry].push_back(R);
-} else if (Warned.insert(R.getFilePath()).second) {
+} else if (Warned.insert(Path).second) {
   errs() << "Described file '" << R.getFilePath()
  << "' doesn't exist. Ignoring...\n";
 }
-SM.getFileManager().getFileSystemOpts().WorkingDir = PrevWorkingDir;
   };
 
   for (const auto  : TUs)

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 377dcd5a68fec..f4f13a34b1746 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -233,6 +233,11 @@ class ModuleDepCollector final : public 
DependencyCollector {
   /// Checks whether the module is known as being prebuilt.
   bool isPrebuiltModule(const Module *M);
 
+  /// Adds \p Path to \c FileDeps, making it absolute if necessary.
+  void addFileDep(StringRef Path);
+  /// Adds \p Path to \c MD.FileDeps, making it absolute if necessary.
+  void addFileDep(ModuleDeps , StringRef Path);
+
   /// Constructs a CompilerInvocation that can be used to build the given
   /// module, excluding paths to discovered modular dependencies that are yet 
to
   /// be built.

diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index 474808d888ec2..c84919138612a 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -28,8 +28,9 @@ namespace {
 class DependencyConsumerForwarder : public DependencyFileGenerator {
 public:
   DependencyConsumerForwarder(std::unique_ptr Opts,
-  DependencyConsumer )
-  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), C(C) {}
+  StringRef WorkingDirectory, DependencyConsumer 
)
+  : DependencyFileGenerator(*Opts), WorkingDirectory(WorkingDirectory),
+Opts(std::move(Opts)), C(C) {}
 
   void finishedMainFile(DiagnosticsEngine ) override {

[PATCH] D130936: [SemaCXX] Validate destructor is valid for dependent classes

2022-08-01 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson updated this revision to Diff 449130.
royjacobson added a comment.
royjacobson retitled this revision from "[SemaCXX] Fix destructor name 
accepts-invalid bug." to "[SemaCXX] Validate destructor is valid for dependent 
classes".
royjacobson edited the summary of this revision.
royjacobson added reviewers: erichkeane, shafik.
royjacobson published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix the C++20 check


We didn't check that a destructor's name matches the directly enclosing class 
if the class was dependent.
I enabled the check we already had for non-dependent types, which seems to 
work. Added appropriate tests.

Fixes GitHub issue #56772


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130936

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/member-class-11.cpp


Index: clang/test/SemaCXX/member-class-11.cpp
===
--- clang/test/SemaCXX/member-class-11.cpp
+++ clang/test/SemaCXX/member-class-11.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
 
 struct rdar9677163 {
   struct Y { ~Y(); };
@@ -6,3 +8,22 @@
   Y::~Y() { } // expected-error{{non-friend class member '~Y' cannot have a 
qualified name}}
   ~Z(); // expected-error{{expected the class name after '~' to name the 
enclosing class}}
 };
+
+namespace GH56772 {
+
+template
+struct A {
+  ~A();
+};
+#if __cplusplus >= 202002L
+// FIXME: This isn't valid in C++20 and later.
+#endif
+
+struct B;
+
+template
+struct C {
+  ~B(); // expected-error {{expected the class name after '~' to name the 
enclosing class}}
+};
+
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11496,17 +11496,12 @@
   CXXRecordDecl *Record = Destructor->getParent();
   QualType ClassType = Context.getTypeDeclType(Record);
 
-  // FIXME: Shouldn't we be able to perform this check even when the class
-  // type is dependent? Both gcc and edg can handle that.
-  if (!ClassType->isDependentType()) {
-DeclarationName Name
-  = Context.DeclarationNames.getCXXDestructorName(
-Context.getCanonicalType(ClassType));
-if (NewFD->getDeclName() != Name) {
-  Diag(NewFD->getLocation(), diag::err_destructor_name);
-  NewFD->setInvalidDecl();
-  return Redeclaration;
-}
+  DeclarationName Name = Context.DeclarationNames.getCXXDestructorName(
+  Context.getCanonicalType(ClassType));
+  if (NewFD->getDeclName() != Name) {
+Diag(NewFD->getLocation(), diag::err_destructor_name);
+NewFD->setInvalidDecl();
+return Redeclaration;
   }
 } else if (auto *Guide = dyn_cast(NewFD)) {
   if (auto *TD = Guide->getDescribedFunctionTemplate())


Index: clang/test/SemaCXX/member-class-11.cpp
===
--- clang/test/SemaCXX/member-class-11.cpp
+++ clang/test/SemaCXX/member-class-11.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
 
 struct rdar9677163 {
   struct Y { ~Y(); };
@@ -6,3 +8,22 @@
   Y::~Y() { } // expected-error{{non-friend class member '~Y' cannot have a qualified name}}
   ~Z(); // expected-error{{expected the class name after '~' to name the enclosing class}}
 };
+
+namespace GH56772 {
+
+template
+struct A {
+  ~A();
+};
+#if __cplusplus >= 202002L
+// FIXME: This isn't valid in C++20 and later.
+#endif
+
+struct B;
+
+template
+struct C {
+  ~B(); // expected-error {{expected the class name after '~' to name the enclosing class}}
+};
+
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11496,17 +11496,12 @@
   CXXRecordDecl *Record = Destructor->getParent();
   QualType ClassType = Context.getTypeDeclType(Record);
 
-  // FIXME: Shouldn't we be able to perform this check even when the class
-  // type is dependent? Both gcc and edg can handle that.
-  if (!ClassType->isDependentType()) {
-DeclarationName Name
-  = Context.DeclarationNames.getCXXDestructorName(
-Context.getCanonicalType(ClassType));
-if (NewFD->getDeclName() != Name) {
-  Diag(NewFD->getLocation(), diag::err_destructor_name);
-  NewFD->setInvalidDecl();
-  return Redeclaration;
-}
+  

[PATCH] D129954: [CodeGen][inlineasm] assume the flag output of inline asm is boolean value

2022-08-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.

Thanks for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129954

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


[PATCH] D130516: [llvm] compression classes

2022-08-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

(still lots of outstanding comments from my last round, so I won't reiterate 
those - but waiting for some responses to them)




Comment at: llvm/lib/Support/Compression.cpp:30-32
+ZStdCompressionAlgorithm
+*llvm::compression::ZStdCompressionAlgorithm::Instance =
+new ZStdCompressionAlgorithm();

ckissane wrote:
> dblaikie wrote:
> > leonardchan wrote:
> > > Perhaps for each of these, you could instead have something like:
> > > 
> > > ```
> > > ZStdCompressionAlgorithm *getZStdCompressionAlgorithm() {
> > >   static ZStdCompressionAlgorithm* instance = new 
> > > ZStdCompressionAlgorithm;
> > >   return instance;
> > > }
> > > ```
> > > 
> > > This way the instances are only new'd when they're actually used.
> > Yep, I'd mentioned/suggested that (so, seconding here) elsewhere 
> > encouraging these to be singletons: https://reviews.llvm.org/D130516#3683384
> > 
> > And they don't even need to be 'new'd in that case, this would be fine:
> > ```
> > ZstdCompressionAlgorithm () {
> >   static ZstdCompressionAlgorithm C;
> >   return C;
> > }
> > ```
> > 
> > Though I think maybe we don't need individual access to the algorithms, and 
> > it'd be fine to have only a single entry point like this:
> > ```
> > CompressionAlgorithm *getCompressionAlgorithm(DebugCompressionType T) {
> >   switch (T) {
> >   case DebugCompressionType::ZStd: {
> > static zstd::CompressionAlgorithm Zstd;
> > if (zstd::isAvailable())
> >   return 
> >   }
> >   ...
> >   }
> >   return nullptr;
> > }
> > ```
> > (or, possibly, we want to return non-null even if it isn't available, if we 
> > include other things (like the configure macro name - so callers can use 
> > that name to print helpful error messages - but then they have to 
> > explicitly check if the algorithm is available after the call))
> they currently already have singleton behavior i.e. 
> `llvm::compression::ZStdCompressionAlgorithm::Instance` is the only place 
> `new ZStdCompressionAlgorithm()` can be put into because the constructor is 
> protected.
> 
> I'd rather not achieve "This way the instances are only new'd when they're 
> actually used."
> Because the rewards of that are relatively small, but it will make the code 
> more verbose, I think the current pattern allows the best of both worlds of 
> the namespace approach:
> (`llvm::compression::zlib::compress` becomes 
> `llvm::compression::ZlibCompression->compress`)
> but they can be passed as class instances.
Global constructors are to be avoided in LLVM: 
https://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors
(also these objects don't need to be dynamically allocated with `new` - they 
can be directly allocated (as static locals though, not as globals))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130516

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


[PATCH] D130754: [X86] Support ``-mindirect-branch-cs-prefix`` for call and jmp to indirect thunk

2022-08-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

LGTM; thanks for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130754

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


[PATCH] D130935: [clang] Only modify FileEntryRef names that are externally remapped

2022-08-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 449124.
benlangmuir added a comment.

Flip the order of comparisons to avoid unnecessary string comparisons.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130935

Files:
  clang/lib/Basic/FileManager.cpp
  clang/unittests/Basic/FileManagerTest.cpp


Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -44,16 +44,16 @@
   }
 }
 
-if (!StatPath)
-  StatPath = Path;
-
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath ? StatPath : Path,
+ llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
+if (StatPath)
+  Status.ExposesExternalVFSPath = true;
 StatCalls[Path] = Status;
   }
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -274,8 +274,8 @@
   if (!UFE)
 UFE = new (FilesAlloc.Allocate()) FileEntry();
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (!Status.ExposesExternalVFSPath || Status.getName() == Filename) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
   } else {
 // Name mismatch. We need a redirect. First grab the actual entry we want
@@ -292,19 +292,7 @@
 // filesystems behave and confuses parts of clang expect to see the
 // name-as-accessed on the \a FileEntryRef.
 //
-// Further, it isn't *just* external names, but will also give back 
absolute
-// paths when a relative path was requested - the check is comparing the
-// name from the status, which is passed an absolute path resolved from the
-// current working directory. `clang-apply-replacements` appears to depend
-// on this behaviour, though it's adjusting the working directory, which is
-// definitely not supported. Once that's fixed this hack should be able to
-// be narrowed to only when there's an externally mapped name given back.
-//
 // A potential plan to remove this is as follows -
-//   - Add API to determine if the name has been rewritten by the VFS.
-//   - Fix `clang-apply-replacements` to pass down the absolute path rather
-// than changing the CWD. Narrow this hack down to just externally
-// mapped paths.
 //   - Expose the requested filename. One possibility would be to allow
 // redirection-FileEntryRefs to be returned, rather than returning
 // the pointed-at-FileEntryRef, and customizing `getName()` to look


Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -44,16 +44,16 @@
   }
 }
 
-if (!StatPath)
-  StatPath = Path;
-
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath ? StatPath : Path,
+ llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
+if (StatPath)
+  Status.ExposesExternalVFSPath = true;
 StatCalls[Path] = Status;
   }
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -274,8 +274,8 @@
   if (!UFE)
 UFE = new (FilesAlloc.Allocate()) FileEntry();
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (!Status.ExposesExternalVFSPath || Status.getName() == Filename) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
   } else {
 // Name mismatch. We need a redirect. First grab the actual entry we want
@@ -292,19 +292,7 @@
 // filesystems behave and confuses parts of clang expect to see the
 // name-as-accessed on the \a FileEntryRef.
 //
-// Further, it isn't *just* external names, but will also give back absolute
-// paths when a relative path was requested - the 

[clang] 4b8f375 - [clang] Temporarily expect failure from test

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T21:11:21Z
New Revision: 4b8f375c9f9ece32106da899bc2debf31ed20970

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

LOG: [clang] Temporarily expect failure from test

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 401564013563..2643ad871835 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,4 +1,5 @@
 // REQUIRES: lld
+// XFAIL: *
 
 // RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s



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


[PATCH] D130791: [clang] Short-circuit trivial constexpr array constructors

2022-08-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> Thank you for working on this! This should also include test coverage (hmmm, 
> we don't have a reasonable way to lit test performance regressions though 
> so perhaps we just need to ensure there's at least one test that would 
> normally have been unreasonably slow?) and a release note.

I think generally for pure-perf fixes we don't include any testing. (like 
switching a container type, adding caching, etc) But may be worth 
double-checking that there's reasonable test coverage for the feature.

also: What about zero length arrays? (which are supported as an extension) - 
this change would cause failures that wouldn't be emitted in the old code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130791

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


[PATCH] D130935: [clang] Only modify FileEntryRef names that are externally remapped

2022-08-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:277-278
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (Status.getName() == Filename || !Status.ExposesExternalVFSPath) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);

bnbarham wrote:
> Is it possible for an `ExposesExternalVFSPath` to have the same filename as 
> the one that was requested? Just in the case of mapping `A -> A` or something 
> equally pointless? Could check for that in the VFS, but probably doesn't 
> matter in the long run.
I think in practice it won't happen, but in theory the VFS can do whatever it 
wants, so I didn't want to introduce any possibility of circularity here.  I 
will flip these checks so the boolean comes before the string compare though, 
since that will be cheaper.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130935

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


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120175#3692032 , @thakis wrote:

> This breaks tests on mac and win:
> http://45.33.8.238/macm1/41545/step_7.txt
> http://45.33.8.238/win/63579/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

Should be fixed in 
https://github.com/llvm/llvm-project/commit/9028966a717239cf586d6c4f606965d444176dc4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[clang] 9028966 - [clang] Don't create executable in test

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T20:59:40Z
New Revision: 9028966a717239cf586d6c4f606965d444176dc4

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

LOG: [clang] Don't create executable in test

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index c0a4e14d2437..401564013563 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,6 +1,6 @@
 // REQUIRES: lld
 
-// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +13,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 
2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:



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


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on mac and win:
http://45.33.8.238/macm1/41545/step_7.txt
http://45.33.8.238/win/63579/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[PATCH] D130935: [clang] Only modify FileEntryRef names that are externally remapped

2022-08-01 Thread Ben Barham via Phabricator via cfe-commits
bnbarham accepted this revision.
bnbarham added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Basic/FileManager.cpp:277-278
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (Status.getName() == Filename || !Status.ExposesExternalVFSPath) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);

Is it possible for an `ExposesExternalVFSPath` to have the same filename as the 
one that was requested? Just in the case of mapping `A -> A` or something 
equally pointless? Could check for that in the VFS, but probably doesn't matter 
in the long run.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130935

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


[PATCH] D130800: [clang][Headers] Avoid compiler warnings in builtin headers

2022-08-01 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 449118.
ddcc added a comment.

Undef macros instead, handle other header files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130800

Files:
  clang/lib/Headers/__clang_cuda_builtin_vars.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/cuda_wrappers/algorithm
  clang/lib/Headers/cuda_wrappers/complex
  clang/lib/Headers/cuda_wrappers/new
  clang/lib/Headers/float.h
  clang/lib/Headers/limits.h
  clang/lib/Headers/openmp_wrappers/new
  clang/lib/Headers/stdarg.h
  clang/lib/Headers/stdatomic.h
  clang/lib/Headers/stdbool.h
  clang/lib/Headers/stddef.h
  clang/lib/Headers/stdint.h
  clang/lib/Headers/stdnoreturn.h
  clang/lib/Headers/velintrin.h

Index: clang/lib/Headers/velintrin.h
===
--- clang/lib/Headers/velintrin.h
+++ clang/lib/Headers/velintrin.h
@@ -13,7 +13,7 @@
 typedef double __vr __attribute__((__vector_size__(2048)));
 
 // Vector mask registers
-#if __STDC_VERSION__ >= 199901L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
 // For C99
 typedef _Bool __vm__attribute__((ext_vector_type(256)));
 typedef _Bool __vm256 __attribute__((ext_vector_type(256)));
Index: clang/lib/Headers/stdnoreturn.h
===
--- clang/lib/Headers/stdnoreturn.h
+++ clang/lib/Headers/stdnoreturn.h
@@ -13,7 +13,7 @@
 #define noreturn _Noreturn
 #define __noreturn_is_defined 1
 
-#if __STDC_VERSION__ > 201710L &&  \
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L) &&   \
 !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
 /* The noreturn macro is deprecated in C2x. We do not mark it as such because
including the header file in C2x is also deprecated and we do not want to
Index: clang/lib/Headers/stdint.h
===
--- clang/lib/Headers/stdint.h
+++ clang/lib/Headers/stdint.h
@@ -96,13 +96,21 @@
 typedef __INT64_TYPE__ int64_t;
 # endif /* __int8_t_defined */
 typedef __UINT64_TYPE__ uint64_t;
+# undef __int_least64_t
 # define __int_least64_t int64_t
+# undef __uint_least64_t
 # define __uint_least64_t uint64_t
+# undef __int_least32_t
 # define __int_least32_t int64_t
+# undef __uint_least32_t
 # define __uint_least32_t uint64_t
+# undef __int_least16_t
 # define __int_least16_t int64_t
+# undef __uint_least16_t
 # define __uint_least16_t uint64_t
+# undef __int_least8_t
 # define __int_least8_t int64_t
+# undef __uint_least8_t
 # define __uint_least8_t uint64_t
 #endif /* __INT64_TYPE__ */
 
@@ -120,11 +128,17 @@
 typedef uint56_t uint_least56_t;
 typedef int56_t int_fast56_t;
 typedef uint56_t uint_fast56_t;
+# undef __int_least32_t
 # define __int_least32_t int56_t
+# undef __uint_least32_t
 # define __uint_least32_t uint56_t
+# undef __int_least16_t
 # define __int_least16_t int56_t
+# undef __uint_least16_t
 # define __uint_least16_t uint56_t
+# undef __int_least8_t
 # define __int_least8_t int56_t
+# undef __uint_least8_t
 # define __uint_least8_t uint56_t
 #endif /* __INT56_TYPE__ */
 
@@ -136,11 +150,17 @@
 typedef uint48_t uint_least48_t;
 typedef int48_t int_fast48_t;
 typedef uint48_t uint_fast48_t;
+# undef __int_least32_t
 # define __int_least32_t int48_t
+# undef __uint_least32_t
 # define __uint_least32_t uint48_t
+# undef __int_least16_t
 # define __int_least16_t int48_t
+# undef __uint_least16_t
 # define __uint_least16_t uint48_t
+# undef __int_least8_t
 # define __int_least8_t int48_t
+# undef __uint_least8_t
 # define __uint_least8_t uint48_t
 #endif /* __INT48_TYPE__ */
 
@@ -152,11 +172,17 @@
 typedef uint40_t uint_least40_t;
 typedef int40_t int_fast40_t;
 typedef uint40_t uint_fast40_t;
+# undef __int_least32_t
 # define __int_least32_t int40_t
+# undef __uint_least32_t
 # define __uint_least32_t uint40_t
+# undef __int_least16_t
 # define __int_least16_t int40_t
+# undef __uint_least16_t
 # define __uint_least16_t uint40_t
+# undef __int_least8_t
 # define __int_least8_t int40_t
+# undef __uint_least8_t
 # define __uint_least8_t uint40_t
 #endif /* __INT40_TYPE__ */
 
@@ -172,11 +198,17 @@
 typedef __UINT32_TYPE__ uint32_t;
 # endif /* __uint32_t_defined */
 
+# undef __int_least32_t
 # define __int_least32_t int32_t
+# undef __uint_least32_t
 # define __uint_least32_t uint32_t
+# undef __int_least16_t
 # define __int_least16_t int32_t
+# undef __uint_least16_t
 # define __uint_least16_t uint32_t
+# undef __int_least8_t
 # define __int_least8_t int32_t
+# undef __uint_least8_t
 # define __uint_least8_t uint32_t
 #endif /* __INT32_TYPE__ */
 
@@ -194,9 +226,13 @@
 typedef uint24_t uint_least24_t;
 typedef int24_t int_fast24_t;
 typedef uint24_t uint_fast24_t;
+# undef __int_least16_t
 # define 

[PATCH] D130934: [clang] Update code that assumes FileEntry::getName is absolute NFC

2022-08-01 Thread Ben Barham via Phabricator via cfe-commits
bnbarham accepted this revision.
bnbarham added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for doing this 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130934

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


[PATCH] D130935: [clang] Only modify FileEntryRef names that are externally remapped

2022-08-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: bnbarham, jansvoboda11.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As progress towards having FileEntryRef contain the requested name of the file, 
this commit narrows the "remap" hack to only apply to paths that were remapped 
to an external contents path by a VFS. That was always the original intent of 
this code, and the fact it was making relative paths absolute was an unintended 
side effect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130935

Files:
  clang/lib/Basic/FileManager.cpp
  clang/unittests/Basic/FileManagerTest.cpp


Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -44,16 +44,16 @@
   }
 }
 
-if (!StatPath)
-  StatPath = Path;
-
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath ? StatPath : Path,
+ llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
+if (StatPath)
+  Status.ExposesExternalVFSPath = true;
 StatCalls[Path] = Status;
   }
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -274,8 +274,8 @@
   if (!UFE)
 UFE = new (FilesAlloc.Allocate()) FileEntry();
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (Status.getName() == Filename || !Status.ExposesExternalVFSPath) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
   } else {
 // Name mismatch. We need a redirect. First grab the actual entry we want
@@ -292,19 +292,7 @@
 // filesystems behave and confuses parts of clang expect to see the
 // name-as-accessed on the \a FileEntryRef.
 //
-// Further, it isn't *just* external names, but will also give back 
absolute
-// paths when a relative path was requested - the check is comparing the
-// name from the status, which is passed an absolute path resolved from the
-// current working directory. `clang-apply-replacements` appears to depend
-// on this behaviour, though it's adjusting the working directory, which is
-// definitely not supported. Once that's fixed this hack should be able to
-// be narrowed to only when there's an externally mapped name given back.
-//
 // A potential plan to remove this is as follows -
-//   - Add API to determine if the name has been rewritten by the VFS.
-//   - Fix `clang-apply-replacements` to pass down the absolute path rather
-// than changing the CWD. Narrow this hack down to just externally
-// mapped paths.
 //   - Expose the requested filename. One possibility would be to allow
 // redirection-FileEntryRefs to be returned, rather than returning
 // the pointed-at-FileEntryRef, and customizing `getName()` to look


Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -44,16 +44,16 @@
   }
 }
 
-if (!StatPath)
-  StatPath = Path;
-
 auto fileType = IsFile ?
   llvm::sys::fs::file_type::regular_file :
   llvm::sys::fs::file_type::directory_file;
-llvm::vfs::Status Status(StatPath, llvm::sys::fs::UniqueID(1, INode),
+llvm::vfs::Status Status(StatPath ? StatPath : Path,
+ llvm::sys::fs::UniqueID(1, INode),
  /*MTime*/{}, /*User*/0, /*Group*/0,
  /*Size*/0, fileType,
  llvm::sys::fs::perms::all_all);
+if (StatPath)
+  Status.ExposesExternalVFSPath = true;
 StatCalls[Path] = Status;
   }
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -274,8 +274,8 @@
   if (!UFE)
 UFE = new (FilesAlloc.Allocate()) FileEntry();
 
-  if (Status.getName() == Filename) {
-// The name matches. Set the FileEntry.
+  if (Status.getName() == Filename || !Status.ExposesExternalVFSPath) {
+// Use the requested name. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
   } else {
 // Name 

[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120175#3691843 , @MaskRay wrote:

> LGTM
>
> (Note: This is a patch which I think would benefit from a second look and 
> 2.5h from approval to push was too short for others to react on this patch.)

Ack, I'll give more time in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[clang] 1ccded0 - [clang] Fix build when targeting ps4

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T20:31:01Z
New Revision: 1ccded0fc111700f72ffa36b5d0160a86c65ec3a

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

LOG: [clang] Fix build when targeting ps4

-fuse-ld is not available for ps4 targets

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index f558b780fb23..c0a4e14d2437 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,6 +1,6 @@
 // REQUIRES: lld
 
-// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +13,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:



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


[PATCH] D130934: [clang] Update code that assumes FileEntry::getName is absolute NFC

2022-08-01 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: bnbarham, jansvoboda11.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

It's an accident that we started return asbolute paths from FileEntry::getName 
for all relative paths. Prepare for getName to get (closer to) return the 
requested path. Note: conceptually it might make sense for the dependency 
scanner to allow relative paths and have the DependencyConsumer decide if it 
wants to make them absolute, but we currently document that it's absolute and I 
didn't want to change behaviour here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130934

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -240,8 +240,7 @@
   // We do not want #line markers to affect dependency generation!
   if (Optional Filename =
   SM.getNonBuiltinFilenameForID(SM.getFileID(SM.getExpansionLoc(Loc
-MDC.FileDeps.push_back(
-std::string(llvm::sys::path::remove_leading_dotslash(*Filename)));
+MDC.addFileDep(llvm::sys::path::remove_leading_dotslash(*Filename));
 }
 
 void ModuleDepCollectorPP::InclusionDirective(
@@ -252,7 +251,7 @@
   if (!File && !Imported) {
 // This is a non-modular include that HeaderSearch failed to find. Add it
 // here as `FileChanged` will never see it.
-MDC.FileDeps.push_back(std::string(FileName));
+MDC.addFileDep(FileName);
   }
   handleImport(Imported);
 }
@@ -282,8 +281,7 @@
  ->getName());
 
   if (!MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
-MDC.FileDeps.push_back(
-MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
+MDC.addFileDep(MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
 
   for (const Module *M : DirectModularDeps) {
 // A top-level module might not be actually imported as a module when
@@ -346,10 +344,10 @@
 // handle it like normal. With explicitly built modules we don't need
 // to play VFS tricks, so replace it with the correct module map.
 if (IF.getFile()->getName().endswith("__inferred_module.map")) {
-  MD.FileDeps.insert(ModuleMap->getName());
+  MDC.addFileDep(MD, ModuleMap->getName());
   return;
 }
-MD.FileDeps.insert(IF.getFile()->getName());
+MDC.addFileDep(MD, IF.getFile()->getName());
   });
 
   // We usually don't need to list the module map files of our dependencies when
@@ -494,3 +492,24 @@
  PrebuiltModuleFileIt->second == M->getASTFile()->getName());
   return true;
 }
+
+static StringRef makeAbsolute(CompilerInstance , StringRef Path,
+  SmallVectorImpl ) {
+  if (llvm::sys::path::is_absolute(Path))
+return Path;
+  Storage.assign(Path.begin(), Path.end());
+  CI.getFileManager().makeAbsolutePath(Storage);
+  return StringRef(Storage.data(), Storage.size());
+}
+
+void ModuleDepCollector::addFileDep(StringRef Path) {
+  llvm::SmallString<256> Storage;
+  Path = makeAbsolute(ScanInstance, Path, Storage);
+  FileDeps.push_back(std::string(Path));
+}
+
+void ModuleDepCollector::addFileDep(ModuleDeps , StringRef Path) {
+  llvm::SmallString<256> Storage;
+  Path = makeAbsolute(ScanInstance, Path, Storage);
+  MD.FileDeps.insert(Path);
+}
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -28,8 +28,9 @@
 class DependencyConsumerForwarder : public DependencyFileGenerator {
 public:
   DependencyConsumerForwarder(std::unique_ptr Opts,
-  DependencyConsumer )
-  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), C(C) {}
+  StringRef WorkingDirectory, DependencyConsumer )
+  : DependencyFileGenerator(*Opts), WorkingDirectory(WorkingDirectory),
+Opts(std::move(Opts)), C(C) {}
 
   void finishedMainFile(DiagnosticsEngine ) override {
 C.handleDependencyOutputOpts(*Opts);
@@ -37,11 +38,13 @@
 for (const auto  : getDependencies()) {
   CanonPath = File;
   llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
+  llvm::sys::fs::make_absolute(WorkingDirectory, CanonPath);
   

[PATCH] D130933: Add docs for function attributes hot/cold

2022-08-01 Thread Ofek Shilon via Phabricator via cfe-commits
OfekShilon created this revision.
OfekShilon added reviewers: xur, davidxl.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
OfekShilon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Following this , add docs for the hot/cold 
function attributes


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130933

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -5241,6 +5241,22 @@
 }];
 }
 
+def HotFunctionEntryDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((hot))`` marks a function as hot, as a manual alternative to 
PGO hotness data. 
+In case PGO data is available too user annotated ``__attribute__((hot))`` 
overwrites profile count based hotness (unlike ``__attribute__((cold))``).
+}];
+}
+
+def ColdFunctionEntryDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((cold))`` marks a function as cold, as a manual alternative to 
PGO hotness data. 
+In case PGO data is available too profile count based hotness overwrites user 
annotated ``__attribute__((cold))`` (unlike ``__attribute__((hot))``).
+}];
+}
+
 def TransparentUnionDocs : Documentation {
   let Category = DocCatDecl;
   let Content = [{
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1073,8 +1073,7 @@
 def Cold : InheritableAttr {
   let Spellings = [GCC<"cold">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
-  let SimpleHandler = 1;
+  let Documentation = [ColdFunctionEntryDocs];
 }
 
 def Common : InheritableAttr {
@@ -1519,8 +1518,7 @@
 def Hot : InheritableAttr {
   let Spellings = [GCC<"hot">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
-  let SimpleHandler = 1;
+  let Documentation = [HotFunctionEntryDocs];
 }
 def : MutualExclusions<[Hot, Cold]>;
 


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -5241,6 +5241,22 @@
 }];
 }
 
+def HotFunctionEntryDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((hot))`` marks a function as hot, as a manual alternative to PGO hotness data. 
+In case PGO data is available too user annotated ``__attribute__((hot))`` overwrites profile count based hotness (unlike ``__attribute__((cold))``).
+}];
+}
+
+def ColdFunctionEntryDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((cold))`` marks a function as cold, as a manual alternative to PGO hotness data. 
+In case PGO data is available too profile count based hotness overwrites user annotated ``__attribute__((cold))`` (unlike ``__attribute__((hot))``).
+}];
+}
+
 def TransparentUnionDocs : Documentation {
   let Category = DocCatDecl;
   let Content = [{
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1073,8 +1073,7 @@
 def Cold : InheritableAttr {
   let Spellings = [GCC<"cold">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
-  let SimpleHandler = 1;
+  let Documentation = [ColdFunctionEntryDocs];
 }
 
 def Common : InheritableAttr {
@@ -1519,8 +1518,7 @@
 def Hot : InheritableAttr {
   let Spellings = [GCC<"hot">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
-  let SimpleHandler = 1;
+  let Documentation = [HotFunctionEntryDocs];
 }
 def : MutualExclusions<[Hot, Cold]>;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LGTM

(Note: I think 2.5h from approval to push was too short for others to react on 
this patch.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5fd03b00ee02: [Driver] Re-run lld with --reproduce when it 
crashes (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Compilation.h
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/lit.local.cfg
  clang/test/Driver/lld-repro.c

Index: clang/test/Driver/lld-repro.c
===
--- /dev/null
+++ clang/test/Driver/lld-repro.c
@@ -0,0 +1,26 @@
+// REQUIRES: lld
+
+// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN:   | FileCheck %s
+
+// check that we still get lld's output
+// CHECK: error: undefined symbol: a
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.c
+// CHECK-NEXT: note: diagnostic msg: {{.*}}/linker-crash-{{.*}}.tar
+// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.sh
+// CHECK-NEXT: note: diagnostic msg:
+// CHECK: 
+
+// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-LINKER
+// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-LINKER
+
+// NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are located at:
+
+extern int a;
+int main() {
+  return a;
+}
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,3 +1,5 @@
+from lit.llvm import llvm_config
+
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
'.cu', '.rs', '.cl', '.clcpp', '.hip', '.hlsl']
 config.substitutions = list(config.substitutions)
@@ -16,3 +18,6 @@
 for name in driver_overwrite_env_vars:
   if name in config.environment:
 del config.environment[name]
+
+if llvm_config.use_lld(required=False):
+config.available_features.add('lld')
Index: clang/test/Driver/crash-report.cpp
===
--- clang/test/Driver/crash-report.cpp
+++ clang/test/Driver/crash-report.cpp
@@ -27,6 +27,29 @@
 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
 
+// Test manually specifying -fcrash-diagnostics[=[compiler|all]] emits
+// diagnostics
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1  \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \
+// RUN:  not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics 2>&1 |\
+// RUN:  FileCheck %s
+// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1   \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1  \
+// RUN:  not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics=compiler 2>&1 |\
+// RUN:  FileCheck %s
+// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1  \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \
+// RUN:  not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics=all 2>&1 |\
+// RUN:  FileCheck %s
+// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
 // REQUIRES: crash-recovery
 
 #ifdef PARSER
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1507,11 +1507,36 @@
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
-  // Don't try to generate diagnostics for link or dsymutil jobs.
-  if (FailingCommand.getCreator().isLinkJob() ||
-  FailingCommand.getCreator().isDsymutilJob())
+  unsigned Level = 1;
+  if (Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_EQ)) {
+Level = llvm::StringSwitch(A->getValue())
+.Case("off", 0)
+.Case("compiler", 1)
+.Case("all", 2)
+.Default(1);
+  }
+  if (!Level)
 return;
 
+ 

[clang] 5fd03b0 - [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T20:01:01Z
New Revision: 5fd03b00ee029b4cc958ae8e6c970a6123bd12f6

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

LOG: [Driver] Re-run lld with --reproduce when it crashes

This was discussed on 
https://discourse.llvm.org/t/rfc-generating-lld-reproducers-on-crashes/58071/12

When lld crashes, or errors when -gen-reproducer=error
and -fcrash-diagnostics=all clang will re-run lld with
--reproduce=$temp_file for easily reproducing the
crash/error.

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

Added: 
clang/test/Driver/lld-repro.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Driver/Compilation.h
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/crash-report.cpp
clang/test/Driver/lit.local.cfg

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 1d11b00a1a78d..15df488e802de 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -667,6 +667,14 @@ a crash. These files should be attached to a bug report to 
ease
 reproducibility of the failure. Below are the command line options to
 control the crash diagnostics.
 
+.. option:: -fcrash-diagnostics=
+
+  Valid values are:
+
+  * ``off`` (Disable auto-generation of preprocessed source files during a 
clang crash.)
+  * ``compiler`` (Generate diagnostics for compiler crashes (default))
+  * ``all`` (Generate diagnostics for all tools which support it)
+
 .. option:: -fno-crash-diagnostics
 
   Disable auto-generation of preprocessed source files during a clang crash.

diff  --git a/clang/include/clang/Driver/Compilation.h 
b/clang/include/clang/Driver/Compilation.h
index c5714d3208884..842efda9f0774 100644
--- a/clang/include/clang/Driver/Compilation.h
+++ b/clang/include/clang/Driver/Compilation.h
@@ -216,6 +216,7 @@ class Compilation {
 
   void addCommand(std::unique_ptr C) { Jobs.addJob(std::move(C)); }
 
+  llvm::opt::ArgStringList () { return TempFiles; }
   const llvm::opt::ArgStringList () const { return TempFiles; }
 
   const ArgStringMap () const { return ResultFiles; }

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 0781d476ec4a0..59c2f1f52cecf 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -600,6 +600,11 @@ class Driver {
   /// Returns the default name for linked images (e.g., "a.out").
   const char *getDefaultImageName() const;
 
+  // Creates a temp file with $Prefix-%%.$Suffix
+  const char *CreateTempFile(Compilation , StringRef Prefix, StringRef 
Suffix,
+ bool MultipleArchs = false,
+ StringRef BoundArch = {}) const;
+
   /// GetNamedOutputPath - Return the name to use for the output of
   /// the action \p JA. The result is appended to the compilation's
   /// list of temporary or result files, as appropriate.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1718234a56988..3312f999a33f7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1433,6 +1433,10 @@ def fexperimental_new_constant_interpreter : Flag<["-"], 
"fexperimental-new-cons
   MarshallingInfoFlag>;
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">,
 Group;
+def fcrash_diagnostics_EQ : Joined<["-"], "fcrash-diagnostics=">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Set level of crash diagnostic reporting, (option: off, compiler, 
all)">;
+def fcrash_diagnostics : Flag<["-"], "fcrash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Enable crash diagnostic reporting (default)">, 
Alias, AliasArgs<["compiler"]>;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
   Alias, AliasArgs<["off"]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3f29afd359718..7c727ba65ada6 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1507,11 +1507,36 @@ void Driver::generateCompilationDiagnostics(
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
-  // Don't try to generate diagnostics for link or dsymutil jobs.
-  if (FailingCommand.getCreator().isLinkJob() ||
-  FailingCommand.getCreator().isDsymutilJob())
+  unsigned Level = 1;
+  if (Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_EQ)) {
+Level = 

[PATCH] D130041: [clangd] Add decl/def support to SymbolDetails

2022-08-01 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

Ah my bad didn't realize you hadn't accepted this, was there anything else you 
wanted me to change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130041

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


[PATCH] D130863: [clangd] Make git ignore index directories

2022-08-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

My 2c, though I'm away with kids right now so will leave to @kadircet to make a 
call

Given that this is fully contained (logically and physically) within clangd's 
index directory, this seems elegant and harmless to me.

(At first i thought it was modifying project-level .gitignores, which would be 
scary).

In D130863#3690275 , @kadircet wrote:

> I am not sure if clangd is the right tool the create those `.gitignore` 
> files, e.g. what if the project's VCS isn't git?

The wrong-tool/slippery-slope argument is legitimate. I'd be pretty comfortable 
personally drawing the line at "git and nothing else" though.

> I believe the right thing to do is for projects that want to make use of such 
> tools to ignore the relevant directory explicitly (e.g. `.cache).

It would be great if there were some general "transient" name patterns that 
were implicitly ignored. Sadly not the case AFAIK




Comment at: clang-tools-extra/clangd/test/background-index.test:23
+# RUN: ls %/t/.cache/clangd/index/.gitignore
+# RUN: ls %/t/sub_dir/.cache/clangd/index/.gitignore
+

Bleh, ideally this would go in clangd/.gitignore but we'd have to break a bunch 
of abstractions to do that. I think this is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130863

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


[PATCH] D130791: [clang] Short-circuit trivial constexpr array constructors

2022-08-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this! This should also include test coverage (hmmm, we 
don't have a reasonable way to lit test performance regressions though so 
perhaps we just need to ensure there's at least one test that would normally 
have been unreasonably slow?) and a release note.




Comment at: clang/lib/AST/ExprConstant.cpp:10836-10838
+bool HasTrivialConstructor = CheckTrivialDefaultConstructor(
+Info, E->getExprLoc(), E->getConstructor(),
+E->requiresZeroInitialization());

The big question this raises for me is: will this cause constexpr to fail 
because of the note diagnostics when the type does not have a trivial default 
constructor? Or does this just bump the failure up a bit so that we fail before 
we start walking over the array elements?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130791

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


[PATCH] D126097: [clang-tidy] Adds the NSDateFormatter checker to clang-tidy

2022-08-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Uh-oh sorry! I have a couple more questions and then we can probably land.




Comment at: clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp:24
+  Finder->addMatcher(
+  objcMessageExpr(hasSelector("setDateFormat:"),
+  hasArgument(0, ignoringImpCasts(

Can or should we check the class name as well? It's probably going to be pretty 
rare that people have a method with the same name, that also accepts the first 
argument as a string literal, but that literal means something else entirely. 
However there's little reason not to be more cautious about that.



Comment at: clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp:67-68
+diag(StrExpr->getExprLoc(),
+ "use of calendar year(y) with week of the year(w); "
+ "did you mean to use week-year(Y) instead?");
+  }

I think we want spaces in such cases. I'm not sure, discussion welcome.


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

https://reviews.llvm.org/D126097

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


[PATCH] D130800: [clang][Headers] Avoid compiler warnings in builtin headers

2022-08-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks for catching this! As far as these changes go, they're pretty 
reasonable, but don't seem like they hit all of the problem areas. There's 20+ 
occurrences of `#if __STDC_VERSION__` and 10+ of `#if __cplusplus` in 
lib/Headers; shouldn't they all be updated?




Comment at: clang/lib/Headers/stdint.h:94-95
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmacro-redefined"
+

It seems to me that a cleaner approach to this is to `#undef` the macros we 
expect to be redefining before we redefine them instead of disabling the 
definition warning entirely. For example, it would still be useful for a user 
to find out that our stdint.h redefines some symbol from their own header files 
from an earlier inclusion.



Comment at: clang/lib/Headers/stdint.h:503
in C2x mode; switch to the correct values once they've been published. */
 #if __STDC_VERSION__ >= 202000L
 # define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH

Why does this usage not need to be changed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130800

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


[PATCH] D126745: [RISCV][Clang] Support policy functions for vmerge, vfmerge and vcompress.

2022-08-01 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

oops.. all tests need to updated and include all intrinsic IR tests...
Is there any benefit to switch UndefValue to PoisonValue?
maybe those changed should be in other follow-up patches?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126745

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


[PATCH] D130041: [clangd] Add decl/def support to SymbolDetails

2022-08-01 Thread David Goldman 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 rG61ef0ab70196: [clangd] Add decl/def support to SymbolDetails 
(authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130041

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/test/symbol-info.test
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
@@ -18,45 +18,79 @@
 
 using ::testing::UnorderedElementsAreArray;
 
-auto CreateExpectedSymbolDetails = [](const std::string ,
-  const std::string ,
-  const std::string ) {
-  return SymbolDetails{Name, Container, USR, SymbolID(USR)};
+// Partial SymbolDetails with the rest filled in at testing time.
+struct ExpectedSymbolDetails {
+  std::string Name;
+  std::string Container;
+  std::string USR;
+  const char *DeclMarker = nullptr;
+  const char *DefMarker = nullptr;
 };
 
 TEST(SymbolInfoTests, All) {
-  std::pair>
+  std::pair>
   TestInputExpectedOutput[] = {
   {
   R"cpp( // Simple function reference - declaration
-  void foo();
+  void $decl[[foo]]();
   int bar() {
 fo^o();
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl"}}},
   {
   R"cpp( // Simple function reference - definition
-  void foo() {}
+  void $def[[foo]]() {}
   int bar() {
 fo^o();
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "def", "def"}}},
+  {
+  R"cpp( // Simple function reference - decl and def
+  void $decl[[foo]]();
+  void $def[[foo]]() {}
+  int bar() {
+fo^o();
+  }
+)cpp",
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl", "def"}}},
+  {
+  R"cpp( // Simple class reference - decl and def
+  @interface $decl[[Foo]]
+  @end
+  @implementation $def[[Foo]]
+  @end
+  void doSomething(F^oo *obj) {}
+)cpp",
+  {ExpectedSymbolDetails{"Foo", "", "c:objc(cs)Foo", "decl",
+ "def"}}},
+  {
+  R"cpp( // Simple method reference - decl and def
+  @interface Foo
+  - (void)$decl[[foo]];
+  @end
+  @implementation Foo
+  - (void)$def[[fo^o]] {}
+  @end
+)cpp",
+  {ExpectedSymbolDetails{"foo", "Foo::", "c:objc(cs)Foo(im)foo",
+ "decl", "def"}}},
   {
   R"cpp( // Function in namespace reference
   namespace bar {
-void foo();
+void $decl[[foo]]();
 int baz() {
   fo^o();
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "bar::", "c:@N@bar@F@foo#",
+ "decl"}}},
   {
   R"cpp( // Function in different namespace reference
   namespace bar {
-void foo();
+void $decl[[foo]]();
   }
   namespace barbar {
 int baz() {
@@ -64,10 +98,11 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "bar::", "c:@N@bar@F@foo#",
+ "decl"}}},
   {
   R"cpp( // Function in global namespace reference
-  void foo();
+  void $decl[[foo]]();
   namespace Nbar {
 namespace Nbaz {
   int baz() {
@@ -76,11 +111,11 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl"}}},
   {
   R"cpp( // Function in anonymous namespace reference
   namespace {
-void foo();
+void $decl[[foo]]();
   }
   namespace barbar {
 int baz() {
@@ -88,13 +123,13 @@
 }
   }
 )cpp",
-   

[clang-tools-extra] 61ef0ab - [clangd] Add decl/def support to SymbolDetails

2022-08-01 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-08-01T14:42:19-04:00
New Revision: 61ef0ab70196bfdc4c301e12384aa91938b15cc4

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

LOG: [clangd] Add decl/def support to SymbolDetails

Add an optional declarationRange and definitionRange to SymbolDetails.

This will allow SourceKit-LSP to implement toggling between goto
definition/declaration based on whether the symbol at the cursor
is a definition or declaration.

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/test/symbol-info.test
clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 85c32574f9e67..31db4cf0f3cf5 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index ab75faaf98586..622f527f75f4f 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -734,7 +734,9 @@ llvm::raw_ostream <<(llvm::raw_ostream ,
 
 bool operator==(const SymbolDetails , const SymbolDetails ) {
   return LHS.name == RHS.name && LHS.containerName == RHS.containerName &&
- LHS.USR == RHS.USR && LHS.ID == RHS.ID;
+ LHS.USR == RHS.USR && LHS.ID == RHS.ID &&
+ LHS.declarationRange == RHS.declarationRange &&
+ LHS.definitionRange == RHS.definitionRange;
 }
 
 llvm::json::Value toJSON(const SymbolDetails ) {
@@ -755,6 +757,12 @@ llvm::json::Value toJSON(const SymbolDetails ) {
   if (P.ID)
 Result["id"] = P.ID.str();
 
+  if (P.declarationRange)
+Result["declarationRange"] = *P.declarationRange;
+
+  if (P.definitionRange)
+Result["definitionRange"] = *P.definitionRange;
+
   // FIXME: workaround for older gcc/clang
   return std::move(Result);
 }

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 0087017efad4f..add24daa1bc6d 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1093,6 +1093,10 @@ struct SymbolDetails {
   std::string USR;
 
   SymbolID ID;
+
+  llvm::Optional declarationRange;
+
+  llvm::Optional definitionRange;
 };
 llvm::json::Value toJSON(const SymbolDetails &);
 llvm::raw_ostream <<(llvm::raw_ostream &, const SymbolDetails &);

diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index c871ea0c437f4..c6a843ec1db43 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1481,7 +1481,7 @@ std::vector getSymbolInfo(ParsedAST , 
Position Pos) {
 llvm::consumeError(CurLoc.takeError());
 return {};
   }
-
+  auto MainFilePath = AST.tuPath();
   std::vector Results;
 
   // We also want the targets of using-decls, so we include
@@ -1489,6 +1489,8 @@ std::vector getSymbolInfo(ParsedAST , 
Position Pos) {
   DeclRelationSet Relations = DeclRelation::TemplatePattern |
   DeclRelation::Alias | DeclRelation::Underlying;
   for (const NamedDecl *D : getDeclAtPosition(AST, *CurLoc, Relations)) {
+D = getPreferredDecl(D);
+
 SymbolDetails NewSymbol;
 std::string QName = printQualifiedName(*D);
 auto SplitQName = splitQualifiedName(QName);
@@ -1505,6 +1507,12 @@ std::vector getSymbolInfo(ParsedAST , 
Position Pos) {
   NewSymbol.USR = std::string(USR.str());
   NewSymbol.ID = SymbolID(NewSymbol.USR);
 }
+if (const NamedDecl *Def = getDefinition(D))
+  NewSymbol.definitionRange = makeLocation(
+  AST.getASTContext(), nameLocation(*Def, SM), MainFilePath);
+NewSymbol.declarationRange =
+makeLocation(AST.getASTContext(), nameLocation(*D, SM), MainFilePath);
+
 Results.push_back(std::move(NewSymbol));
   }
 

diff  --git a/clang-tools-extra/clangd/test/symbol-info.test 
b/clang-tools-extra/clangd/test/symbol-info.test
index 1142f3b80edb7..ba788e1c398eb 100644
--- a/clang-tools-extra/clangd/test/symbol-info.test
+++ b/clang-tools-extra/clangd/test/symbol-info.test
@@ -1,10 +1,36 @@
 # RUN: clangd -lit-test < %s | FileCheck %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---

[PATCH] D126097: [clang-tidy] Adds the NSDateFormatter checker to clang-tidy

2022-08-01 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud added a comment.

Ping


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

https://reviews.llvm.org/D126097

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


[PATCH] D126745: [RISCV][Clang] Support policy functions for vmerge, vfmerge and vcompress.

2022-08-01 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

In D126745#3691544 , @craig.topper 
wrote:

> In D126745#3691528 , @khchen wrote:
>
>> In D126745#3678776 , @nlopes wrote:
>>
>>> While at it, could you switch those UndefValue with PoisonValue if 
>>> possible?  Thank you!
>>
>> I'm not sure UndefValue will work because the backend would only check 
>> isUndef() to generate correct code...
>
> PoisonValue and UndefValue are both turned into undef in SelectionDAG today.

thanks @craig.topper, I will switch UndefValue with PoisonValue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126745

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-08-01 Thread Philip Reames via Phabricator via cfe-commits
reames added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:286
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasExtension("zve32x"))
+HasStrictFP = false;

craig.topper wrote:
> reames wrote:
> > craig.topper wrote:
> > > reames wrote:
> > > > asb wrote:
> > > > > There's also code in RISCVISAInfo.cpp that does `HasVector = 
> > > > > Exts.count("zve32x") != 0`. It's probably worth adding a helper 
> > > > > (`hasVInstructions`?) that encapsulates this, and use it from both 
> > > > > places.
> > > > It's not clear to me why this condition is specific to embedded vector 
> > > > variants.  Do we have strict FP with +V?  Either you need to fix a 
> > > > comment here, or the condition.  One or the other.  
> > > V implies Zve64d implies Zve64f implies Zve32f and Zve64x. Zve32f implies 
> > > Zve32x. Zve32x is the root of the vector inheritance tree.
> > So, I went digging.  I agree that our *implementation* treats V as implying 
> > Zve64d, but I can find anything in the *specification* to that effect.  The 
> > feature set seems like it might be identical between the two, but I don't 
> > see anything in the spec which requires a +V implementation to claim 
> > support for Zve64d.  Do you have particular wording in mind I'm missing?  
> > 
> > (Regardless, the fact we assume this elsewhere means this is a non-blocking 
> > comment for this review.  At the very least, this isn't introducing a new 
> > problem.)
> We removed the implication for a brief period but Krste and Andrew disagreed. 
> I believe this is now covered by the note at the end of 
> https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#183-v-vector-extension-for-application-processors
> 
> "As is the case with other RISC-V extensions, it is valid to include 
> overlapping extensions in the same ISA string. For example, RV64GCV and 
> RV64GCV_Zve64f are both valid and equivalent ISA strings, as is 
> RV64GCV_Zve64f_Zve32x_Zvl128b."
Er, yuck that's subtle.  Not quite sure I'd read it the way you do, but your 
read is at least easily defensible.  We can wait until someone has a concrete 
case where they aren't implied before figuring out if that case is disallowed 
per the spec.  :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-08-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:286
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasExtension("zve32x"))
+HasStrictFP = false;

reames wrote:
> craig.topper wrote:
> > reames wrote:
> > > asb wrote:
> > > > There's also code in RISCVISAInfo.cpp that does `HasVector = 
> > > > Exts.count("zve32x") != 0`. It's probably worth adding a helper 
> > > > (`hasVInstructions`?) that encapsulates this, and use it from both 
> > > > places.
> > > It's not clear to me why this condition is specific to embedded vector 
> > > variants.  Do we have strict FP with +V?  Either you need to fix a 
> > > comment here, or the condition.  One or the other.  
> > V implies Zve64d implies Zve64f implies Zve32f and Zve64x. Zve32f implies 
> > Zve32x. Zve32x is the root of the vector inheritance tree.
> So, I went digging.  I agree that our *implementation* treats V as implying 
> Zve64d, but I can find anything in the *specification* to that effect.  The 
> feature set seems like it might be identical between the two, but I don't see 
> anything in the spec which requires a +V implementation to claim support for 
> Zve64d.  Do you have particular wording in mind I'm missing?  
> 
> (Regardless, the fact we assume this elsewhere means this is a non-blocking 
> comment for this review.  At the very least, this isn't introducing a new 
> problem.)
We removed the implication for a brief period but Krste and Andrew disagreed. I 
believe this is now covered by the note at the end of 
https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#183-v-vector-extension-for-application-processors

"As is the case with other RISC-V extensions, it is valid to include 
overlapping extensions in the same ISA string. For example, RV64GCV and 
RV64GCV_Zve64f are both valid and equivalent ISA strings, as is 
RV64GCV_Zve64f_Zve32x_Zvl128b."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-08-01 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

In D130311#3691146 , @craig.topper 
wrote:

> In D130311#3691029 , @reames wrote:
>
>> I'm not fluent on strict FP, so let me summarize my understanding.  This is 
>> mostly so you can easily correct me if one my assumptions is wrong.
>>
>> - Under strict FP, clang will emit constrained fp intrinsics instead of 
>> normal floating point ops.
>> - To my knowledge, clang will never emit an explicit vector constrained 
>> intrinsic.
>
> operator +, -, *, / etc. on __attribute__((__vector_size__)) types will 
> generate vector constrained intrinsics.

And probably also explicit intrinsic calls now that I'm thinking about it.

However, that doesn't really resolve my user interface concern.  If I have 
purely scalar code, just adding +v to the extension list at the command line 
doesn't change whether strict FP is supported or not.  This change would cause 
us to start reporting warnings which seems less than actionable to the user.  
It really seems like we need to be reporting warnings *when the explicit vector 
constructs are used*.

Worse than the warning bit, having strict FP scalar code stop being strict FP 
if you add +v seems... error prone.

(In case it's not clear, I can probably be convinced this is an imperfect step 
in the right general direction.  I just want to make sure I fully understand 
the implications before giving an LGTM.)




Comment at: clang/lib/Basic/Targets/RISCV.cpp:286
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasExtension("zve32x"))
+HasStrictFP = false;

craig.topper wrote:
> reames wrote:
> > asb wrote:
> > > There's also code in RISCVISAInfo.cpp that does `HasVector = 
> > > Exts.count("zve32x") != 0`. It's probably worth adding a helper 
> > > (`hasVInstructions`?) that encapsulates this, and use it from both places.
> > It's not clear to me why this condition is specific to embedded vector 
> > variants.  Do we have strict FP with +V?  Either you need to fix a comment 
> > here, or the condition.  One or the other.  
> V implies Zve64d implies Zve64f implies Zve32f and Zve64x. Zve32f implies 
> Zve32x. Zve32x is the root of the vector inheritance tree.
So, I went digging.  I agree that our *implementation* treats V as implying 
Zve64d, but I can find anything in the *specification* to that effect.  The 
feature set seems like it might be identical between the two, but I don't see 
anything in the spec which requires a +V implementation to claim support for 
Zve64d.  Do you have particular wording in mind I'm missing?  

(Regardless, the fact we assume this elsewhere means this is a non-blocking 
comment for this review.  At the very least, this isn't introducing a new 
problem.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

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


[PATCH] D130918: [clang][ExtractAPI] Record availability information on all platforms

2022-08-01 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

Thanks Daniel!




Comment at: clang/test/ExtractAPI/availability.c:16
+//--- input.h
+/// Documentation for a.
+void a(void);

Do we care about doc comments for this particular test?
The testing convention for all the ExtractAPI tests is probably not the most 
ideal one because every test is a complete matching of the full Symbol Graph 
output.
So if we try to limit the scope of this test to just availability attributes it 
would be easier to read, and also avoid potential irrelevant failures in this 
test if something should broke the doc comment part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130918

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


[PATCH] D126745: [RISCV][Clang] Support policy functions for vmerge, vfmerge and vcompress.

2022-08-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D126745#3691528 , @khchen wrote:

> In D126745#3678776 , @nlopes wrote:
>
>> While at it, could you switch those UndefValue with PoisonValue if possible? 
>>  Thank you!
>
> I'm not sure UndefValue will work because the backend would only check 
> isUndef() to generate correct code...

PoisonValue and UndefValue are both turned into undef in SelectionDAG today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126745

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


[PATCH] D126745: [RISCV][Clang] Support policy functions for vmerge, vfmerge and vcompress.

2022-08-01 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

In D126745#3678776 , @nlopes wrote:

> While at it, could you switch those UndefValue with PoisonValue if possible?  
> Thank you!

I'm not sure UndefValue will work because the backend would only check 
isUndef() to generate correct code...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126745

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


[PATCH] D126266: Mark the file entry invalid, until reread. Invalidate SLocEntry cache, readd it on reread. Do not use translateFile, because it pulls in parts of the pch.

2022-08-01 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@tapaswenipathak, ping...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126266

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


[PATCH] D130918: [clang][ExtractAPI] Record availability information on all platforms

2022-08-01 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added reviewers: zixuw, QuietMisdreavus, ributzka.
Herald added a subscriber: mgorny.
Herald added a project: All.
dang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently ExtractAPI only emits availability information for the
current platform. This makes it easy for clients to get all availability
information for a given symbol in one invocation as opposed to having to invoke
clang once per-platform and then merge the symbol-graphs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130918

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/AvailabilityInfo.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/AvailabilityInfo.cpp
  clang/lib/ExtractAPI/CMakeLists.txt
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/availability.c

Index: clang/test/ExtractAPI/availability.c
===
--- /dev/null
+++ clang/test/ExtractAPI/availability.c
@@ -0,0 +1,551 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api --product-name=Availability -triple arm64-apple-macosx -x c-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+/// Documentation for a.
+void a(void);
+
+/// Documentation for b.
+void b(void) __attribute__((availability(macos, introduced=12.0)));
+
+/// Documentation for c.
+void c(void) __attribute__((availability(macos, introduced=11.0, deprecated=12.0, obsoleted=20.0)));
+
+/// Documentation for d.
+void d(void) __attribute__((availability(macos, introduced=11.0, deprecated=12.0, obsoleted=20.0))) __attribute__((availability(ios, introduced=13.0)));
+
+/// Documentation for e.
+void e(void) __attribute__((deprecated)) __attribute__((availability(macos, introduced=11.0)));
+
+/// Documentation for f.
+void f(void) __attribute__((unavailable)) __attribute__((availability(macos, introduced=11.0)));
+
+// Later declaration for d that adds availability for a new domain.
+void d(void) __attribute__((availability(tvos, introduced=15.0)));
+///expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "Availability",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "a"
+},
+{
+  "kind": "text",
+  "spelling": "()"
+}
+  ],
+  "docComment": {
+"lines": [
+  {
+"range": {
+  "end": {
+"character": 25,
+"line": 1
+  },
+  "start": {
+"character": 5,
+"line": 1
+  }
+},
+"text": "Documentation for a."
+  }
+]
+  },
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@F@a"
+  },
+  "kind": {
+"displayName": "Function",
+"identifier": "c.func"
+  },
+  "location": {
+"position": {
+  "character": 6,
+  "line": 2
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "a"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "a"
+  }
+],
+"title": "a"
+  },
+  "pathComponents": [
+"a"
+  ]
+},
+{
+  "accessLevel": "public",
+  "availability": [
+{
+ 

[PATCH] D126743: [RISCV][Clang] Add tests for all supported policy functions. (NFC)

2022-08-01 Thread Zakk 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 rG8e51917b39cd: [RISCV][Clang] Add tests for all supported 
policy functions. (NFC) (authored by khchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126743

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfclass.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfncvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrec7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsqrt7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsgnj.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsqrt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnclip.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrem.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrgather.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsext.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslidedown.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslideup.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsll.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vzext.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vaadd.c
  

[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-08-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D130058#3689053 , @thakis wrote:

> In D130058#3687868 , @aaron.ballman 
> wrote:
>
>> In D130058#3687680 , @thakis wrote:
>>
>>> Hello, this breaks a bunch of existing code over here (and I imagine 
>>> elsewhere).
>>
>> Do you have an idea on how much a bunch is and whether the fixes are 
>> particularly involved or not? Did it break a system header?
>
> Sorry for the slow reply, this was fairly involved to count. (Since this is 
> an error, not a warning, I had to do local builds on all our supported 
> platforms, and fix all instances before I could know I found everything.)

Thank you for helping to track those numbers down, I really appreciate it!

> With D130811 , the most annoying instance 
> is resolved. I'd say it's now few enough instances in few enough repositories 
> that this isn't necessary for Chromium, but based on the numbers below I'd 
> expect that this change will be fairly annoying for people with larger 
> codebases.
>
> For Chromium, this affects:
>
> - 6 different places in v8, all due to due using enums with a spiffy BitField 
> class (reduced example here 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1348574#c7). This 
> BitField class takes a "size" template arg, and clang now happens to complain 
> if that size arg is too large to hold all enum fields: If you have an enum 
> with 8 values but try to store it in a BitField<.., 4> you now happen to get 
> an error, because a BitField<..., 3>. (This is kind of cool!) 
> (https://chromium-review.googlesource.com/c/v8/v8/+/3794708)

That's neat!

> - 11 different places in chromium that are related to a macro that takes an 
> enum (summary here: 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1348574#c11) where the 
> workaround is to give those enums a fixed underlying type
> - 4 places in unit tests that do something like `constexpr auto 
> kImpossibleEnumValue = static_cast(-1);` (replaced "constexpr" 
> with "const" as workaround)
> - 1 place that checked that static_assert()ed that two enumerators from two 
> distinct enum types have the same value, this just needed rewriting the 
> expression slightly
>
> After D130811 , we're lucky that no code in 
> difficult-to-change third-party repositories are affected.

Glad to hear that!

> It does affect 22 distinct places though, so it seems likely that other 
> projects might be less lucky.
>
> (But since it's no longer a problem for us, I also won't push for a warning 
> more than I did in this comment.)

Thank you for these details! That does seem like a fairly substantial amount of 
broken code for one project, but it also sounds like everything it caught was a 
true positive (at least as far as the language standard is concerned) and none 
of it required major changes to fix the issues. Based on that, I think we're 
still okay with the functionality as-is, but if we start to find cases where 
the fix is really involved (or is in a system header) and the code is otherwise 
reasonable, we may want to reconsider.


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

https://reviews.llvm.org/D130058

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


[PATCH] D130807: [InstrProf] Add the omitprofile attribute

2022-08-01 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.



> I agree that `omitprofile` probably doesn't communicate the correct meaning 
> very well. I like `nodirectprofile` because it hopefully implies that 
> indirect profiles are allowed. I'm wondering if anyone else has suggestions.
>
> Is there any precedent for renaming function attributes? My assumption was 
> that users would add the `noprofile` attribute to source mostly for 
> correctness concerns and `noprofile` is easy to remember and already in use, 
> so I'd rather not change it.

I agree with you that it's probably best to avoid changing the spelling of 
`noprofile`, but since you're making a change in the area, we may as well 
discuss if 1) that is still the best name, and 2) if we want to keep it.

I don't know if we've ever changed the spelling of a `FnAttribute` before. IIRC 
we've dropped them, and changed their format e.g., from being a boolean to 
taking a value or an enum. At least that's my memory, which seems to correspond 
to the autoupgrade stuff in `BitcodeReader`. But I think the project's stance 
on this(like most things) is that "if there's a good reason, then we should do 
it." At least if we can maintain our stated compatibility guarantees. This is a 
place where I think we should get additional feedback before proceeding though.

It might be worth asking about this on discourse. Even if we don't want to make 
such a change in these patches, it may be good for the project to have a policy 
(or at least guidelines) about changing attributes.

> I actually do have a change in `PGOInstrumentation.cpp` that skips profiling 
> functions with this new attribute. As far as I know, this stack has all the 
> necessary code changes.

I can't believe I missed that. I looked three times before I commented, and 
blew right passed it every time. That's what happens when I look at code late 
on a Friday...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130807

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-08-01 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:3381
  ) &&
   isConstructorDeclarator(/*Unqualified*/ false))
 goto DoneWithDeclSpec;

The only remaining failure is in `test/Parser/cxx-class.cpp` where we have 
something similar to:
```
namespace ctor_error {
  class Ctor { // expected-note{{not complete until the closing '}'}}
Ctor(f)(int); // ok
Ctor(g(int)); // ok
  };

  Ctor::Ctor (x) = { 0 }; // \
// expected-error{{qualified reference to 'Ctor' is a constructor name}}
}
```

Now, `Ctor::Ctor` is recognized as a constructor and the diagnostic message 
regresses to:
```
error: 'error' diagnostics expected but not seen: 
  File 
/home/vvassilev/workspace/sources/llvm-project/clang/test/Parser/cxx-class.cpp 
Line 116: qualified reference to 'Ctor' is a constructor name
error: 'error' diagnostics seen but not expected: 
  File 
/home/vvassilev/workspace/sources/llvm-project/clang/test/Parser/cxx-class.cpp 
Line 116: unknown type name 'x'
2 errors generated.
```

It seems that the more accurate diagnostic used to come from 
`Actions.getTypeName`... Any ideas how to fix this?


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

https://reviews.llvm.org/D127284

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


[PATCH] D130516: [llvm] compression classes

2022-08-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane added inline comments.



Comment at: llvm/lib/Support/Compression.cpp:30-32
+ZStdCompressionAlgorithm
+*llvm::compression::ZStdCompressionAlgorithm::Instance =
+new ZStdCompressionAlgorithm();

dblaikie wrote:
> leonardchan wrote:
> > Perhaps for each of these, you could instead have something like:
> > 
> > ```
> > ZStdCompressionAlgorithm *getZStdCompressionAlgorithm() {
> >   static ZStdCompressionAlgorithm* instance = new ZStdCompressionAlgorithm;
> >   return instance;
> > }
> > ```
> > 
> > This way the instances are only new'd when they're actually used.
> Yep, I'd mentioned/suggested that (so, seconding here) elsewhere encouraging 
> these to be singletons: https://reviews.llvm.org/D130516#3683384
> 
> And they don't even need to be 'new'd in that case, this would be fine:
> ```
> ZstdCompressionAlgorithm () {
>   static ZstdCompressionAlgorithm C;
>   return C;
> }
> ```
> 
> Though I think maybe we don't need individual access to the algorithms, and 
> it'd be fine to have only a single entry point like this:
> ```
> CompressionAlgorithm *getCompressionAlgorithm(DebugCompressionType T) {
>   switch (T) {
>   case DebugCompressionType::ZStd: {
> static zstd::CompressionAlgorithm Zstd;
> if (zstd::isAvailable())
>   return 
>   }
>   ...
>   }
>   return nullptr;
> }
> ```
> (or, possibly, we want to return non-null even if it isn't available, if we 
> include other things (like the configure macro name - so callers can use that 
> name to print helpful error messages - but then they have to explicitly check 
> if the algorithm is available after the call))
they currently already have singleton behavior i.e. 
`llvm::compression::ZStdCompressionAlgorithm::Instance` is the only place `new 
ZStdCompressionAlgorithm()` can be put into because the constructor is 
protected.

I'd rather not achieve "This way the instances are only new'd when they're 
actually used."
Because the rewards of that are relatively small, but it will make the code 
more verbose, I think the current pattern allows the best of both worlds of the 
namespace approach:
(`llvm::compression::zlib::compress` becomes 
`llvm::compression::ZlibCompression->compress`)
but they can be passed as class instances.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130516

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-08-01 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 449066.
v.g.vassilev edited the summary of this revision.
v.g.vassilev added a comment.
Herald added subscribers: sstefan1, Anastasia.
Herald added a reviewer: jdoerfert.

Rely on the CXXScopeSpec to detect more accurately if we are parsing a 
constructor declarator.


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

https://reviews.llvm.org/D127284

Files:
  clang/include/clang/AST/ASTConsumer.h
  clang/include/clang/Parse/Parser.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Interpreter/disambiguate-decl-stmt.cpp
  clang/test/Interpreter/execute-stmts.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -120,12 +120,7 @@
 
   // FIXME: Add support for wrapping and running statements.
   auto R2 = Interp->Parse("var1++; printf(\"var1 value %d\\n\", var1);");
-  EXPECT_FALSE(!!R2);
-  using ::testing::HasSubstr;
-  EXPECT_THAT(DiagnosticsOS.str(),
-  HasSubstr("error: unknown type name 'var1'"));
-  auto Err = R2.takeError();
-  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+  EXPECT_TRUE(!!R2);
 }
 
 TEST(InterpreterTest, UndoCommand) {
Index: clang/test/Interpreter/execute-stmts.cpp
===
--- /dev/null
+++ clang/test/Interpreter/execute-stmts.cpp
@@ -0,0 +1,34 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc  -verify | FileCheck %s
+
+// expected-no-diagnostics
+
+extern "C" int printf(const char*,...);
+
+//template  T call() { printf("call\n"); return T(); }
+//call();
+ C: call
+
+int i = 1;
+++i;
+printf("i = %d\n", i);
+// CHECK: i = 2
+
+namespace Ns { void f(){ i++; } }
+Ns::f();
+
+void g() { ++i; }
+g();
+::g();
+
+printf("i = %d\n", i);
+// CHECK-NEXT: i = 5
+
+for (; i > 4; --i) printf("i = %d\n", i);
+// CHECK-NEXT: i = 5
+
+int j = i; printf("j = %d\n", j);
+// CHECK-NEXT: j = 4
+
+%quit
Index: clang/test/Interpreter/disambiguate-decl-stmt.cpp
===
--- /dev/null
+++ clang/test/Interpreter/disambiguate-decl-stmt.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+
+// expected-no-diagnostics
+
+extern "C" int printf(const char*,...);
+
+// Decls which are hard to disambiguate
+
+// Dtors
+using I = int;
+I x = 10;
+x.I::~I();
+x = 20;
+
+// Ctors
+
+// FIXME: Support deduction guide
+// template struct A { A(); A(T); };
+// A() -> A;
+
+namespace N { struct S { S(); }; }
+N::S::S() { printf("N::S::S()\n"); }
+N::S s;
+// CHECK: N::S::S()
+
+namespace Ns {namespace Ns { void Ns(); void Fs();}}
+void Ns::Ns::Ns() { printf("void Ns::Ns::Ns()\n"); }
+void Ns::Ns::Fs() {}
+
+Ns::Ns::Fs();
+Ns::Ns::Ns();
+// CHECK-NEXT: void Ns::Ns::Ns()
+
+struct Attrs1 { Attrs1(); };
+Attrs1::Attrs1() __attribute((pure)) = default;
+
+struct Attrs2 { Attrs2(); };
+__attribute((pure)) Attrs2::Attrs2() = default;
+
+// Extra semicolon
+namespace N {};
+
+%quit
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -582,13 +582,14 @@
 ///
 /// Note that in C, it is an error if there is no first declaration.
 bool Parser::ParseFirstTopLevelDecl(DeclGroupPtrTy ,
-Sema::ModuleImportState ) {
+Sema::ModuleImportState ,
+StmtVector *Stmts) {
   Actions.ActOnStartOfTranslationUnit();
 
   // For C++20 modules, a module decl must be the first in the TU.  We also
   // need to track module imports.
   ImportState = Sema::ModuleImportState::FirstDecl;
-  bool NoTopLevelDecls = ParseTopLevelDecl(Result, ImportState);
+  bool NoTopLevelDecls = ParseTopLevelDecl(Result, ImportState, Stmts);
 
   // C11 6.9p1 says translation units must have at least one top-level
   // declaration. C++ doesn't have this restriction. We also don't want to
@@ -609,7 +610,8 @@
 ///   declaration
 /// [C++20]   module-import-declaration
 bool Parser::ParseTopLevelDecl(DeclGroupPtrTy ,
-   Sema::ModuleImportState ) {
+   Sema::ModuleImportState ,
+   StmtVector *Stmts /*=nullptr*/) {
   DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
 
   // Skip over the EOF token, flagging end 

[PATCH] D130827: [clang] Fixed a number of typos

2022-08-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D130827#3691371 , @GabrielRavier 
wrote:

>> Do you need someone to land this on your behalf?
>
> I assume so since landing seems to mean pushing the commit to the repo which 
> I'm pretty sure I don't have the rights to do.

Okie dokie! I try to double-check with anyone who I'm not used to seeing 
commits from.

>> If so, what name and email address would you like used for patch attribution?
>
> `Gabriel Ravier`, `gabrav...@gmail.com`
>
> (By the way, is there any way to make this information part of my Phabricator 
> account so that I don't need to repeat this every time I submit a patch ? The 
> patch I made for `clang-tools-extra` got in with the right name/email pair 
> just fine without me having to say anything, so I was assuming it was there 
> somewhere...)

Thank you! I've gone ahead and landed the changes. I don't think there's a way 
to add the information to Phab in a way that all the code reviewers will 
notice. Some reviewers will land based on whatever email address you are using 
for Phabricator, others ask explicitly, some others will go look at prior 
reviews to see if they can find the info without asking, etc. FWIW, after you 
have a few patched submitted on your behalf, we'll often ask if you'd like to 
obtain commit privileges of your own 
(https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130827

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


[PATCH] D130827: [clang] Fixed a number of typos

2022-08-01 Thread Aaron Ballman 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 rG5674a3c88088: Fixed a number of typos (authored by 
GabrielRavier, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130827

Files:
  clang/bindings/python/clang/cindex.py
  clang/cmake/caches/MultiDistributionExample.cmake
  clang/docs/ClangFormat.rst
  clang/docs/JSONCompilationDatabase.rst
  clang/docs/LanguageExtensions.rst
  clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Analysis/ConstructionContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowValues.h
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsVE.def
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/include/clang/Lex/DependencyDirectivesScanner.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/SourceLocationEncoding.h
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/Tooling/Core/Replacement.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Headers/arm_acle.h
  clang/lib/Headers/opencl-c.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/Tooling/AllTUsExecution.cpp
  clang/lib/Tooling/Core/Replacement.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/test/CodeGen/vectorcall.c
  clang/test/CodeGenCXX/target-features-error.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
  clang/tools/clang-shlib/CMakeLists.txt
  clang/tools/include-mapping/gen_std.py
  clang/tools/scan-build-py/lib/libear/ear.c
  clang/unittests/AST/StructuralEquivalenceTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp
  clang/utils/TableGen/NeonEmitter.cpp
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/exploded-graph-rewriter.py
  clang/www/analyzer/installation.html

Index: clang/www/analyzer/installation.html
===
--- clang/www/analyzer/installation.html
+++ clang/www/analyzer/installation.html
@@ -58,7 +58,7 @@
 
 
 scan-build: scan-build is the high-level command line utility for running the analyzer
-scan-view: scan-view a companion comannd line
+scan-view: scan-view a companion command line
 utility to scan-build, scan-view is used to view
 analysis results generated by scan-build.  There is an option
 that one can pass to scan-build to cause scan-view to
Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -388,7 +388,7 @@
 # Also on Windows macros __FILE__ produces specific delimiters `\`
 # and a directory or file may starts with the letter `l`.
 # Find all `\l` (like `,\l`, `}\l`, `[\l`) except `\\l`,
-# because the literal as a rule containes multiple `\` before `\l`.
+# because the literal as a rule contains multiple `\` before `\l`.
 node_label = re.sub(r'(? 1)
Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -255,7 +255,7 @@
   Visitor.runOverAnnotated(R"cpp(
   #define ATTR __attribute__((deprecated("message")))
   $r[[ATTR
-  // Commment.
+  // Comment.
   int x;]])cpp");
 }
 
@@ -410,7 +410,7 @@
   Visit(R"cpp(
   #define ATTR __attribute__((deprecated("message")))
   $r[[ATTR
-  // Commment.
+  // Comment.
   int x;]])cpp");
 }
 
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

[clang] 5674a3c - Fixed a number of typos

2022-08-01 Thread Aaron Ballman via cfe-commits

Author: Gabriel Ravier
Date: 2022-08-01T13:13:18-04:00
New Revision: 5674a3c88088e668b684326c2194a6282e8270ff

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

LOG: Fixed a number of typos

I went over the output of the following mess of a command:

(ulimit -m 200; ulimit -v 200; git ls-files -z |
 parallel --xargs -0 cat | aspell list --mode=none --ignore-case |
 grep -E '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n |
 grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' -f2 | less)

and proceeded to spend a few days looking at it to find probable typos
and fixed a few hundred of them in all of the llvm project (note, the
ones I found are not anywhere near all of them, but it seems like a
good start).

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

Added: 


Modified: 
clang/bindings/python/clang/cindex.py
clang/cmake/caches/MultiDistributionExample.cmake
clang/docs/ClangFormat.rst
clang/docs/JSONCompilationDatabase.rst
clang/docs/LanguageExtensions.rst
clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Analysis/ConstructionContext.h
clang/include/clang/Analysis/FlowSensitive/DataflowValues.h
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/BuiltinsVE.def
clang/include/clang/Basic/SourceManager.h
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
clang/include/clang/Lex/DependencyDirectivesScanner.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/SourceLocationEncoding.h
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
clang/include/clang/Tooling/Core/Replacement.h
clang/include/clang/Tooling/Syntax/Tree.h
clang/lib/AST/ASTContext.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
clang/lib/Headers/arm_acle.h
clang/lib/Headers/opencl-c.h
clang/lib/Lex/Lexer.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/Tooling/AllTUsExecution.cpp
clang/lib/Tooling/Core/Replacement.cpp
clang/lib/Tooling/Syntax/Tokens.cpp
clang/test/CodeGen/vectorcall.c
clang/test/CodeGenCXX/target-features-error.cpp
clang/test/SemaCXX/builtin-align-cxx.cpp
clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
clang/tools/clang-shlib/CMakeLists.txt
clang/tools/include-mapping/gen_std.py
clang/tools/scan-build-py/lib/libear/ear.c
clang/unittests/AST/StructuralEquivalenceTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/Tooling/SourceCodeTest.cpp
clang/utils/TableGen/NeonEmitter.cpp
clang/utils/analyzer/SATest.py
clang/utils/analyzer/exploded-graph-rewriter.py
clang/www/analyzer/installation.html

Removed: 




diff  --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 597dc5dd49738..89063dd40155b 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1152,7 +1152,7 @@ def __repr__(self):
 # Objective-C's @synchronized statement.
 CursorKind.OBJC_AT_SYNCHRONIZED_STMT = CursorKind(220)
 
-# Objective-C's autorealease pool statement.
+# Objective-C's autorelease pool statement.
 CursorKind.OBJC_AUTORELEASE_POOL_STMT = CursorKind(221)
 
 # Objective-C's for collection statement.

diff  --git a/clang/cmake/caches/MultiDistributionExample.cmake 
b/clang/cmake/caches/MultiDistributionExample.cmake
index 0c97611e252b4..de10dcc11b969 100644
--- a/clang/cmake/caches/MultiDistributionExample.cmake
+++ b/clang/cmake/caches/MultiDistributionExample.cmake
@@ -1,5 +1,5 @@
 # This file sets up a CMakeCache for a simple build with multiple 
distributions.
-# Note that for a real distribution, you likely want to perform a boostrap
+# Note that for a real distribution, you likely want to perform a bootstrap
 # build; see clang/cmake/caches/DistributionExample.cmake and the
 # BuildingADistribution documentation for details. This cache file doesn't
 # 

[PATCH] D130827: [clang] Fixed a number of typos

2022-08-01 Thread Gabriel Ravier via Phabricator via cfe-commits
GabrielRavier added a comment.

> Do you need someone to land this on your behalf?

Yes.

> If so, what name and email address would you like used for patch attribution?

`Gabriel Ravier`, `gabrav...@gmail.com`

(By the way, is there any way to make this information part of my Phabricator 
account so that I don't need to repeat this every time I submit a patch ? The 
patch I made for `clang-tools-extra` got in with the right name/email pair just 
fine without me having to say anything, so I was assuming it was there 
somewhere...)


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

https://reviews.llvm.org/D130827

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


[PATCH] D130807: [InstrProf] Add the omitprofile attribute

2022-08-01 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added a comment.

In D130807#3688798 , @paulkirth wrote:

> Do you expect the difference between `noprofile` and `omitprofile` to be 
> confusing to users? I can certainly see how users could be confused by what 
> the difference is between `noprofile` and `omitprofile` ...
>
> Since what you want to communicate is "never profile"(which `noprofile` can 
> probably communicate as is) and "never profile this, but allow inlining of 
> profiled functions" (which I'm not sure `omitprofile` communicates), then 
> maybe there is a more obvious way we could communicate that? Maybe 
> `neverprofile` and `nodirectprofile` are more descriptive names? I don't love 
> the idea of changing an existing attribute name, but we can transparently 
> upgrade existing uses for backwards compatibility if we have to.  What do you 
> think?

I agree that `omitprofile` probably doesn't communicate the correct meaning 
very well. I like `nodirectprofile` because it hopefully implies that indirect 
profiles are allowed. I'm wondering if anyone else has suggestions.

Is there any precedent for renaming function attributes? My assumption was that 
users would add the `noprofile` attribute to source mostly for correctness 
concerns and `noprofile` is easy to remember and already in use, so I'd rather 
not change it.

> I also think this will need to need to be supported in LLVM's passes, right? 
> So the instrumentation passes in `PGOInstrumentation.cpp` (I can't remember 
> if 'InstrProfiling.cpp` will need this too), and probably the Inlining passes 
> too, right?  I assume those will be follow up patches, but I don't see them 
> in the current stack. Is that an accurate assumption?

I actually do have a change in `PGOInstrumentation.cpp` that skips profiling 
functions with this new attribute. As far as I know, this stack has all the 
necessary code changes.

> BTW I like the direction of these patches, I think adding the ability to 
> differentiate these cases will add a lot of value to the profiling runtimes + 
> coverage. :)

Thanks for the suggestion and feedback!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130807

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


[clang-tools-extra] 556c422 - clang-tidy doc: fix some typos

2022-08-01 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2022-08-01T18:57:36+02:00
New Revision: 556c422de1c3b0623e83c85b36a43dd743660fb1

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

LOG: clang-tidy doc: fix some typos

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst

clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst
clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst

clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst
index d0b18bd4595c7..72860e8cf2a1d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst
@@ -47,7 +47,7 @@ A good example from the CERT description when a ``char`` 
variable is used to
 read from a file that might contain non-ASCII characters. The problem comes
 up when the code uses the ``-1`` integer value as EOF, while the 255 character
 code is also stored as ``-1`` in two's complement form of char type.
-See a simple example of this bellow. This code stops not only when it reaches
+See a simple example of this below. This code stops not only when it reaches
 the end of the file, but also when it gets a character with the 255 code.
 
 .. code-block:: c++

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst
index 3ed6372840a89..6e9a4e02e6d0e 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst
@@ -269,7 +269,7 @@ The check is aware of aliases of optional types that are 
created via
 Lambdas
 ---
 
-The check does not currently report unsafe optional acceses in lambdas.
+The check does not currently report unsafe optional accesses in lambdas.
 A future version will expand the scope to lambdas, following the rules
 outlined above. It is best to follow the same principles when using
 optionals in lambdas.

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst 
b/clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst
index 4a05629d6070c..c75ee8d3c09d7 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst
@@ -5,7 +5,7 @@ cert-err33-c
 
 Warns on unused function return values. Many of the standard library functions
 return a value that indicates if the call was successful. Ignoring the returned
-value can cause unexpected behavior if an error has occured. The following
+value can cause unexpected behavior if an error has occurred. The following
 functions are checked:
 
 * aligned_alloc()

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst
index c693387d9e4bf..af6ec1416e5e2 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst
@@ -17,7 +17,7 @@ Exceptions:
 are not susceptible to slicing and the usage of string literals is
 idiomatic.
   * Catching character pointers (``char``, ``wchar_t``, unicode character 
types)
-will not be flagged to allow catching sting literals.
+will not be flagged to allow catching string literals.
   * Moved named values will not be flagged as not throwing an anonymous
 temporary. In this case we can be sure that the user knows that the object
 can't be accessed outside catch blocks handling the error.



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


[PATCH] D130531: [IR] Use Min behavior for module flag "PIC Level"

2022-08-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130531

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


[PATCH] D130827: [clang] Fixed a number of typos

2022-08-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks for the typo fixes! All the changes look correct to me, so LGTM. Do you 
need someone to land this on your behalf? If so, what name and email address 
would you like used for patch attribution?




Comment at: clang/lib/Headers/opencl-c.h:17856
+intel_sub_group_avc_sic_payload_t __ovld intel_sub_group_avc_sic_configure_ipe(
+uchar luma_intra_partition_mask, uchar intra_neighbour_availability,
 uchar left_edge_luma_pixels, uchar upper_left_corner_luma_pixel,

GabrielRavier wrote:
> junaire wrote:
> > Not sure if we want to format this...
> Well, it is what clang-format did, so I don't really know... Is it also 
> legacy code as mentioned above ?
I think it's fine to reformat this given that the code is being updated. I 
validated that the only identifiers changed here are parameter names (so 
there's no chance to break user code).


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

https://reviews.llvm.org/D130827

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


[PATCH] D125944: Template instantiation error recovery

2022-08-01 Thread Purva Chaudhari via Phabricator via cfe-commits
Purva-Chaudhari updated this revision to Diff 449059.
Purva-Chaudhari added a comment.

Rebase


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

https://reviews.llvm.org/D125944

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/test/Interpreter/template-recovery.cpp


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9592,6 +9592,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema ): S(S) {} ;
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema 
+  };
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -146,6 +146,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema();
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, 
/*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 
   PTUs.emplace_back(PartialTranslationUnit());
   PartialTranslationUnit  = PTUs.back();
Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+
+template T f() { return T(); }
+auto ptu2 = f(); err;
+auto ptu2 = f();
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+quit


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9592,6 +9592,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema ): S(S) {} ;
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema 
+  };
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -146,6 +146,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema();
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, /*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 
   PTUs.emplace_back(PartialTranslationUnit());
   PartialTranslationUnit  = PTUs.back();
Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+
+template T f() { return T(); }
+auto ptu2 = f(); err;
+auto ptu2 = f();
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 37047a2 - misc-const-correctness: fix the link to readability-isolate-declaration

2022-08-01 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2022-08-01T18:52:53+02:00
New Revision: 37047a26731a6731c949682e159fe40786e6d711

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

LOG: misc-const-correctness: fix the link to readability-isolate-declaration

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst 
b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
index 852d9346576da..76d283da37dd1 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
@@ -41,7 +41,7 @@ The check can analyzes values, pointers and references but 
not (yet) pointees:
 
 The automatic code transformation is only applied to variables that are 
declared in single
 declarations. You may want to prepare your code base with
-`readability-isolate-declaration `_ 
first.
+`readability-isolate-declaration <../readability/isolate-declaration.html>`_ 
first.
 
 Note that there is the check
 `cppcoreguidelines-avoid-non-const-global-variables 
`_



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


[PATCH] D130041: [clangd] Add decl/def support to SymbolDetails

2022-08-01 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 449050.
dgoldman added a comment.

Run clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130041

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/test/symbol-info.test
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
@@ -18,45 +18,79 @@
 
 using ::testing::UnorderedElementsAreArray;
 
-auto CreateExpectedSymbolDetails = [](const std::string ,
-  const std::string ,
-  const std::string ) {
-  return SymbolDetails{Name, Container, USR, SymbolID(USR)};
+// Partial SymbolDetails with the rest filled in at testing time.
+struct ExpectedSymbolDetails {
+  std::string Name;
+  std::string Container;
+  std::string USR;
+  const char *DeclMarker = nullptr;
+  const char *DefMarker = nullptr;
 };
 
 TEST(SymbolInfoTests, All) {
-  std::pair>
+  std::pair>
   TestInputExpectedOutput[] = {
   {
   R"cpp( // Simple function reference - declaration
-  void foo();
+  void $decl[[foo]]();
   int bar() {
 fo^o();
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl"}}},
   {
   R"cpp( // Simple function reference - definition
-  void foo() {}
+  void $def[[foo]]() {}
   int bar() {
 fo^o();
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "def", "def"}}},
+  {
+  R"cpp( // Simple function reference - decl and def
+  void $decl[[foo]]();
+  void $def[[foo]]() {}
+  int bar() {
+fo^o();
+  }
+)cpp",
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl", "def"}}},
+  {
+  R"cpp( // Simple class reference - decl and def
+  @interface $decl[[Foo]]
+  @end
+  @implementation $def[[Foo]]
+  @end
+  void doSomething(F^oo *obj) {}
+)cpp",
+  {ExpectedSymbolDetails{"Foo", "", "c:objc(cs)Foo", "decl",
+ "def"}}},
+  {
+  R"cpp( // Simple method reference - decl and def
+  @interface Foo
+  - (void)$decl[[foo]];
+  @end
+  @implementation Foo
+  - (void)$def[[fo^o]] {}
+  @end
+)cpp",
+  {ExpectedSymbolDetails{"foo", "Foo::", "c:objc(cs)Foo(im)foo",
+ "decl", "def"}}},
   {
   R"cpp( // Function in namespace reference
   namespace bar {
-void foo();
+void $decl[[foo]]();
 int baz() {
   fo^o();
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "bar::", "c:@N@bar@F@foo#",
+ "decl"}}},
   {
   R"cpp( // Function in different namespace reference
   namespace bar {
-void foo();
+void $decl[[foo]]();
   }
   namespace barbar {
 int baz() {
@@ -64,10 +98,11 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "bar::", "c:@N@bar@F@foo#",
+ "decl"}}},
   {
   R"cpp( // Function in global namespace reference
-  void foo();
+  void $decl[[foo]]();
   namespace Nbar {
 namespace Nbaz {
   int baz() {
@@ -76,11 +111,11 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl"}}},
   {
   R"cpp( // Function in anonymous namespace reference
   namespace {
-void foo();
+void $decl[[foo]]();
   }
   namespace barbar {
 int baz() {
@@ -88,13 +123,13 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "(anonymous)",
-   "c:TestTU.cpp@aN@F@foo#")}},
+  

[PATCH] D130181: [clang-tidy] Add readability-use-early-exits check

2022-08-01 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 449048.
njames93 added a comment.

Rebase and Ping??


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130181

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/use-early-exits.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-braces.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-split.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
@@ -0,0 +1,164 @@
+// RUN: %check_clang_tidy %s readability-use-early-exits -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2}}"
+
+// Run the check with the braces around statements check also enabled, but
+// ShortStatementLines is set so that we shouldn't add braces.
+// RUN: %check_clang_tidy %s readability-use-early-exits,readability-braces-around-statements -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2, \
+// RUN:readability-braces-around-statements.ShortStatementLines: 2}}"
+
+// Just to hit the threshold
+void padLines();
+
+void nomralFunc(int *A) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (A) {
+*A = 10;
+  }
+  //   CHECK-FIXES: if (!A)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *A = 10;
+}
+
+void funcWithTrailing(int *B) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (B) {
+*B = 10;
+  }
+  return;
+  ;
+  //   CHECK-FIXES: if (!B)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *B = 10;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: return;
+  //  CHECK-FIXES-NEXT: ;
+}
+
+void normal(int A, int B) {
+
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A == B) {
+  padLines();
+}
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A != B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  //  CHECK-FIXES-NEXT: }
+
+  // Eat continue and empty nulls
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A != B) {
+  padLines();
+}
+continue;
+;
+continue;
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT:   ;
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: }
+}
+
+void toShort(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+  }
+}
+
+void hasElse(int A, int B) {
+  while (true) {
+if (A == B) {
+
+} else {
+}
+  }
+}
+
+void hasTrailingStmt(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+padLines();
+  }
+}
+
+void nested(int A, int B) {
+  // if (A > B) {
+  // CHECK-MESSAGES: [[@LINE+6]]:5: warning: use early exit
+  // if (B < A) {
+  // CHECK-MESSAGES: [[@LINE+5]]:7: warning: use early exit
+  // if (A == B) {
+  // CHECK-MESSAGES: [[@LINE+4]]:9: warning: use early exit
+  while (true) { // Nested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  }
+}
+  } // EndLoop
+  //   CHECK-FIXES: while (true) { // Nested
+  //  CHECK-FIXES-NEXT: if (A <= B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (B >= A)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: } // EndLoop
+}
+
+void badNested(bool B) {
+  // Ensure check doesn't check for nested `if` if outer `if` has else.
+  while (true) {
+if (B) {
+  if (B) {
+  }
+} else {
+}
+  }
+}
+
+void semiNested(int A, int B) {
+  // CHECK-MESSAGES: [[@LINE+2]]:5: warning: use early exit
+  while (true) { // SemiNested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  } else {
+  }
+}
+  }
+  //   CHECK-FIXES: 

[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-08-01 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 449046.
njames93 added a comment.

Revert to first version, just so we can sort out the 15.X branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/test/diagnostics-tidy.test


Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": 
"https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html;
+# CHECK-NEXT:  "href": 
"https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html;
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 
'K'?",
 # CHECK-NEXT:"range": {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -918,9 +918,19 @@
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/; + Name + 
".html")
-.str()};
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with 
a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+return ("https://clang.llvm.org/extra/clang-tidy/checks/; + Module + "/" +
+Check + ".html")
+.str();
+  }
   case Diag::Clangd:
 if (Name == "unused-includes")
   return {"https://clangd.llvm.org/guides/include-cleaner"};


Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html;
+# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html;
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
 # CHECK-NEXT:"range": {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -918,9 +918,19 @@
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/; + Name + ".html")
-.str()};
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+return ("https://clang.llvm.org/extra/clang-tidy/checks/; + Module + "/" +
+Check + ".html")
+.str();
+  }
   case Diag::Clangd:
 if (Name == "unused-includes")
   return {"https://clangd.llvm.org/guides/include-cleaner"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128372: [Clang-Tidy] Empty Check

2022-08-01 Thread Abraham Corea Diaz via Phabricator via cfe-commits
abrahamcd added a comment.

Hi all, I just wanted to check in on this again and see if any more feedback or 
progress could be made. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128372

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


[PATCH] D130019: [HLSL] CodeGen HLSL Resource annotations

2022-08-01 Thread Chris Bieneman 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 rG5dbb92d8cdf7: [HLSL] CodeGen HLSL Resource annotations 
(authored by beanz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130019

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h
  clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl

Index: clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s 
+
+RWBuffer Buffer1;
+RWBuffer > BufferArray[4];
+
+[numthreads(1,1,1)]
+void main() {
+}
+
+// CHECK: !hlsl.uavs = !{![[Single:[0-9]+]], ![[Array:[0-9]+]]}
+// CHECK-DAG: ![[Single]] = !{ptr @"?Buffer1@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer", i32 0}
+// CHECK-DAG: ![[Array]] = !{ptr @"?BufferArray@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer >", i32 1}
Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -15,7 +15,16 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 #define LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 
+#include "clang/Basic/HLSLRuntime.h"
+
+namespace llvm {
+class Value;
+class GlobalVariable;
+} // namespace llvm
 namespace clang {
+class CallExpr;
+class Type;
+class VarDecl;
 
 namespace CodeGen {
 
@@ -24,11 +33,15 @@
 class CGHLSLRuntime {
 protected:
   CodeGenModule 
+  uint32_t ResourceCounters[static_cast(
+  hlsl::ResourceClass::NumClasses)] = {0};
 
 public:
   CGHLSLRuntime(CodeGenModule ) : CGM(CGM) {}
   virtual ~CGHLSLRuntime() {}
 
+  void annotateHLSLResource(const VarDecl *D, llvm::GlobalVariable *GV);
+
   void finishCodeGen();
 };
 
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -20,6 +20,7 @@
 
 using namespace clang;
 using namespace CodeGen;
+using namespace hlsl;
 using namespace llvm;
 
 namespace {
@@ -50,3 +51,38 @@
   llvm::Module  = CGM.getModule();
   addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
 }
+
+void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) {
+  const Type *Ty = D->getType()->getPointeeOrArrayElementType();
+  if (!Ty)
+return;
+  const auto *RD = Ty->getAsCXXRecordDecl();
+  if (!RD)
+return;
+  const auto *Attr = RD->getAttr();
+  if (!Attr)
+return;
+
+  HLSLResourceAttr::ResourceClass RC = Attr->getResourceType();
+  uint32_t Counter = ResourceCounters[static_cast(RC)]++;
+
+  NamedMDNode *ResourceMD = nullptr;
+  switch (RC) {
+  case HLSLResourceAttr::ResourceClass::UAV:
+ResourceMD = CGM.getModule().getOrInsertNamedMetadata("hlsl.uavs");
+break;
+  default:
+assert(false && "Unsupported buffer type!");
+return;
+  }
+
+  assert(ResourceMD != nullptr &&
+ "ResourceMD must have been set by the switch above.");
+
+  auto  = CGM.getModule().getContext();
+  IRBuilder<> B(Ctx);
+  QualType QT(Ty, 0);
+  ResourceMD->addOperand(MDNode::get(
+  Ctx, {ValueAsMetadata::get(GV), MDString::get(Ctx, QT.getAsString()),
+ConstantAsMetadata::get(B.getInt32(Counter))}));
+}
Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "CGCXXABI.h"
+#include "CGHLSLRuntime.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
 #include "CodeGenFunction.h"
@@ -977,6 +978,9 @@
 EmitCXXGlobalVarDeclInit(*D, Addr, PerformInit);
   }
 
+  if (getLangOpts().HLSL)
+CGM.getHLSLRuntime().annotateHLSLResource(D, Addr);
+
   FinishFunction();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5dbb92d - [HLSL] CodeGen HLSL Resource annotations

2022-08-01 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-08-01T11:19:43-05:00
New Revision: 5dbb92d8cdf751d5960225e874c27d19597fa65e

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

LOG: [HLSL] CodeGen HLSL Resource annotations

HLSL Resource types need special annotations that the backend will use
to build out metadata and resource annotations that are required by
DirectX and Vulkan drivers in order to provide correct data bindings
for shader exeuction.

This patch adds some of the required data for unordered-access-views
(UAV) resource binding into the module flags. This data will evolve
over time to cover all the required use cases, but this should get
things started.

Depends on D130018.

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

Added: 
clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl

Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGHLSLRuntime.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 949112c63cc9e..620af1e633b73 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "CGCXXABI.h"
+#include "CGHLSLRuntime.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
 #include "CodeGenFunction.h"
@@ -977,6 +978,9 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 EmitCXXGlobalVarDeclInit(*D, Addr, PerformInit);
   }
 
+  if (getLangOpts().HLSL)
+CGM.getHLSLRuntime().annotateHLSLResource(D, Addr);
+
   FinishFunction();
 }
 

diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 7dfcc65969a86..3321d4ad0afb5 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -20,6 +20,7 @@
 
 using namespace clang;
 using namespace CodeGen;
+using namespace hlsl;
 using namespace llvm;
 
 namespace {
@@ -50,3 +51,38 @@ void CGHLSLRuntime::finishCodeGen() {
   llvm::Module  = CGM.getModule();
   addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
 }
+
+void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) 
{
+  const Type *Ty = D->getType()->getPointeeOrArrayElementType();
+  if (!Ty)
+return;
+  const auto *RD = Ty->getAsCXXRecordDecl();
+  if (!RD)
+return;
+  const auto *Attr = RD->getAttr();
+  if (!Attr)
+return;
+
+  HLSLResourceAttr::ResourceClass RC = Attr->getResourceType();
+  uint32_t Counter = ResourceCounters[static_cast(RC)]++;
+
+  NamedMDNode *ResourceMD = nullptr;
+  switch (RC) {
+  case HLSLResourceAttr::ResourceClass::UAV:
+ResourceMD = CGM.getModule().getOrInsertNamedMetadata("hlsl.uavs");
+break;
+  default:
+assert(false && "Unsupported buffer type!");
+return;
+  }
+
+  assert(ResourceMD != nullptr &&
+ "ResourceMD must have been set by the switch above.");
+
+  auto  = CGM.getModule().getContext();
+  IRBuilder<> B(Ctx);
+  QualType QT(Ty, 0);
+  ResourceMD->addOperand(MDNode::get(
+  Ctx, {ValueAsMetadata::get(GV), MDString::get(Ctx, QT.getAsString()),
+ConstantAsMetadata::get(B.getInt32(Counter))}));
+}

diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 268810f2ec9e6..5953be4117f94 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -15,7 +15,16 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 #define LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 
+#include "clang/Basic/HLSLRuntime.h"
+
+namespace llvm {
+class Value;
+class GlobalVariable;
+} // namespace llvm
 namespace clang {
+class CallExpr;
+class Type;
+class VarDecl;
 
 namespace CodeGen {
 
@@ -24,11 +33,15 @@ class CodeGenModule;
 class CGHLSLRuntime {
 protected:
   CodeGenModule 
+  uint32_t ResourceCounters[static_cast(
+  hlsl::ResourceClass::NumClasses)] = {0};
 
 public:
   CGHLSLRuntime(CodeGenModule ) : CGM(CGM) {}
   virtual ~CGHLSLRuntime() {}
 
+  void annotateHLSLResource(const VarDecl *D, llvm::GlobalVariable *GV);
+
   void finishCodeGen();
 };
 

diff  --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
new file mode 100644
index 0..4d12fa197f5e2
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s 
+
+RWBuffer Buffer1;
+RWBuffer > BufferArray[4];
+
+[numthreads(1,1,1)]
+void main() {
+}
+
+// CHECK: !hlsl.uavs = !{![[Single:[0-9]+]], ![[Array:[0-9]+]]}
+// CHECK-DAG: ![[Single]] = !{ptr 

[PATCH] D130019: [HLSL] CodeGen HLSL Resource annotations

2022-08-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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130019

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-08-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D130311#3691029 , @reames wrote:

> I'm not fluent on strict FP, so let me summarize my understanding.  This is 
> mostly so you can easily correct me if one my assumptions is wrong.
>
> - Under strict FP, clang will emit constrained fp intrinsics instead of 
> normal floating point ops.
> - To my knowledge, clang will never emit an explicit vector constrained 
> intrinsic.

operator +, -, *, / etc. on __attribute__((__vector_size__)) types will 
generate vector constrained intrinsics.

> - The vectorizers (LV, SLP) don't appear to have any handling for constrained 
> FP intrinsics.  If it did, I'd expect it to have to ask about legality of the 
> widened operation - the same way it does for e.g. a scatter/gather.
>
> So, my question is: why don't we support StrictFP when targeting a vector 
> enabled platform?  Don't we trivially support them by simply never using the 
> vector forms?






Comment at: clang/lib/Basic/Targets/RISCV.cpp:286
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasExtension("zve32x"))
+HasStrictFP = false;

reames wrote:
> asb wrote:
> > There's also code in RISCVISAInfo.cpp that does `HasVector = 
> > Exts.count("zve32x") != 0`. It's probably worth adding a helper 
> > (`hasVInstructions`?) that encapsulates this, and use it from both places.
> It's not clear to me why this condition is specific to embedded vector 
> variants.  Do we have strict FP with +V?  Either you need to fix a comment 
> here, or the condition.  One or the other.  
V implies Zve64d implies Zve64f implies Zve32f and Zve64x. Zve32f implies 
Zve32x. Zve32x is the root of the vector inheritance tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

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


[PATCH] D130041: [clangd] Add decl/def support to SymbolDetails

2022-08-01 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 449033.
dgoldman added a comment.

Fix broken test and swap to AST.tuPath()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130041

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/test/symbol-info.test
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
@@ -18,45 +18,79 @@
 
 using ::testing::UnorderedElementsAreArray;
 
-auto CreateExpectedSymbolDetails = [](const std::string ,
-  const std::string ,
-  const std::string ) {
-  return SymbolDetails{Name, Container, USR, SymbolID(USR)};
+// Partial SymbolDetails with the rest filled in at testing time.
+struct ExpectedSymbolDetails {
+  std::string Name;
+  std::string Container;
+  std::string USR;
+  const char *DeclMarker = nullptr;
+  const char *DefMarker = nullptr;
 };
 
 TEST(SymbolInfoTests, All) {
-  std::pair>
+  std::pair>
   TestInputExpectedOutput[] = {
   {
   R"cpp( // Simple function reference - declaration
-  void foo();
+  void $decl[[foo]]();
   int bar() {
 fo^o();
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl"}}},
   {
   R"cpp( // Simple function reference - definition
-  void foo() {}
+  void $def[[foo]]() {}
   int bar() {
 fo^o();
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "def", "def"}}},
+  {
+  R"cpp( // Simple function reference - decl and def
+  void $decl[[foo]]();
+  void $def[[foo]]() {}
+  int bar() {
+fo^o();
+  }
+)cpp",
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl", "def"}}},
+  {
+  R"cpp( // Simple class reference - decl and def
+  @interface $decl[[Foo]]
+  @end
+  @implementation $def[[Foo]]
+  @end
+  void doSomething(F^oo *obj) {}
+)cpp",
+  {ExpectedSymbolDetails{"Foo", "", "c:objc(cs)Foo", "decl",
+ "def"}}},
+  {
+  R"cpp( // Simple method reference - decl and def
+  @interface Foo
+  - (void)$decl[[foo]];
+  @end
+  @implementation Foo
+  - (void)$def[[fo^o]] {}
+  @end
+)cpp",
+  {ExpectedSymbolDetails{"foo", "Foo::", "c:objc(cs)Foo(im)foo",
+ "decl", "def"}}},
   {
   R"cpp( // Function in namespace reference
   namespace bar {
-void foo();
+void $decl[[foo]]();
 int baz() {
   fo^o();
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "bar::", "c:@N@bar@F@foo#",
+ "decl"}}},
   {
   R"cpp( // Function in different namespace reference
   namespace bar {
-void foo();
+void $decl[[foo]]();
   }
   namespace barbar {
 int baz() {
@@ -64,10 +98,11 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "bar::", "c:@N@bar@F@foo#",
+ "decl"}}},
   {
   R"cpp( // Function in global namespace reference
-  void foo();
+  void $decl[[foo]]();
   namespace Nbar {
 namespace Nbaz {
   int baz() {
@@ -76,11 +111,11 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}},
+  {ExpectedSymbolDetails{"foo", "", "c:@F@foo#", "decl"}}},
   {
   R"cpp( // Function in anonymous namespace reference
   namespace {
-void foo();
+void $decl[[foo]]();
   }
   namespace barbar {
 int baz() {
@@ -88,13 +123,13 @@
 }
   }
 )cpp",
-  {CreateExpectedSymbolDetails("foo", "(anonymous)",
-   "c:TestTU.cpp@aN@F@foo#")}},
+  

[PATCH] D119051: Extend the C++03 definition of POD to include defaulted functions

2022-08-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D130906: [clang] format string checking for conpile-time evaluated str literal

2022-08-01 Thread YingChi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: clang/test/Sema/format-strings-scanf.c:235
   scanf(0 ? "%s" : "%d", i); // no warning
-  scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char 
*'}}
+  scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char 
*'}} \
+ // expected-note{{format string is defined here}}

These new notes are FixIt hints, looks much better than before.



Comment at: clang/test/Sema/format-strings.c:263
   // expected-note@-1{{treat the string as an argument to avoid this}}
-  printf(s4); // expected-warning{{not a string literal}}
-  // expected-note@-1{{treat the string as an argument to avoid this}}
+  printf(s4);
   printf(s5); // expected-warning{{not a string literal}}

Here, s4 is declared as `char * const` and initialized as `const char`, so 
warning generates at the declaration of  `s4` is sufficient? Since modify 
characters in string literal causes UB.

```
Initializing 'char *const' with an expression of type 'const char[6]' discards 
qualifiers
```

Currently the checker in this patch just qualifies `"hello"` as a string 
literal, and does not report `-Wformat-nonliteral` as before


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130906

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


[PATCH] D130906: [clang] format string checking for conpile-time evaluated str literal

2022-08-01 Thread YingChi Long via Phabricator via cfe-commits
inclyc created this revision.
Herald added a project: All.
inclyc edited the summary of this revision.
inclyc updated this revision to Diff 449023.
inclyc added a comment.
inclyc added reviewers: mizvekov, rsmith, aaron.ballman.
inclyc added a project: clang.
inclyc added a subscriber: clang.
inclyc published this revision for review.
Herald added a subscriber: cfe-commits.

add newline


This patch enhances clang's ability to check compile-time determinable
string literals as format strings, and can give FixIt hints at literals
(unlike gcc). Issue https://github.com/llvm/llvm-project/issues/55805
mentiond two compile-time string cases. And this patch partially fixes
one.

  constexpr const char* foo() {
return "%s %d";
  }
  int main() {
 printf(foo(), "abc", "def");
 return 0;
  }

This patch enables clang check format string for this:

  :4:24: warning: format specifies type 'int' but the argument has type 
'const char *' [-Wformat]
printf(foo(), "abc", "def");
   ~ ^
  :2:42: note: format string is defined here
  constexpr const char *foo() { return "%s %d"; }
   ^~
   %s
  1 warning generated.

Signed-off-by: YingChi Long 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130906

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/format-strings-scanf.c
  clang/test/Sema/format-strings.c
  clang/test/SemaCXX/format-strings.cpp

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -163,3 +163,48 @@
   t::func4("Hello %s"); // expected-warning {{more '%' conversions than data arguments}}
 }
 }
+#if __cplusplus >= 201103L
+namespace evaluated {
+
+constexpr const char *basic() { 
+  return 
+"%s %d"; // expected-note {{format string is defined here}}
+}
+
+constexpr const char *correct_fmt() { 
+  return 
+"%d %d";
+}
+
+constexpr const char *string_linebreak() { 
+  return 
+"%d %d"
+"%d %s"; // expected-note {{format string is defined here}}
+}
+
+/*non-constexpr*/ const char *not_literal() { 
+  return 
+"%d %d"
+"%d %s";
+}
+
+constexpr const char *inner_call() {
+  return "%d %s"; // expected-note {{format string is defined here}}
+}
+
+constexpr const char *wrap_constexpr() {
+  return inner_call();
+}
+
+
+void f() {
+  printf(basic(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(correct_fmt(), 1, 2);
+  printf(string_linebreak(), 1, 2, 3, 4); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+  printf(not_literal(), 1, 2, 3, 4); // expected-warning {{format string is not a string literal}}
+  printf(wrap_constexpr(), 1, 2); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
+}
+
+
+}
+#endif
Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -105,7 +105,8 @@
   // expected-note@-1{{treat the string as an argument to avoid this}}
   printf("yes" ?: "no %d", 1); // expected-warning{{data argument not used by format string}}
   printf(0 ? "yes %s" : "no %d", 1); // no-warning
-  printf(0 ? "yes %d" : "no %s", 1); // expected-warning{{format specifies type 'char *'}}
+  printf(0 ? "yes %d" : "no %s", 1); // expected-warning{{format specifies type 'char *'}} \
+ // expected-note{{format string is defined here}}
 
   printf(0 ? "yes" : "no %d", 1); // no-warning
   printf(0 ? "yes %d" : "no", 1); // expected-warning{{data argument not used by format string}}
@@ -259,8 +260,7 @@
   printf(s2); // no-warning
   printf(s3); // expected-warning{{not a string literal}}
   // expected-note@-1{{treat the string as an argument to avoid this}}
-  printf(s4); // expected-warning{{not a string literal}}
-  // expected-note@-1{{treat the string as an argument to avoid this}}
+  printf(s4);
   printf(s5); // expected-warning{{not a string literal}}
   // expected-note@-1{{treat the string as an argument to avoid this}}
 }
@@ -621,7 +621,8 @@
 
   // Make sure that the "format string is defined here" note is not emitted
   // when the original string is within the argument expression.
-  printf(1 ? "yes %d" : "no %d"); // expected-warning{{more '%' conversions than data arguments}}
+  printf(1 ? "yes %d" : "no %d"); // expected-warning{{more '%' conversions than data arguments}} \
+  // expected-note {{format string is defined here}}
 
   const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}}
   printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
Index: clang/test/Sema/format-strings-scanf.c

[PATCH] D130907: [Clang] Use pragma FENV_ROUND to reset rounding mode settings.

2022-08-01 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rjmccall, aaron.ballman, kpn.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a project: clang.

Now starting from the first use of `pragma FENV_ROUND` rounding mode
becomes user-defined and there is no way to return back to initial
state. Default rounding mode and the same explicitly defined one result
in different AST. For example, the code:

  float func_04(float x, float y) {
return x + y;
  }

produces AST where the FP operation is represented with the node:

  `-BinaryOperator 0x25d6e2cecb8  'float' '+'

The same code with `#pragma STDC FENV_ROUND FE_TONEAREST` before the
function definition produces slightly different representation:

  `-BinaryOperator 0x1832c1a4ce8  'float' '+' 
ConstRoundingMode=tonearest

Code generation is not changed in this case because `tonearest` is the
rounding mode in default FP environment. However if an AST object has
an override for a FP property, it considered as explicitly specified
and is preserved in some cases where default property may be overridden.

Default rounding mode is `dynamic` according to the C2x standard
draft (7.6.2p3):

  ... If no FENV_ROUND pragma is in effect, or the specified constant
  rounding mode is FE_DYNAMIC, rounding is according to the mode
  specified by the dynamic floating-point environment ...

So pragma `FENV_ROUND FE_DYNAMIC` must reset rounding to default state,
but now it only adds related override:

  `-BinaryOperator 0x1cb8cfaaec8  'float' '+' 
ConstRoundingMode=dynamic

This change fixes the pragma behavior. If `FENV_ROUND FE_DYNAMIC` is
specified without `FENV_ACCESS ON`, the rounding mode override is
removed, which effectively establish default rounding mode state.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130907

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp


Index: clang/test/AST/ast-dump-fpfeatures.cpp
===
--- clang/test/AST/ast-dump-fpfeatures.cpp
+++ clang/test/AST/ast-dump-fpfeatures.cpp
@@ -109,7 +109,18 @@
 }
 
 // CHECK-LABEL: FunctionDecl {{.*}} func_12 'float (float, float)'
+// CHECK: BinaryOperator {{.*}} 'float' '+'
+
+#pragma STDC FENV_ROUND FE_DYNAMIC
+#pragma STDC FENV_ACCESS ON
+
+float func_12a(float x, float y) {
+  return x + y;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} func_12a 'float (float, float)'
 // CHECK: BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=dynamic
+#pragma STDC FENV_ACCESS OFF
 
 #pragma STDC FENV_ROUND FE_TONEAREST
 
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -391,7 +391,14 @@
 }
 
 void Sema::ActOnAfterCompoundStatementLeadingPragmas() {
-  if (getCurFPFeatures().isFPConstrained()) {
+  FPOptions  = getCurFPFeatures();
+  if (FPO.getConstRoundingMode() == llvm::RoundingMode::Dynamic &&
+  !FPO.getAllowFEnvAccess()) {
+// If dynamic rounding mode is specified in absence of FENV_ACCESS, treat 
it
+// as setting default rounding mode.
+FpPragmaStack.CurrentValue.clearConstRoundingModeOverride();
+  }
+  if (FPO.isFPConstrained()) {
 FunctionScopeInfo *FSI = getCurFunction();
 assert(FSI);
 FSI->setUsesFPIntrin();


Index: clang/test/AST/ast-dump-fpfeatures.cpp
===
--- clang/test/AST/ast-dump-fpfeatures.cpp
+++ clang/test/AST/ast-dump-fpfeatures.cpp
@@ -109,7 +109,18 @@
 }
 
 // CHECK-LABEL: FunctionDecl {{.*}} func_12 'float (float, float)'
+// CHECK: BinaryOperator {{.*}} 'float' '+'
+
+#pragma STDC FENV_ROUND FE_DYNAMIC
+#pragma STDC FENV_ACCESS ON
+
+float func_12a(float x, float y) {
+  return x + y;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} func_12a 'float (float, float)'
 // CHECK: BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=dynamic
+#pragma STDC FENV_ACCESS OFF
 
 #pragma STDC FENV_ROUND FE_TONEAREST
 
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -391,7 +391,14 @@
 }
 
 void Sema::ActOnAfterCompoundStatementLeadingPragmas() {
-  if (getCurFPFeatures().isFPConstrained()) {
+  FPOptions  = getCurFPFeatures();
+  if (FPO.getConstRoundingMode() == llvm::RoundingMode::Dynamic &&
+  !FPO.getAllowFEnvAccess()) {
+// If dynamic rounding mode is specified in absence of FENV_ACCESS, treat it
+// as setting default rounding mode.
+FpPragmaStack.CurrentValue.clearConstRoundingModeOverride();
+  }
+  if (FPO.isFPConstrained()) {
 FunctionScopeInfo *FSI = getCurFunction();
 assert(FSI);
 FSI->setUsesFPIntrin();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D130372: [analyzer] Add a new factory function RangeSet::Factory::invert

2022-08-01 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D130372#3683275 , @ASDenysPetrov 
wrote:

> Now I'm working on the next patch and you'll see a motivation soon.

Thanks for the update! Looks good, but I am still waiting with my formal 
approve to understand the motivation.




Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:1130
+  // Check inverting single range.
+  this->checkInvert({{MIN, MAX}}, {});
+  this->checkInvert({{MIN, MID}}, {{MID + 1, MAX}});

ASDenysPetrov wrote:
> martong wrote:
> > I'd expect that inversion on finite sets is an invert-able function thus
> > ```
> > this->checkInvert({}, {MIN, MAX});
> > ```
> > would make sense instead of assertion.
> > 
> > Besides, it would make sense to test the composition of two invert 
> > operations to identity. 
> I'm afraid the function would be overheaded and less usable. Why do we have 
> an assertion here? I thought about this. This is kinda a tradeoff.
> 
> What range would be a correct range from inversion of `[]`? `[-128, 127]`? 
> `[0, 65535]`?
> In order to make `[MIN, MAX]` from empty range `[]` we should know the exact 
> `APSIntType`. We extract the type from the given range 
> `What.getAPSIntType();`.
> 
> But though, let's consider we have `QualType` as a second parameter. We have 
> two options about what type to use.
> 1. Always use the second parameter. The function would not only invert but do 
> what `castTo` actually do. Such behavior would violates a single 
> responsibility principle and duplicate the functionality.
> 2. Always use the type from the given range and for the case of empty range 
> from the second parameter. The function contract would be more complex and 
> obscure.
> 
> So, I decided not to introduce a new parameter and shift responsibility to 
> the user. Empty range is an edge case when we usually produce infeasible 
> state or use `infer(QualType)`. This may pretty fit with what user is going 
> to do first before using `invert`, so it shouldn't affect the convinience of 
> function usage too much.
Okay, I see your point.

So, considering `RangeSet::Factory::invert(RangeSet What)` we have only one 
parameter and that is the RangeSet to be inverted. And that set might be empty 
and in that case we are left without any type information, thus there is no way 
to return [MIN, MAX]. Please correct me if I am wrong.


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

https://reviews.llvm.org/D130372

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


  1   2   >