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

2022-08-01 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added a reviewer: iains.
ChuanqiXu added a project: clang-modules.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

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=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
+//
+//--- 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
@@ -649,8 +649,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;
@@ -778,8 +778,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


[PATCH] D130710: [ASTWriter] Provide capability to output a PCM/PCH file that does not write out information about its output path

2022-08-01 Thread Richard Howell via Phabricator via cfe-commits
rmaz added a comment.

In D130710#3688338 , @akyrtzi wrote:

> In D130710#3685436 , @benlangmuir 
> wrote:
>
>> Is the functionality provided by `ORIGINAL_PCH_DIR` still useful for making 
>> it possible to move a PCH and its referenced headers?  It's not completely 
>> clear to me when this feature is used in practice.  It would be nice to 
>> remove it or change the default behaviour if possible, rather than require a 
>> new option, but I'm open to this approach if we think we can't change the 
>> default.
>
> Given that there was a recent change  
> related to `ORIGINAL_PCH_DIR`, I'm reluctant to change the default at this 
> point, I added a `FIXME` for following up to see if we can remove it or 
> change the default later on.

We don't use this functionality, no. My change was made for the same reason: to 
be able to relocate and cache pcm files when used in conjunction with 
`-fmodule-file-home-is-cwd`, removing the field entirely would be preferable 
from our perspective.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130710

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


[clang] ef9df0d - [ARM] Simplify ArchGuard predicates in arm_neon.h.

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

Author: David Green
Date: 2022-08-01T08:20:23+01:00
New Revision: ef9df0dc000c2c294398ab6fe13533d967dc29cd

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

LOG: [ARM] Simplify ArchGuard predicates in arm_neon.h.

__ARM_ARCH >= 8 is implied by defined(__aarch64__), so we don't need to
guard against both together.

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 93f9961931370..69371113c1c8f 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1141,7 +1141,7 @@ def SHA256H2 : SInst<"vsha256h2", "", "QUi">;
 def SHA256SU1 : SInst<"vsha256su1", "", "QUi">;
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA3) && 
defined(__aarch64__)" in {
+let ArchGuard = "defined(__ARM_FEATURE_SHA3) && defined(__aarch64__)" in {
 def BCAX : SInst<"vbcax", "", "QUcQUsQUiQUlQcQsQiQl">;
 def EOR3 : SInst<"veor3", "", "QUcQUsQUiQUlQcQsQiQl">;
 def RAX1 : SInst<"vrax1", "...", "QUl">;
@@ -1151,7 +1151,7 @@ def XAR :  SInst<"vxar", "...I", "QUl">;
 }
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA512) && 
defined(__aarch64__)" in {
+let ArchGuard = "defined(__ARM_FEATURE_SHA512) && defined(__aarch64__)" in {
 
 def SHA512SU0 : SInst<"vsha512su0", "...", "QUl">;
 def SHA512su1 : SInst<"vsha512su1", "", "QUl">;
@@ -1159,7 +1159,7 @@ def SHA512H : SInst<"vsha512h", "", "QUl">;
 def SHA512H2 : SInst<"vsha512h2", "", "QUl">;
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SM3) && 
defined(__aarch64__)" in {
+let ArchGuard = "defined(__ARM_FEATURE_SM3) && defined(__aarch64__)" in {
 def SM3SS1 : SInst<"vsm3ss1", "", "QUi">;
 def SM3TT1A : SInst<"vsm3tt1a", "I", "QUi">;
 def SM3TT1B : SInst<"vsm3tt1b", "I", "QUi">;
@@ -1169,7 +1169,7 @@ def SM3PARTW1 : SInst<"vsm3partw1", "", "QUi">;
 def SM3PARTW2 : SInst<"vsm3partw2", "", "QUi">;
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SM4) && 
defined(__aarch64__)" in {
+let ArchGuard = "defined(__ARM_FEATURE_SM4) && defined(__aarch64__)" in {
 def SM4E : SInst<"vsm4e", "...", "QUi">;
 def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;
 }
@@ -1192,7 +1192,7 @@ def FCVTAS_S32 : SInst<"vcvta_s32", "S.", "fQf">;
 def FCVTAU_S32 : SInst<"vcvta_u32", "U.", "fQf">;
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__)" in {
+let ArchGuard = "defined(__aarch64__)" in {
 def FCVTNS_S64 : SInst<"vcvtn_s64", "S.", "dQd">;
 def FCVTNU_S64 : SInst<"vcvtn_u64", "U.", "dQd">;
 def FCVTPS_S64 : SInst<"vcvtp_s64", "S.", "dQd">;
@@ -1216,7 +1216,7 @@ def FRINTZ_S32 : SInst<"vrnd", "..", "fQf">;
 def FRINTI_S32 : SInst<"vrndi", "..", "fQf">;
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__) && 
defined(__ARM_FEATURE_DIRECTED_ROUNDING)" in {
+let ArchGuard = "defined(__aarch64__) && 
defined(__ARM_FEATURE_DIRECTED_ROUNDING)" in {
 def FRINTN_S64 : SInst<"vrndn", "..", "dQd">;
 def FRINTA_S64 : SInst<"vrnda", "..", "dQd">;
 def FRINTP_S64 : SInst<"vrndp", "..", "dQd">;
@@ -1226,7 +1226,7 @@ def FRINTZ_S64 : SInst<"vrnd", "..", "dQd">;
 def FRINTI_S64 : SInst<"vrndi", "..", "dQd">;
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__) && 
defined(__ARM_FEATURE_FRINT)" in {
+let ArchGuard = "defined(__aarch64__) && defined(__ARM_FEATURE_FRINT)" in {
 def FRINT32X_S32 : SInst<"vrnd32x", "..", "fQf">;
 def FRINT32Z_S32 : SInst<"vrnd32z", "..", "fQf">;
 def FRINT64X_S32 : SInst<"vrnd64x", "..", "fQf">;
@@ -1241,7 +1241,7 @@ def FMAXNM_S32 : SInst<"vmaxnm", "...", "fQf">;
 def FMINNM_S32 : SInst<"vminnm", "...", "fQf">;
 }
 
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__) && 
defined(__ARM_FEATURE_NUMERIC_MAXMIN)" in {
+let ArchGuard = "defined(__aarch64__) && 
defined(__ARM_FEATURE_NUMERIC_MAXMIN)" in {
 def FMAXNM_S64 : SInst<"vmaxnm", "...", "dQd">;
 def FMINNM_S64 : SInst<"vminnm", "...", "dQd">;
 }
@@ -1283,7 +1283,7 @@ def VQTBX4_A64 : WInst<"vqtbx4", "..(4Q)U", 
"UccPcQUcQcQPc">;
 // itself during generation so, unlike all other intrinsics, this one should
 // include *all* types, not just additional ones.
 def VVREINTERPRET : 
REINTERPRET_CROSS_SELF<"csilUcUsUiUlhfdPcPsPlQcQsQiQlQUcQUsQUiQUlQhQfQdQPcQPsQPlQPk">
 {
-  let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__)";
+  let ArchGuard = "defined(__aarch64__)";
   let BigEndianSafe = 1;
 }
 



___
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 Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2524-2525
 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?");

See the example about `M.cppm`.


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


[clang] 2bb7c54 - [Clang] Remove unused parameter. NFC

2022-08-01 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2022-08-01T14:53:13+07:00
New Revision: 2bb7c54621f31a957302a4deb3d25b752acb07bd

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

LOG: [Clang] Remove unused parameter. NFC

BinaryOperator::getFPFeatures get parameter, which is not used. Similar
methods of other AST nodes do not have any parameter.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/lib/AST/ASTImporter.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 1f3d524691ed6..1fc6dc90b6c7c 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4009,7 +4009,7 @@ class BinaryOperator : public Expr {
   }
 
   // This is used in ASTImporter
-  FPOptionsOverride getFPFeatures(const LangOptions &LO) const {
+  FPOptionsOverride getFPFeatures() const {
 if (BinaryOperatorBits.HasFPFeatures)
   return getStoredFPFeatures();
 return FPOptionsOverride();

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 0273e50683716..159010713f434 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -7224,7 +7224,7 @@ ExpectedStmt 
ASTNodeImporter::VisitBinaryOperator(BinaryOperator *E) {
   return BinaryOperator::Create(
   Importer.getToContext(), ToLHS, ToRHS, E->getOpcode(), ToType,
   E->getValueKind(), E->getObjectKind(), ToOperatorLoc,
-  E->getFPFeatures(Importer.getFromContext().getLangOpts()));
+  E->getFPFeatures());
 }
 
 ExpectedStmt ASTNodeImporter::VisitConditionalOperator(ConditionalOperator *E) 
{
@@ -7335,7 +7335,7 @@ 
ASTNodeImporter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
   return CompoundAssignOperator::Create(
   Importer.getToContext(), ToLHS, ToRHS, E->getOpcode(), ToType,
   E->getValueKind(), E->getObjectKind(), ToOperatorLoc,
-  E->getFPFeatures(Importer.getFromContext().getLangOpts()),
+  E->getFPFeatures(),
   ToComputationLHSType, ToComputationResultType);
 }
 

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index ee3f9c6767fa9..30c1f5c978945 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -7381,7 +7381,7 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) {
   return BinaryOperator::Create(Context, BO->getLHS(), RHS.get(), BO_Comma,
 BO->getType(), BO->getValueKind(),
 BO->getObjectKind(), BO->getOperatorLoc(),
-BO->getFPFeatures(getLangOpts()));
+BO->getFPFeatures());
 }
   }
 

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index c52e12d3eb9ba..86d92158da8df 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11186,7 +11186,7 @@ 
TreeTransform::TransformBinaryOperator(BinaryOperator *E) {
 return getDerived().RebuildBinaryOperator(
 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
   Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
-  FPOptionsOverride NewOverrides(E->getFPFeatures(getSema().getLangOpts()));
+  FPOptionsOverride NewOverrides(E->getFPFeatures());
   getSema().CurFPFeatures =
   NewOverrides.applyOverrides(getSema().getLangOpts());
   getSema().FpPragmaStack.CurrentValue = NewOverrides;
@@ -11253,7 +11253,7 @@ ExprResult
 TreeTransform::TransformCompoundAssignOperator(
   CompoundAssignOperator 
*E) {
   Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
-  FPOptionsOverride NewOverrides(E->getFPFeatures(getSema().getLangOpts()));
+  FPOptionsOverride NewOverrides(E->getFPFeatures());
   getSema().CurFPFeatures =
   NewOverrides.applyOverrides(getSema().getLangOpts());
   getSema().FpPragmaStack.CurrentValue = NewOverrides;



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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-01 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3689157 , @thakis wrote:

> Is it expected and intentional that this increases the mac deployment target 
> to 10.12?

I wasn't aware of that - but I think it's expected since the check in RWMutex 
checks for the C++ standard and doesn't care about the deployment target for 
macOS. It seems pretty easy to change, but I wonder if that matters? 10.12 was 
released in 2016 so it's pretty old and this wouldn't affect most users of LLVM.

My gut feeling say that we should be fine with requiring 10.12 and if that 
becomes a big problem during the development phase someone could propose a 
patch to improve the check in RWMutex.

But in that case we should probably have a check for the deployment target as 
part of the cmake config and error if CXX_STANDARD > 17 and 
OSX_DEPLOYMENT_TARGET < 10.12.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[clang] 834a878 - [C++2b] [Modules] Handle HaveModules with C++2b

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

Author: Chuanqi Xu
Date: 2022-08-01T16:06:34+08:00
New Revision: 834a878367f549c58313200ce2c3a0da1a29d842

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

LOG: [C++2b] [Modules] Handle HaveModules with C++2b

Closing https://github.com/llvm/llvm-project/issues/56803. The root
cause for this bug is that we lack a good method to detect the language
mdoe when parsing the command line. There is a FIXME too. Dut to we lack
a good solution now, keep the workaround.

Added: 
clang/test/Driver/modules-fprebuilt-mdoule-path.cpp

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f41d6f4228b62..c691cae27c972 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6595,7 +6595,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // support by default, or just assume that all languages do.
   bool HaveModules =
   Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") ||
-  Std->containsValue("c++latest"));
+  Std->containsValue("c++2b") || Std->containsValue("c++latest"));
   RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules);
 
   if (Args.hasFlag(options::OPT_fpch_validate_input_files_content,

diff  --git a/clang/test/Driver/modules-fprebuilt-mdoule-path.cpp 
b/clang/test/Driver/modules-fprebuilt-mdoule-path.cpp
new file mode 100644
index 0..a2c830bfda00b
--- /dev/null
+++ b/clang/test/Driver/modules-fprebuilt-mdoule-path.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang -std=c++2a -fprebuilt-module-path=. -### -c %s 2>&1 | FileCheck 
%s
+// RUN: %clang -std=c++20 -fprebuilt-module-path=. -### -c %s 2>&1 | FileCheck 
%s
+// RUN: %clang -std=c++2b -fprebuilt-module-path=. -### -c %s 2>&1 | FileCheck 
%s
+// RUN: %clang -std=c++latest -fprebuilt-module-path=. -### -c %s 2>&1 | 
FileCheck %s
+//
+// CHECK-NOT: warning: argument unused during compilation
+// CHECK: -fprebuilt-module-path=.



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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-01 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D130689#3690258 , @thieta wrote:

> In D130689#3689157 , @thakis wrote:
>
>> Is it expected and intentional that this increases the mac deployment target 
>> to 10.12?
>
> I wasn't aware of that - but I think it's expected since the check in RWMutex 
> checks for the C++ standard and doesn't care about the deployment target for 
> macOS. It seems pretty easy to change, but I wonder if that matters? 10.12 
> was released in 2016 so it's pretty old and this wouldn't affect most users 
> of LLVM.
>
> My gut feeling say that we should be fine with requiring 10.12 and if that 
> becomes a big problem during the development phase someone could propose a 
> patch to improve the check in RWMutex.
>
> But in that case we should probably have a check for the deployment target as 
> part of the cmake config and error if CXX_STANDARD > 17 and 
> OSX_DEPLOYMENT_TARGET < 10.12.

Given 
https://github.com/llvm/llvm-project/blob/2bb7c54621f31a957302a4deb3d25b752acb07bd/llvm/include/llvm/Support/RWMutex.h#L22-L27,
 it seems like this is supposed to be supported. This is probably just a matter 
of moving the shared_mutex use behind the LLVM_USE_RW_MUTEX_IMPL guard?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

___
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 Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

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? 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).


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] D130689: [LLVM] Update C++ standard to 17

2022-08-01 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3690274 , @nikic wrote:

> Given 
> https://github.com/llvm/llvm-project/blob/2bb7c54621f31a957302a4deb3d25b752acb07bd/llvm/include/llvm/Support/RWMutex.h#L22-L27,
>  it seems like this is supposed to be supported. This is probably just a 
> matter of moving the shared_mutex use behind the LLVM_USE_RW_MUTEX_IMPL guard?

Yeah - I just realized that when I checked this. Just building the rest of the 
tree now to confirm this is the only change we need and I will publish this a 
different diff first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


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

2022-08-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

sorry this has slipped through. since we're going to backport it, let's make it 
minimal and always point to in-progress release notes (so sorry for reverting 
back to original version of the patch).

i think having clangd point to versioned docs would be much nicer, but it seems 
like we don't really have precise release guarantees for docs, especially in 
point releases. so i think we should first figure that story out, before going 
down that path (i don't think not pointing to exact version is a win, we might 
still be stale due to backports and there isn't much value in it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

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


[clang] 892e6e2 - [clang] Update Clang version from 15 to 16 in scan-build.1.

2022-08-01 Thread Frederic Cambus via cfe-commits

Author: Frederic Cambus
Date: 2022-08-01T10:34:55+02:00
New Revision: 892e6e2200d90e1b3140dc7feda6f46318688441

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

LOG: [clang] Update Clang version from 15 to 16 in scan-build.1.

Similar to D110763.

Added: 


Modified: 
clang/tools/scan-build/man/scan-build.1

Removed: 




diff  --git a/clang/tools/scan-build/man/scan-build.1 
b/clang/tools/scan-build/man/scan-build.1
index d213298706fea..10593dc1cd92e 100644
--- a/clang/tools/scan-build/man/scan-build.1
+++ b/clang/tools/scan-build/man/scan-build.1
@@ -2,9 +2,9 @@
 .\" See https://llvm.org/LICENSE.txt for license information.
 .\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 .\" $Id$
-.Dd Jun 24, 2022
+.Dd Aug 1, 2022
 .Dt SCAN-BUILD 1
-.Os "clang" "15"
+.Os "clang" "16"
 .Sh NAME
 .Nm scan-build
 .Nd Clang static analyzer



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


[PATCH] D130735: [Clang][LLD][cmake] Drop deprecated support for `llvm-config`-based build

2022-08-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM we should consider removing `llvm-config` from other subprojects as a 
follow up cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130735

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


[PATCH] D130363: [clang] Give priority to Class context while parsing declarations

2022-08-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> Is my invocation correct or is this case handled by clangd and not clang?

yeah your invocation is correct. this is because clang's printer does a prefix 
based filtering (while clangd does a fuzzy match) 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/CodeCompleteConsumer.cpp#L623.




Comment at: clang/test/CodeCompletion/overrides.cpp:41
+// Runs completion at empty line on line 13.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:13:1 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: COMPLETION: Pattern : void vfunc(bool param) override{{$}}

no need for `-code-completion-patterns`. can you also move the new test case 
below (after `CHECK-CC3-NOT`) that way we get to keep the line numbers for old 
tests the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130363

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


[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-08-01 Thread Marco Elver via Phabricator via cfe-commits
melver created this revision.
Herald added a subscriber: ormris.
Herald added a project: All.
melver requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Introduces the frontend flag -fexperimental-sanitize-metadata=, which
enables SanitizerBinaryMetadata instrumentation.

The first intended user of the binary metadata emitted will be a variant
of GWP-TSan [1]. The plan is to open source a stable and production
quality version of GWP-TSan. The development of which, however, requires
upstream compiler support.

[1] https://llvm.org/devmtg/2020-09/slides/Morehouse-GWP-Tsan.pdf

Until the tool has been open sourced, we mark this kind of
instrumentation as "experimental", and reserve the option to change
binary format, remove features, and similar.

Depends on D130887 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130888

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize-metadata.c

Index: clang/test/Driver/fsanitize-metadata.c
===
--- /dev/null
+++ clang/test/Driver/fsanitize-metadata.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-linux-gnu %s -### 2>&1 | FileCheck %s
+// CHECK-NOT: -fexperimental-sanitize-metadata
+
+// RUN: %clang -target x86_64-linux-gnu -fexperimental-sanitize-metadata=bad_arg %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-INVALID %s
+// CHECK-INVALID: error: unsupported argument 'bad_arg' to option '-fexperimental-sanitize-metadata='
+
+// RUN: %clang -target x86_64-linux-gnu -fexperimental-sanitize-metadata=covered %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-COVERED %s
+// CHECK-COVERED: "-fexperimental-sanitize-metadata-covered"
+
+// RUN: %clang -target x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ATOMICS %s
+// CHECK-ATOMICS: "-fexperimental-sanitize-metadata-atomics"
+
+// RUN: %clang -target x86_64-linux-gnu \
+// RUN:   -fexperimental-sanitize-metadata=covered,atomics %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang -target x86_64-linux-gnu -fexperimental-sanitize-metadata=all %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ALL %s
+// CHECK-ALL: "-fexperimental-sanitize-metadata-covered"
+// CHECK-ALL: "-fexperimental-sanitize-metadata-atomics"
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -98,6 +98,11 @@
   CoverageTraceStores = 1 << 17,
 };
 
+enum BinaryMetadataFeature {
+  BinaryMetadataCovered = 1 << 0,
+  BinaryMetadataAtomics = 1 << 1,
+};
+
 /// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
 /// invalid components. Returns a SanitizerMask.
 static SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A,
@@ -108,6 +113,11 @@
 static int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A,
  bool DiagnoseErrors);
 
+/// Parse -f(no-)?sanitize-metadata= flag values, diagnosing any invalid
+/// components. Returns OR of members of \c BinaryMetadataFeature enumeration.
+static int parseBinaryMetadataFeatures(const Driver &D, const llvm::opt::Arg *A,
+   bool DiagnoseErrors);
+
 /// Produce an argument string from ArgList \p Args, which shows how it
 /// provides some sanitizer kind from \p Mask. For example, the argument list
 /// "-fsanitize=thread,vptr -fsanitize=address" with mask \c NeedsUbsanRt
@@ -825,6 +835,21 @@
 DiagnoseErrors);
   }
 
+  // Parse -f(no-)?sanitize-metadata.
+  for (const auto *Arg : Args) {
+if (Arg->getOption().matches(
+options::OPT_fexperimental_sanitize_metadata)) {
+  Arg->claim();
+  BinaryMetadataFeatures |=
+  parseBinaryMetadataFeatures(D, Arg, DiagnoseErrors);
+} else if (Arg->getOption().matches(
+   options::OPT_fno_experimental_sanitize_metadata)) {
+  Arg->claim();
+  BinaryMetadataFeatures &=
+  ~parseBinaryMetadataFeatures(D, Arg, DiagnoseErrors);
+}
+  }
+
   SharedRuntime =
   Args.hasFlag(options::OPT_shared_libsan, options::OPT_static_libsan,
TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia() ||
@@ -1086,6 +,17 @@
   addSpecialCaseListOpt(Args, CmdArgs, "-fsanitize-coverage-ignorelist=",
 CoverageIgnorelistFiles);
 
+  // Translate available BinaryMetadataFeatures to corresponding clang-cc1
+  // flags. Does not depend on any other sanitizers.
+  const std::pair BinaryMetadataFlags[] = {

[PATCH] D126880: [clang-tidy] Add cppcoreguidelines-avoid-const-or-ref-data-members check

2022-08-01 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 448965.
carlosgalvezp added a comment.

- Display type information in the diagnostic.
- Rebase onto latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126880

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
@@ -0,0 +1,169 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-const-or-ref-data-members %t
+namespace std {
+template 
+struct unique_ptr {};
+
+template 
+struct shared_ptr {};
+} // namespace std
+
+namespace gsl {
+template 
+struct not_null {};
+} // namespace gsl
+
+struct Ok {
+  int i;
+  int *p;
+  const int *pc;
+  std::unique_ptr up;
+  std::shared_ptr sp;
+  gsl::not_null n;
+};
+
+struct ConstMember {
+  const int c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: member 'c' of type 'const int' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]
+};
+
+struct LvalueRefMember {
+  int &lr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: member 'lr' of type 'int &' is a reference
+};
+
+struct ConstRefMember {
+  const int &cr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: member 'cr' of type 'const int &' is a reference
+};
+
+struct RvalueRefMember {
+  int &&rr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: member 'rr' of type 'int &&' is a reference
+};
+
+struct ConstAndRefMembers {
+  const int c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: member 'c' of type 'const int' is const qualified
+  int &lr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: member 'lr' of type 'int &' is a reference
+  const int &cr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: member 'cr' of type 'const int &' is a reference
+  int &&rr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: member 'rr' of type 'int &&' is a reference
+};
+
+struct Foo {};
+
+struct Ok2 {
+  Foo i;
+  Foo *p;
+  const Foo *pc;
+  std::unique_ptr up;
+  std::shared_ptr sp;
+  gsl::not_null n;
+};
+
+struct ConstMember2 {
+  const Foo c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: member 'c' of type 'const Foo' is const qualified
+};
+
+struct LvalueRefMember2 {
+  Foo &lr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: member 'lr' of type 'Foo &' is a reference
+};
+
+struct ConstRefMember2 {
+  const Foo &cr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: member 'cr' of type 'const Foo &' is a reference
+};
+
+struct RvalueRefMember2 {
+  Foo &&rr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: member 'rr' of type 'Foo &&' is a reference
+};
+
+struct ConstAndRefMembers2 {
+  const Foo c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: member 'c' of type 'const Foo' is const qualified
+  Foo &lr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: member 'lr' of type 'Foo &' is a reference
+  const Foo &cr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: member 'cr' of type 'const Foo &' is a reference
+  Foo &&rr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: member 'rr' of type 'Foo &&' is a reference
+};
+
+using ConstType = const int;
+using RefType = int &;
+using ConstRefType = const int &;
+using RefRefType = int &&;
+
+struct WithAlias {
+  ConstType c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: member 'c' of type 'ConstType' (aka 'const int') is const qualified
+  RefType lr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: member 'lr' of type 'RefType' (aka 'int &') is a reference
+  ConstRefType cr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: member 'cr' of type 'ConstRefType' (aka 'const int &') is a reference
+  RefRefType rr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: member 'rr' of type 'RefRefType' (aka 'int &&') is a reference
+};
+
+template 
+using Array = int[N];
+
+struct ConstArrayMember {
+  const Array<1> c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: member 'c' of type 'const Array<1>' (aka 'const int[1]') is const qualified
+};
+
+struct LvalueRefArrayMember {
+  Array<2> &lr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: member 'lr' of type 'Array<2> &' (aka 'int (&)[2]') is a reference
+};
+
+struct ConstLvalueRefArrayMember {
+  const Array<3> &cr;
+  // CHECK-MESSAGES: :[[@LIN

[PATCH] D126880: [clang-tidy] Add cppcoreguidelines-avoid-const-or-ref-data-members check

2022-08-01 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

@njames93  I've updated the patch with extra type information, let me know if 
you think it's good enough!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126880

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


[PATCH] D130889: [llvm] Introduce a pass plugin registry and loader

2022-08-01 Thread Philippe Virouleau via Phabricator via cfe-commits
viroulep created this revision.
viroulep added reviewers: w2yehia, mehdi_amini, pcc.
Herald added subscribers: ormris, steven_wu, hiraditya, arichardson, mgorny, 
emaste.
Herald added a reviewer: MaskRay.
Herald added a project: All.
viroulep requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, StephenFan.
Herald added projects: clang, LLVM.

This basically extends what has been done for opt in 
https://reviews.llvm.org/D121566.

The general issue is that, at the moment and except for opt, you can't use 
command line options defined by plugins when using only -load-pass-plugin (or 
-fpass-plugin), and you have to also load the library with the "old" entry 
point through -load to have them recognized.

This is due to the fact that parsing command line options occurs before plugins 
are loaded through -load-pass-plugin, and basically each tool has its own way 
of dealing with the loading of pass plugins.
The patch tries to mimic what was done for the existing `-load` command line 
option and aims at providing common entry points for the lib and tools:

- tools make sure to register the loaded plugin (through the option or manually)
- any part of the lib/tools can query the registry to have the plugins register 
their callbacks.

As a result -load-pass-plugin has a behavior that matches the -load option, and 
tools can simply include the header defining the -load-pass-plugin option if 
they want to have the feature.

I'm not exactly sure why -load-pass-plugin wasn't created with the same 
behavior as -load, which makes me think I may be missing something: if the 
implementation I suggest doesn't look good to you I'd be happy to look into 
something else (hopefully the general idea of having a single load for old/new 
plugins does sound good to you).

This patch touches a couple of tools (clang, llvm-lto2, opt) in addition to 
llvm; I tried to include only a couple of appropriate reviewers; my apologies 
if I missed someone, please feel free to add more relevant people if you think 
it's necessary!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130889

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/CompilerInstance.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/test/ELF/lto/ltopasses-extension.ll
  lld/test/lit.cfg.py
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/Passes/PassPluginLoader.h
  llvm/include/llvm/Passes/PassPluginRegistry.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/CMakeLists.txt
  llvm/lib/Passes/PassPluginLoader.cpp
  llvm/lib/Passes/PassPluginRegistry.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/NewPMDriver.h
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -39,7 +39,8 @@
 #include "llvm/LinkAllPasses.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/MC/TargetRegistry.h"
-#include "llvm/Passes/PassPlugin.h"
+#include "llvm/Passes/PassPluginLoader.h"
+#include "llvm/Passes/PassPluginRegistry.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
@@ -278,10 +279,6 @@
 cl::desc("The format used for serializing remarks (default: YAML)"),
 cl::value_desc("format"), cl::init("yaml"));
 
-static cl::list
-PassPlugins("load-pass-plugin",
-cl::desc("Load passes from plugin library"));
-
 namespace llvm {
 cl::opt
 PGOKindFlag("pgo-kind", cl::init(NoPGO), cl::Hidden,
@@ -533,17 +530,6 @@
   initializeExampleIRTransforms(Registry);
 #endif
 
-  SmallVector PluginList;
-  PassPlugins.setCallback([&](const std::string &PluginPath) {
-auto Plugin = PassPlugin::Load(PluginPath);
-if (!Plugin) {
-  errs() << "Failed to load passes from '" << PluginPath
- << "'. Request ignored.\n";
-  return;
-}
-PluginList.emplace_back(Plugin.get());
-  });
-
   cl::ParseCommandLineOptions(argc, argv,
 "llvm .bc -> .bc modular optimizer and analysis printer\n");
 
@@ -556,7 +542,7 @@
   const bool UseNPM = (EnableNewPassManager && !shouldForceLegacyPM()) ||
   PassPipeline.getNumOccurrences() > 0;
 
-  if (!UseNPM && PluginList.size()) {
+  if (!UseNPM && PassPluginRegistry::getPlugins().size()) {
 errs() << argv[0] << ": " << PassPlugins.ArgStr
<< " specified with legacy PM.\n";
 return 1;
@@ -781,7 +767,7 @@
 // layer.
 return runPassPipeline(argv[0], *M, TM.get(), &TLII, Out.get(),
ThinLinkOut.get(), RemarksFile.get(), Pipeline,
-   Passes, PluginList, OK, VK, PreserveAssemblyUseListOrder,
+   Passes, OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
Em

[clang] d90b7bf - Add support for lowering simd if clause to LLVM IR

2022-08-01 Thread Dominik Adamski via cfe-commits

Author: Dominik Adamski
Date: 2022-08-01T04:43:32-05:00
New Revision: d90b7bf2c53d0315a13a81904862929252bb6824

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

LOG: Add support for lowering simd if clause to LLVM IR

Scope of changes:
  1) Added new function to generate loop versioning
  2) Added support for if clause to applySimd function
  2) Added tests which confirm that lowering is successful

If ifCond is specified, then collapsed loop is duplicated and if branch
is added. Duplicated loop is executed if simd ifCond is evaluated to false.

Reviewed By: Meinersbur

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

Signed-off-by: Dominik Adamski 

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index aa55cdaca5dca..962620f43a393 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2646,7 +2646,9 @@ void CodeGenFunction::EmitOMPSimdDirective(const 
OMPSimdDirective &S) {
   auto *Val = cast(Len.getScalarVal());
   Simdlen = Val;
 }
-OMPBuilder.applySimd(CLI, Simdlen);
+// Add simd metadata to the collapsed loop. Do not generate
+// another loop for if clause. Support for if clause is done earlier.
+OMPBuilder.applySimd(CLI, /*IfCond*/ nullptr, Simdlen);
 return;
   }
 };

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 40ca2da4c911d..5ae9baab0e5d6 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
 #define LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
 
+#include "llvm/Analysis/MemorySSAUpdater.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/IRBuilder.h"
@@ -467,6 +468,20 @@ class OpenMPIRBuilder {
   bool NeedsBarrier,
   Value *Chunk = nullptr);
 
+  /// Create alternative version of the loop to support if clause
+  ///
+  /// OpenMP if clause can require to generate second loop. This loop
+  /// will be executed when if clause condition is not met. createIfVersion
+  /// adds branch instruction to the copied loop if \p  ifCond is not met.
+  ///
+  /// \param Loop   Original loop which should be versioned.
+  /// \param IfCond Value which corresponds to if clause condition
+  /// \param VMap   Value to value map to define relation between
+  ///   original and copied loop values and loop blocks.
+  /// \param NamePrefix Optional name prefix for if.then if.else blocks.
+  void createIfVersion(CanonicalLoopInfo *Loop, Value *IfCond,
+   ValueToValueMapTy &VMap, const Twine &NamePrefix = "");
+
 public:
   /// Modifies the canonical loop to be a workshare loop.
   ///
@@ -597,11 +612,15 @@ class OpenMPIRBuilder {
   void unrollLoopPartial(DebugLoc DL, CanonicalLoopInfo *Loop, int32_t Factor,
  CanonicalLoopInfo **UnrolledCLI);
 
-  /// Add metadata to simd-ize a loop.
+  /// Add metadata to simd-ize a loop. If IfCond is not nullptr, the loop
+  /// is cloned. The metadata which prevents vectorization is added to
+  /// to the cloned loop. The cloned loop is executed when ifCond is evaluated
+  /// to false.
   ///
   /// \param LoopThe loop to simd-ize.
+  /// \param IfCond  The value which corresponds to the if clause condition.
   /// \param Simdlen The Simdlen length to apply to the simd loop.
-  void applySimd(CanonicalLoopInfo *Loop, ConstantInt *Simdlen);
+  void applySimd(CanonicalLoopInfo *Loop, Value *IfCond, ConstantInt *Simdlen);
 
   /// Generator for '#omp flush'
   ///

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index cee4cddab5e89..736976d406438 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -34,6 +34,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Cloning.h"
 #include "llvm/Transforms/Utils/CodeExtractor.h"
 #include "llvm/Transforms/Utils/LoopPeel.h"
 #include "llvm/Transforms/Utils/UnrollLoop.h"
@@ -2839,32 +2840,40 @@ OpenMPIRBuilder::tileLo

[PATCH] D129368: [mlir][OpenMP] Lower simd if clause to LLVM IR

2022-08-01 Thread Dominik Adamski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
domada marked an inline comment as done.
Closed by commit rGd90b7bf2c53d: Add support for lowering simd if clause to 
LLVM IR (authored by domada).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D129368?vs=448666&id=448974#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129368

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/openmp-llvm.mlir

Index: mlir/test/Target/LLVMIR/openmp-llvm.mlir
===
--- mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -750,6 +750,34 @@
 
 // -
 
+// CHECK-LABEL: @simdloop_if
+llvm.func @simdloop_if(%arg0: !llvm.ptr {fir.bindc_name = "n"}, %arg1: !llvm.ptr {fir.bindc_name = "threshold"}) {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>} : (i64) -> !llvm.ptr
+  %2 = llvm.mlir.constant(1 : i64) : i64
+  %3 = llvm.alloca %2 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFtest_simdEi"} : (i64) -> !llvm.ptr
+  %4 = llvm.mlir.constant(0 : i32) : i32
+  %5 = llvm.load %arg0 : !llvm.ptr
+  %6 = llvm.mlir.constant(1 : i32) : i32
+  %7 = llvm.load %arg0 : !llvm.ptr
+  %8 = llvm.load %arg1 : !llvm.ptr
+  %9 = llvm.icmp "sge" %7, %8 : i32
+  omp.simdloop   if(%9) for  (%arg2) : i32 = (%4) to (%5) inclusive step (%6) {
+// The form of the emitted IR is controlled by OpenMPIRBuilder and
+// tested there. Just check that the right metadata is added.
+// CHECK: llvm.access.group
+llvm.store %arg2, %1 : !llvm.ptr
+omp.yield
+  }
+  llvm.return
+}
+// Be sure that llvm.loop.vectorize.enable metadata appears twice
+// CHECK: llvm.loop.parallel_accesses
+// CHECK-NEXT: llvm.loop.vectorize.enable
+// CHECK: llvm.loop.vectorize.enable
+
+// -
+
 llvm.func @body(i64)
 
 llvm.func @test_omp_wsloop_ordered(%lb : i64, %ub : i64, %step : i64) -> () {
Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -912,11 +912,6 @@
   SmallVector loopInfos;
   SmallVector bodyInsertPoints;
   LogicalResult bodyGenStatus = success();
-
-  // TODO: The code generation for if clause is not supported yet.
-  if (loop.if_expr())
-return failure();
-
   auto bodyGen = [&](llvm::OpenMPIRBuilder::InsertPointTy ip, llvm::Value *iv) {
 // Make sure further conversions know about the induction variable.
 moduleTranslation.mapValue(
@@ -975,7 +970,10 @@
   if (llvm::Optional simdlenVar = loop.simdlen())
 simdlen = builder.getInt64(simdlenVar.value());
 
-  ompBuilder->applySimd(loopInfo, simdlen);
+  ompBuilder->applySimd(
+  loopInfo,
+  loop.if_expr() ? moduleTranslation.lookupValue(loop.if_expr()) : nullptr,
+  simdlen);
 
   builder.restoreIP(afterIP);
   return success();
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1771,7 +1771,7 @@
   CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
 
   // Simd-ize the loop.
-  OMPBuilder.applySimd(CLI, nullptr);
+  OMPBuilder.applySimd(CLI, /* IfCond */ nullptr, /* Simdlen */ nullptr);
 
   OMPBuilder.finalize();
   EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -1802,7 +1802,8 @@
   CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
 
   // Simd-ize the loop.
-  OMPBuilder.applySimd(CLI, ConstantInt::get(Type::getInt32Ty(Ctx), 3));
+  OMPBuilder.applySimd(CLI, /*IfCond */ nullptr,
+   ConstantInt::get(Type::getInt32Ty(Ctx), 3));
 
   OMPBuilder.finalize();
   EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -1828,6 +1829,54 @@
   }));
 }
 
+TEST_F(OpenMPIRBuilderTest, ApplySimdLoopIf) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  IRBuilder<> Builder(BB);
+  AllocaInst *Alloc1 = Builder.CreateAlloca(Builder.getInt32Ty());
+  AllocaInst *Alloc2 = Builder.CreateAlloca(Builder.getInt32Ty());
+
+  // Generation of if condition
+  Builder.CreateStore(ConstantInt::get(Type::getInt32Ty(Ctx), 0U), Alloc1);
+  Builder.CreateStore(ConstantInt::get(Type::getInt32Ty(Ctx), 1U), Alloc2);
+  LoadInst 

[PATCH] D54943: [clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

2022-08-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

I agree with Sam on this one, especially on big files it just floods and hides 
non-stylistic diagnostics (you even hit max diagnostics exceeded errors).

I believe unless someone takes the extra mile to fix all the value types in 
LLVM to be const-correct, this is harmful then being useful. I can't speak for 
the projects out in the wild for the overall default (i have a personal 
preference for having everything const-correct, but it's mostly for stylistic 
reasons ...), but i think the default of diagnosing values for LLVM should 
definitely be off. Do you mind performing that change for `.clang-tidy` configs 
if others are not objecting on this either?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

___
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 448977.
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/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -146,6 +146,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, 
/*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 
   PTUs.emplace_back(PartialTranslationUnit());
   PartialTranslationUnit &LastPTU = 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,20 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S): S(S) {} ;
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };
+
+
   /// 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(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, /*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 
   PTUs.emplace_back(PartialTranslationUnit());
   PartialTranslationUnit &LastPTU = 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,20 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S): S(S) {} ;
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };
+
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
___
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 Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

I don't feel very qualified on the current state of strict FP, but I've left a 
couple of minor comments inline. I'm happy to trust your knowledge the state of 
strictfp and the patch looks good to me otherwise.




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

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.



Comment at: clang/test/CodeGen/builtin_float_strictfp.c:3
 // 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
 

craig.topper wrote:
> I just picked a test to have some coverage that the strict FP is enabled. 
> Most strict FP tests use `-Xclang -fexperimental-strict-floating-point` to 
> avoid needing a specific target.
I think it would be worth at least having coverage for the logic that disables 
strict FP if vector extensions are enabled.


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] D118996: [clang-tidy] Support C++14 in bugprone-signal-handler.

2022-08-01 Thread Whisperity via Phabricator via cfe-commits
whisperity accepted this revision.
whisperity added a comment.

Alright, I think we should have this in and let C++17 things to be future work. 
Please see the inline comment, but otherwise this should be good enough. Can 
always improve in a future version. 😉

LLVM 15 has branched off, so this should be rebased for the last time against 
the current main branch, just to ensure everything is good.




Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:284-298
+bool isCXXOnlyStmt(const Stmt *S) {
+  StringRef Name = S->getStmtClassName();
+  if (Name.startswith("CXX"))
+return true;
+  // Check for all other class names in ExprCXX.h that have no 'CXX' prefix.
+  return isahttps://reviews.llvm.org/D118996/new/

https://reviews.llvm.org/D118996

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


[PATCH] D54943: [clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

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

In D54943#3687827 , @JonasToth wrote:

> In D54943#3681527 , @sammccall wrote:
>
>> This check is enabled by default in LLVM (`Checks: misc-*` in 
>> `llvm-project/.clang-tidy`)
>>
>> The warning on mutable non-ref local variables is pretty noisy: a *lot* of 
>> existing code does not do this, for defensible reasons (some of us think 
>> that the ratio of extra safety to extra syntactic noise for locals is too 
>> low). The LLVM style guide doesn't take a position on this.
>>
>> Should this check
>>
>> - be disabled for LLVM? (i.e. this is opt-in for codebases with strong 
>> const-correctness rules, LLVM does not, it was unintentionally enabled by 
>> `misc-*`)
>> - be configured only to warn on references? (i.e. we expect that is de-facto 
>> LLVM style and so uncontroversial)
>
> IMHO just enable for references in LLVM, thats still enough warnings to take 
> a while to process and the guide is clear on that.
> If the community wants it for values as well, that can be done later anyway.
>
> Do you think the defaults for this check should change? Originally, it was 
> "default on" because `cppcoreguidelines` state so.

I agree with Sam that this definitely needs to be disabled for LLVM -- we don't 
have anywhere near enough const correctness to get significant value out of 
this check yet, even if it was limited to just references. As for whether we 
should default to only warn on references by default -- I think that might be a 
better approach now that this is no longer tied directly to the C++ Core 
Guidelines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D130826: [clang-tools-extra] Fixed a number of typos

2022-08-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130826

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


[PATCH] D130826: [clang-tools-extra] Fixed a number of typos

2022-08-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

also LMK if I should land this for you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130826

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


[PATCH] D130701: [clang-tidy] Rename a local cmake variables to match the new tool name. NFC.

2022-08-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ping @sammccall


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130701

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


[PATCH] D130766: [SPIR-V] Disable opaque pointers in relese 15

2022-08-01 Thread Ilia Diachkov via Phabricator via cfe-commits
iliya-diyachkov added a comment.

Looks good to me.


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

https://reviews.llvm.org/D130766

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


[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added a reviewer: aaron.ballman.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For

  c++
  static constexpr m = 10;
  static_assert(m == 11);

the output is before:

  ./test.cpp:2:1: error: static_assert failed due to requirement 'm == 11'
  static_assert(m == 11);
  ^ ~~~
  1 error generated.

and after:

  ./test.cpp:2:1: error: static assertion failed due to requirement 'm == 11'
  static_assert(m == 11);
  ^ ~~~
  ./test.cpp:2:15: note: left-hand side of operator '==' evaluates to '10'
  static_assert(m == 11);
^
  1 error generated.

The patch adds a new function `Sema::DiagnoseStaticAssertDetails()`, which 
currently only handles binary operators with an integer literal on one side and 
a non-integer literal on the other side. This is intentionally kept simple, but 
can be improved incrementally over time of course.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130894

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/drs/dr7xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/SemaTemplate/instantiate-var-template.cpp
  clang/test/SemaTemplate/instantiation-dependence.cpp

Index: clang/test/SemaTemplate/instantiation-dependence.cpp
===
--- clang/test/SemaTemplate/instantiation-dependence.cpp
+++ clang/test/SemaTemplate/instantiation-dependence.cpp
@@ -68,8 +68,10 @@
   struct D : B, C {};
 
   static_assert(trait::specialization == 0);
-  static_assert(trait::specialization == 1); // FIXME expected-error {{failed}}
-  static_assert(trait::specialization == 2); // FIXME expected-error {{failed}}
+  static_assert(trait::specialization == 1); // FIXME expected-error {{failed}} \
+// expected-note {{evaluates to '0'}}
+  static_assert(trait::specialization == 2); // FIXME expected-error {{failed}} \
+// expected-note {{evaluates to '0'}}
   static_assert(trait::specialization == 0); // FIXME-error {{ambiguous partial specialization}}
 }
 
Index: clang/test/SemaTemplate/instantiate-var-template.cpp
===
--- clang/test/SemaTemplate/instantiate-var-template.cpp
+++ clang/test/SemaTemplate/instantiate-var-template.cpp
@@ -31,7 +31,8 @@
   static_assert(b == 1, ""); // expected-note {{in instantiation of}} expected-error {{not an integral constant}}
 
   template void f() {
-static_assert(a == 0, ""); // expected-error {{static assertion failed due to requirement 'a == 0'}}
+static_assert(a == 0, ""); // expected-error {{static assertion failed due to requirement 'a == 0'}} \
+   // expected-note {{evaluates to '1'}}
   }
 }
 
Index: clang/test/PCH/cxx-templates.cpp
===
--- clang/test/PCH/cxx-templates.cpp
+++ clang/test/PCH/cxx-templates.cpp
@@ -167,7 +167,8 @@
   // This used to mark 'f' invalid without producing any diagnostic. That's a
   // little hard to detect, but we can make sure that constexpr evaluation
   // fails when it should.
-  static_assert(A().f() == 1); // expected-error {{static assertion failed}}
+  static_assert(A().f() == 1); // expected-error {{static assertion failed}} \
+// expected-note {{left-hand side of operator '==' evaluates to '0'}}
 #endif
 }
 
Index: clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
@@ -40,8 +40,10 @@
 
 template constexpr auto x = [...z = a] (auto F) { return F(z...); };
 static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 123);
-static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}}
+static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}} \
+  // expected-note {{evaluates to '123'}}
 
 template constexpr auto y = [z = a...] (auto F) { return F(z...); }; // expected-error {{must appear before the name of the capture}}
 static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 123);
-static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}}
+static_assert(y<1,2,3>([](int a, int b, int c)

[PATCH] D130894: [clang] Print more information about failed static assertions

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



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16656
&& !isa(InnerCond)) {
+
 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)

Oops, this needs to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130894

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


[PATCH] D130826: [clang-tools-extra] Fixed a number of typos

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

Well I'm pretty sure I don't have commit rights to LLVM and it seems landing 
means to push the revision onto main, so that would be nice, yes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130826

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


[PATCH] D130636: [clangd] Upgrade vlog() to log() for preamble build stats

2022-08-01 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang-tools-extra/clangd/Preamble.cpp:555
   if (BuiltPreamble) {
-vlog("Built preamble of size {0} for file {1} version {2} in {3} seconds",
+log("Built preamble of size {0} for file {1} version {2} in {3} seconds",
  BuiltPreamble->getSize(), FileName, Inputs.Version,

kadircet wrote:
> what about also moving this log into TUScheduler.cpp::reportPreamble, in 
> which we can also log whether this is a "first preamble" or not?
I considered that, but this isn't structured log or something you'd process 
automatically and it's already clear from context in that log file if it's 
first build or rebuild. I think it's simpler to keep the log line here, to 
match the error line below.

If you have a use case for this information let me know and I'll update this 
change, otherwise I'll just go with the simple solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130636

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


[clang-tools-extra] 6b2fed3 - [clangd] Upgrade vlog() to log() for preamble build stats

2022-08-01 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2022-08-01T15:08:21+02:00
New Revision: 6b2fed3ab4193cfb50c4e60fb4cd19c7e6b3603f

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

LOG: [clangd] Upgrade vlog() to log() for preamble build stats

This is very useful information for better understanding performance and
preamble builds don't happen that often, so it's not that spammy.

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

Added: 


Modified: 
clang-tools-extra/clangd/Preamble.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index 9fc249afcc224..337f71bed9bae 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -552,7 +552,7 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
   }
 
   if (BuiltPreamble) {
-vlog("Built preamble of size {0} for file {1} version {2} in {3} seconds",
+log("Built preamble of size {0} for file {1} version {2} in {3} seconds",
  BuiltPreamble->getSize(), FileName, Inputs.Version,
  PreambleTimer.getTime());
 std::vector Diags = PreambleDiagnostics.take();



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


[PATCH] D130636: [clangd] Upgrade vlog() to log() for preamble build stats

2022-08-01 Thread Adam Czachorowski 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 rG6b2fed3ab419: [clangd] Upgrade vlog() to log() for preamble 
build stats (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130636

Files:
  clang-tools-extra/clangd/Preamble.cpp


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -552,7 +552,7 @@
   }
 
   if (BuiltPreamble) {
-vlog("Built preamble of size {0} for file {1} version {2} in {3} seconds",
+log("Built preamble of size {0} for file {1} version {2} in {3} seconds",
  BuiltPreamble->getSize(), FileName, Inputs.Version,
  PreambleTimer.getTime());
 std::vector Diags = PreambleDiagnostics.take();


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -552,7 +552,7 @@
   }
 
   if (BuiltPreamble) {
-vlog("Built preamble of size {0} for file {1} version {2} in {3} seconds",
+log("Built preamble of size {0} for file {1} version {2} in {3} seconds",
  BuiltPreamble->getSize(), FileName, Inputs.Version,
  PreambleTimer.getTime());
 std::vector Diags = PreambleDiagnostics.take();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130811: [Clang] Fix handling of Max from getValueRange(...) in IntExprEvaluator::VisitCastExpr(...)

2022-08-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:13540
 ED->getValueRange(Max, Min);
+--Max;
 

I don't think this is the correct answer.  Even though the other use of this 
seems to 'work', `getValueRange` is still returning wrapped values here.  The 
fix is to figure out how to fix the math in getValueRange, and change the 
sanitizer's IR generation if necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130811

___
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 added a comment.

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? 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).

I believe clangd is the right tool, as the choice to use clangd or not is made 
by individual developers rather than project maintainers. Every git controlled 
C++ project would potentially have to include this directory to their gitignore.

I only thought of this after seeing how the meson build system behaves. A user 
can give any name to their build directory, so they add a gitignore to ignore 
it automatically. Users that don't want this behavior can simply remove the 
gitignore file, and it won't get recreated. The same behavior is present (and 
tested) with this change as well.

Lastly, this also has the benefit of only ignoring `.cache/clangd/index/*`, and 
it'll also stay up to date if the directory path/structure changes.


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


[clang-tools-extra] 0ed2bd9 - [clang-tools-extra] Fixed a number of typos

2022-08-01 Thread Kadir Cetinkaya via cfe-commits

Author: Gabriel Ravier
Date: 2022-08-01T15:32:25+02:00
New Revision: 0ed2bd9311fd54f0b414549b96a2cd4036ef0945

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

LOG: [clang-tools-extra] 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).

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/HeuristicResolver.cpp
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/SemanticHighlighting.cpp

clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
clang-tools-extra/clangd/index/CanonicalIncludes.h
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang-tools-extra/pseudo/gen/Main.cpp
clang-tools-extra/pseudo/lib/cxx/cxx.bnf

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/virtual-class-destructor.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
index 024a06bf3aa70..f9dd542b5c996 100644
--- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
@@ -138,7 +138,7 @@ static bool hasRValueOverload(const CXXConstructorDecl 
*Ctor,
   const int ParamIdx = Param->getFunctionScopeIndex();
   const CXXRecordDecl *Record = Ctor->getParent();
 
-  // Check whether a ctor `C` forms a pair with `Ctor` under the 
aforementionned
+  // Check whether a ctor `C` forms a pair with `Ctor` under the aforementioned
   // rules.
   const auto IsRValueOverload = [&Ctor, ParamIdx](const CXXConstructorDecl *C) 
{
 if (C == Ctor || C->isDeleted() ||

diff  --git 
a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h 
b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
index 28050e079cf5c..dee1e2149ab6e 100644
--- a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
@@ -19,7 +19,7 @@ namespace performance {
 /// Finds calls to C math library functions with implicit float to double
 /// promotions.
 ///
-/// For example, warns on ::sin(0.f), because this funciton's parameter is a
+/// For example, warns on ::sin(0.f), because this function's parameter is a
 /// double.  You probably meant to call std::sin(0.f) (in C++), or sinf(0.f) 
(in
 /// C).
 ///

diff  --git a/clang-tools-extra/clangd/CodeComplete.h 
b/clang-tools-extra/clangd/CodeComplete.h
index 73139ba40e765..ebd451c95c76c 100644
--- a/clang-tools-extra/clangd/CodeComplete.h
+++ b/clang-tools-extra/clangd/CodeComplete.h
@@ -142,9 +142,9 @@ struct CodeCompleteOptions {
   /// CompletionScore is NameMatch * pow(Base, Prediction).
   /// The optimal value of Base largely depends on the semantics of the model
   /// and prediction score (e.g. algorithm used during training, number of
-  /// trees, etc.). Usually if the range of Prediciton is [-20, 20] then a Base
+  /// trees, etc.). Usually if the range of Prediction is [-20, 20] then a Base
   /// in [1.2, 1.7] works fine.
-  /// Semantics: E.g. For Base = 1.3, if the Prediciton score reduces by 2.6
+  /// Semantics: E.g. For Base = 1.3, if the Prediction score reduces by 2.6
   /// points then completion score reduces by 50% or 1.3^(-2.6).
   float DecisionForestBase = 1.3f;
 };

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 5950f8ff655c3..98923b516752b 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -163,8 +163,8 @@ struct Fragment {
 /// Flags added by the same CompileFlags entry will not be removed.
 std::vector> Remove;
 
-/// Directory to search for compilation database (compile_comands.json 
etc).

[PATCH] D130826: [clang-tools-extra] Fixed a number of typos

2022-08-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ed2bd9311fd: [clang-tools-extra] Fixed a number of typos 
(authored by GabrielRavier, committed by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130826

Files:
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/HeuristicResolver.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  
clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/virtual-class-destructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/virtual-class-destructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/virtual-class-destructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/virtual-class-destructor.cpp
@@ -143,7 +143,7 @@
   // CHECK-FIXES: virtual ~PublicNonVirtualBaseClass() {}
 };
 
-class PublicNonVirtualNonBaseClass { // OK accoring to C.35, since this class does not have any virtual methods.
+class PublicNonVirtualNonBaseClass { // OK according to C.35, since this class does not have any virtual methods.
   void f();
 
 public:
Index: clang-tools-extra/pseudo/lib/cxx/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -1,7 +1,7 @@
 # This is a C++ grammar from the C++ standard [1].
 #
 # The grammar is a superset of the true grammar requring semantic constraints to
-# resolve ambiguties. The grammar is context-free and ambiguous (beyond the
+# resolve ambiguities. The grammar is context-free and ambiguous (beyond the
 # limit of LR(k)). We use general parsing algorithm (e.g GLR) to handle the
 # grammar and generate a transition table which is used to drive the parsing.
 #
Index: clang-tools-extra/pseudo/gen/Main.cpp
===
--- clang-tools-extra/pseudo/gen/Main.cpp
+++ clang-tools-extra/pseudo/gen/Main.cpp
@@ -65,7 +65,7 @@
 // Mangles a symbol name into a valid identifier.
 //
 // These follow names in the grammar fairly closely:
-//   nonterminal: `ptr-declartor` becomes `ptr_declarator`;
+//   nonterminal: `ptr-declarator` becomes `ptr_declarator`;
 //   punctuator: `,` becomes `COMMA`;
 //   keyword: `INT` becomes `INT`;
 //   terminal: `IDENTIFIER` becomes `IDENTIFIER`;
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1801,7 +1801,7 @@
   }
 }
 
-TEST(FindImplementations, CaptureDefintion) {
+TEST(FindImplementations, CaptureDefinition) {
   llvm::StringRef Test = R"cpp(
 struct Base {
   virtual void F^oo();
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1035,7 +1035,7 @@
   // Starts handling the update action and blocks until the
   // first preamble is built.
   ASTAction::RunningAction,
-  // Afterwqards it builds an AST for that preamble to publish
+  // Afterwards it builds an AST for that preamble to publish
   // diagnostics.
   ASTAction::Building,
   // Then goes idle.
Index: clang-tools-extra/clangd/index/CanonicalIncludes.h
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.h
+++ clang-tools-extra/clangd/index/CanonicalIncludes.h
@@ -78,7 +78,7 @@
 /// - export: this is common and potentially interesting, there are three cases:
 ///* Points to a public header (common): we can suppress include2 if you
 ///  already have include1. Only marginally useful.
-///* Points to a private header annotated with `private` (somewhat commmon):
+///* Points to a private header annotated with `private` (somewhat common):
 ///  No

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

2022-08-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:6217
+  // If one is not module, they must not be in the same module.
+  if (!X != !Y)
+return false;

Please find another way to write this... this is about the most jarring way to 
compare these...

perhaps you can take advantage of the fact that the compare on 6222 basically 
does the other half to this:

`if (!X || !Y)`

replaces the next compare as well.  



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

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.


Repository:
  rG LLVM Github Monorepo

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


[clang] b978fa2 - OffloadBundler.cpp - fix Wdocumentation warnings. NFC.

2022-08-01 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-08-01T15:24:47+01:00
New Revision: b978fa2844391bd9c12eb9b9b002daebf51bf1ca

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

LOG: OffloadBundler.cpp - fix Wdocumentation warnings. NFC.

Fix param list instead of embedding \p tag

Added: 


Modified: 
clang/lib/Driver/OffloadBundler.cpp

Removed: 




diff  --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index d590c2360fae..4a73d2c02120 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -1086,8 +1086,8 @@ bool isCodeObjectCompatible(OffloadTargetInfo 
&CodeObjectInfo,
 
 /// @brief Computes a list of targets among all given targets which are
 /// compatible with this code object
-/// @param [in] Code Object \p CodeObject
-/// @param [out] List of all compatible targets \p CompatibleTargets among all
+/// @param [in] CodeObjectInfo Code Object
+/// @param [out] CompatibleTargets List of all compatible targets among all
 /// given targets
 /// @return false, if no compatible target is found.
 static bool



___
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
beanz updated this revision to Diff 449014.
beanz added a comment.

Updates based on PR feedback. Thanks @aaron.ballman!


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 &CGM;
+  uint32_t ResourceCounters[static_cast(
+  hlsl::ResourceClass::NumClasses)] = {0};
 
 public:
   CGHLSLRuntime(CodeGenModule &CGM) : 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 &M = 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 &Ctx = 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-tools-extra] cb5d0b4 - AST.h - fix Wdocumentation warnings. NFC.

2022-08-01 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-08-01T15:38:06+01:00
New Revision: cb5d0b41baf2f137f377a8d03481d6a5574a31ec

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

LOG: AST.h - fix Wdocumentation warnings. NFC.

But ObjC code examples in quotes to stop confusing the doxygen parser

Added: 


Modified: 
clang-tools-extra/clangd/AST.h

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index f313161b6c60..de03e471be40 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -98,22 +98,22 @@ SymbolID getSymbolID(const llvm::StringRef MacroName, const 
MacroInfo *MI,
 ///
 /// Objective-C classes can have three types of declarations:
 ///
-/// - forward declaration: @class MyClass;
-/// - true declaration (interface definition): @interface MyClass ... @end
-/// - true definition (implementation): @implementation MyClass ... @end
+/// - forward declaration: "@class MyClass;"
+/// - true declaration (interface definition): "@interface MyClass ... @end"
+/// - true definition (implementation): "@implementation MyClass ... @end"
 ///
 /// Objective-C categories are extensions on classes:
 ///
-/// - declaration: @interface MyClass (Ext) ... @end
-/// - definition: @implementation MyClass (Ext) ... @end
+/// - declaration: "@interface MyClass (Ext) ... @end"
+/// - definition: "@implementation MyClass (Ext) ... @end"
 ///
 /// With one special case, a class extension, which is normally used to keep
 /// some declarations internal to a file without exposing them in a header.
 ///
-/// - class extension declaration: @interface MyClass () ... @end
-/// - which really links to class definition: @implementation MyClass ... @end
+/// - class extension declaration: "@interface MyClass () ... @end"
+/// - which really links to class definition: "@implementation MyClass ... 
@end"
 ///
-/// For Objective-C protocols, e.g. @protocol MyProtocol ... @end this will
+/// For Objective-C protocols, e.g. "@protocol MyProtocol ... @end" this will
 /// return nullptr as protocols don't have an implementation.
 const ObjCImplDecl *getCorrespondingObjCImpl(const ObjCContainerDecl *D);
 



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


[PATCH] D130847: [clang] SourceManager: fix isOffsetInFileID for the case of a fake SLocEntry

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

Thanks for working on this!

I think the same is true for `SourceManager::isInFileID()` as well, right? (Or 
any other place that calls `getSLocEntry()` and doesn't check whether the entry 
is invalid, which also seems to happen a fair amount in SourceManager.cpp.)

Given that this code is on the hot path, should it be the caller's 
responsibility to have already validated the `FileID` that's passed in so that 
the fake entry can never be returned? If not and we really do need the extra 
branch here (and potentially elsewhere), I'd like to see how this impacts 
compile time performance on something like 
http://llvm-compile-time-tracker.com/ to know what we're signing up for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130847

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


[PATCH] D130123: Extend ptr32 support to be applied on typedef

2022-08-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

That sounds reasonable to me, I confirmed that MSVC really only lets you apply 
these attributes directly to pointer types and to typedefs.

Can you add a test for the other most common type sugar node, the template 
parameter? It looks like this:

  template 
  void f(T __ptr32 a) {
  (*a) += 1;
  }
  void g(int *p) {
  f(p);
  }

If there isn't already a C++ test for __ptr32 & co, go ahead and make one.




Comment at: clang/lib/Sema/SemaType.cpp:7150
-  // type sugar between it and the pointer (other than attributes)? Eg, this
-  // disallows the attribute on a parenthesized pointer.
-  // And if so, should we really allow *any* type attribute?

I raised the issue because it wasn't clear if we had a definitive answer for 
the question in this FIXME.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130123

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


[PATCH] D130735: [Clang][LLD][cmake] Drop deprecated support for `llvm-config`-based build

2022-08-01 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

Should I wait for anyone else / do something like announcing this on discourse?

It looks like the only other use case is libclc, which sadly only supports the 
old way so we will need to do another deprecation cycle I'd think for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130735

___
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.

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.
- 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;

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.  


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] 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


[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 &FPO = 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 &FPO = 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
https://lists.llvm.org/cgi-bin/mailman/listinfo/

[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] 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] 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] 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 &Name,
-  const std::string &Container,
-  const std::string &USR) {
-  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] 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] 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


[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 &M = 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 &Ctx = 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 &CGM;
+  uint32_t ResourceCounters[static_cast(
+  hlsl::ResourceClass::NumClasses)] = {0};
 
 public:
   CGHLSLRuntime(CodeGenModule &CGM) : 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 @"?Buffer1

[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 &CGM;
+  uint32_t ResourceCounters[static_cast(
+  hlsl::ResourceClass::NumClasses)] = {0};
 
 public:
   CGHLSLRuntime(CodeGenModule &CGM) : 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 &M = 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 &Ctx = 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


[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] 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] 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: whi

[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 &Name,
-  const std::string &Container,
-  const std::string &USR) {
-  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#")}},
+  {Expe

[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] 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(S) {} ;
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };
+
   /// 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(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, 
/*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 
   PTUs.emplace_back(PartialTranslationUnit());
   PartialTranslationUnit &LastPTU = 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(S) {} ;
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };
+
   /// 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(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, /*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 
   PTUs.emplace_back(PartialTranslationUnit());
   PartialTranslationUnit &LastPTU = 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


[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] 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


[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] 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


[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


[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
 # demonstr

[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
++

[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] 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 &Result,
-Sema::ModuleImportState &ImportState) {
+Sema::ModuleImportState &ImportState,
+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 &Result,
-   Sema::ModuleImportState &ImportState) {
+   Sema::ModuleImportState &ImportState,
+   StmtVector *Stmts /*=nullptr*/) {
   DestroyTemplateIdAnnotationsRAIIObj Clea

[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 &getZstdCompressionAlgorithm() {
>   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 &Zstd;
>   }
>   ...
>   }
>   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 added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:3381
  &SS) &&
   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] 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] 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] 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
  clang/test/CodeGen/RISCV/rvv-intri

[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] 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] 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] 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] 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] 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] 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 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] 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] 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


[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 &operator<<(llvm::raw_ostream &O,
 
 bool operator==(const SymbolDetails &LHS, const SymbolDetails &RHS) {
   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 &P) {
@@ -755,6 +757,12 @@ llvm::json::Value toJSON(const SymbolDetails &P) {
   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 &operator<<(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 &AST, 
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 &AST, 
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 &AST, 
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] 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 &Name,
-  const std::string &Container,
-  const std::string &USR) {
-  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 @@
 }
   }
 

[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] 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] 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] 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] 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] 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


[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 &getTempFiles() { return TempFiles; }
   const llvm::opt::ArgStringList &getTempFiles() const { return TempFiles; }
 
   const ArgStringMap &getResultFiles() 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 &C, 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_d

[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;
 
+ 

[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] 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] 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 &CI, StringRef Path,
+  SmallVectorImpl &Storage) {
+  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 &MD, 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 &C)
-  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), C(C) {}
+  StringRef WorkingDirectory, DependencyConsumer &C)
+  : DependencyFileGenerator(*Opts), WorkingDirectory(WorkingDirectory),
+Opts(std::move(Opts)), C(C) {}
 
   void finishedMainFile(DiagnosticsEngine &Diags) override {
 C.handleDependencyOutputOpts(*Opts);
@@ -37,11 +38,13 @@
 for (const auto &File : getDependencies()) {
   CanonPath = File;
   llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
+  llvm::sys::fs::make_absolute(WorkingDirectory, CanonPath);
  

  1   2   >