[clang] 5ddb623 - [clang][dataflow] Remove unnecessary `ASTContext` parameter from `ControlFlowContext::build` overload.

2023-05-30 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-05-30T07:05:35Z
New Revision: 5ddb623952cacba0a3933dacd4c70439ca95c70d

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

LOG: [clang][dataflow] Remove unnecessary `ASTContext` parameter from 
`ControlFlowContext::build` overload.

When introducing this new overload in https://reviews.llvm.org/D151183, I 
didn't consider that the `ASTContext` parameter was unnecessary because it 
could also be obtained from the `FunctionDecl`.

Reviewed By: gribozavr2, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h 
b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
index f327011766069..bb36ed237c1e3 100644
--- a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
@@ -33,8 +33,7 @@ class ControlFlowContext {
 public:
   /// Builds a ControlFlowContext from a `FunctionDecl`.
   /// `Func.hasBody()` must be true, and `Func.isTemplated()` must be false.
-  static llvm::Expected build(const FunctionDecl &Func,
-  ASTContext &C);
+  static llvm::Expected build(const FunctionDecl &Func);
 
   /// Builds a ControlFlowContext from an AST node. `D` is the function in 
which
   /// `S` resides. `D.isTemplated()` must be false.

diff  --git a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp 
b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
index c62bff33524cf..c80525dc4f34f 100644
--- a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -68,13 +68,13 @@ static llvm::BitVector findReachableBlocks(const CFG &Cfg) {
 }
 
 llvm::Expected
-ControlFlowContext::build(const FunctionDecl &Func, ASTContext &C) {
+ControlFlowContext::build(const FunctionDecl &Func) {
   if (!Func.hasBody())
 return llvm::createStringError(
 std::make_error_code(std::errc::invalid_argument),
 "Cannot analyze function without a body");
 
-  return build(Func, *Func.getBody(), C);
+  return build(Func, *Func.getBody(), Func.getASTContext());
 }
 
 llvm::Expected

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 32612397ec024..27ec15adc5350 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -211,7 +211,7 @@ DataflowAnalysisContext::getControlFlowContext(const 
FunctionDecl *F) {
 return &It->second;
 
   if (F->hasBody()) {
-auto CFCtx = ControlFlowContext::build(*F, F->getASTContext());
+auto CFCtx = ControlFlowContext::build(*F);
 // FIXME: Handle errors.
 assert(CFCtx);
 auto Result = FunctionContexts.insert({F, std::move(*CFCtx)});

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index d5591bee12dc2..aa2b2a241b224 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -241,7 +241,7 @@ checkDataflow(AnalysisInputs AI,
   llvm::errc::invalid_argument, "Could not find the target function.");
 
 // Build the control flow graph for the target function.
-auto MaybeCFCtx = ControlFlowContext::build(*Target, Context);
+auto MaybeCFCtx = ControlFlowContext::build(*Target);
 if (!MaybeCFCtx) return MaybeCFCtx.takeError();
 auto &CFCtx = *MaybeCFCtx;
 

diff  --git 
a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index 1d94b69cfce81..473750ad7a6cb 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -65,7 +65,7 @@ runAnalysis(llvm::StringRef Code, AnalysisT 
(*MakeAnalysis)(ASTContext &)) {
   assert(Func != nullptr);
 
   auto CFCtx =
-  llvm::cantFail(ControlFlowContext::build(*Func, AST->getASTContext()));
+  llvm::cantFail(ControlFlowContext::build(*Func));
 
   AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
   DataflowAnalysisContext DACtx(std::make_unique());



___

[PATCH] D151549: [clang][dataflow] Remove unnecessary `ASTContext` parameter from `ControlFlowContext::build` overload.

2023-05-30 Thread Martin Böhme 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 rG5ddb623952ca: [clang][dataflow] Remove unnecessary 
`ASTContext` parameter from… (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151549

Files:
  clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -65,7 +65,7 @@
   assert(Func != nullptr);
 
   auto CFCtx =
-  llvm::cantFail(ControlFlowContext::build(*Func, AST->getASTContext()));
+  llvm::cantFail(ControlFlowContext::build(*Func));
 
   AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
   DataflowAnalysisContext DACtx(std::make_unique());
Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -241,7 +241,7 @@
   llvm::errc::invalid_argument, "Could not find the target function.");
 
 // Build the control flow graph for the target function.
-auto MaybeCFCtx = ControlFlowContext::build(*Target, Context);
+auto MaybeCFCtx = ControlFlowContext::build(*Target);
 if (!MaybeCFCtx) return MaybeCFCtx.takeError();
 auto &CFCtx = *MaybeCFCtx;
 
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -211,7 +211,7 @@
 return &It->second;
 
   if (F->hasBody()) {
-auto CFCtx = ControlFlowContext::build(*F, F->getASTContext());
+auto CFCtx = ControlFlowContext::build(*F);
 // FIXME: Handle errors.
 assert(CFCtx);
 auto Result = FunctionContexts.insert({F, std::move(*CFCtx)});
Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -68,13 +68,13 @@
 }
 
 llvm::Expected
-ControlFlowContext::build(const FunctionDecl &Func, ASTContext &C) {
+ControlFlowContext::build(const FunctionDecl &Func) {
   if (!Func.hasBody())
 return llvm::createStringError(
 std::make_error_code(std::errc::invalid_argument),
 "Cannot analyze function without a body");
 
-  return build(Func, *Func.getBody(), C);
+  return build(Func, *Func.getBody(), Func.getASTContext());
 }
 
 llvm::Expected
Index: clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
===
--- clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
+++ clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
@@ -33,8 +33,7 @@
 public:
   /// Builds a ControlFlowContext from a `FunctionDecl`.
   /// `Func.hasBody()` must be true, and `Func.isTemplated()` must be false.
-  static llvm::Expected build(const FunctionDecl &Func,
-  ASTContext &C);
+  static llvm::Expected build(const FunctionDecl &Func);
 
   /// Builds a ControlFlowContext from an AST node. `D` is the function in 
which
   /// `S` resides. `D.isTemplated()` must be false.


Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -65,7 +65,7 @@
   assert(Func != nullptr);
 
   auto CFCtx =
-  llvm::cantFail(ControlFlowContext::build(*Func, AST->getASTContext()));
+  llvm::cantFail(ControlFlowContext::build(*Func));
 
   AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
   DataflowAnalysisContext DACtx(std::make_unique());
Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -241,7 +241,7 @@
   llvm::errc::invalid_argument, "Could not find the target function.");
 

[clang] 536b76e - [NFC] [serialization] Refactor the outdated AbrrevToUse of VarDecl

2023-05-30 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-05-30T15:07:35+08:00
New Revision: 536b76e873c56994a7dc611a6081a7a79e9fb526

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

LOG: [NFC] [serialization] Refactor the outdated AbrrevToUse of VarDecl

The implementation and the comment of the AbrrevToUse of VarDecl
looks not consistent with the implementation. This patch refactors it.

Added: 


Modified: 
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 54b5e3877782d..bd935472bcef4 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1136,10 +1136,10 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
   !D->isConstexpr() &&
   !D->isInitCapture() &&
   !D->isPreviousDeclInSameBlockScope() &&
-  !D->hasAttr() &&
   !D->isEscapingByref() &&
   !HasDeducedType &&
   D->getStorageDuration() != SD_Static &&
+  !D->getDescribedVarTemplate() &&
   !D->getMemberSpecializationInfo())
 AbbrevToUse = Writer.getDeclVarAbbrev();
 
@@ -2244,8 +2244,8 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(0));   // InitStyle
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
   Abv->Add(BitCodeAbbrevOp(0));   // Linkage
-  Abv->Add(BitCodeAbbrevOp(0));   // HasInit
-  Abv->Add(BitCodeAbbrevOp(0));   // 
HasMemberSpecializationInfo
+  Abv->Add(BitCodeAbbrevOp(0));   // ModulesCodegen
+  Abv->Add(BitCodeAbbrevOp(0));   // VarKind (local enum)
   // ParmVarDecl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // 
IsObjCMethodParameter
   Abv->Add(BitCodeAbbrevOp(0));   // ScopeDepth
@@ -2334,8 +2334,8 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(0)); // EscapingByref
   Abv->Add(BitCodeAbbrevOp(0)); // HasDeducedType
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // HasConstant*
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
+  Abv->Add(BitCodeAbbrevOp(0)); // ModulesCodeGen
+  Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
   // Type Source Info
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc



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


[PATCH] D151661: [clang] [test] Narrow down an MSVC specific behaviour to only not covever MinGW

2023-05-30 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added a comment.

In D151661#4380060 , @mstorsjo wrote:

> In D151661#4379958 , @Endill wrote:
>
>> Thank you!
>> I've asked Aaron what is the best way to check for MSVC-like triple before 
>> relanding this test. So today we both learned.
>
> Generally, the canonical way to check for it is `#ifdef _MSC_VER` - however 
> in the `%clang_cc1` tests, it's not automatically defined. This, because the 
> driver heuristically tries to guess a MSVC version to mimic, which it then 
> passes as a version number to `clang -cc1` with `-fms-compatibility-version` 
> or similar. When invoking `clang -cc1` manually, this doesn't get set and 
> `_MSC_VER` is undefined.

Yes, I remember checking `_MSC_VER` and `_MSC_FULL_VER`, but they didn't work.

> (I'm considering changing code to make sure that `_MSC_VER` always is defined 
> in such cases too, even to a dummy version number .)

That would be fantastic for DR and conformance tests!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151661

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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-30 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D150646#4380058 , @mstorsjo wrote:

> Regarding "fixed" - do you see any better way of fixing it there? As it's a 
> static inline function, there's no simple way of knowing whether it was 
> already defined or not; I went with the same pattern used for the existing 
> version check for GCC.

I mean, it fixes the issue if you apply the patch or update mingw headers. 
Whether that should be required or not is a good question.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-05-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 526539.
pmatos added a comment.

Remove test portion attempting to test coroutines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/builtins-table.c
  clang/test/Sema/builtins-wasm.c
  clang/test/Sema/wasm-refs-and-table-ped.c
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/test/SemaCXX/wasm-refs.cpp
  llvm/include/llvm/CodeGen/WasmAddressSpaces.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -62,8 +62,9 @@
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
 PtrToIntInst *PTI = dyn_cast(&*I);
 IntToPtrInst *ITP = dyn_cast(&*I);
-if (!(PTI && WebAssembly::isRefType(PTI->getPointerOperand()->getType())) &&
-!(ITP && WebAssembly::isRefType(ITP->getDestTy(
+if (!(PTI && WebAssembly::isWebAssemblyReferenceType(
+ PTI->getPointerOperand()->getType())) &&
+!(ITP && WebAssembly::isWebAssemblyReferenceType(ITP->getDestTy(
   continue;
 
 UndefValue *U = UndefValue::get(I->getType());
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1203,7 +1203,7 @@
   // Lastly, if this is a call to a funcref we need to add an instruction
   // table.set to the chain and transform the call.
   if (CLI.CB &&
-  WebAssembly::isFuncrefType(CLI.CB->getCalledOperand()->getType())) {
+  WebAssembly::isWebAssemblyFuncrefType(CLI.CB->getCalledOperand()->getType())) {
 // In the absence of function references proposal where a funcref call is
 // lowered to call_ref, using reference types we generate a table.set to set
 // the funcref to a special table used solely for this purpose, followed by
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
@@ -18,6 +18,7 @@
 #include "MCTargetDesc/WebAssemblyMCTypeUtilities.h"
 #include "llvm/BinaryFormat/Wasm.h"
 #include "llvm/CodeGen/MachineValueType.h"
+#include "llvm/CodeGen/WasmAddressSpaces.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/MC/MCSymbolWasm.h"
 
@@ -27,41 +28,21 @@
 
 namespace WebAssembly {
 
-enum WasmAddressSpace : unsigned {
-  // Default address space, for pointers to linear memory (stack, heap, data).
-  WASM_ADDRESS_SPACE_DEFAULT = 0,
-  // A non-integral address space for pointers to named objects outside of
-  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores
-  // to these pointers are lowered to global.get / global.set or local.get /
-  // local.set, as appropriate.
-  WASM_ADDRESS_SPACE_VAR = 1,
-  // A non-integral address space for externref values
-  WASM_ADDRESS_SPACE_EXTERNREF = 10,
-  // A non-integral address space for funcref values
-  WASM_ADDRESS_SPACE_FUNCREF = 20,
-};
-
-inline bool isDefaultAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_DEFAULT;
-}
-inline bool isWasmVarAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_VAR;
-}
-inline bool isValidAddressSpace(unsigned AS) {
-  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
+/// Return true if this is a WebAssembly Externref Type.
+inline bool isWebAssemblyExternrefType(const Type *Ty) {
+  return Ty->getPointerAddressSpace() ==
+ WebAssembly::WasmAddressSpace::WASM_ADDRESS_SPACE_EXTERNREF;
 }
-inline bool isFuncrefType(con

[PATCH] D148723: [clang] Restrict Inline Builtin to non-static, non-odr linkage

2023-05-30 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This causes failed asserts with `_FORTIFY_SOURCE` with the mingw-w64 headers. 
Here's a reduced reproducer:

  $ cat reduced.c
  typedef unsigned int size_t;
  
  void *memcpy(void *_Dst, const void *_Src, size_t _Size);
  
  extern __inline__ __attribute__((__always_inline__, __gnu_inline__)) 
__attribute__((__artificial__)) 
  void *memcpy(void *__dst, const void *__src, size_t __n) 
  {
return __builtin___memcpy_chk(__dst, __src, __n, 
__builtin_object_size((__dst), ((0) > 0) && (2 > 1))); 
  } 
  
  void *memcpy(void *_Dst, const void *_Src, size_t _Size);
  
  char *a, *b;
  void func(void) {
  memcpy(a, b, 42);
  }
  $ clang -target i686-w64-mingw32 -c reduced.c -O2
  clang: ../../clang/lib/AST/Decl.cpp:3763: bool 
clang::FunctionDecl::isInlineDefinitionExternallyVisible() const: Assertion 
`(doesThisDeclarationHaveABody() || willHaveBody() || hasAttr()) && 
"Must be a function definition"' failed.

Here, the second declaration of the regular extern version of the function is 
what is triggering the issue.

Can we revert this to unbreak my builds until we have a fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148723

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


[PATCH] D150549: Move SubtargetFeature.h from MC to TargetParser

2023-05-30 Thread Job Noorman via Phabricator via cfe-commits
jobnoorman added a comment.

Friendly ping. Any thoughts on my previous comment @MaskRay?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150549

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


[PATCH] D150758: [AIX] make integrated-as as default on AIX.

2023-05-30 Thread Esme Yi via Phabricator via cfe-commits
Esme updated this revision to Diff 526545.
Esme added a comment.

Remove unnecessary check lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150758

Files:
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/aix-as.c
  clang/test/Driver/aix-integrated-as.c


Index: clang/test/Driver/aix-integrated-as.c
===
--- /dev/null
+++ clang/test/Driver/aix-integrated-as.c
@@ -0,0 +1,15 @@
+// Test integrated-as is called by default on AIX.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS32 %s
+// CHECK-IAS32-NOT: "-a32"
+// CHECK-IAS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" "-emit-obj"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS64 %s
+// CHECK-IAS64-NOT: "-a64"
+// CHECK-IAS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" "-emit-obj"
Index: clang/test/Driver/aix-as.c
===
--- clang/test/Driver/aix-as.c
+++ clang/test/Driver/aix-as.c
@@ -2,7 +2,7 @@
 // only test assembler functionalities in this suite.
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
 // RUN: --target=powerpc-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS32 %s
 // CHECK-AS32-NOT: warning:
@@ -12,7 +12,7 @@
 // CHECK-AS32: "-many" 
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
 // RUN: --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS64 %s
 // CHECK-AS64-NOT: warning:
@@ -22,7 +22,7 @@
 // CHECK-AS64: "-many"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. -Xassembler  option. 
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
 // RUN: -Xassembler -w \
 // RUN: --target=powerpc-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS32-Xassembler %s
@@ -34,7 +34,7 @@
 // CHECK-AS32-Xassembler: "-w"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -Wa,, option.
-// RUN: %clang %s -### -c 2>&1 \
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
 // RUN: -Wa,-v,-w \
 // RUN: --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-AS64-Wa %s
@@ -47,7 +47,7 @@
 // CHECK-AS64-Wa: "-w"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Multiple input files.
-// RUN: %clang -### -c \
+// RUN: %clang -### -c -fno-integrated-as \
 // RUN: %S/Inputs/aix_ppc_tree/dummy0.s \
 // RUN: %S/Inputs/aix_ppc_tree/dummy1.s \
 // RUN: %S/Inputs/aix_ppc_tree/dummy2.s 2>&1 \
@@ -67,8 +67,8 @@
 // Check not passing no-integrated-as flag by default.
 // RUN: %clang %s -### -c 2>&1 --target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:   | FileCheck --check-prefix=CHECK-IAS 
--implicit-check-not=-no-integrated-as %s
+// CHECK-IAS-NOT: "-a64"
 // CHECK-IAS: InstalledDir
-// CHECK-IAS: "-a64"
 
 // Check passing no-integrated-as flag if specified by user.
 // RUN: %clang %s -### -c 2>&1 --target=powerpc64-ibm-aix7.1.0.0 
-fno-integrated-as \
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -68,6 +68,7 @@
   }
   bool isPICDefaultForced() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
+  bool IsIntegratedAssemblerDefault() const override { return true; }
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,


Index: clang/test/Driver/aix-integrated-as.c
===
--- /dev/null
+++ clang/test/Driver/aix-integrated-as.c
@@ -0,0 +1,15 @@
+// Test integrated-as is called by default on AIX.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS32 %s
+// CHECK-IAS32-NOT: "-a32"
+// CHECK-IAS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" "-emit-obj"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-IAS64 %s
+// CHECK-IAS64-NOT: "-a64"
+// CHECK-IAS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" "-emit-obj"
Index: clang/test/Driver/aix-as.c
===
--- clang/test/Driver/aix-as.c
+++ clang/test/Driver/aix-as.c
@@ -2,7 +2,7 @@
 // only test assembler functionalities in this suite.
 
 // Check powerpc-ibm-aix7.1.0.

[PATCH] D150758: [AIX] make integrated-as as default on AIX.

2023-05-30 Thread Esme Yi via Phabricator via cfe-commits
Esme added inline comments.



Comment at: clang/test/Driver/aix-integrated-as.c:9
+// CHECK-IAS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" "-emit-obj"
+// CHECK-IAS32: "aix-integrated-as.o"
+

DiggerLin wrote:
> both -fno-integrated-as and -fintegrated-as output the same file name 
> "aix-integrated-as.o" , do you want to check "aix-integrated-as.o" here 
Thanks, it seems an unnecessary check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150758

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


[PATCH] D151696: Remove CPU_SPECIFIC* MACROs and use unified getManglingForCPU

2023-05-30 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151696

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -23,6 +23,32 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=emeraldrapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=generic 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii_no_xmm_regs 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_pro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4_sse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_2_duo_ssse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_2_duo_sse4_1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=atom_sse4_2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=atom_sse4_2_movbe 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=goldmont_plus 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_i7_sse4_2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_aes_pclmulqdq 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_2nd_gen_avx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_3rd_gen_avx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_4th_gen_avx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_4th_gen_avx_tsx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_5th_gen_avx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=core_5th_gen_avx_tsx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=skylake_avx512 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=icelake_client 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unkno

[PATCH] D151697: [clang] Add test for CWG1710 and related issues

2023-05-30 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added reviewers: clang-language-wg, shafik.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Those issues focus on `template` keyword being optional in certain type-only 
contexts (base specifiers, member initializers, typename specifiers), as 
opposed to be disallowed by the grammar, or required by some implementations. 
GCC accepts all the tests this patch touches since 10, others fail on various 
tests: https://godbolt.org/z/1M6KE3W1a

It should be noted that the wording in 1710 
 that resolves those issues 
has been substantially changed by P1787 . I can't find 
the post-P1787 wording that covers those issues, but I can't find the intent of 
changing relevant behavior in P1787  either, so 
I assume that intent of the 1710 resolution is preserved somewhere.

This patch covers the following issues:
CWG314 
CWG343 
CWG1710 
CWG1794 
CWG1812 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151697

Files:
  clang/test/CXX/drs/dr17xx.cpp
  clang/test/CXX/drs/dr18xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1923,7 +1923,7 @@
 https://cplusplus.github.io/CWG/issues/314.html";>314
 C++17
 template in base class specifier
-Unknown
+No
   
   
 https://cplusplus.github.io/CWG/issues/315.html";>315
@@ -2097,7 +2097,7 @@
 https://cplusplus.github.io/CWG/issues/343.html";>343
 C++17
 Make template optional in contexts that require a type
-Unknown
+No
   
   
 https://cplusplus.github.io/CWG/issues/344.html";>344
@@ -10067,7 +10067,7 @@
 https://cplusplus.github.io/CWG/issues/1710.html";>1710
 C++17
 Missing template keyword in class-or-decltype
-Unknown
+No
   
   
 https://cplusplus.github.io/CWG/issues/1711.html";>1711
@@ -10571,7 +10571,7 @@
 https://cplusplus.github.io/CWG/issues/1794.html";>1794
 C++17
 template keyword and alias templates
-Unknown
+Yes
   
   
 https://cplusplus.github.io/CWG/issues/1795.html";>1795
@@ -10679,7 +10679,7 @@
 https://cplusplus.github.io/CWG/issues/1812.html";>1812
 C++17
 Omission of template in a typename-specifier
-Unknown
+No
   
   
 https://cplusplus.github.io/CWG/issues/1813.html";>1813
Index: clang/test/CXX/drs/dr3xx.cpp
===
--- clang/test/CXX/drs/dr3xx.cpp
+++ clang/test/CXX/drs/dr3xx.cpp
@@ -208,14 +208,20 @@
 #endif
 }
 
-namespace dr314 { // FIXME 314: dup 1710
-  template struct A {
-template struct B {};
-  };
-  template struct C : public A::template B {
-C() : A::template B() {}
-  };
-}
+namespace dr314 { // dr314: no
+  // NB: dup 1710
+template  struct A {
+  template  struct B {};
+};
+template  struct C : public A::template B {
+  C() : A::template B() {}
+};
+template  struct C2 : public A::B {
+  // expected-error@-1 {{use 'template' keyword to treat 'B' as a dependent template name}}
+  C2() : A::B() {}
+  // expected-error@-1 {{use 'template' keyword to treat 'B' as a dependent template name}}
+};
+} // namespace dr314
 
 // dr315: na
 // dr316: sup 1004
@@ -591,7 +597,7 @@
 
 // dr342: na
 
-namespace dr343 { // FIXME 343: no
+namespace dr343 { // dr343: no
   // FIXME: dup 1710
   template struct A {
 template struct B {};
Index: clang/test/CXX/drs/dr18xx.cpp
===
--- clang/test/CXX/drs/dr18xx.cpp
+++ clang/test/CXX/drs/dr18xx.cpp
@@ -4,12 +4,23 @@
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-error@+1 {{variadic macro}}
 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
 #endif
 
+namespace dr1812 { // dr1812: no
+   // NB: dup 1710
+#if __cplusplus >= 201103L
+template  struct A {
+  using B 

[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

2023-05-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.

Can you commit this change or should I do it on your behalf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150430

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


[PATCH] D143319: [clangd] Support iwyu pragma: no_include

2023-05-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the patch, and sorry for the long delay.

You probably need to do a large rebase when updating this patch (since the 
include-cleaner clangd code has been changed a lot)

This is a big patch, touching several pieces (I'd suggest split this patch, and 
narrow its scope.):

1. support no_include pragma in include-cleaner library (I made some comments 
regarding the implementation)
2. usage of no_include pragma:
  - 2.1 include-cleaner diagnostics in clangd -- for missing-includes, we 
should not insert a spelled include when it is in the NoIncludeSet;
  - 2.2 global code completion respects no_include pragma

It makes sense to support 1 and 2.1. And 2.2 is nice to have -- global code 
completion was built long time ago, and we haven't heard of any user complains, 
I'm less certain, it is probably fine if it is trivial to implement.




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:579
 
+std::vector issueNoIncludesDiagnostics(ParsedAST &AST,
+ llvm::StringRef Code) {

I'm not sure it is worth to make a dedicated function for this marginal pragma, 
I think we can treat it as an unused-include case, and we can move it to 
`issueUnusedIncludesDiagnostics`. 



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h:44
 
+struct IwyuNoInclude {
+  std::string

I think we can do it simpler. The `Resolved` field is no used anywhere, and is 
expensive to get.

The critical information to store is the header spelled in the no_include 
pragma, so having a `StringSet<> NoIncludes` field in `PragmaIncludes` should 
be sufficient.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h:165
+/// \class PragmaIncludes because the directive could be scattered throughout
+/// the source rather than being limited in preamble bounds.
+struct RecordedNoIncludes {

This is not a specific issue for no_include pragma, it is a known limitation -- 
ideally we should make PragmaIncludes collect all IWYU pragmas outside of the 
preamble region, tracking in https://github.com/clangd/clangd/issues/1571. 
I think we should merge this logic to the `PragmaIncludes` structure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143319

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


[clang] 9c561e8 - [clang] Add test for CWG1397

2023-05-30 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-05-30T12:09:02+03:00
New Revision: 9c561e8f3c2e8292bce9d7b36657144ba26a1c91

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

LOG: [clang] Add test for CWG1397

Resolution of this CWG breaks potential dependency loop between complete-class 
context of non-static data member initializer (NSDMI), and defaulted default 
constructor, which is `noexcept` depending on NSDMIs among other things.

For whatever reason in C++11 mode we issue an additional note and a different 
line number for the primary error. But I find the message itself even worse 
than aforementioned issues. It describes what's going on, but doesn't say 
what's bad about it. I find the previous version of this message more clear: 
https://github.com/llvm/llvm-project/commit/8dbc6b26171167b8ddf66a5f4b6d6fb9baf28336
 . Created an issue for that: #62823

Reviewed By: #clang-language-wg, shafik

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

Added: 


Modified: 
clang/test/CXX/drs/dr13xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 65eb8a293276f..feaf523c44fc2 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -480,6 +480,23 @@ namespace dr1395 { // dr1395: 16
 #endif
 }
 
+namespace dr1397 { // dr1397: 3.2
+#if __cplusplus >= 201103L
+struct A {   // #dr1397-struct-A
+  void *p = A{}; // #dr1397-void-p
+#if __cplusplus == 201103L
+  // expected-error@#dr1397-struct-A {{default member initializer for 'p' 
needed within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{in evaluation of exception specification 
for 'dr1397::A::A' needed here}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#elif __cplusplus >= 201402L
+  // expected-error@#dr1397-void-p {{default member initializer for 'p' needed 
within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#endif
+  operator void*() const { return nullptr; }
+};
+#endif
+} // namespace dr1397
+
 namespace dr1399 { // dr1399: dup 1388
   template void f(T..., int, T...) {} // expected-note 
{{candidate}} expected-error 0-1{{C++11}}
   void g() {

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 59a0b0c05295c..ec2ac24450832 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -8189,7 +8189,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/1397.html";>1397
 CD4
 Class completeness in non-static data member initializers
-Unknown
+Clang 3.2
   
   
 https://cplusplus.github.io/CWG/issues/1398.html";>1398



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


[PATCH] D151034: [clang] Add test for CWG1397

2023-05-30 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c561e8f3c2e: [clang] Add test for CWG1397 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151034

Files:
  clang/test/CXX/drs/dr13xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -8189,7 +8189,7 @@
 https://cplusplus.github.io/CWG/issues/1397.html";>1397
 CD4
 Class completeness in non-static data member initializers
-Unknown
+Clang 3.2
   
   
 https://cplusplus.github.io/CWG/issues/1398.html";>1398
Index: clang/test/CXX/drs/dr13xx.cpp
===
--- clang/test/CXX/drs/dr13xx.cpp
+++ clang/test/CXX/drs/dr13xx.cpp
@@ -480,6 +480,23 @@
 #endif
 }
 
+namespace dr1397 { // dr1397: 3.2
+#if __cplusplus >= 201103L
+struct A {   // #dr1397-struct-A
+  void *p = A{}; // #dr1397-void-p
+#if __cplusplus == 201103L
+  // expected-error@#dr1397-struct-A {{default member initializer for 'p' 
needed within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{in evaluation of exception specification 
for 'dr1397::A::A' needed here}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#elif __cplusplus >= 201402L
+  // expected-error@#dr1397-void-p {{default member initializer for 'p' needed 
within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#endif
+  operator void*() const { return nullptr; }
+};
+#endif
+} // namespace dr1397
+
 namespace dr1399 { // dr1399: dup 1388
   template void f(T..., int, T...) {} // expected-note 
{{candidate}} expected-error 0-1{{C++11}}
   void g() {


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -8189,7 +8189,7 @@
 https://cplusplus.github.io/CWG/issues/1397.html";>1397
 CD4
 Class completeness in non-static data member initializers
-Unknown
+Clang 3.2
   
   
 https://cplusplus.github.io/CWG/issues/1398.html";>1398
Index: clang/test/CXX/drs/dr13xx.cpp
===
--- clang/test/CXX/drs/dr13xx.cpp
+++ clang/test/CXX/drs/dr13xx.cpp
@@ -480,6 +480,23 @@
 #endif
 }
 
+namespace dr1397 { // dr1397: 3.2
+#if __cplusplus >= 201103L
+struct A {   // #dr1397-struct-A
+  void *p = A{}; // #dr1397-void-p
+#if __cplusplus == 201103L
+  // expected-error@#dr1397-struct-A {{default member initializer for 'p' needed within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{in evaluation of exception specification for 'dr1397::A::A' needed here}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#elif __cplusplus >= 201402L
+  // expected-error@#dr1397-void-p {{default member initializer for 'p' needed within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#endif
+  operator void*() const { return nullptr; }
+};
+#endif
+} // namespace dr1397
+
 namespace dr1399 { // dr1399: dup 1388
   template void f(T..., int, T...) {} // expected-note {{candidate}} expected-error 0-1{{C++11}}
   void g() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 993060e - [StaticAnalyzer] Fix block pointer type nullability check

2023-05-30 Thread Balazs Benics via cfe-commits

Author: tripleCC
Date: 2023-05-30T11:20:05+02:00
New Revision: 993060e1d31d07e9c44e7164d24f9f495197ca87

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

LOG: [StaticAnalyzer] Fix block pointer type nullability check

This patch fixes a false negative when the property type
is an objective-c block pointer.

Patch By tripleCC!

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
clang/test/Analysis/nullability.mm

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
index da8529f4ea813..11d5e77db0c73 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -306,6 +306,10 @@ static NullConstraint 
getNullConstraint(DefinedOrUnknownSVal Val,
   return NullConstraint::Unknown;
 }
 
+static bool isValidPointerType(QualType T) {
+  return T->isAnyPointerType() || T->isBlockPointerType();
+}
+
 const SymbolicRegion *
 NullabilityChecker::getTrackRegion(SVal Val, bool CheckSuperRegion) const {
   if (!NeedTracking)
@@ -621,7 +625,7 @@ void NullabilityChecker::checkPreStmt(const ReturnStmt *S,
   if (!RetExpr)
 return;
 
-  if (!RetExpr->getType()->isAnyPointerType())
+  if (!isValidPointerType(RetExpr->getType()))
 return;
 
   ProgramStateRef State = C.getState();
@@ -754,7 +758,7 @@ void NullabilityChecker::checkPreCall(const CallEvent &Call,
 if (!ArgSVal)
   continue;
 
-if (!Param->getType()->isAnyPointerType() &&
+if (!isValidPointerType(Param->getType()) &&
 !Param->getType()->isReferenceType())
   continue;
 
@@ -841,7 +845,7 @@ void NullabilityChecker::checkPostCall(const CallEvent 
&Call,
   if (!FuncType)
 return;
   QualType ReturnType = FuncType->getReturnType();
-  if (!ReturnType->isAnyPointerType())
+  if (!isValidPointerType(ReturnType))
 return;
   ProgramStateRef State = C.getState();
   if (State->get())
@@ -935,7 +939,7 @@ void NullabilityChecker::checkPostObjCMessage(const 
ObjCMethodCall &M,
   if (!Decl)
 return;
   QualType RetType = Decl->getReturnType();
-  if (!RetType->isAnyPointerType())
+  if (!isValidPointerType(RetType))
 return;
 
   ProgramStateRef State = C.getState();
@@ -1089,9 +1093,9 @@ void NullabilityChecker::checkPostStmt(const 
ExplicitCastExpr *CE,
CheckerContext &C) const {
   QualType OriginType = CE->getSubExpr()->getType();
   QualType DestType = CE->getType();
-  if (!OriginType->isAnyPointerType())
+  if (!isValidPointerType(OriginType))
 return;
-  if (!DestType->isAnyPointerType())
+  if (!isValidPointerType(DestType))
 return;
 
   ProgramStateRef State = C.getState();
@@ -1215,7 +1219,7 @@ void NullabilityChecker::checkBind(SVal L, SVal V, const 
Stmt *S,
 return;
 
   QualType LocType = TVR->getValueType();
-  if (!LocType->isAnyPointerType())
+  if (!isValidPointerType(LocType))
 return;
 
   ProgramStateRef State = C.getState();

diff  --git a/clang/test/Analysis/nullability.mm 
b/clang/test/Analysis/nullability.mm
index f9b3fc60c5a02..44c241e07ee50 100644
--- a/clang/test/Analysis/nullability.mm
+++ b/clang/test/Analysis/nullability.mm
@@ -46,10 +46,13 @@ - (int *_Nonnull)returnsNonnull;
 - (int *_Nullable)returnsNullable;
 - (int *)returnsUnspecified;
 - (void)takesNonnull:(int *_Nonnull)p;
+- (void)takesNonnullBlock:(void (^ _Nonnull)(void))block;
 - (void)takesNullable:(int *_Nullable)p;
 - (void)takesUnspecified:(int *)p;
 @property(readonly, strong) NSString *stuff;
 @property(readonly, nonnull) int *propReturnsNonnull;
+@property(readonly, nonnull) void (^propReturnsNonnullBlock)(void);
+@property(readonly, nullable) void (^propReturnsNullableBlock)(void);
 @property(readonly, nullable) int *propReturnsNullable;
 @property(readonly) int *propReturnsUnspecified;
 @end
@@ -65,6 +68,7 @@ - (void)takesUnspecified:(int *)p;
 void takesNullable(Dummy *_Nullable);
 void takesNonnull(Dummy *_Nonnull);
 void takesUnspecified(Dummy *);
+void takesNonnullBlock(void (^ _Nonnull)(void));
 
 Dummy *_Nullable returnsNullable();
 Dummy *_Nonnull returnsNonnull();
@@ -197,6 +201,7 @@ void testObjCPropertyReadNullability() {
   switch (getRandom()) {
   case 0:
 [o takesNonnull:o.propReturnsNonnull]; // no-warning
+[o takesNonnullBlock:o.propReturnsNonnullBlock]; // no-warning
 break;
   case 1:
 [o takesNonnull:o.propReturnsUnspecified]; // no-warning
@@ -236,6 +241,9 @@ void testObjCPropertyReadNullability() {
 assert(o.propReturnsNullable);
 [o takesNonnull:o.propReturnsNullable]; // no-warning
 break;
+  case 8:
+[o takesNonnullBlock:o.propRetur

[PATCH] D151651: [StaticAnalyzer] Fix block pointer type nullability check

2023-05-30 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG993060e1d31d: [StaticAnalyzer] Fix block pointer type 
nullability check (authored by tripleCC, committed by steakhal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151651

Files:
  clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  clang/test/Analysis/nullability.mm

Index: clang/test/Analysis/nullability.mm
===
--- clang/test/Analysis/nullability.mm
+++ clang/test/Analysis/nullability.mm
@@ -46,10 +46,13 @@
 - (int *_Nullable)returnsNullable;
 - (int *)returnsUnspecified;
 - (void)takesNonnull:(int *_Nonnull)p;
+- (void)takesNonnullBlock:(void (^ _Nonnull)(void))block;
 - (void)takesNullable:(int *_Nullable)p;
 - (void)takesUnspecified:(int *)p;
 @property(readonly, strong) NSString *stuff;
 @property(readonly, nonnull) int *propReturnsNonnull;
+@property(readonly, nonnull) void (^propReturnsNonnullBlock)(void);
+@property(readonly, nullable) void (^propReturnsNullableBlock)(void);
 @property(readonly, nullable) int *propReturnsNullable;
 @property(readonly) int *propReturnsUnspecified;
 @end
@@ -65,6 +68,7 @@
 void takesNullable(Dummy *_Nullable);
 void takesNonnull(Dummy *_Nonnull);
 void takesUnspecified(Dummy *);
+void takesNonnullBlock(void (^ _Nonnull)(void));
 
 Dummy *_Nullable returnsNullable();
 Dummy *_Nonnull returnsNonnull();
@@ -197,6 +201,7 @@
   switch (getRandom()) {
   case 0:
 [o takesNonnull:o.propReturnsNonnull]; // no-warning
+[o takesNonnullBlock:o.propReturnsNonnullBlock]; // no-warning
 break;
   case 1:
 [o takesNonnull:o.propReturnsUnspecified]; // no-warning
@@ -236,6 +241,9 @@
 assert(o.propReturnsNullable);
 [o takesNonnull:o.propReturnsNullable]; // no-warning
 break;
+  case 8:
+[o takesNonnullBlock:o.propReturnsNullableBlock]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
+break;
   }
 }
 
@@ -308,6 +316,11 @@
   takesNonnull(p);  // expected-warning {{Null passed to a callee that requires a non-null 1st parameter}}
 }
 
+void testBlockIndirectNilPassToNonnull() {
+  void (^p)(void) = nil;
+  takesNonnullBlock(p);  // expected-warning {{Null passed to a callee that requires a non-null 1st parameter}}
+}
+
 void testConditionalNilPassToNonnull(Dummy *p) {
   if (!p) {
 takesNonnull(p);  // expected-warning {{Null passed to a callee that requires a non-null 1st parameter}}
Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -306,6 +306,10 @@
   return NullConstraint::Unknown;
 }
 
+static bool isValidPointerType(QualType T) {
+  return T->isAnyPointerType() || T->isBlockPointerType();
+}
+
 const SymbolicRegion *
 NullabilityChecker::getTrackRegion(SVal Val, bool CheckSuperRegion) const {
   if (!NeedTracking)
@@ -621,7 +625,7 @@
   if (!RetExpr)
 return;
 
-  if (!RetExpr->getType()->isAnyPointerType())
+  if (!isValidPointerType(RetExpr->getType()))
 return;
 
   ProgramStateRef State = C.getState();
@@ -754,7 +758,7 @@
 if (!ArgSVal)
   continue;
 
-if (!Param->getType()->isAnyPointerType() &&
+if (!isValidPointerType(Param->getType()) &&
 !Param->getType()->isReferenceType())
   continue;
 
@@ -841,7 +845,7 @@
   if (!FuncType)
 return;
   QualType ReturnType = FuncType->getReturnType();
-  if (!ReturnType->isAnyPointerType())
+  if (!isValidPointerType(ReturnType))
 return;
   ProgramStateRef State = C.getState();
   if (State->get())
@@ -935,7 +939,7 @@
   if (!Decl)
 return;
   QualType RetType = Decl->getReturnType();
-  if (!RetType->isAnyPointerType())
+  if (!isValidPointerType(RetType))
 return;
 
   ProgramStateRef State = C.getState();
@@ -1089,9 +1093,9 @@
CheckerContext &C) const {
   QualType OriginType = CE->getSubExpr()->getType();
   QualType DestType = CE->getType();
-  if (!OriginType->isAnyPointerType())
+  if (!isValidPointerType(OriginType))
 return;
-  if (!DestType->isAnyPointerType())
+  if (!isValidPointerType(DestType))
 return;
 
   ProgramStateRef State = C.getState();
@@ -1215,7 +1219,7 @@
 return;
 
   QualType LocType = TVR->getValueType();
-  if (!LocType->isAnyPointerType())
+  if (!isValidPointerType(LocType))
 return;
 
   ProgramStateRef State = C.getState();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 10d6562 - Fix "not all control paths return a value" MSVC warning. NFC.

2023-05-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-05-30T10:33:31+01:00
New Revision: 10d6562ff1bc0009024633b1fd6ab6c3abaea4b7

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

LOG: Fix "not all control paths return a value" MSVC warning. NFC.

Added: 


Modified: 
clang/lib/AST/Decl.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index e441c338a2c76..99926b2786ef2 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3331,6 +3331,7 @@ bool FunctionDecl::isInlineBuiltinDeclaration() const {
   case GVA_StrongExternal:
 return true;
   }
+  llvm_unreachable("Unknown GVALinkage");
 }
 
 bool FunctionDecl::isDestroyingOperatorDelete() const {



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


[PATCH] D148793: [WIP][clang-tidy] Implement an include-cleaner check.

2023-05-30 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo marked 8 inline comments as done.
VitaNuo added a comment.

Thanks for the comments! I'll re-assign the review to Haojian for now, so that 
we can hopefully make more progress this week.




Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:48
+void IncludeCleanerCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

kadircet wrote:
> in theory this is not enough to disable the check for objc++, it'll have both 
> objc and cplusplus set. so we should check `ObjC` is false (there's no need 
> to disable it for `c`, right?)
> 
> nit: we can also override ` isLanguageVersionSupported` to disable check for 
> non-c++.
Ah thanks for the tip with `isLanguageVersionSupported`, doing that now.



Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:67
+  for (const auto &Header : IgnoreHeaders)
+IgnoreHeadersRegex.push_back(llvm::Regex{Header});
+  return IgnoreHeadersRegex;

kadircet wrote:
> let's make sure we're only going to match suffixes by appending `$` to the 
> `Header` here.
> 
> also before pushing into `IgnoreHeadersRegex` can you verify the regex 
> `isValid` and report a diagnostic via `configurationDiag` if regex is invalid.
Thanks, good ideas!



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst:15
+
+   A comma-separated list of header files that should be ignored during the 
+   analysis. The option allows for regular expressions. E.g., `foo/.*` disables

kadircet wrote:
> 
You probably wanted to say `insertion/removal` instead of `inclusion/insertion`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148793

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


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 526556.
pmatos added a comment.

Implement optimization when demanded bits are known, skip otherwise for rotates.

@nikic Things look much better now. Thanks for your help with the changes in 
InstCombine. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

Files:
  clang/test/CodeGen/WebAssembly/wasm-rotate.c
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
  llvm/test/Transforms/InstCombine/fsh.ll

Index: llvm/test/Transforms/InstCombine/fsh.ll
===
--- llvm/test/Transforms/InstCombine/fsh.ll
+++ llvm/test/Transforms/InstCombine/fsh.ll
@@ -440,12 +440,10 @@
   ret <2 x i32> %r
 }
 
-; TODO: Don't let SimplifyDemandedBits split up a rotate - keep the same operand.
-
 define i32 @rotl_common_demanded(i32 %a0) {
 ; CHECK-LABEL: @rotl_common_demanded(
 ; CHECK-NEXT:[[X:%.*]] = xor i32 [[A0:%.*]], 2
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X]], i32 [[A0]], i32 8)
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X]], i32 [[X]], i32 8)
 ; CHECK-NEXT:ret i32 [[R]]
 ;
   %x = xor i32 %a0, 2
@@ -456,7 +454,7 @@
 define i33 @rotr_common_demanded(i33 %a0) {
 ; CHECK-LABEL: @rotr_common_demanded(
 ; CHECK-NEXT:[[X:%.*]] = xor i33 [[A0:%.*]], 2
-; CHECK-NEXT:[[R:%.*]] = call i33 @llvm.fshl.i33(i33 [[X]], i33 [[A0]], i33 25)
+; CHECK-NEXT:[[R:%.*]] = call i33 @llvm.fshl.i33(i33 [[X]], i33 [[X]], i33 25)
 ; CHECK-NEXT:ret i33 [[R]]
 ;
   %x = xor i33 %a0, 2
Index: llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: sed 's/iX/i32/g' %s | llc --mtriple=wasm32-unknown-unknown | FileCheck --check-prefix=I32 %s
+; RUN: sed 's/iX/i64/g' %s | llc --mtriple=wasm64-unknown-unknown | FileCheck --check-prefix=I64 %s
+
+declare iX @llvm.fshl.iX(iX, iX, iX)
+declare iX @llvm.fshr.iX(iX, iX, iX)
+
+; from https://github.com/llvm/llvm-project/issues/62703
+
+define iX @testLeft(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testLeft:
+; I32: .functype testLeft (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotl
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testLeft:
+; I64: .functype testLeft (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotl
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshl.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
+
+define iX @testRight(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testRight:
+; I32: .functype testRight (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotr
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testRight:
+; I64: .functype testRight (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotr
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshr.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
Index: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -912,9 +912,24 @@
 
 APInt DemandedMaskLHS(DemandedMask.lshr(ShiftAmt));
 APInt DemandedMaskRHS(DemandedMask.shl(BitWidth - ShiftAmt));
-if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
-SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
-  return I;
+if (I->getOperand(0) != I->getOperand(1)) {
+if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
+  SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1)) 
+return I;
+} else { // fshl is a rotate
+  KnownBits LHSKnown = computeKnownBits(I->getOperand(0), Depth + 1, I);
+  KnownBits RHSKnown = computeKnownBits(I->getOperand(1), Depth + 1, I);
+
+  // Although this is a rotate there are cases where we want to optimize
+  // it. If the demanded bits are known, then we proceed with the
+  // optimization.
+  if ((DemandedMaskLHS.isSubsetOf(LHSKnown.Zero | LHSKnown.One)
+  || DemandedMaskRHS.isSubsetOf(RHSKnown.Zero | RHSKnown.One)) &&
+  (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
+   SimplifyDemandedBits

[PATCH] D148793: [WIP][clang-tidy] Implement an include-cleaner check.

2023-05-30 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 526558.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148793

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
  clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/bar.h
  clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/baz.h
  clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/foo.h
  clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/private.h
  clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/system/string.h
  clang-tools-extra/test/clang-tidy/checkers/misc/system/vector.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
@@ -0,0 +1,169 @@
+#include "ClangTidyDiagnosticConsumer.h"
+#include "ClangTidyOptions.h"
+#include "ClangTidyTest.h"
+#include "misc/IncludeCleanerCheck.h"
+#include "gtest/gtest.h"
+
+#include 
+#include 
+
+using namespace clang::tidy::misc;
+
+namespace clang {
+namespace tidy {
+namespace test {
+
+TEST(IncludeCleanerCheckTest, BasicUnusedIncludes) {
+  const char *PreCode = R"(
+#include "bar.h"
+#include 
+#include "bar.h"
+)";
+  const char *PostCode = "\n";
+
+  std::vector Errors;
+  EXPECT_EQ(PostCode, runCheckOnCode(
+  PreCode, &Errors, "file.cpp", std::nullopt,
+  ClangTidyOptions(), {{"bar.h", ""}, {"vector", ""}}));
+}
+
+TEST(IncludeCleanerCheckTest, SuppressUnusedIncludes) {
+  const char *PreCode = R"(
+#include "bar.h"
+#include "foo/qux.h"
+#include "baz/qux/qux.h"
+#include 
+)";
+
+  const char *PostCode = R"(
+#include "bar.h"
+#include "foo/qux.h"
+#include 
+)";
+
+  std::vector Errors;
+  ClangTidyOptions Opts;
+  Opts.CheckOptions["IgnoreHeaders"] = "bar.h,foo/.*,baz/qux,vector";
+  EXPECT_EQ(PostCode, runCheckOnCode(
+  PreCode, &Errors, "file.cpp", std::nullopt, Opts,
+  {{"bar.h", ""},
+   {"vector", ""},
+   {"foo/qux.h", ""},
+   {"baz/qux/qux.h", ""}}));
+}
+
+TEST(IncludeCleanerCheckTest, BasicMissingIncludes) {
+  const char *PreCode = R"(
+#include "bar.h"
+
+int BarResult = bar();
+int BazResult = baz();
+)";
+  const char *PostCode = R"(
+#include "bar.h"
+#include "baz.h"
+
+int BarResult = bar();
+int BazResult = baz();
+)";
+
+  std::vector Errors;
+  EXPECT_EQ(PostCode,
+runCheckOnCode(
+PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+{{"bar.h", R"(#pragma once
+  #include "baz.h"
+  int bar();
+   )"},
+ {"baz.h", R"(#pragma once
+  int baz();
+   )"}}));
+}
+
+TEST(IncludeCleanerCheckTest, SuppressMissingIncludes) {
+  const char *PreCode = R"(
+#include "bar.h"
+
+int BarResult = bar();
+int BazResult = baz();
+int QuxResult = qux();
+)";
+
+  ClangTidyOptions Opts;
+  Opts.CheckOptions["IgnoreHeaders"] = "baz.h,foo/.*";
+  std::vector Errors;
+  EXPECT_EQ(PreCode, runCheckOnCode(
+ PreCode, &Errors, "file.cpp", std::nullopt, Opts,
+ {{"bar.h", R"(#pragma once
+  #include "baz.h"
+  #include "foo/qux.h"
+  int bar();
+   )"},
+  {"baz.h", R"(#pragma once
+  int baz();
+   )"},
+  {"foo/qux.h", R"(#pragma once
+  int qux();
+   )"}}));
+}
+
+TEST(IncludeCleanerCheckTest, SystemMissingIncludes) {
+  const char *PreCode = R"(
+#include 
+
+std::string HelloString;
+std::vector Vec;
+)";
+  const char *PostCode = R"(
+#include 
+#include 
+
+std::string HelloString;
+std::vector Vec;
+)";
+
+  std::vector Errors;
+  EXPECT_EQ(PostCode,
+runCheckOnCode(
+PreCode, &Errors, "file.cpp", std::nullopt, C

[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 526559.
pmatos added a comment.

Fix up some spacing issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

Files:
  clang/test/CodeGen/WebAssembly/wasm-rotate.c
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
  llvm/test/Transforms/InstCombine/fsh.ll

Index: llvm/test/Transforms/InstCombine/fsh.ll
===
--- llvm/test/Transforms/InstCombine/fsh.ll
+++ llvm/test/Transforms/InstCombine/fsh.ll
@@ -440,12 +440,10 @@
   ret <2 x i32> %r
 }
 
-; TODO: Don't let SimplifyDemandedBits split up a rotate - keep the same operand.
-
 define i32 @rotl_common_demanded(i32 %a0) {
 ; CHECK-LABEL: @rotl_common_demanded(
 ; CHECK-NEXT:[[X:%.*]] = xor i32 [[A0:%.*]], 2
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X]], i32 [[A0]], i32 8)
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X]], i32 [[X]], i32 8)
 ; CHECK-NEXT:ret i32 [[R]]
 ;
   %x = xor i32 %a0, 2
@@ -456,7 +454,7 @@
 define i33 @rotr_common_demanded(i33 %a0) {
 ; CHECK-LABEL: @rotr_common_demanded(
 ; CHECK-NEXT:[[X:%.*]] = xor i33 [[A0:%.*]], 2
-; CHECK-NEXT:[[R:%.*]] = call i33 @llvm.fshl.i33(i33 [[X]], i33 [[A0]], i33 25)
+; CHECK-NEXT:[[R:%.*]] = call i33 @llvm.fshl.i33(i33 [[X]], i33 [[X]], i33 25)
 ; CHECK-NEXT:ret i33 [[R]]
 ;
   %x = xor i33 %a0, 2
Index: llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: sed 's/iX/i32/g' %s | llc --mtriple=wasm32-unknown-unknown | FileCheck --check-prefix=I32 %s
+; RUN: sed 's/iX/i64/g' %s | llc --mtriple=wasm64-unknown-unknown | FileCheck --check-prefix=I64 %s
+
+declare iX @llvm.fshl.iX(iX, iX, iX)
+declare iX @llvm.fshr.iX(iX, iX, iX)
+
+; from https://github.com/llvm/llvm-project/issues/62703
+
+define iX @testLeft(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testLeft:
+; I32: .functype testLeft (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotl
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testLeft:
+; I64: .functype testLeft (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotl
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshl.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
+
+define iX @testRight(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testRight:
+; I32: .functype testRight (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotr
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testRight:
+; I64: .functype testRight (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotr
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshr.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
Index: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -912,9 +912,23 @@
 
 APInt DemandedMaskLHS(DemandedMask.lshr(ShiftAmt));
 APInt DemandedMaskRHS(DemandedMask.shl(BitWidth - ShiftAmt));
-if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
-SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
-  return I;
+if (I->getOperand(0) != I->getOperand(1)) {
+if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
+SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
+return I;
+} else { // fshl is a rotate
+  KnownBits LHSKnown = computeKnownBits(I->getOperand(0), Depth + 1, I);
+  KnownBits RHSKnown = computeKnownBits(I->getOperand(1), Depth + 1, I);
+
+  // Although this is a rotate there are cases where we want to optimize
+  // it. If the demanded bits are known, then we proceed with the
+  // optimization.
+  if ((DemandedMaskLHS.isSubsetOf(LHSKnown.Zero | LHSKnown.One)
+  || DemandedMaskRHS.isSubsetOf(RHSKnown.Zero | RHSKnown.One)) &&
+  (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
+   SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))) 
+  return I;
+}
 
 Known.Zero = LHSKnown.Zero.shl(ShiftAmt) |
  RHS

[PATCH] D148614: [clang][Interp] Add frame depth checking

2023-05-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.cpp:345-352
+  if ((S.Current->getDepth() + 1) > S.getLangOpts().ConstexprCallDepth) {
+S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_depth_limit_exceeded)
+<< S.getLangOpts().ConstexprCallDepth;
+return false;
+  }
+

aaron.ballman wrote:
> aaron.ballman wrote:
> > `-fconstexpr-depth` sets the number of *recursive* constexpr calls, but 
> > this looks like it's measuring the depth of the call stack regardless of 
> > whether there's recursion or not. Can you add a test where you set this 
> > value to something low and make nested calls that exceed that depth?
> > 
> > (Also, there's `-fconstexpr-steps` 
> > https://clang.llvm.org/docs/UsersManual.html#cmdoption-fconstexpr-steps 
> > we'll need to support at some point, in case you weren't aware of the 
> > option.)
> Whelp, TIL that our docs are wrong and should be updated (I'll take care of 
> that): https://godbolt.org/z/ahPjPnhGr
> 
> It has nothing to do with recursion, that's just the way in which you'd 
> typically run into it.
I know about `-fconstexpr-steps`, but the notion of "steps" is implementation 
dependent, isn't it? I.e. I could just cal a "step" the execution of one opcode?


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

https://reviews.llvm.org/D148614

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


[PATCH] D148614: [clang][Interp] Add frame depth checking

2023-05-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 526565.

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

https://reviews.llvm.org/D148614

Files:
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/InterpFrame.h
  clang/lib/AST/Interp/InterpState.cpp
  clang/lib/AST/Interp/InterpState.h
  clang/test/AST/Interp/depth-limit.cpp
  clang/test/AST/Interp/depth-limit2.cpp

Index: clang/test/AST/Interp/depth-limit2.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/depth-limit2.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fconstexpr-depth 2 -verify %s
+// RUN: %clang_cc1 -fconstexpr-depth 2 -verify=ref %s
+
+
+constexpr int func() {
+  return 12;
+}
+
+constexpr int foo() {
+  return func(); // expected-note {{exceeded maximum depth of 2 calls}} \
+ // ref-note {{exceeded maximum depth of 2 calls}}
+}
+
+constexpr int bar() {
+  return foo(); // expected-note {{in call to 'foo()'}} \
+// ref-note {{in call to 'foo()'}}
+}
+
+static_assert(bar() == 12); // expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'bar()'}} \
+// ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'bar()'}}
+
Index: clang/test/AST/Interp/depth-limit.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/depth-limit.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fconstexpr-depth 100 -verify %s
+// RUN: %clang_cc1 -fconstexpr-depth 100 -verify=ref %s
+
+constexpr int f(int a) {
+  if (a == 100)
+return 1 / 0; // expected-warning {{division by zero is undefined}} \
+  // ref-warning {{division by zero is undefined}}
+
+  return f(a + 1); // ref-note {{exceeded maximum depth of 100 calls}} \
+   // ref-note {{in call to 'f(99)'}} \
+   // ref-note {{in call to 'f(98)'}} \
+   // ref-note {{in call to 'f(97)'}} \
+   // ref-note {{in call to 'f(96)'}} \
+   // ref-note {{in call to 'f(95)'}} \
+   // ref-note {{skipping 90 calls in backtrace}} \
+   // ref-note {{in call to 'f(4)'}} \
+   // ref-note {{in call to 'f(3)'}} \
+   // ref-note {{in call to 'f(2)'}} \
+   // ref-note {{in call to 'f(1)'}} \
+   // expected-note {{exceeded maximum depth of 100 calls}} \
+   // expected-note {{in call to 'f(99)'}} \
+   // expected-note {{in call to 'f(98)'}} \
+   // expected-note {{in call to 'f(97)'}} \
+   // expected-note {{in call to 'f(96)'}} \
+   // expected-note {{in call to 'f(95)'}} \
+   // expected-note {{skipping 90 calls in backtrace}} \
+   // expected-note {{in call to 'f(4)'}} \
+   // expected-note {{in call to 'f(3)'}} \
+   // expected-note {{in call to 'f(2)'}} \
+   // expected-note {{in call to 'f(1)'}}
+}
+static_assert(f(0) == 100); // ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'f(0)'}} \
+// expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'f(0)'}}
Index: clang/lib/AST/Interp/InterpState.h
===
--- clang/lib/AST/Interp/InterpState.h
+++ clang/lib/AST/Interp/InterpState.h
@@ -15,6 +15,7 @@
 
 #include "Context.h"
 #include "Function.h"
+#include "InterpFrame.h"
 #include "InterpStack.h"
 #include "State.h"
 #include "clang/AST/APValue.h"
@@ -41,7 +42,9 @@
   // Stack frame accessors.
   Frame *getSplitFrame() { return Parent.getCurrentFrame(); }
   Frame *getCurrentFrame() override;
-  unsigned getCallStackDepth() override { return CallStackDepth; }
+  unsigned getCallStackDepth() override {
+return Current ? (Current->getDepth() + 1) : 1;
+  }
   const Frame *getBottomFrame() const override {
 return Parent.getBottomFrame();
   }
@@ -105,8 +108,6 @@
   Context &Ctx;
   /// The current frame.
   InterpFrame *Current = nullptr;
-  /// Call stack depth.
-  unsigned CallStackDepth;
 };
 
 } // namespace interp
Index: clang/lib/AST/Interp/InterpState.cpp
===
--- clang/lib/AST/Interp/InterpState.cpp
+++ clang/lib/AST/Interp/InterpState.cpp
@@ -17,8 +17,7 @@
 
 InterpState::InterpState(State &Parent, Program &P, InterpStack &Stk,
  Context &Ctx, SourceMapper *M)
-: Parent(Parent), M(M), P(P), Stk(Stk), Ctx(Ctx), Current(

[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-05-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1030
   NegFlag>;
+def mprintf_kind_EQ : Joined<["-"], "mprintf-kind=">, Group,
+  HelpText<"Specify the printf lowering scheme (AMDGPU only), allowed values 
are "

I'm a bit worried this is introducing a side-ABI option not captured in the 
triple or at least module flags 



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4695
+  // Device side compilation printf
+  if (Args.getLastArg(options::OPT_mprintf_kind_EQ))
+CmdArgs.push_back(Args.MakeArgString(

Braces 



Comment at: clang/test/CodeGenHIP/printf_nonhostcall.cpp:64
+// CHECK-NEXT:[[PRINTBUFFNEXTPTR4:%.*]] = getelementptr inbounds i8, ptr 
addrspace(1) [[PRINTBUFFNEXTPTR3]], i64 [[TMP13]]
+// CHECK-NEXT:[[TMP21:%.*]] = ptrtoint ptr [[TMP1]] to i64
+// CHECK-NEXT:store i64 [[TMP21]], ptr addrspace(1) [[PRINTBUFFNEXTPTR4]], 
align 8

Can directly store the pointer, don't ptrtoint? Should have some other pointer 
address spaces tested, the spec is quiet on how %p is supposed to work with 
different sized pointers 



Comment at: clang/test/CodeGenHIP/printf_nonhostcall.cpp:228
+  return printf(s, 10);
+}

Need some vector tests, especially 3 x vectors 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:211
+struct StringData {
+  std::string Str = "";
+  bool isConst = true;

Don't need = ""



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:212
+  std::string Str = "";
+  bool isConst = true;
+  Value *RealSize = nullptr;

Move last 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:224
+static Value *callBufferedPrintfStart(
+IRBuilder<> &Builder, ArrayRef &Args, Value *Fmt,
+bool isConstFmtStr, SparseBitVector<8> &SpecIsCString,

ArrayRef should be passed by value 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:235
+  else {
+auto LenWithNull = getStrlenWithNull(Builder, Fmt);
+

arsenm wrote:
> No auto 
No auto 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:235-238
+auto LenWithNull = getStrlenWithNull(Builder, Fmt);
+
+// Align the computed length to next 8 byte boundary
+auto TempAdd = Builder.CreateAdd(

No auto 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:294
+  Type *Tys_alloc[1] = {Builder.getInt32Ty()};
+  Type *I8Ptr = Builder.getInt8PtrTy(1);
+  FunctionType *FTy_alloc = FunctionType::get(I8Ptr, Tys_alloc, false);

I suppose you can't access the AMDGPU enum from Utils. You could use 
DL.getDefaultGlobalsAddrSpace 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:381
+} else {
+  if (Args[i]->getType()->isDoubleTy())
+WhatToStore.push_back(Args[i]);

Don't see why isDoubleTy would be special cased here and not part of 
fitArgInto64Bits



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:395
+  Builder.getInt8Ty(), PtrToStore,
+  M->getDataLayout().getTypeStoreSize(toStore->getType()),
+  "PrintBuffNextPtr");

This should probably be getTypeAllocSize 



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:369
+// to alignment padding is not populated with any specific value
+// here, I feel this would be safe as long as runtime is sync with
+// the offsets.

sameerds wrote:
> Avoid first person comments. 
You have better alignment info than Align(1)



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:458
+auto CreateControlDWord = M->getOrInsertFunction(
+StringRef("__ockl_create_control_dword"), Builder.getInt32Ty(),
+Builder.getInt32Ty(), Int1Ty, Int1Ty);

sameerds wrote:
> vikramRH wrote:
> > arsenm wrote:
> > > vikramRH wrote:
> > > > arsenm wrote:
> > > > > Do we really need another ockl control variable for this? Why isn't 
> > > > > it a parameter? printf=stdout always 
> > > > There are certain HIP API's such as "hip_assert" that output to stderr. 
> > > > currently such API's are supported via hostcalls. Although this 
> > > > implementation does not currently support the API's ,its kept as an 
> > > > option. 
> > > Right but the way to handle that would be a parameter for where to 
> > > output, not an externally set global 
> > I am not clear here, you expect additional inputs to device lib function ?
> @arsenm, this "control word" written into the buffer. In that sense, it is 
> indeed a parameter passed from device to host as part of the printf packet. 
> It is not yet another global variable.
I'm not following why this part requires introducing 

[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 526566.
junaire marked 2 inline comments as done.
junaire added a comment.

Add LLVM preamble


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/PartialTranslationUnit.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_interpreter_runtime_printvalue.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/DeviceOffload.cpp
  clang/lib/Interpreter/DeviceOffload.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValuePrinter.cpp
  clang/test/Interpreter/pretty-print.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -29,6 +29,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace caas;
 
 #if defined(_AIX)
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
@@ -46,12 +47,12 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CB = clang::IncrementalCompilerBuilder();
+  auto CB = clang::caas::IncrementalCompilerBuilder();
   CB.SetCompilerArgs(ClangArgs);
   auto CI = cantFail(CB.CreateCpp());
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 static size_t DeclsSize(TranslationUnitDecl *PTUDecl) {
Index: clang/unittests/Interpreter/IncrementalProcessingTest.cpp
===
--- clang/unittests/Interpreter/IncrementalProcessingTest.cpp
+++ clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -27,6 +27,7 @@
 
 using namespace llvm;
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 
@@ -52,12 +53,12 @@
 
 TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) {
   std::vector ClangArgv = {"-Xclang", "-emit-llvm-only"};
-  auto CB = clang::IncrementalCompilerBuilder();
+  auto CB = clang::caas::IncrementalCompilerBuilder();
   CB.SetCompilerArgs(ClangArgv);
   auto CI = cantFail(CB.CreateCpp());
   auto Interp = llvm::cantFail(Interpreter::create(std::move(CI)));
 
-  std::array PTUs;
+  std::array PTUs;
 
   PTUs[0] = &llvm::cantFail(Interp->Parse(TestProgram1));
   ASSERT_TRUE(PTUs[0]->TheModule);
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -30,6 +30,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 using Args = std::vector;
@@ -38,12 +39,12 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CB = clang::IncrementalCompilerBuilder();
+  auto CB = clang::caas::IncrementalCompilerBuilder();
   CB.SetCompilerArgs(ClangArgs);
   auto CI = cantFail(CB.CreateCpp());
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 TEST(InterpreterTest, CatchException) {
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -97,7 +97,7 @@
 return 0;
   }
 
-  clang::IncrementalCompilerBuilder CB;
+  clang::caas::IncrementalCompilerBuilder CB;
   CB.SetCompilerArgs(ClangArgv);
 
   std::unique_ptr DeviceCI;
@@ -132,10 +132,10 @@
   if (CudaEnabled)
 DeviceCI->LoadRequestedPlugins();
 
-  std::unique_ptr Interp;
+  std::unique_ptr Interp;
   if (CudaEnabled) {
-Interp = ExitOnErr(
-clang::Interpreter::createWithCUDA(std::move(CI

[PATCH] D149013: [clang][Interp] Check pointers when accessing base class

2023-05-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149013

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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-05-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:211
+struct StringData {
+  std::string Str = "";
+  bool isConst = true;

arsenm wrote:
> Don't need = ""
Can't you just use the raw StringRef out of getConstantStringInfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire added inline comments.



Comment at: clang/lib/Interpreter/ValuePrinter.cpp:262
+
+static llvm::Expected CompileDecl(Interpreter &Interp,
+   Decl *D) {

v.g.vassilev wrote:
> Let's add a FIXME here. The problem `CompileDecl` and `GenModule` intends to 
> solve is that when we synthesize AST we need to inform the rest of the Clang 
> infrastructure about it and attach the produced `llvm::Module` to the JIT so 
> that it can resolve symbols from it.
> 
> In cling that is solved with a RAII object which marks a scope where the 
> synthesis happens and takes care to inform the rest of the infrastructure. We 
> need something similar and a little more robust maybe. Something like 
> `ASTSynthesisRAII` which ultimately hides this machinery especially from the 
> public API.
I can't really get the point. I agree we shouldn't expose 
`Interpreter::GenModule` as a public interface but I don't understand the 
solution.



Comment at: clang/lib/Interpreter/ValuePrinter.cpp:442
+
+REPL_EXTERNAL_VISIBILITY std::string PrintValueRuntime(const char *const *Val) 
{
+  return PrintString(Val);

v.g.vassilev wrote:
> All of the `PrintValueRuntime` seem to be duplicating code. We could use the 
> preprocessor to expand these to but it would require some changes which I 
> believe could be done as a separate patch:
> 
> * Perhaps we should be compatible with cling here in terms of naming as 
> that's a public API - there I believe we use `printValue`.
> * We should try to leverage `TemplateBase.cpp::printIntegral` for integral 
> types.
> * We should not return `std::string` here but a `const char*` and we should 
> provide somewhere storage for them. That would probably make porting to 
> embedded systems easier since on many the  header is hard to support. 
> 
> I believe it would be enough to have a fixme for now.
* I'd propose using `PrintValueRuntime` here. This is because we have used it 
across RFC and other documentation so I don't want to change it :(

> We should not return std::string here but a const char* and we should provide 
> somewhere storage for them. That would probably make porting to embedded 
> systems easier since on many the  header is hard to support.

* That really touches the dark corner of our design. On the one hand, we try to 
keep `Value` itself as lightweight as possible, on the other hand, we use heavy 
headers like `` and `` in value pretty printing. While 
this is awkward, we can hardly avoid it because the implementation needs to see 
the definition of these types to know how to print it. So how can we do this on 
resources limited systems? My point is that perhaps we can keep it as is, 
because it's very hard to measure how expensive the feature is on the targeting 
platform. If the system can afford this, then we don't need to worry about 
anything, but if the system can't even use STL itself, presumably it shouldn't 
use value printing at all! Note that this doesn't conflicts with the lightness 
of the value runtime as it SHOULD add as little overhead as possible no matter 
whether the host can afford it or not.



Comment at: clang/lib/Interpreter/ValuePrinter.cpp:473
+  else if (auto *BT = DesugaredTy.getCanonicalType()->getAs()) {
+switch (BT->getKind()) {
+case BuiltinType::Bool: {

v.g.vassilev wrote:
> We could use the preprocessor the way we do in `Value.cpp` to expand this 
> dispatcher.
We actually can't because it doesn't strictly match everything. For example 
`Char_S` and `SChar` both map to `V.getSChar()` IIUC?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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


[PATCH] D151088: [flang][hlfir] Separate -emit-fir and -emit-hlfir for flang-new

2023-05-30 Thread Tom Eccles via Phabricator via cfe-commits
tblah added a comment.

@awarzynski ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151088

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


[PATCH] D151701: [HIP] Add missing __hip_atomic_fetch_sub support

2023-05-30 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm created this revision.
ldrumm added reviewers: yaxunl, nikic, gandhi21299.
Herald added a subscriber: StephenFan.
Herald added a project: All.
ldrumm requested review of this revision.
Herald added a project: clang.

The rest of the fetch/op intrinsics were added in e13246a2ec3 
 but sub 
was conspicuous by its absence.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151701

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/atomic-ops.cu

Index: clang/test/CodeGenCUDA/atomic-ops.cu
===
--- clang/test/CodeGenCUDA/atomic-ops.cu
+++ clang/test/CodeGenCUDA/atomic-ops.cu
@@ -6,6 +6,7 @@
 // CHECK: cmpxchg weak ptr {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as") monotonic monotonic, align 4
 // CHECK: atomicrmw xchg ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw add ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw sub ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw and ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw or ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
 // CHECK: atomicrmw xor ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
@@ -18,6 +19,7 @@
   flag = __hip_atomic_compare_exchange_weak(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_sub(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_and(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_or(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
@@ -42,6 +44,7 @@
 // CHECK: cmpxchg weak ptr {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as") monotonic monotonic, align 4
 // CHECK: atomicrmw xchg ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw add ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw sub ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw and ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw or ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
 // CHECK: atomicrmw xor ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
@@ -54,6 +57,7 @@
   flag = __hip_atomic_compare_exchange_weak(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_fetch_sub(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_fetch_and(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_fetch_or(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
@@ -78,6 +82,7 @@
 // CHECK: cmpxchg weak ptr {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as") monotonic monotonic, align 4
 // CHECK: atomicrmw xchg ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as")
 // CHECK: atomicrmw add ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as")
+// CHECK: atomicrmw sub ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as")
 // CHECK: atomicrmw and ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as")
 // CHECK: atomicrmw or ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as")
 // CHECK: atomicrmw xor ptr {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("workgroup-one-as")
@@ -89,6 +94,7 @@
   flag = __hip_atomic_compare_exchange_weak(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WORKGROUP);
   val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WORKGROUP);
   val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WORKGROUP);
+  val = __hip_atomic_fetch_sub(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WORKGROUP);
   val = __hip_atomic_fetch_and(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WORKGROUP);
   val = __hip_atomic_fetch_or(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WORKGROUP);
   val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WORKG

[PATCH] D151701: [HIP] Add missing __hip_atomic_fetch_sub support

2023-05-30 Thread Nikita Popov via Phabricator via cfe-commits
nikic resigned from this revision.
nikic added a comment.

(Looks reasonable, but is pretty far outside my area of expertise...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151701

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


[PATCH] D144654: [Lex] Warn when defining or undefining any builtin macro

2023-05-30 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

gcc has the same warning so I wasn't expecting this cause to change problems, 
but looking more closely at gcc's behaviour it looks like it only warns for 
some builtin macros and not others (though glancing over the gcc source code 
it's not clear which macros and for what reason).

I'll look at this some more and see if I can improve the behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144654

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


[PATCH] D150670: Disable generation of fshl/fshr for rotates

2023-05-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 526577.
pmatos added a comment.

Apply clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

Files:
  clang/test/CodeGen/WebAssembly/wasm-rotate.c
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
  llvm/test/Transforms/InstCombine/fsh.ll

Index: llvm/test/Transforms/InstCombine/fsh.ll
===
--- llvm/test/Transforms/InstCombine/fsh.ll
+++ llvm/test/Transforms/InstCombine/fsh.ll
@@ -440,12 +440,10 @@
   ret <2 x i32> %r
 }
 
-; TODO: Don't let SimplifyDemandedBits split up a rotate - keep the same operand.
-
 define i32 @rotl_common_demanded(i32 %a0) {
 ; CHECK-LABEL: @rotl_common_demanded(
 ; CHECK-NEXT:[[X:%.*]] = xor i32 [[A0:%.*]], 2
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X]], i32 [[A0]], i32 8)
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X]], i32 [[X]], i32 8)
 ; CHECK-NEXT:ret i32 [[R]]
 ;
   %x = xor i32 %a0, 2
@@ -456,7 +454,7 @@
 define i33 @rotr_common_demanded(i33 %a0) {
 ; CHECK-LABEL: @rotr_common_demanded(
 ; CHECK-NEXT:[[X:%.*]] = xor i33 [[A0:%.*]], 2
-; CHECK-NEXT:[[R:%.*]] = call i33 @llvm.fshl.i33(i33 [[X]], i33 [[A0]], i33 25)
+; CHECK-NEXT:[[R:%.*]] = call i33 @llvm.fshl.i33(i33 [[X]], i33 [[X]], i33 25)
 ; CHECK-NEXT:ret i33 [[R]]
 ;
   %x = xor i33 %a0, 2
Index: llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: sed 's/iX/i32/g' %s | llc --mtriple=wasm32-unknown-unknown | FileCheck --check-prefix=I32 %s
+; RUN: sed 's/iX/i64/g' %s | llc --mtriple=wasm64-unknown-unknown | FileCheck --check-prefix=I64 %s
+
+declare iX @llvm.fshl.iX(iX, iX, iX)
+declare iX @llvm.fshr.iX(iX, iX, iX)
+
+; from https://github.com/llvm/llvm-project/issues/62703
+
+define iX @testLeft(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testLeft:
+; I32: .functype testLeft (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotl
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testLeft:
+; I64: .functype testLeft (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotl
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshl.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
+
+define iX @testRight(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testRight:
+; I32: .functype testRight (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotr
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testRight:
+; I64: .functype testRight (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotr
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshr.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
Index: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -912,9 +912,26 @@
 
 APInt DemandedMaskLHS(DemandedMask.lshr(ShiftAmt));
 APInt DemandedMaskRHS(DemandedMask.shl(BitWidth - ShiftAmt));
-if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
-SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
-  return I;
+if (I->getOperand(0) != I->getOperand(1)) {
+  if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown,
+   Depth + 1) ||
+  SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
+return I;
+} else { // fshl is a rotate
+  KnownBits LHSKnown = computeKnownBits(I->getOperand(0), Depth + 1, I);
+  KnownBits RHSKnown = computeKnownBits(I->getOperand(1), Depth + 1, I);
+
+  // Although this is a rotate there are cases where we want to optimize
+  // it. If the demanded bits are known, then we proceed with the
+  // optimization.
+  if ((DemandedMaskLHS.isSubsetOf(LHSKnown.Zero | LHSKnown.One) ||
+   DemandedMaskRHS.isSubsetOf(RHSKnown.Zero | RHSKnown.One)) &&
+  (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown,
+Depth + 1) ||
+   SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown,
+Depth + 1)))
+return I;
+ 

[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-05-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 526578.
pmatos added a comment.

Apply clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/builtins-table.c
  clang/test/Sema/builtins-wasm.c
  clang/test/Sema/wasm-refs-and-table-ped.c
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/test/SemaCXX/wasm-refs.cpp
  llvm/include/llvm/CodeGen/WasmAddressSpaces.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -62,8 +62,9 @@
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
 PtrToIntInst *PTI = dyn_cast(&*I);
 IntToPtrInst *ITP = dyn_cast(&*I);
-if (!(PTI && WebAssembly::isRefType(PTI->getPointerOperand()->getType())) &&
-!(ITP && WebAssembly::isRefType(ITP->getDestTy(
+if (!(PTI && WebAssembly::isWebAssemblyReferenceType(
+ PTI->getPointerOperand()->getType())) &&
+!(ITP && WebAssembly::isWebAssemblyReferenceType(ITP->getDestTy(
   continue;
 
 UndefValue *U = UndefValue::get(I->getType());
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1202,8 +1202,8 @@
 
   // Lastly, if this is a call to a funcref we need to add an instruction
   // table.set to the chain and transform the call.
-  if (CLI.CB &&
-  WebAssembly::isFuncrefType(CLI.CB->getCalledOperand()->getType())) {
+  if (CLI.CB && WebAssembly::isWebAssemblyFuncrefType(
+CLI.CB->getCalledOperand()->getType())) {
 // In the absence of function references proposal where a funcref call is
 // lowered to call_ref, using reference types we generate a table.set to set
 // the funcref to a special table used solely for this purpose, followed by
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
@@ -18,6 +18,7 @@
 #include "MCTargetDesc/WebAssemblyMCTypeUtilities.h"
 #include "llvm/BinaryFormat/Wasm.h"
 #include "llvm/CodeGen/MachineValueType.h"
+#include "llvm/CodeGen/WasmAddressSpaces.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/MC/MCSymbolWasm.h"
 
@@ -27,41 +28,21 @@
 
 namespace WebAssembly {
 
-enum WasmAddressSpace : unsigned {
-  // Default address space, for pointers to linear memory (stack, heap, data).
-  WASM_ADDRESS_SPACE_DEFAULT = 0,
-  // A non-integral address space for pointers to named objects outside of
-  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores
-  // to these pointers are lowered to global.get / global.set or local.get /
-  // local.set, as appropriate.
-  WASM_ADDRESS_SPACE_VAR = 1,
-  // A non-integral address space for externref values
-  WASM_ADDRESS_SPACE_EXTERNREF = 10,
-  // A non-integral address space for funcref values
-  WASM_ADDRESS_SPACE_FUNCREF = 20,
-};
-
-inline bool isDefaultAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_DEFAULT;
-}
-inline bool isWasmVarAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_VAR;
-}
-inline bool isValidAddressSpace(unsigned AS) {
-  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
+/// Return true if this is a WebAssembly Externref Type.
+inline bool isWebAssemblyExternrefType(const Type *Ty) {
+  return Ty->getPointerAddressSpace() ==
+ WebAssembly::WasmAddressSpace::WASM_ADDRESS_SPACE_EXTERNREF;
 }
-inline bool isFuncrefType(

[PATCH] D144654: [Lex] Warn when defining or undefining any builtin macro

2023-05-30 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

FWIW, I've also run into noisy warnings caused by this, in a few places. 
D151662  fixes a bunch of clang's tests when 
run in MinGW configurations, and 
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230526104837.20594-1-mar...@martin.st/
 tries to avoid warnings due to `-U__STRICT_ANSI__` in an external project.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144654

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


[PATCH] D151704: [clang] Add test for CWG873

2023-05-30 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added reviewers: clang-language-wg, shafik, erichkeane.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Also add missing marking to the test of related issue 621.

https://cplusplus.github.io/CWG/issues/621.html
https://cplusplus.github.io/CWG/issues/873.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151704

Files:
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/drs/dr8xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3767,7 +3767,7 @@
 https://cplusplus.github.io/CWG/issues/621.html";>621
 C++11
 Template argument deduction from function return types
-Unknown
+Yes
   
   
 https://cplusplus.github.io/CWG/issues/622.html";>622
@@ -5117,7 +5117,7 @@
 https://cplusplus.github.io/CWG/issues/873.html";>873
 C++11
 Deducing rvalue references in declarative contexts
-Unknown
+Yes
   
   
 https://cplusplus.github.io/CWG/issues/874.html";>874
Index: clang/test/CXX/drs/dr8xx.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr8xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+
+// expected-no-diagnostics
+
+namespace dr873 { // dr873: yes
+#if __cplusplus >= 201103L
+template  void f(T &&);
+template <> void f(int &) {}  // #1
+template <> void f(int &&) {} // #2
+void g(int i) {
+  f(i); // calls f(int&), i.e., #1
+#pragma clang __debug dump f(i)
+  //  CHECK: CallExpr {{.*}}
+  // CHECK-NEXT: |-ImplicitCastExpr {{.*}}
+  // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'f' 'void (int &)' {{.*}}
+
+  f(0); // calls f(int&&), i.e., #2
+#pragma clang __debug dump f(0)
+  //  CHECK: CallExpr {{.*}}
+  // CHECK-NEXT: |-ImplicitCastExpr {{.*}}
+  // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'f' 'void (int &&)' {{.*}}
+}
+#endif
+} // namespace dr873
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -234,7 +234,7 @@
 
 // dr620: dup 568
 
-namespace dr621 {
+namespace dr621 { // dr621: yes
   template T f();
   template<> int f() {} // expected-note {{previous}}
   template<> int f() {} // expected-error {{redefinition}}


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3767,7 +3767,7 @@
 https://cplusplus.github.io/CWG/issues/621.html";>621
 C++11
 Template argument deduction from function return types
-Unknown
+Yes
   
   
 https://cplusplus.github.io/CWG/issues/622.html";>622
@@ -5117,7 +5117,7 @@
 https://cplusplus.github.io/CWG/issues/873.html";>873
 C++11
 Deducing rvalue references in declarative contexts
-Unknown
+Yes
   
   
 https://cplusplus.github.io/CWG/issues/874.html";>874
Index: clang/test/CXX/drs/dr8xx.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr8xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fe

[PATCH] D148793: [clang-tidy] Implement an include-cleaner check.

2023-05-30 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Not too bad, you on a right road. Tests failed on windows, and clang-format 
failed.




Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:86
+  llvm::SmallVector MainFileDecls;
+  for (auto *D : Result.Nodes.getNodeAs("top")->decls()) {
+SourceLocation Loc = D->getLocation();

auto -> const Decl* 



Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:170-175
+diag(Inc.SymRefLocation, "missing include %0")
+<< Inc.MissingHeaderSpelling
+<< FixItHint::CreateInsertion(
+   SM->getComposedLoc(SM->getMainFileID(),
+  Replacement->getOffset()),
+   Replacement->getReplacementText());

Use IncludeInserter::createIncludeInsertion if possible...
So include style would be properly handled.



Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h:28-29
+
+/// Compute unused and missing includes and suggest fixes.
+/// Findings correspond to https://clangd.llvm.org/design/include-cleaner.
+///

this description does not match first sentence in check documentation.



Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h:42
+llvm::SmallVector SplitIgnoreHeaders;
+llvm::StringRef{*IgnoreHeaders}.split(SplitIgnoreHeaders, ",");
+for (const auto &Header : SplitIgnoreHeaders) {

many check uses ; as separator, and uses parseStringList function to do that 
from OptionsUtils.



Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h:44
+for (const auto &Header : SplitIgnoreHeaders) {
+  std::string HeaderSuffix{Header.str() + "$"};
+  if (!llvm::Regex{HeaderSuffix}.isValid())

if someone will put empty string like this `,,` you will end up with `$` as 
regex, wont it match "everything" ?



Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h:47
+configurationDiag("Invalid ignore headers regex '%0'") << Header;
+  IgnoreHeadersRegex.push_back(llvm::Regex{HeaderSuffix});
+}

llvm::Regex got constructor, use emplace_back



Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h:55
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
+
+private:

Missing "void storeOptions(ClangTidyOptions::OptionMap &Opts) override;"
to store IgnoreHeaders option. --export-config may not work correctly without 
this.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:189
+
+  Enforces include-what-you-use on headers using include-cleaner.
+

is this actually a "include-what-you-use" ?
Simply if I use iwyu tool, will it give same output and result in same 
behaviour ?
If this is different tool, then change this to avoid confusion.





Comment at: clang-tools-extra/docs/ReleaseNotes.rst:189
+
+  Enforces include-what-you-use on headers using include-cleaner.
+

PiotrZSL wrote:
> is this actually a "include-what-you-use" ?
> Simply if I use iwyu tool, will it give same output and result in same 
> behaviour ?
> If this is different tool, then change this to avoid confusion.
> 
> 
This description does not match first sentence in check documentation.



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst:6
+
+Checks for unused and missing includes. The check only generates findings for
+the main file of a translation unit.

avoid "The check"



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst:9
+Findings correspond to https://clangd.llvm.org/design/include-cleaner.
+
+Options

Try adding some very simple "example"



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst:17
+   files that match this regex as a suffix.  E.g., `foo/.*` disables
+   insertion/removal for all headers under the directory `foo`.

add some info about default value, is there any ?



Comment at: clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp:9
+#include 
+
+using namespace clang::tidy::misc;

this test file is fine, but there is no validation of output warning.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148793

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


[PATCH] D149162: [Clang][OpenMP][IRBuilder] Move registerTargetGlobalVariable & getAddrOfDeclareTargetVar into the OMPIRBuilder

2023-05-30 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

small ping for a further review on this if possible! Thank you very much ahead 
of time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149162

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


[PATCH] D148793: [clang-tidy] Implement an include-cleaner check.

2023-05-30 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp:9
+#include 
+
+using namespace clang::tidy::misc;

PiotrZSL wrote:
> this test file is fine, but there is no validation of output warning.
> 
nwm, somehow I missed one file.



Comment at: clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp:19
+#include "bar.h"
+#include 
+#include "bar.h"

make sure that those tests does not depend on actual system headers (check what 
headers are included here).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148793

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23136
+  TargetVarDecl->hasInit() && TargetVarDecl->hasGlobalStorage()) {
+if (auto *Ex = TargetVarDecl->getInit()) 
+ Visit(Ex);

Better to expand `auto` here



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23137
+if (auto *Ex = TargetVarDecl->getInit()) 
+ Visit(Ex);
+  }

Formatting?


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

https://reviews.llvm.org/D146418

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


[PATCH] D151529: [NFC][CLANG] Fix nullptr dereference issue in DeduceTemplateArgumentsByTypeMatch()

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

1 nit to do on commit.




Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:1707
+  const auto *IAP = S.Context.getAsIncompleteArrayType(P);
+  assert(IAP && "Template arguments not of incomplete array type!");
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151529

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


[PATCH] D151701: [HIP] Add missing __hip_atomic_fetch_sub support

2023-05-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

HIP did not add fetch/sub since fetch/sub x can be trivially implemented 
through fetch/add -x and performance-wise equivalent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151701

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


[PATCH] D151553: [clang] Fix consteval operators in template contexts

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Like @cor3ntin I'm concerned about removing the transform call.  I'm just as 
concerned that it caused no regressions...

If we have to transform the arguments, then this can be a dependent thing, 
which means the callee should be possible to be dependent, right? Thus needs to 
be transformed somewhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151553

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


[PATCH] D151515: [Sema] add cast from IncompleteArrayType to ConstantArrayType in TryReferenceListInitialization

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4433
+// where H is the initializer list.
+Sequence.AddQualificationConversionStep(cv1T1, VK_XValue);
+  }

Is `VK_XValue` correct here?  The standards quote says it is a PRValue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151515

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


[PATCH] D151709: [Clang][SVE2.1] Add builtins for svrevd

2023-05-30 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto created this revision.
Herald added subscribers: kristof.beyls, tschuett.
Herald added a project: All.
CarolineConcatto requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As described in: https://github.com/ARM-software/acle/pull/257

Patch by: Rosie Sumpter 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151709

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_revd.c

Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_revd.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_revd.c
@@ -0,0 +1,390 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve2p1 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve2p1 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve2p1 -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve2p1 -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+// CHECK-LABEL: @test_svrevd_s8_z(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv16i8( zeroinitializer,  [[PG:%.*]],  [[OP:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z16test_svrevd_s8_zu10__SVBool_tu10__SVInt8_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv16i8( zeroinitializer,  [[PG:%.*]],  [[OP:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svint8_t test_svrevd_s8_z(svbool_t pg, svint8_t op) {
+  return SVE_ACLE_FUNC(svrevd, _s8, _z, )(pg, op);
+}
+
+// CHECK-LABEL: @test_svrevd_s16_z(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PG:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv8i16( zeroinitializer,  [[TMP0]],  [[OP:%.*]])
+// CHECK-NEXT:ret  [[TMP1]]
+//
+// CPP-CHECK-LABEL: @_Z17test_svrevd_s16_zu10__SVBool_tu11__SVInt16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PG:%.*]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv8i16( zeroinitializer,  [[TMP0]],  [[OP:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP1]]
+//
+svint16_t test_svrevd_s16_z(svbool_t pg, svint16_t op) {
+  return SVE_ACLE_FUNC(svrevd, _s16, _z, )(pg, op);
+}
+
+// CHECK-LABEL: @test_svrevd_s32_z(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( [[PG:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv4i32( zeroinitializer,  [[TMP0]],  [[OP:%.*]])
+// CHECK-NEXT:ret  [[TMP1]]
+//
+// CPP-CHECK-LABEL: @_Z17test_svrevd_s32_zu10__SVBool_tu11__SVInt32_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( [[PG:%.*]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv4i32( zeroinitializer,  [[TMP0]],  [[OP:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP1]]
+//
+svint32_t test_svrevd_s32_z(svbool_t pg, svint32_t op) {
+  return SVE_ACLE_FUNC(svrevd, _s32, _z, )(pg, op);
+}
+
+// CHECK-LABEL: @test_svrevd_s64_z(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PG:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv2i64( zeroinitializer,  [[TMP0]],  [[OP:%.*]])
+// CHECK-NEXT:ret  [[TMP1]]
+//
+// CPP-CHECK-LABEL: @_Z17test_svrevd_s64_zu10__SVBool_tu11__SVInt64_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PG:%.*]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv2i64( zeroinitializer,  [[TMP0]],  [[OP:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP1]]
+//
+svint64_t test_svrevd_s64_z(svbool_t pg, svint64_t op) {
+  return SVE_ACLE_FUNC(svrevd, _s64, _z, )(pg, op);
+}
+
+// CHECK-LABEL: @test_svrevd_u8_z(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.revd.nxv16i8( zeroinitializer,  [[PG:%.*]],  [[OP:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//

[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-05-30 Thread Fahad Nayyar via Phabricator via cfe-commits
fahadnayyar updated this revision to Diff 526596.
fahadnayyar added a comment.

Rebasing to main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150988

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/arclite-link-external-toolchain.c
  clang/test/Driver/arclite-link.c


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck 
-check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE 
%s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a'.
+// CHECK-ARCLITE-OSX: This likely means you need to increase your minimum 
deployment target
 // CHECK-ARCLITE-OSX: -lfoo
 // CHECK-ARCLITE-OSX: libarclite_macosx.a
 // CHECK-ARCLITE-OSX: -framework
Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,8 @@
 // RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path '
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a'.
+// CHECK: This likely means you need to increase your minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'. This likely means you 
need to increase your minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE

[PATCH] D151625: [clang] Add `clang::equality_operator_compares_members_lexicographically`

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I'm a little dense today perhaps, but I don't get the use case for this?  Can 
you ELI-EWG?  Is this an attribute we expect our users to use?  The name is 
horrifyingly long for users to use, but perhaps that is a good thing.




Comment at: clang/include/clang/Basic/AttrDocs.td:542
 If a statement is marked ``nomerge`` and contains call expressions, those call
-expressions inside the statement will not be merged during optimization. This 
+expressions inside the statement will not be merged during optimization. This
 attribute can be used to prevent the optimizer from obscuring the source

Unrelated changes. I realize your editor probably does this, please don't have 
it do it on this file.



Comment at: clang/include/clang/Basic/AttrDocs.td:3531
+defaulted equality comparison operator should be preferred over this attribute.
+On enums, the attribute guarantees that there are either no custom compatison
+operators defined, or any that defined are quivalent to the builtin comparison




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151625

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


[PATCH] D151607: [AST] Remove unused function removeLocalCVRQualifiers

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Since this is part of the public API, do we need to publish/alert folks of 
this?  This could perhaps be in use by someone using libclang/etc, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151607

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


[PATCH] D151623: [clang] Extend __is_trivially_equality_comparable to check for hidden friends

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Is this a builtin that is supposed to model something in the standard?  It 
isn't clear to me how this one is supposed to work.




Comment at: clang/test/SemaCXX/type-traits.cpp:3439
+
 #endif // __cplusplus >= 202002L
 };

Is there a reason these tests need to be c++20 only?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151623

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


[PATCH] D151537: [NFC] Update cpu_specific test to use a newer CPU

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I don't really see the justification here?  Why do this change?  If the intent 
is to just test a newer architecture, we can add tests for that, not change 
existing ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151537

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


[PATCH] D151701: [HIP] Add missing __hip_atomic_fetch_sub support

2023-05-30 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm added a comment.

In D151701#4380666 , @yaxunl wrote:

> HIP did not add fetch/sub since fetch/sub x can be trivially implemented 
> through fetch/add -x and performance-wise equivalent.

There is existing isel for `global_atomic_sub` for RDNA targets which means we 
can avoid a subtraction. I also have a patch for the hip runtime ready to go 
that uses the this new builtin. It should shave off an extra instruction.

  __global__ void test_natural_sub(int *data, int rhs) {
__hip_atomic_fetch_sub(data, rhs, __ATOMIC_RELAXED, 
__HIP_MEMORY_SCOPE_WAVEFRONT);
  }
  
  __global__ void test_kernel_neg_add_sub(int *data, int rhs) {
__hip_atomic_fetch_add(data, -rhs, __ATOMIC_RELAXED, 
__HIP_MEMORY_SCOPE_WAVEFRONT);
  }

->

   <_Z16test_natural_subPii>:   

  
  s_clause 0x1   // 
: BFA10001
  s_load_dword s2, s[4:5], 0x8   // 
0004: F482 FA08
  s_load_dwordx2 s[0:1], s[4:5], null// 
000C: F4040002 FA00
  v_mov_b32_e32 v0, 0// 
0014: 7E000280
  s_waitcnt lgkmcnt(0)   // 
0018: BF8CC07F
  v_mov_b32_e32 v1, s2   // 
001C: 7E020202
  global_atomic_sub v0, v1, s[0:1]   // 
0020: DCCC8000 0100
  s_endpgm   // 
0028: BF81 
  
  
  0100 <_Z23test_kernel_neg_add_subPii>:
  s_clause 0x1   // 
0100: BFA10001
  s_load_dword s2, s[4:5], 0x8   // 
0104: F482 FA08
  s_load_dwordx2 s[0:1], s[4:5], null// 
010C: F4040002 FA00
  v_mov_b32_e32 v0, 0// 
0114: 7E000280
  s_waitcnt lgkmcnt(0)   // 
0118: BF8CC07F
  s_sub_i32 s2, 0, s2// 
011C: 81820280
  v_mov_b32_e32 v1, s2   // 
0120: 7E020202
  global_atomic_add v0, v1, s[0:1]   // 
0124: DCC88000 0100
  s_endpgm   // 
012C: BF81

The backend has isel for this instruction, but the frontend will never generate 
it. I think this improves things


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151701

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


[PATCH] D148702: [clang] Add Parse and Sema support for RegularKeyword attributes

2023-05-30 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 526600.
rsandifo-arm added a comment.

Avoid most uses of `<< 0`.  Add comments to those that remain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148702

Files:
  clang/examples/Attribute/Attribute.cpp
  clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/ParsedAttr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Parser/c2x-attribute-keywords.c
  clang/test/Parser/c2x-attribute-keywords.m
  clang/test/Parser/cxx0x-keyword-attributes.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3879,7 +3879,8 @@
   OS << "bool diagAppertainsToDecl(Sema &S, const ParsedAttr &AL, ";
   OS << "const Decl *D) const override {\n";
   OS << "  S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_decl)\n";
-  OS << "<< AL << D->getLocation();\n";
+  OS << "<< AL << AL.isRegularKeywordAttribute() << "
+"D->getLocation();\n";
   OS << "  return false;\n";
   OS << "}\n\n";
 }
@@ -3908,7 +3909,7 @@
 OS << (Warn ? "warn_attribute_wrong_decl_type_str"
 : "err_attribute_wrong_decl_type_str");
 OS << ")\n";
-OS << "  << Attr << ";
+OS << "  << Attr << Attr.isRegularKeywordAttribute() << ";
 OS << CalculateDiagnostic(*SubjectObj) << ";\n";
 OS << "return false;\n";
 OS << "  }\n";
@@ -3923,7 +3924,8 @@
   OS << "bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, ";
   OS << "const Stmt *St) const override {\n";
   OS << "  S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt)\n";
-  OS << "<< AL << St->getBeginLoc();\n";
+  OS << "<< AL << AL.isRegularKeywordAttribute() << "
+"St->getBeginLoc();\n";
   OS << "  return false;\n";
   OS << "}\n\n";
 }
@@ -3942,7 +3944,7 @@
 OS << (Warn ? "warn_attribute_wrong_decl_type_str"
 : "err_attribute_wrong_decl_type_str");
 OS << ")\n";
-OS << "  << Attr << ";
+OS << "  << Attr << Attr.isRegularKeywordAttribute() << ";
 OS << CalculateDiagnostic(*SubjectObj) << ";\n";
 OS << "return false;\n";
 OS << "  }\n";
@@ -4013,7 +4015,8 @@
 for (const std::string &A : DeclAttrs) {
   OS << "if (const auto *A = D->getAttr<" << A << ">()) {\n";
   OS << "  S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)"
- << " << AL << A;\n";
+ << " << AL << A << (AL.isRegularKeywordAttribute() ||"
+ << " A->isRegularKeywordAttribute());\n";
   OS << "  S.Diag(A->getLocation(), diag::note_conflicting_attribute);";
   OS << "  \nreturn false;\n";
   OS << "}\n";
@@ -4034,7 +4037,8 @@
 << ">()) {\n";
 MergeDeclOS << "  S.Diag(First->getLocation(), "
 << "diag::err_attributes_are_not_compatible) << First << "
-<< "Second;\n";
+<< "Second << (First->isRegularKeywordAttribute() || "
+<< "Second->isRegularKeywordAttribute());\n";
 MergeDeclOS << "  S.Diag(Second->getLocation(), "
 << "diag::note_conflicting_attribute);\n";
 MergeDeclOS << "  return false;\n";
@@ -4074,7 +4078,8 @@
 MergeStmtOS << "  if (Iter != C.end()) {\n";
 MergeStmtOS << "S.Diag((*Iter)->getLocation(), "
 << "diag::err_attributes_are_not_compatible) << *Iter << "
-<< "Second;\n";
+<< "Second << ((*Iter)->isRegularKeywordAttribute() || "
+<< "Second->isRegularKeywordAttribute());\n";
 MergeStmtOS << "S.Diag(Second->getLocation(), "
 << "diag::note_conflicting_attribute);\n";
 MergeStmtOS << "return false;\n";
Index: clang/test/Parser/cxx0x-keyword-attributes.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx0x-keyword-attributes.cpp
@@ -0,0 +1,345 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fdeclspec -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-c

[PATCH] D148702: [clang] Add Parse and Sema support for RegularKeyword attributes

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

1 nit, feel free to do this as a part of the commit.




Comment at: clang/lib/Sema/ParsedAttr.cpp:208
+// The appurtenance rules are applied strictly for all regular keyword
+// atributes.
+return false;

Humorously, I spent an absurd amount of time trying to figure out whether 
appurtenance was a word/the correct spelling, determined you had it right and 
closed the phab review box, just to see `atributes` :D  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148702

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


[PATCH] D150549: Move SubtargetFeature.h from MC to TargetParser

2023-05-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D150549#4352174 , @jobnoorman 
wrote:

> In D150549#4351614 , @MaskRay wrote:
>
>> In D150549#4349531 , @jobnoorman 
>> wrote:
>>
>>> In D150549#4347056 , @MaskRay 
>>> wrote:
>>>
 This seems fine, but please consider making `MC/SubtargetFeature.h` a 
 forwarding header temporarily.
>>>
>>> To be clear: do you want me to check-in this forwarding header or should I 
>>> just do it locally for the tests below? If the former, what exactly is the 
>>> purpose of adding this header?
>>
>> The motivation is similar to https://reviews.llvm.org/D137838#3921828
>>
>>> That way, you don't have to update oodles of include lines in this patch, 
>>> and it makes it a bit easier to see what's going on. (You can then update 
>>> all the include lines in a trivial follow-up if this change goes through, 
>>> and then remove the forwarding headers in Support, to cut the dependency 
>>> you want to remove.)
>>
>> (There is a non-zero probability that the patch may miss something and get 
>> reverted. By creating a forwarding header we don't risk causing too much 
>> churn to the many files.)
>> For a large-scaling refactoring
>
> Thanks for the link! If I understand the discussion there correctly, the 
> motivation for adding the forwarding header was to not have to update any 
> `#include` sites directly in order to reduce the size of the patch. So what 
> you are asking me to do is
>
> 1. Update this patch to have a forwarding header and //not// change 
> `#include` sites;
> 2. Create a second patch that updates `#include`s and removes the forward. 
> This patch would be committed at some point in the future once we're sure the 
> move is fine.
>
> Is this correct?
>
> I do wonder if this is necessary in this case as the patch is much smaller 
> than the one in the link you shared.

If we are certain this will not be reverted and cause churn, making the header 
switch in one single patch looks fine to me...

I have checked that this patch has migrated things that might be neglected: 
`unittest` directories, openmp,mlir,clang, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150549

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


[PATCH] D148702: [clang] Add Parse and Sema support for RegularKeyword attributes

2023-05-30 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm marked an inline comment as done.
rsandifo-arm added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2902
 S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type)
-<< AL << ExpectedTypeOrNamespace;
+<< AL << 0 << ExpectedTypeOrNamespace;
 return;

erichkeane wrote:
> Every where you are doing just a '0' in a diagnostic here it makes it 
> incredibly unreadable.  I'd prefer 1 of 2 solutions:
> 
> 1- Create an enum somewhere that encodes the meaning here, and use those 
> instead.
> 2- use a `/*Whatever*/` comment every place you're passing a raw literal.
Yeah, that's fair.  Sorry about that.  I got some of my own medicine reading 
the patch back after a while away from it.

Most of those `<< 0` come from looking at individual uses to see whether a 
regular keyword spelling is ever possible.  If it wasn't possible, `<< 0` was 
supposed to be a justification for not covering that line of code in the new 
test cases.

But I now think that was a mistake.  Using `isRegularKeywordAttribute()` is 
useful for readability even if we “know” what its value ahead of time.  And 
using it is more future-proof as well.

So this update converts most uses of `<< 0` to `<< 
Something.isRegulardKeywordAttribute` in cases where the appropriate 
`Something` is readily available.  There are a handful of cases where an 
immediate is still needed, so I went for option (2) and added a comment to 
those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148702

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


[PATCH] D140690: [compiler-rt][dfsan] Enable loongarch64 and add test support

2023-05-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

This should be rebased after D140744  removed 
`// REQUIRES: x86_64-target-arch`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140690

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


[PATCH] D151701: [HIP] Add missing __hip_atomic_fetch_sub support

2023-05-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151701

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


[PATCH] D151590: [Driver] Add ClangFlags::TargetSpecific to simplify err_drv_unsupported_opt_for_target processing

2023-05-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D151590#4379087 , @qiongsiwu1 
wrote:

> Thanks for the patch!
>
> Recently we added the options `mxcoff-roptr` and `mno-xcoff-roptr` 
> https://reviews.llvm.org/D144190 that fall into this the scope of this patch 
> (e.g. 
> https://github.com/llvm/llvm-project/blob/0508ac32cfcc1a9fc5a81d16de8d418dc5a0666b/clang/lib/Driver/ToolChains/Clang.cpp#LL5278C19-L5278C19),
>  since they are only supported on AIX. Could you add the handling of options 
> `mxcoff-roptr` and `mno-xcoff-roptr`?

Hi @qiongsiwu1, thanks for chiming in. I am aware of `-mxcoff-roptr`. This 
patch picks some example patterns, but does not attempt to be comprehensive (on 
the GNU side, these are many many `-m` options that are not covered. E.g. 
LoongArch has a `-mabi` hack, so I cannot make `-mabi` `TargetSpecific` yet)
I can fold the `-mxcoff-roptr` change into this patch since it's 
straightforward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151590

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-05-30 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn updated this revision to Diff 526606.
hnrklssn added a comment.

Revert checker behaviour for global variables to check hard-coded identifiers
Remove 'seen' mode
Replace 'transitive' mode with 'smart', where attributes are no longer checked 
as metadata
Introduce version bump to v3, and make 'smart' mode the default in v3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

Files:
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
  clang/test/utils/update_cc_test_checks/annotations.test
  clang/test/utils/update_cc_test_checks/check-globals.test
  clang/test/utils/update_cc_test_checks/generated-funcs.test
  clang/test/utils/update_cc_test_checks/global-hex-value-regex.test
  clang/test/utils/update_cc_test_checks/global-value-regex.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/generated_funcs.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/generated_funcs_prefix_reuse.test
  llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -59,7 +59,7 @@
   help='Remove attribute annotations (#0) from the end of check line')
   parser.add_argument('--check-attributes', action='store_true',
   help='Check "Function Attributes" for functions')
-  parser.add_argument('--check-globals', action='store_true',
+  parser.add_argument('--check-globals', default='default', choices=['none', 'smart', 'all'],
   help='Check global entries (global variables, metadata, attribute sets, ...) for functions')
   parser.add_argument('tests', nargs='+')
   initial_args = common.parse_commandline_args(parser)
@@ -158,12 +158,12 @@
   common.dump_input_lines(output_lines, ti, prefix_set, ';')
 
   args = ti.args
-  if args.check_globals:
+  if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(builder.global_var_dict(), ';',
  prefix_list, output_lines,
  global_vars_seen_dict, args.preserve_names,
- True))
+ True, args.check_globals))
 
   # Now generate all the checks.
   generated_prefixes.extend(
@@ -211,12 +211,11 @@
 
 m = common.IR_FUNCTION_RE.match(input_line)
 if m and not has_checked_pre_function_globals:
-  if args.check_globals:
-generated_prefixes.extend(
-common.add_global_checks(builder.global_var_dict(), ';',
- prefix_list, output_lines,
- global_vars_seen_dict,
- args.preserve_names, True))
+  generated_prefixes.extend(
+  common.add_global_checks(builder.global_var_dict(), ';',
+   prefix_list, output_lines,
+   global_vars_seen_dict,
+   args.preserve_names, True, args.check_globals))
   has_checked_pre_function_globals = True
 
 if common.should_add_line_to_output(input_line, prefix_set, not is_in_function):
@@ -240,11 +239,11 @@
   continue
 is_in_function = is_in_function_start = True
 
-if args.check_globals:
+if args.check_globals != 'none':
   generated_prefixes.extend(

[PATCH] D150185: [include-cleaner] Allow multiple strategies for spelling includes.

2023-05-30 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 526610.
VitaNuo marked 8 inline comments as done.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150185

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp

Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -12,6 +12,7 @@
 #include "clang-include-cleaner/Types.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/FileEntry.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -20,14 +21,42 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Registry.h"
+#include 
+#include 
 #include 
 
+LLVM_INSTANTIATE_REGISTRY(clang::include_cleaner::IncludeSpellingStrategy)
+
 namespace clang::include_cleaner {
 
+std::function defaultHeaderMapper() {
+  return [](llvm::StringRef HeaderPhysicalPath) {
+static auto Spellers = [] {
+  auto Result =
+  llvm::SmallVector>{};
+  for (const auto &Strategy :
+   include_cleaner::IncludeSpellingStrategy::entries())
+Result.push_back(Strategy.instantiate());
+  return Result;
+}();
+
+std::string Result;
+for (const auto &Speller : Spellers) {
+  Result = (*Speller)(HeaderPhysicalPath);
+  if (!Result.empty())
+break;
+}
+return Result;
+  };
+}
+
 void walkUsed(llvm::ArrayRef ASTRoots,
   llvm::ArrayRef MacroRefs,
   const PragmaIncludes *PI, const SourceManager &SM,
@@ -53,19 +82,25 @@
   }
 }
 
-std::string spellHeader(const Header &H, HeaderSearch &HS,
-const FileEntry *Main) {
+std::string spellHeader(
+const Header &H, HeaderSearch &HS, const FileEntry *Main,
+llvm::function_ref MapHeader) {
   switch (H.kind()) {
-  case Header::Physical: {
-bool IsSystem = false;
-std::string Path = HS.suggestPathToFileForDiagnostics(
-H.physical(), Main->tryGetRealPathName(), &IsSystem);
-return IsSystem ? "<" + Path + ">" : "\"" + Path + "\"";
-  }
   case Header::Standard:
 return H.standard().name().str();
   case Header::Verbatim:
 return H.verbatim().str();
+  case Header::Physical:
+// Spelling physical headers allows for various plug-in strategies.
+std::string FinalSpelling = MapHeader(H.physical()->tryGetRealPathName());
+if (!FinalSpelling.empty())
+  return FinalSpelling;
+
+// Fallback to default spelling via header search.
+bool IsSystem = false;
+FinalSpelling = HS.suggestPathToFileForDiagnostics(
+H.physical(), Main->tryGetRealPathName(), &IsSystem);
+return IsSystem ? "<" + FinalSpelling + ">" : "\"" + FinalSpelling + "\"";
   }
   llvm_unreachable("Unknown Header kind");
 }
@@ -89,8 +124,9 @@
}
  }
  if (!Satisfied && !Providers.empty() &&
- Ref.RT == RefType::Explicit)
+ Ref.RT == RefType::Explicit) {
Missing.insert(spellHeader(Providers.front(), HS, MainFile));
+ }
});
 
   AnalysisResults Results;
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
@@ -14,11 +14,14 @@
 #include "clang-include-cleaner/Record.h"
 #include "clang-include-cleaner/Types.h"
 #include "clang/Format/Format.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/MemoryBufferRef.h"
-#include 
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Registry.h"
+#include 
+#include 
 
 namespace clang {
 class SourceLocation;
@@ -75,9 +78,6 @@
 std::string fixIncludes(const AnalysisResults &Results, llvm::StringRef Code,
 const format::FormatStyle &IncludeStyle);
 
-std::string spellHeader(const Header &H, HeaderSearch &HS,
-const FileEntry *Main);
-
 /// Gets all the providers for a symbol by traversing each location.
 /// Ret

[PATCH] D150185: [include-cleaner] Allow multiple strategies for spelling includes.

2023-05-30 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thanks for the comments!




Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h:104
+  ApplyFirstIncludeSpeller() {
+for (const auto &Strategy :
+ include_cleaner::IncludeSpellingStrategy::entries()) {

kadircet wrote:
> instead of a constructor you can have:
> ```
> static auto *Strategies = []{
>   auto *Result = new 
> llvm::SmallVector>;
>   for(auto &Strategy: include_cleaner::IncludeSpellingStrategy::entries()) {
>Result->push_back(Strategy.instantiate());
>   }
> }();
> ```
> 
> in the functor implementation.
Ok, in that case I'll get rid of the class altogether.



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:110
+ Ref.RT == RefType::Explicit) {
+   ApplyFirstIncludeSpeller Speller;
+   Missing.insert(

kadircet wrote:
> we should instantiate this outside the callback instead (to make sure we do 
> it once). it would become obsolete if you're to use a static variable to 
> store the strategies though.
Using a static variable now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150185

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


[PATCH] D151590: [Driver] Add ClangFlags::TargetSpecific to simplify err_drv_unsupported_opt_for_target processing

2023-05-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 526614.
MaskRay added a comment.

Handle -mxcoff-roptr as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151590

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  clang/lib/Driver/ToolChains/Arch/Sparc.cpp
  clang/lib/Driver/ToolChains/Clang.cpp

Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5275,19 +5275,6 @@
   << A->getSpelling() << RawTriple.str();
   }
 
-  if (Args.hasArg(options::OPT_mxcoff_roptr) ||
-  Args.hasArg(options::OPT_mno_xcoff_roptr)) {
-bool HasRoptr = Args.hasFlag(options::OPT_mxcoff_roptr,
- options::OPT_mno_xcoff_roptr, false);
-StringRef OptStr = HasRoptr ? "-mxcoff-roptr" : "-mno-xcoff-roptr";
-if (!Triple.isOSAIX())
-  D.Diag(diag::err_drv_unsupported_opt_for_target)
-  << OptStr << RawTriple.str();
-
-if (HasRoptr)
-  CmdArgs.push_back("-mxcoff-roptr");
-  }
-
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
 StringRef V = A->getValue(), V1 = V;
 unsigned Size;
@@ -6147,23 +6134,6 @@
 }
   }
 
-  if (const Arg *A = Args.getLastArg(options::OPT_mignore_xcoff_visibility)) {
-if (Triple.isOSAIX())
-  CmdArgs.push_back("-mignore-xcoff-visibility");
-else
-  D.Diag(diag::err_drv_unsupported_opt_for_target)
-  << A->getAsString(Args) << TripleStr;
-  }
-
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_mdefault_visibility_export_mapping_EQ)) {
-if (Triple.isOSAIX())
-  A->render(Args, CmdArgs);
-else
-  D.Diag(diag::err_drv_unsupported_opt_for_target)
-  << A->getAsString(Args) << TripleStr;
-  }
-
   if (Args.hasFlag(options::OPT_fvisibility_inlines_hidden,
 options::OPT_fno_visibility_inlines_hidden, false))
 CmdArgs.push_back("-fvisibility-inlines-hidden");
@@ -6976,10 +6946,6 @@
   Args.addOptInFlag(CmdArgs, options::OPT_fapple_pragma_pack,
 options::OPT_fno_apple_pragma_pack);
 
-  if (Args.hasFlag(options::OPT_fxl_pragma_pack,
-   options::OPT_fno_xl_pragma_pack, RawTriple.isOSAIX()))
-CmdArgs.push_back("-fxl-pragma-pack");
-
   // Remarks can be enabled with any of the `-f.*optimization-record.*` flags.
   if (willEmitRemarks(Args) && checkRemarksOptions(D, Args, Triple))
 renderRemarksOptions(Args, CmdArgs, Triple, Input, Output, JA);
Index: clang/lib/Driver/ToolChains/Arch/Sparc.cpp
===
--- clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -118,12 +118,6 @@
 
 std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
  const llvm::Triple &Triple) {
-  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
-D.Diag(diag::err_drv_unsupported_opt_for_target)
-<< A->getSpelling() << Triple.getTriple();
-return "";
-  }
-
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
 StringRef CPUName = A->getValue();
 if (CPUName == "native") {
Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -87,10 +87,6 @@
 /// Get the (LLVM) name of the PowerPC cpu we are targeting.
 std::string ppc::getPPCTargetCPU(const Driver &D, const ArgList &Args,
  const llvm::Triple &T) {
-  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
-D.Diag(diag::err_drv_unsupported_opt_for_target)
-<< A->getSpelling() << T.getTriple();
-  }
   if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ))
 return normalizeCPUName(A->getValue(), T);
   return getPPCGenericTargetCPU(T);
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -80,6 +80,10 @@
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
 
+  void addClangTargetOptions(
+  const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1Args,
+  Action::OffloadKind DeviceOffloadingKind) const override;
+
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const override;
 
Index: clang/lib/Driver/ToolChains/AIX.cpp
=

[PATCH] D150185: [include-cleaner] Allow multiple strategies for spelling includes.

2023-05-30 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 526615.
VitaNuo added a comment.

Remove extra braces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150185

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp

Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -12,6 +12,7 @@
 #include "clang-include-cleaner/Types.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/FileEntry.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -20,14 +21,42 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Registry.h"
+#include 
+#include 
 #include 
 
+LLVM_INSTANTIATE_REGISTRY(clang::include_cleaner::IncludeSpellingStrategy)
+
 namespace clang::include_cleaner {
 
+std::function defaultHeaderMapper() {
+  return [](llvm::StringRef HeaderPhysicalPath) {
+static auto Spellers = [] {
+  auto Result =
+  llvm::SmallVector>{};
+  for (const auto &Strategy :
+   include_cleaner::IncludeSpellingStrategy::entries())
+Result.push_back(Strategy.instantiate());
+  return Result;
+}();
+
+std::string Result;
+for (const auto &Speller : Spellers) {
+  Result = (*Speller)(HeaderPhysicalPath);
+  if (!Result.empty())
+break;
+}
+return Result;
+  };
+}
+
 void walkUsed(llvm::ArrayRef ASTRoots,
   llvm::ArrayRef MacroRefs,
   const PragmaIncludes *PI, const SourceManager &SM,
@@ -53,19 +82,25 @@
   }
 }
 
-std::string spellHeader(const Header &H, HeaderSearch &HS,
-const FileEntry *Main) {
+std::string spellHeader(
+const Header &H, HeaderSearch &HS, const FileEntry *Main,
+llvm::function_ref MapHeader) {
   switch (H.kind()) {
-  case Header::Physical: {
-bool IsSystem = false;
-std::string Path = HS.suggestPathToFileForDiagnostics(
-H.physical(), Main->tryGetRealPathName(), &IsSystem);
-return IsSystem ? "<" + Path + ">" : "\"" + Path + "\"";
-  }
   case Header::Standard:
 return H.standard().name().str();
   case Header::Verbatim:
 return H.verbatim().str();
+  case Header::Physical:
+// Spelling physical headers allows for various plug-in strategies.
+std::string FinalSpelling = MapHeader(H.physical()->tryGetRealPathName());
+if (!FinalSpelling.empty())
+  return FinalSpelling;
+
+// Fallback to default spelling via header search.
+bool IsSystem = false;
+FinalSpelling = HS.suggestPathToFileForDiagnostics(
+H.physical(), Main->tryGetRealPathName(), &IsSystem);
+return IsSystem ? "<" + FinalSpelling + ">" : "\"" + FinalSpelling + "\"";
   }
   llvm_unreachable("Unknown Header kind");
 }
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
@@ -14,11 +14,14 @@
 #include "clang-include-cleaner/Record.h"
 #include "clang-include-cleaner/Types.h"
 #include "clang/Format/Format.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/MemoryBufferRef.h"
-#include 
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Registry.h"
+#include 
+#include 
 
 namespace clang {
 class SourceLocation;
@@ -75,9 +78,6 @@
 std::string fixIncludes(const AnalysisResults &Results, llvm::StringRef Code,
 const format::FormatStyle &IncludeStyle);
 
-std::string spellHeader(const Header &H, HeaderSearch &HS,
-const FileEntry *Main);
-
 /// Gets all the providers for a symbol by traversing each location.
 /// Returned headers are sorted by relevance, first element is the most
 /// likely provider for the symbol.
@@ -85,6 +85,31 @@
const SourceManager &SM,
const PragmaIncludes *PI);
 
+class IncludeSpeller {
+public:
+  virtual ~IncludeSpeller() = default;
+
+  /// An extension point to let applications intro

[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

What is the justification for this?  Do other compilers do this?  Was there an 
RFC?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-05-30 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn marked an inline comment as done.
hnrklssn added inline comments.



Comment at: 
clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected:12
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//

nikic wrote:
> hnrklssn wrote:
> > nikic wrote:
> > > hnrklssn wrote:
> > > > nikic wrote:
> > > > > nikic wrote:
> > > > > > hnrklssn wrote:
> > > > > > > hnrklssn wrote:
> > > > > > > > nikic wrote:
> > > > > > > > > hnrklssn wrote:
> > > > > > > > > > delcypher wrote:
> > > > > > > > > > > @hnrklssn I just noticed we don't have a `CHECK` for what 
> > > > > > > > > > > `META2` actually refers to. Should we?
> > > > > > > > > > > 
> > > > > > > > > > > Not something that has to be fixed in this patch, more 
> > > > > > > > > > > just an observation.
> > > > > > > > > > Indeed this is true for metadata in general, presumably 
> > > > > > > > > > because the RHS often refer to things like other metadata 
> > > > > > > > > > identifiers. In the case of annotations they seem to always 
> > > > > > > > > > refer to simple strings however, so it would be feasible to 
> > > > > > > > > > do a straight match without having to do recursive matching 
> > > > > > > > > > or complex regexes to determine which part of the metadata 
> > > > > > > > > > to match against.
> > > > > > > > > > 
> > > > > > > > > > In many cases with metadata attached to IR nodes, multiple 
> > > > > > > > > > nodes refer to the same metadata node, so at least you 
> > > > > > > > > > verify that they still are consistent. But I agree that 
> > > > > > > > > > verifying the content would be a great future addition.
> > > > > > > > > You need to pass `--check-globals` to check the actual 
> > > > > > > > > metadata.
> > > > > > > > When I add that to this test case it adds
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > //.
> > > > > > > > // CHECK: attributes #0 = { noinline nounwind optnone 
> > > > > > > > "min-legal-vector-width"="0" "no-trapping-math"="true" 
> > > > > > > > "stack-protector-buffer-size"="8" 
> > > > > > > > "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
> > > > > > > > //.
> > > > > > > > // CHECK: !0 = !{i32 1, !"wchar_size", i32 4}
> > > > > > > > // CHECK: !1 = !{!"clang version 17.0.0 
> > > > > > > > (g...@github.com:llvm/llvm-project.git 
> > > > > > > > 684914f47cf59e9ab6d8b0f73c58ca6272ea28d4)"}
> > > > > > > > // CHECK: !2 = !{!"auto-init"}
> > > > > > > > //.
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > So it seems to just be doing a simple literal matching on all 
> > > > > > > > metadata, regardless of whether we captured that metadata in 
> > > > > > > > any filecheck variable. And it still doesn't use the META2 
> > > > > > > > variable to match the definition. Am I missing something? If we 
> > > > > > > > use the literal metadata names instead of variable matching for 
> > > > > > > > the definitions, there isn't much point in doing variable 
> > > > > > > > matching for the metadata uses either, since the test still 
> > > > > > > > very much relies on the metadata numbering being stable.
> > > > > > > @nikic Do you have more information to add about how metadata 
> > > > > > > definition matchers can be generated without hardcoding 
> > > > > > > everything (which is kind of the opposite of what this patch is 
> > > > > > > trying to do), or in general if you're happy with the state of 
> > > > > > > the PR?
> > > > > > This works fine with update_test_checks, so it must be some bug in 
> > > > > > update_cc_test_checks in particular. From a quick look, I suspect 
> > > > > > it's because 
> > > > > > https://github.com/llvm/llvm-project/blob/3d05ab6d3e24e76ff53b8d7d623c436b4be5b809/llvm/utils/update_cc_test_checks.py#L447
> > > > > >  hardcodes a True value, while update_test_checks makes this 
> > > > > > dependent on `--preserve-names`, which is disabled by default there.
> > > > > Or maybe just test this with update_test_checks? This change is 
> > > > > valuable for that script as well, and it doesn't have this extra 
> > > > > issue.
> > > > I couldn't find any uses of 
> > > > `--preserve-names` in the entire repo (not even in tests for 
> > > > update_test_checks), so I went ahead and changed update_cc_test_checks 
> > > > to pass True instead.
> > > > 
> > > > While at it I added 2 new options to match some, but not necessarily 
> > > > all, globals. I set the least verbose one (other than "none") as the 
> > > > default, emitting checks for the definitions of all globals that we 
> > > > emit matches for in the IR. Do you agree that this is reasonable?
> > > That sounds like a nice approach. My main question would be whether 
> > > `--check-globals seen` is the right default: My gut feeling here is that 
> > > this will introduce additional checks for attributes/metadata in tests 
> > > that don't actually care about it, but I'm not particularly sure about 
> > > that.
> > > 
> > > Y

[PATCH] D151623: [clang] Extend __is_trivially_equality_comparable to check for hidden friends

2023-05-30 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

In D151623#4380760 , @erichkeane 
wrote:

> Is this a builtin that is supposed to model something in the standard?  It 
> isn't clear to me how this one is supposed to work.

No, this is for optimization purposes. It is true when it is know that 
comparing two instances of T is equivalent to a `memcmp`. Or in other words 
every bit in the type is part of its value representation. Does that help?




Comment at: clang/test/SemaCXX/type-traits.cpp:3439
+
 #endif // __cplusplus >= 202002L
 };

erichkeane wrote:
> Is there a reason these tests need to be c++20 only?
Defaulted equality comparison is a C++20 feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151623

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


[PATCH] D151525: [NFC][CLANG] Fix nullptr dereference issue in Type::getSveEltType()

2023-05-30 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151525

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


[PATCH] D151623: [clang] Extend __is_trivially_equality_comparable to check for hidden friends

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

In D151623#4380885 , @philnik wrote:

> In D151623#4380760 , @erichkeane 
> wrote:
>
>> Is this a builtin that is supposed to model something in the standard?  It 
>> isn't clear to me how this one is supposed to work.
>
> No, this is for optimization purposes. It is true when it is know that 
> comparing two instances of T is equivalent to a `memcmp`. Or in other words 
> every bit in the type is part of its value representation. Does that help?

I found the patch a few months ago where you added this, so I'm more 
knowledgeable now.




Comment at: clang/test/SemaCXX/type-traits.cpp:3439
+
 #endif // __cplusplus >= 202002L
 };

philnik wrote:
> erichkeane wrote:
> > Is there a reason these tests need to be c++20 only?
> Defaulted equality comparison is a C++20 feature.
Ah, right, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151623

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


[PATCH] D134680: [Clang][AArch64][SME] Add intrinsics for adding vector elements to ZA tile

2023-05-30 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 526621.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134680

Files:
  clang/include/clang/Basic/arm_sme.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i32.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c

Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c
@@ -0,0 +1,116 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+#ifdef DISABLE_SME_ATTRIBUTES
+#define ARM_STREAMING_ATTR
+#else
+#define ARM_STREAMING_ATTR __attribute__((arm_streaming))
+#endif
+
+#ifdef SME_OVERLOADED_FORMS
+#define SME_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SME_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+// CHECK-C-LABEL: @test_svaddha_za64_u64(
+// CHECK-CXX-LABEL: @_Z21test_svaddha_za64_u64u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 0,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+ARM_STREAMING_ATTR void test_svaddha_za64_u64(svbool_t pn, svbool_t pm, svuint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _u64, _m)(0, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_u64_1(
+// CHECK-CXX-LABEL: @_Z23test_svaddha_za64_u64_1u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 7,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+ARM_STREAMING_ATTR void test_svaddha_za64_u64_1(svbool_t pn, svbool_t pm, svuint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _u64, _m)(7, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_s64(
+// CHECK-CXX-LABEL: @_Z21test_svaddha_za64_s64u10__SVBool_tu10__SVBool_tu11__SVInt64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 0,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+ARM_STREAMING_ATTR void test_svaddha_za64_s64(svbool_t pn, svbool_t pm, svint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _s64, _m)(0, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_s64_1(
+// CHECK-CXX-LABEL: @_Z23test_svaddha_za64_s64_1u10__SVBool_tu10__SVBool_tu11__SVInt64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 7,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+ARM_STREAMING_ATTR void test_svaddha_za64_s64_1(svbool_t pn, svbool_t pm, svint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _s64, _m)(7, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddva_za64_u64(
+// CHECK-CXX-LABEL: @_Z21test_svaddva_za64_u64u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:  

[PATCH] D151225: [clang][analyzer] Merge apiModeling.StdCLibraryFunctions and StdCLibraryFunctionArgs checkers into one.

2023-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 526623.
balazske added a comment.

Updated documentation and removed occurrences of old checker name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151225

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/PR49642.c
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/conversion.c
  clang/test/Analysis/errno-stdlibraryfunctions-notes.c
  clang/test/Analysis/errno-stdlibraryfunctions.c
  clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
  clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
  clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c
  clang/test/Analysis/std-c-library-functions-arg-weakdeps.c
  clang/test/Analysis/std-c-library-functions-eof.c
  clang/test/Analysis/std-c-library-functions-inlined.c
  clang/test/Analysis/std-c-library-functions-lookup.c
  clang/test/Analysis/std-c-library-functions-lookup.cpp
  clang/test/Analysis/std-c-library-functions-path-notes.c
  clang/test/Analysis/std-c-library-functions-restrict.c
  clang/test/Analysis/std-c-library-functions-restrict.cpp
  clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
  clang/test/Analysis/std-c-library-functions.c
  clang/test/Analysis/std-c-library-functions.cpp
  clang/test/Analysis/std-c-library-posix-crash.c
  clang/test/Analysis/stream-errno-note.c
  clang/test/Analysis/stream-errno.c
  clang/test/Analysis/stream-noopen.c
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream-stdlibraryfunctionargs.c
  clang/test/Analysis/weak-dependencies.c

Index: clang/test/Analysis/weak-dependencies.c
===
--- clang/test/Analysis/weak-dependencies.c
+++ clang/test/Analysis/weak-dependencies.c
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 %s -verify \
-// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=core
 
 typedef __typeof(sizeof(int)) size_t;
Index: clang/test/Analysis/stream-stdlibraryfunctionargs.c
===
--- clang/test/Analysis/stream-stdlibraryfunctionargs.c
+++ clang/test/Analysis/stream-stdlibraryfunctionargs.c
@@ -1,11 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,alpha.unix.StdCLibraryFunctionArgs,debug.ExprInspection \
-// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true -verify=stdargs,any %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,alpha.unix.StdCLibraryFunctions,debug.ExprInspection \
+// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=stdargs,any %s
 
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,debug.ExprInspection \
-// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true -verify=any %s
+// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=any %s
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.StdCLibraryFunctionArgs,debug.ExprInspection \
-// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true -verify=stdargs,any %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.StdCLibraryFunctions,debug.ExprInspection \
+// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=stdargs,any %s
 
 #include "Inputs/system-header-simulator.h"
 
Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream -analyzer-output text \
 // RUN:   -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,alpha.unix.StdCLibraryFunctionArgs -analyzer-output text \
-// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true -verify=expected,stdargs %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,alpha.unix.StdCLibraryFunctions -analyzer-output text \
+// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true -verify=expected,st

[clang] f64f760 - [NFC][CLANG] Fix nullptr dereference issue in Type::getSveEltType()

2023-05-30 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-30T08:00:12-07:00
New Revision: f64f760e2d20340ef7d1a95c8598a90e42ac31e7

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

LOG: [NFC][CLANG] Fix nullptr dereference issue in Type::getSveEltType()

This patch uses castAs instead of getAs which will assert if the type
 doesn't match in clang::Type::getSveEltType(clang::ASTContext const &)

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/AST/Type.cpp

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 51e206d8c463..508965fc38e5 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2434,7 +2434,7 @@ bool Type::isVLSTBuiltinType() const {
 QualType Type::getSveEltType(const ASTContext &Ctx) const {
   assert(isVLSTBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs();
+  const BuiltinType *BTy = castAs();
   if (BTy->getKind() == BuiltinType::SveBool)
 // Represent predicates as i8 rather than i1 to avoid any layout issues.
 // The type is bitcasted to a scalable predicate type when casting between



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


[PATCH] D151525: [NFC][CLANG] Fix nullptr dereference issue in Type::getSveEltType()

2023-05-30 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf64f760e2d20: [NFC][CLANG] Fix nullptr dereference issue in 
Type::getSveEltType() (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151525

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2434,7 +2434,7 @@
 QualType Type::getSveEltType(const ASTContext &Ctx) const {
   assert(isVLSTBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs();
+  const BuiltinType *BTy = castAs();
   if (BTy->getKind() == BuiltinType::SveBool)
 // Represent predicates as i8 rather than i1 to avoid any layout issues.
 // The type is bitcasted to a scalable predicate type when casting between


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2434,7 +2434,7 @@
 QualType Type::getSveEltType(const ASTContext &Ctx) const {
   assert(isVLSTBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs();
+  const BuiltinType *BTy = castAs();
   if (BTy->getKind() == BuiltinType::SveBool)
 // Represent predicates as i8 rather than i1 to avoid any layout issues.
 // The type is bitcasted to a scalable predicate type when casting between
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151225: [clang][analyzer] Merge apiModeling.StdCLibraryFunctions and StdCLibraryFunctionArgs checkers into one.

2023-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

There are still some problems with dependencies, the `ErrnoChecker` really 
needs now the `StdCLibraryFunctions` checker (to be turned on and run before) 
but this is not enforced. The checker order looks to work but not enforced 
specially.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151225

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


[PATCH] D151088: [flang][hlfir] Separate -emit-fir and -emit-hlfir for flang-new

2023-05-30 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thanks Tom, mostly makes sense, but I suggest the following:

- `EmitMLIR` --> `EmitFIR` (nfc, just clarifying the name),
- `EmitHLFIRToFIR` --> `EmitHLFIR` (functional change).

More comments inline.




Comment at: flang/include/flang/Frontend/FrontendOptions.h:42
+  /// resulting FIR
+  EmitHLFIRToFIR,
+

To me having `EmitFIR` and `EmitHLFIR` would make more sense. With 2 dialects, 
`EmitMLIR` becomes rather confusing (and, I suspect, rarely used).



Comment at: flang/lib/Frontend/FrontendActions.cpp:651
+// Lower using HLFIR then run the FIR to HLFIR pipeline
+void CodeGenAction::lowerHLFIRToFIR() {
+  assert(mlirModule && "The MLIR module has not been generated yet.");

I wouldn't really consider this hook as a separate action. Instead, I'd use it 
here: 
https://github.com/llvm/llvm-project/blob/6130c9df99a7a7eb9c6adc118a48f8f2acc534ab/flang/lib/Frontend/FrontendActions.cpp#L917-L920.
 As in, it basically "tweaks" `EmitMLIR` (which I would rename as `EmitFIR`).



Comment at: flang/lib/Frontend/FrontendActions.cpp:652
+void CodeGenAction::lowerHLFIRToFIR() {
+  assert(mlirModule && "The MLIR module has not been generated yet.");
+

This `mlirModule` comes from here: 
https://github.com/llvm/llvm-project/blob/6130c9df99a7a7eb9c6adc118a48f8f2acc534ab/flang/lib/Frontend/FrontendActions.cpp#L277.
 That will either be FIR or HLFIR, depending on whether 
`-flang-experimental-hlfir` was used or not, right?



Comment at: flang/lib/Frontend/FrontendActions.cpp:673
+unsigned diagID = ci.getDiagnostics().getCustomDiagID(
+clang::DiagnosticsEngine::Error, "Lowering to LLVM IR failed");
+ci.getDiagnostics().Report(diagID);

"Lowering to LLVM IR"? ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151088

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


[PATCH] D151720: [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls

2023-05-30 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, erichkeane, tbaeder, cjdb.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

This patch changes the display of member function calls in constexpr evaluator 
diagnostics from arrow operator to dot operator.
This avoids the syntactical invalidness in notes previously caused by the 
display of `&` operator
(lack of parentheses and reference of rvalue)

Fixes https://github.com/llvm/llvm-project/issues/57081


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151720

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
  clang/test/CXX/temp/temp.param/p8-cxx20.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp

Index: clang/test/SemaCXX/deduced-return-type-cxx14.cpp
===
--- clang/test/SemaCXX/deduced-return-type-cxx14.cpp
+++ clang/test/SemaCXX/deduced-return-type-cxx14.cpp
@@ -296,7 +296,7 @@
   void f() {
 X().f();
 Y().f();
-constexpr int q = Y().f(); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to '&Y()->f()'}}
+constexpr int q = Y().f(); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'Y().f()'}}
   }
   struct NonLiteral { ~NonLiteral(); } nl; // cxx14-note {{user-provided destructor}}
   // cxx20_23-note@-1 {{'NonLiteral' is not literal because its destructor is not constexpr}}
Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -840,13 +840,13 @@
   copy fail1{good0}; // expected-error {{call to consteval function 'defaulted_special_member_template::copy::copy' is not a constant expression}} \
  expected-note {{in call to 'copy(good0)'}}
   fail1 = good0;  // expected-error {{call to consteval function 'defaulted_special_member_template::copy::operator=' is not a constant expression}} \
- expected-note {{in call to '&fail1->operator=(good0)'}}
+ expected-note {{in call to 'fail1.operator=(good0)'}}
 
   move good1;
   move fail2{static_cast&&>(good1)}; // expected-error {{call to consteval function 'defaulted_special_member_template::move::move' is not a constant expression}} \
expected-note {{in call to 'move(good1)'}}
   fail2 = static_cast&&>(good1);  // expected-error {{call to consteval function 'defaulted_special_member_template::move::operator=' is not a constant expression}} \
-   expected-note {{in call to '&fail2->operator=(good1)'}}
+   expected-note {{in call to 'fail2.operator=(good1)'}}
 }
 } // namespace defaulted_special_member_template
 
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -975,7 +975,7 @@
   int n;
 };
 constexpr int S::f() const {
-  return static_cast(this)->n; // expected-note {{cannot cast}}
+  return static_cast(this)->n; // expected-note 5{{cannot cast}}
 }
 constexpr int S::g() const {
   // FIXME: Better diagnostic for this.
@@ -984,8 +984,16 @@
 // The T temporary is implicitly cast to an S subobject, but we can recover the
 // T full-object via a base-to-derived cast, or a derived-to-base-casted member
 // pointer.
-static_assert(S().f(), ""); // expected-error {{constant expression}} expected-note {{in call to '&S()->f()'}}
-static_assert(S().g(), ""); // expected-error {{constant expression}} expected-note {{in call to '&S()->g()'}}
+static_assert(S().f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'S().f()'}}
+static_assert(S().g(), ""); // expected-error {{constant expression}} expected-note {{in call to 'S().g()'}}
+constexpr S sobj;
+constexpr const S& slref = sobj;
+constexpr const S&& srref = S();
+constexpr const S *sptr = &sobj;
+static_assert(sobj.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'sobj.f()'}}
+static_assert(sptr->f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'sobj.f()'}}
+static_assert(slref.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'sobj.f()'}}
+static_assert(srref.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'S().f()'}}
 static_assert(T(3).f() == 3, "");
 static_asse

[clang] 0e4c4c7 - [clang] Extend __is_trivially_equality_comparable to check for hidden friends

2023-05-30 Thread Nikolas Klauser via cfe-commits

Author: Nikolas Klauser
Date: 2023-05-30T08:33:31-07:00
New Revision: 0e4c4c77730810db235d377d49ba5860dfa0bd8d

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

LOG: [clang] Extend __is_trivially_equality_comparable to check for hidden 
friends

This allows types to be considered trivially equality comparable if a defaulted 
hidden friend is used.

Reviewed By: erichkeane

Spies: cfe-commits

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

Added: 


Modified: 
clang/lib/AST/Type.cpp
clang/test/SemaCXX/type-traits.cpp

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 508965fc38e55..bde88653417d9 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DependenceFlags.h"
@@ -2640,11 +2641,21 @@ HasNonDeletedDefaultedEqualityComparison(const 
CXXRecordDecl *Decl) {
   if (Decl->isUnion())
 return false;
 
-  if (llvm::none_of(Decl->methods(), [](const CXXMethodDecl *MemberFunction) {
-return MemberFunction->isOverloadedOperator() &&
-   MemberFunction->getOverloadedOperator() ==
-   OverloadedOperatorKind::OO_EqualEqual &&
-   MemberFunction->isDefaulted();
+  auto IsDefaultedOperatorEqualEqual = [&](const FunctionDecl *Function) {
+return Function->getOverloadedOperator() ==
+   OverloadedOperatorKind::OO_EqualEqual &&
+   Function->isDefaulted() && Function->getNumParams() > 0 &&
+   (Function->getParamDecl(0)->getType()->isReferenceType() ||
+Decl->isTriviallyCopyable());
+  };
+
+  if (llvm::none_of(Decl->methods(), IsDefaultedOperatorEqualEqual) &&
+  llvm::none_of(Decl->friends(), [&](const FriendDecl *Friend) {
+if (NamedDecl *ND = Friend->getFriendDecl()) {
+  return ND->isFunctionOrFunctionTemplate() &&
+ IsDefaultedOperatorEqualEqual(ND->getAsFunction());
+}
+return false;
   }))
 return false;
 

diff  --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index 75f172d1c3452..d5388d4eb89be 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3270,6 +3270,172 @@ struct NotTriviallyEqualityComparableHasEnum {
 };
 
static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasEnum));
 
+namespace hidden_friend {
+
+struct TriviallyEqualityComparable {
+  int i;
+  int j;
+
+  void func();
+  bool operator==(int) const { return false; }
+
+  friend bool operator==(const TriviallyEqualityComparable&, const 
TriviallyEqualityComparable&) = default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable), 
"");
+
+struct TriviallyEqualityComparableNonTriviallyCopyable {
+  TriviallyEqualityComparableNonTriviallyCopyable(const 
TriviallyEqualityComparableNonTriviallyCopyable&);
+  ~TriviallyEqualityComparableNonTriviallyCopyable();
+  friend bool operator==(const 
TriviallyEqualityComparableNonTriviallyCopyable&, const 
TriviallyEqualityComparableNonTriviallyCopyable&) = default;
+  int i;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableNonTriviallyCopyable));
+
+struct NotTriviallyEqualityComparableHasPadding {
+  short i;
+  int j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableHasPadding&, 
const NotTriviallyEqualityComparableHasPadding&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasPadding),
 "");
+
+struct NotTriviallyEqualityComparableHasFloat {
+  float i;
+  int j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableHasFloat&, const 
NotTriviallyEqualityComparableHasFloat&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasFloat),
 "");
+
+struct NotTriviallyEqualityComparableHasTailPadding {
+  int i;
+  char j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableHasTailPadding&, 
const NotTriviallyEqualityComparableHasTailPadding&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasTailPadding),
 "");
+
+struct NotTriviallyEqualityComparableBase : 
NotTriviallyEqualityComparableHasTailPadding {
+  char j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableBase&, const 
NotTriviallyEqualityComparableBase&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBase),
 "");
+
+class TriviallyEqualityComparablePaddedOutBase {
+  int i;
+  char 

[PATCH] D151721: [NFC][CLANG] Fix nullptr dereference issue in Type::getRVVEltType()

2023-05-30 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

This patch uses castAs instead of getAs which will assert if the type doesn't 
match in clang::​Type::​getRVVEltType(clang::​ASTContext const &),


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151721

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2462,7 +2462,7 @@
 QualType Type::getRVVEltType(const ASTContext &Ctx) const {
   assert(isRVVVLSBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs();
+  const BuiltinType *BTy = castAs();
   return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType;
 }
 


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2462,7 +2462,7 @@
 QualType Type::getRVVEltType(const ASTContext &Ctx) const {
   assert(isRVVVLSBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs();
+  const BuiltinType *BTy = castAs();
   return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151623: [clang] Extend __is_trivially_equality_comparable to check for hidden friends

2023-05-30 Thread Nikolas Klauser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e4c4c777308: [clang] Extend 
__is_trivially_equality_comparable to check for hidden friends (authored by 
philnik).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151623

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3270,6 +3270,172 @@
 };
 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasEnum));
 
+namespace hidden_friend {
+
+struct TriviallyEqualityComparable {
+  int i;
+  int j;
+
+  void func();
+  bool operator==(int) const { return false; }
+
+  friend bool operator==(const TriviallyEqualityComparable&, const TriviallyEqualityComparable&) = default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable), "");
+
+struct TriviallyEqualityComparableNonTriviallyCopyable {
+  TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable&);
+  ~TriviallyEqualityComparableNonTriviallyCopyable();
+  friend bool operator==(const TriviallyEqualityComparableNonTriviallyCopyable&, const TriviallyEqualityComparableNonTriviallyCopyable&) = default;
+  int i;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableNonTriviallyCopyable));
+
+struct NotTriviallyEqualityComparableHasPadding {
+  short i;
+  int j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableHasPadding&, const NotTriviallyEqualityComparableHasPadding&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasPadding), "");
+
+struct NotTriviallyEqualityComparableHasFloat {
+  float i;
+  int j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableHasFloat&, const NotTriviallyEqualityComparableHasFloat&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasFloat), "");
+
+struct NotTriviallyEqualityComparableHasTailPadding {
+  int i;
+  char j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableHasTailPadding&, const NotTriviallyEqualityComparableHasTailPadding&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasTailPadding), "");
+
+struct NotTriviallyEqualityComparableBase : NotTriviallyEqualityComparableHasTailPadding {
+  char j;
+
+  friend bool operator==(const NotTriviallyEqualityComparableBase&, const NotTriviallyEqualityComparableBase&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBase), "");
+
+class TriviallyEqualityComparablePaddedOutBase {
+  int i;
+  char c;
+
+public:
+  friend bool operator==(const TriviallyEqualityComparablePaddedOutBase&, const TriviallyEqualityComparablePaddedOutBase&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(TriviallyEqualityComparablePaddedOutBase), "");
+
+struct TriviallyEqualityComparablePaddedOut : TriviallyEqualityComparablePaddedOutBase {
+  char j[3];
+
+  friend bool operator==(const TriviallyEqualityComparablePaddedOut&, const TriviallyEqualityComparablePaddedOut&) = default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparablePaddedOut), "");
+
+struct TriviallyEqualityComparable1 {
+  char i;
+
+  friend bool operator==(const TriviallyEqualityComparable1&, const TriviallyEqualityComparable1&) = default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable1));
+
+struct TriviallyEqualityComparable2 {
+  int i;
+
+  friend bool operator==(const TriviallyEqualityComparable2&, const TriviallyEqualityComparable2&) = default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable2));
+
+struct NotTriviallyEqualityComparableTriviallyEqualityComparableBases
+: TriviallyEqualityComparable1, TriviallyEqualityComparable2 {
+  friend bool operator==(const NotTriviallyEqualityComparableTriviallyEqualityComparableBases&, const NotTriviallyEqualityComparableTriviallyEqualityComparableBases&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableTriviallyEqualityComparableBases));
+
+struct NotTriviallyEqualityComparableBitfield {
+  int i : 1;
+
+  friend bool operator==(const NotTriviallyEqualityComparableBitfield&, const NotTriviallyEqualityComparableBitfield&) = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBitfield));
+
+// TODO: This is trivially equality comparable
+struct NotTriviallyEqualityComparableBitfieldFilled {
+  char i : __CHAR_BIT__;
+
+  friend bool operator==(const NotTriviallyEqualityComparableBitfieldFilled&, const NotTriviallyEqualityComparableBitfieldF

[PATCH] D151723: [clang] Remove unnecessary FALLTHROUGH markers

2023-05-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: NoQ.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

They are redundant with the [[fallthrough]]; attribute that follows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151723

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -395,7 +395,6 @@
   return evalCast(*Val, CE->getType(), SE->getType());
 }
 }
-// FALLTHROUGH
 [[fallthrough]];
   }
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2121,7 +2121,6 @@
   }
 }
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -5716,7 +5716,6 @@
   assert(unpaddedIndex == 0);
 Builder.CreateStore(elt, eltAddr);
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -395,7 +395,6 @@
   return evalCast(*Val, CE->getType(), SE->getType());
 }
 }
-// FALLTHROUGH
 [[fallthrough]];
   }
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2121,7 +2121,6 @@
   }
 }
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -5716,7 +5716,6 @@
   assert(unpaddedIndex == 0);
 Builder.CreateStore(elt, eltAddr);
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151529: [NFC][CLANG] Fix nullptr dereference issue in DeduceTemplateArgumentsByTypeMatch()

2023-05-30 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 526647.
Manna added a comment.

Thank you @erichkeane for reviews!

I have updated assert message.


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

https://reviews.llvm.org/D151529

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp


Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1703,10 +1703,12 @@
   if (!IAA)
 return Sema::TDK_NonDeducedMismatch;
 
+  const auto *IAP = S.Context.getAsIncompleteArrayType(P);
+  assert(IAP && "Template parameter not of incomplete array type");
+
   return DeduceTemplateArgumentsByTypeMatch(
-  S, TemplateParams,
-  S.Context.getAsIncompleteArrayType(P)->getElementType(),
-  IAA->getElementType(), Info, Deduced, TDF & TDF_IgnoreQualifiers);
+  S, TemplateParams, IAP->getElementType(), IAA->getElementType(), 
Info,
+  Deduced, TDF & TDF_IgnoreQualifiers);
 }
 
 // T [integer-constant]


Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1703,10 +1703,12 @@
   if (!IAA)
 return Sema::TDK_NonDeducedMismatch;
 
+  const auto *IAP = S.Context.getAsIncompleteArrayType(P);
+  assert(IAP && "Template parameter not of incomplete array type");
+
   return DeduceTemplateArgumentsByTypeMatch(
-  S, TemplateParams,
-  S.Context.getAsIncompleteArrayType(P)->getElementType(),
-  IAA->getElementType(), Info, Deduced, TDF & TDF_IgnoreQualifiers);
+  S, TemplateParams, IAP->getElementType(), IAA->getElementType(), Info,
+  Deduced, TDF & TDF_IgnoreQualifiers);
 }
 
 // T [integer-constant]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151725: [clang] Move dyn_cast's into if statements for readability

2023-05-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: NoQ.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151725

Files:
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp


Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -712,21 +712,17 @@
 }
 
 SourceRange MemRegion::sourceRange() const {
-  const auto *const VR = dyn_cast(this->getBaseRegion());
-  const auto *const FR = dyn_cast(this);
-
   // Check for more specific regions first.
-  // FieldRegion
-  if (FR) {
+  if (auto *FR = dyn_cast(this)) {
 return FR->getDecl()->getSourceRange();
   }
-  // VarRegion
-  else if (VR) {
+
+  if (auto *VR = dyn_cast(this->getBaseRegion())) {
 return VR->getDecl()->getSourceRange();
   }
+
   // Return invalid source range (can be checked by client).
-  else
-return {};
+  return {};
 }
 
 
//===--===//


Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -712,21 +712,17 @@
 }
 
 SourceRange MemRegion::sourceRange() const {
-  const auto *const VR = dyn_cast(this->getBaseRegion());
-  const auto *const FR = dyn_cast(this);
-
   // Check for more specific regions first.
-  // FieldRegion
-  if (FR) {
+  if (auto *FR = dyn_cast(this)) {
 return FR->getDecl()->getSourceRange();
   }
-  // VarRegion
-  else if (VR) {
+
+  if (auto *VR = dyn_cast(this->getBaseRegion())) {
 return VR->getDecl()->getSourceRange();
   }
+
   // Return invalid source range (can be checked by client).
-  else
-return {};
+  return {};
 }
 
 //===--===//
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151726: [clang] Remove unnecessary casts around Allocate function calls

2023-05-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: NoQ.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151726

Files:
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -170,7 +170,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolRegionValue(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -189,7 +189,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -206,7 +206,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolDerived(SymbolCounter, parentSymbol, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -222,7 +222,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolExtent(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -240,7 +240,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -257,7 +257,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = (SymbolCast*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) SymbolCast(Op, From, To);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -275,7 +275,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = (SymIntExpr*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) SymIntExpr(lhs, op, v, t);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -293,7 +293,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = (IntSymExpr*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) IntSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -311,7 +311,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = (SymSymExpr*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) SymSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -327,7 +327,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = (UnarySymExpr *)BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) UnarySymExpr(Operand, Opc, T);
 DataSet.InsertNode(data, InsertPos);
   }
Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -424,7 +424,7 @@
 freeStates.pop_back();
   }
   else {
-newState = (ProgramState*) Alloc.Allocate();
+newState = Alloc.Allocate();
   }
   new (newState) ProgramState(State);
   StateSet.InsertNode(newState, InsertPos);
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -408,7 +408,7 @@
 }
 else {
   // Allocate a new node.
-  V = (NodeTy*) getAllocator().Allocate();
+  V = getAllocator().Allocate();
 }
 
 ++NumNodes;
@@ -432,7 +432,7 @@
 ProgramStateRef State,
 int64_t Id,
 bool IsSink) {
-  NodeTy *V = (NodeTy *) getAllocator().Allocate();
+  NodeTy *V = getAllocator().Allocate();
   new (V) NodeTy(L, State, Id, IsSink);
   return V;
 }
Index: clang/lib/StaticAnal

[PATCH] D151727: [clang] Replace dyn_cast with cast in MemRegion::getMemorySpace

2023-05-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: NoQ.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

MemRegion::getMemorySpace() is annotated with
LLVM_ATTRIBUTE_RETURNS_NONNULL (which triggers instant UB if a null
pointer is returned), and callers indeed don't check the return value
for null. Thus, even though llvm::dyn_cast is called, it can never
return null in this context. Therefore, we can safely call llvm::cast.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151727

Files:
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp


Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1283,7 +1283,7 @@
 SR = dyn_cast(R);
   }
 
-  return dyn_cast(R);
+  return cast(R);
 }
 
 bool MemRegion::hasStackStorage() const {


Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1283,7 +1283,7 @@
 SR = dyn_cast(R);
   }
 
-  return dyn_cast(R);
+  return cast(R);
 }
 
 bool MemRegion::hasStackStorage() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151727: [clang] Replace dyn_cast with cast in MemRegion::getMemorySpace

2023-05-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151727

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


[PATCH] D150953: [Clang][SVE2.1] Add clang support for prototypes using svcount_t

2023-05-30 Thread hassnaaHamdi via Phabricator via cfe-commits
hassnaa-arm added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:42
 //  q -> Scalable vector, followed by the number of elements and the base type.
+//  Q -> AArch64 svcount_t builtin type.
 //  E -> ext_vector, followed by the number of elements and the base type.

sdesmalen wrote:
> Can we make 'Q' something to mean 'target type' and then use a second letter 
> to clarify which exact target type it is, e.g.
> 
>   // Q -> target builtin type, followed by a character to distinguish the 
> builtin type
>   //   Qa -> AArch64 svcount_t builtin type.
> 
> That should make it more extensible for other target types in the future.
Is that suggestion because maybe other targets don't support svcount ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150953

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


[PATCH] D151726: [clang] Remove unnecessary casts around Allocate function calls

2023-05-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151726

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


[PATCH] D151721: [NFC][CLANG] Fix nullptr dereference issue in Type::getRVVEltType()

2023-05-30 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151721

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


[PATCH] D151720: [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls

2023-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:994
+static_assert(sobj.f(), ""); // expected-error {{constant expression}} 
expected-note {{in call to 'sobj.f()'}}
+static_assert(sptr->f(), ""); // expected-error {{constant expression}} 
expected-note {{in call to 'sobj.f()'}}
+static_assert(slref.f(), ""); // expected-error {{constant expression}} 
expected-note {{in call to 'sobj.f()'}}

So I think this is just trading 1 'wrong' for another.  We should be looking to 
see if we can figure out whether this is called with an arrow or not.  I don't 
have a good way of doing that unfortunately, but perhaps Aaron has an idea?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151720

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


[PATCH] D151725: [clang] Move dyn_cast's into if statements for readability

2023-05-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

I think should mention "NFC" for such commits. Also, we tend to use the 
"analyzer" tag for CSA related changes.

BTW thanks for these simplifications.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151725

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


[PATCH] D150953: [Clang][SVE2.1] Add clang support for prototypes using svcount_t

2023-05-30 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:42
 //  q -> Scalable vector, followed by the number of elements and the base type.
+//  Q -> AArch64 svcount_t builtin type.
 //  E -> ext_vector, followed by the number of elements and the base type.

hassnaa-arm wrote:
> sdesmalen wrote:
> > Can we make 'Q' something to mean 'target type' and then use a second 
> > letter to clarify which exact target type it is, e.g.
> > 
> >   // Q -> target builtin type, followed by a character to distinguish the 
> > builtin type
> >   //   Qa -> AArch64 svcount_t builtin type.
> > 
> > That should make it more extensible for other target types in the future.
> Is that suggestion because maybe other targets don't support svcount ?
Correct, `svcount_t` is an AArch64 specific type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150953

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


[PATCH] D150953: [Clang][SVE2.1] Add clang support for prototypes using svcount_t

2023-05-30 Thread hassnaaHamdi via Phabricator via cfe-commits
hassnaa-arm added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:42
 //  q -> Scalable vector, followed by the number of elements and the base type.
+//  Q -> AArch64 svcount_t builtin type.
 //  E -> ext_vector, followed by the number of elements and the base type.

sdesmalen wrote:
> hassnaa-arm wrote:
> > sdesmalen wrote:
> > > Can we make 'Q' something to mean 'target type' and then use a second 
> > > letter to clarify which exact target type it is, e.g.
> > > 
> > >   // Q -> target builtin type, followed by a character to distinguish the 
> > > builtin type
> > >   //   Qa -> AArch64 svcount_t builtin type.
> > > 
> > > That should make it more extensible for other target types in the future.
> > Is that suggestion because maybe other targets don't support svcount ?
> Correct, `svcount_t` is an AArch64 specific type.
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150953

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-30 Thread Ritanya via Phabricator via cfe-commits
RitanyaB updated this revision to Diff 526665.

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

https://reviews.llvm.org/D146418

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_variables_ast_print.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp

Index: clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
===
--- clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
+++ clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
@@ -95,7 +95,7 @@
 int (*D)() = C; // expected-note {{used here}}
 // host-note@-1 {{used here}}
 #pragma omp end declare target
-int foobar3() { throw 1; }
+int foobar3() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
 
 // Check no infinite recursion in deferred diagnostic emitter.
 long E = (long)&E;
Index: clang/test/OpenMP/declare_target_variables_ast_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_variables_ast_print.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -w -verify -fopenmp -I %S/Inputs -ast-print %s | FileCheck %s --check-prefix=CHECK
+// expected-no-diagnostics
+
+static int variable = 100;
+static float variable1 = 200;
+static float variable2 = variable1;
+
+static int var = 1;
+
+static int var1 = 10;
+static int *var2 = &var1;
+static int **ptr1 = &var2;
+
+int arr[2] = {1,2};
+int (*arrptr)[2] = &arr;
+
+class declare{
+  public: int x;
+  void print();
+};
+declare obj1;
+declare *obj2 = &obj1;
+
+struct target{
+  int x;
+  void print();
+};
+static target S;
+
+#pragma omp declare target
+int target_var = variable;
+float target_var1 = variable2;
+int *ptr = &var;
+int ***ptr2 = &ptr1;
+int (**ptr3)[2] = &arrptr;
+declare **obj3 = &obj2;
+target *S1 = &S;
+#pragma omp end declare target
+// CHECK: #pragma omp declare target
+// CHECK-NEXT: static int variable = 100;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static float variable1 = 200;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static float variable2 = variable1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK: #pragma omp declare target
+// CHECK-NEXT: static int var = 1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int var1 = 10;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int *var2 = &var1;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int **ptr1 = &var2;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int arr[2] = {1, 2};
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int (*arrptr)[2] = &arr;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: class declare {
+// CHECK-NEXT: public:
+// CHECK-NEXT:  int x;
+// CHECK-NEXT:  void print();
+// CHECK-NEXT: };
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare obj1;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare *obj2 = &obj1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: struct target {
+// CHECK-NEXT:  int x;
+// CHECK-NEXT:  void print();
+// CHECK-NEXT: };
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static target S;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int target_var = variable;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: float target_var1 = variable2;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int *ptr = &var;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int ***ptr2 = &ptr1;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int (**ptr3)[2] = &arrptr;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare **obj3 = &obj2;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: target *S1 = &S;
+// CHECK-NEXT: #pragma omp end declare target
+
Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -233,6 +233,42 @@
 #pragma omp declare 

[clang] 0da99ff - [clang][analyzer][NFC] Remove unnecessary casts around Allocate function calls

2023-05-30 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2023-05-30T18:10:15+02:00
New Revision: 0da99ffe1afc526844f4146c95b4b2ab251de1a9

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

LOG: [clang][analyzer][NFC] Remove unnecessary casts around Allocate function 
calls

Reviewed By: steakhal

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
clang/lib/StaticAnalyzer/Core/ProgramState.cpp
clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp 
b/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
index fc736dd452aa..5a5851975bb6 100644
--- a/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -97,7 +97,7 @@ const llvm::APSInt& BasicValueFactory::getValue(const 
llvm::APSInt& X) {
   FoldNodeTy* P = APSIntSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!P) {
-P = (FoldNodeTy*) BPAlloc.Allocate();
+P = BPAlloc.Allocate();
 new (P) FoldNodeTy(X);
 APSIntSet.InsertNode(P, InsertPos);
   }
@@ -132,7 +132,7 @@ BasicValueFactory::getCompoundValData(QualType T,
   CompoundValData* D = CompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!D) {
-D = (CompoundValData*) BPAlloc.Allocate();
+D = BPAlloc.Allocate();
 new (D) CompoundValData(T, Vals);
 CompoundValDataSet.InsertNode(D, InsertPos);
   }
@@ -151,7 +151,7 @@ BasicValueFactory::getLazyCompoundValData(const StoreRef 
&store,
 LazyCompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!D) {
-D = (LazyCompoundValData*) BPAlloc.Allocate();
+D = BPAlloc.Allocate();
 new (D) LazyCompoundValData(store, region);
 LazyCompoundValDataSet.InsertNode(D, InsertPos);
   }
@@ -169,7 +169,7 @@ const PointerToMemberData 
*BasicValueFactory::getPointerToMemberData(
   PointerToMemberDataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!D) {
-D = (PointerToMemberData *)BPAlloc.Allocate();
+D = BPAlloc.Allocate();
 new (D) PointerToMemberData(ND, L);
 PointerToMemberDataSet.InsertNode(D, InsertPos);
   }
@@ -358,7 +358,7 @@ BasicValueFactory::getPersistentSValWithData(const SVal& V, 
uintptr_t Data) {
   FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!P) {
-P = (FoldNodeTy*) BPAlloc.Allocate();
+P = BPAlloc.Allocate();
 new (P) FoldNodeTy(std::make_pair(V, Data));
 Map.InsertNode(P, InsertPos);
   }
@@ -383,7 +383,7 @@ BasicValueFactory::getPersistentSValPair(const SVal& V1, 
const SVal& V2) {
   FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!P) {
-P = (FoldNodeTy*) BPAlloc.Allocate();
+P = BPAlloc.Allocate();
 new (P) FoldNodeTy(std::make_pair(V1, V2));
 Map.InsertNode(P, InsertPos);
   }

diff  --git a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp 
b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
index cac7ec3f8cf7..314a4feda81b 100644
--- a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -408,7 +408,7 @@ ExplodedNode *ExplodedGraph::getNode(const ProgramPoint &L,
 }
 else {
   // Allocate a new node.
-  V = (NodeTy*) getAllocator().Allocate();
+  V = getAllocator().Allocate();
 }
 
 ++NumNodes;
@@ -432,7 +432,7 @@ ExplodedNode *ExplodedGraph::createUncachedNode(const 
ProgramPoint &L,
 ProgramStateRef State,
 int64_t Id,
 bool IsSink) {
-  NodeTy *V = (NodeTy *) getAllocator().Allocate();
+  NodeTy *V = getAllocator().Allocate();
   new (V) NodeTy(L, State, Id, IsSink);
   return V;
 }

diff  --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp 
b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
index 90ebbaad2bf3..e90ebab43c78 100644
--- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -424,7 +424,7 @@ ProgramStateRef 
ProgramStateManager::getPersistentState(ProgramState &State) {
 freeStates.pop_back();
   }
   else {
-newState = (ProgramState*) Alloc.Allocate();
+newState = Alloc.Allocate();
   }
   new (newState) ProgramState(State);
   StateSet.InsertNode(newState, InsertPos);

diff  --git a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp 
b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
index 032605ffe7a2..b4f64bc3a7b3 100644
--- a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -170,7 +170,7 @@ SymbolManager::getRegionValueSymbol(const TypedValueRegion* 
R) {
   void *InsertPos;
   Sym

[PATCH] D151726: [clang][analyzer][NFC] Remove unnecessary casts around Allocate function calls

2023-05-30 Thread Dmitri Gribenko 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 rG0da99ffe1afc: [clang][analyzer][NFC] Remove unnecessary 
casts around Allocate function calls (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151726

Files:
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -170,7 +170,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolRegionValue(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -189,7 +189,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -206,7 +206,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolDerived(SymbolCounter, parentSymbol, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -222,7 +222,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolExtent(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -240,7 +240,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = (SymExpr*) BPAlloc.Allocate();
+SD = BPAlloc.Allocate();
 new (SD) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
@@ -257,7 +257,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = (SymbolCast*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) SymbolCast(Op, From, To);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -275,7 +275,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = (SymIntExpr*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) SymIntExpr(lhs, op, v, t);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -293,7 +293,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = (IntSymExpr*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) IntSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -311,7 +311,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = (SymSymExpr*) BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) SymSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
@@ -327,7 +327,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = (UnarySymExpr *)BPAlloc.Allocate();
+data = BPAlloc.Allocate();
 new (data) UnarySymExpr(Operand, Opc, T);
 DataSet.InsertNode(data, InsertPos);
   }
Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -424,7 +424,7 @@
 freeStates.pop_back();
   }
   else {
-newState = (ProgramState*) Alloc.Allocate();
+newState = Alloc.Allocate();
   }
   new (newState) ProgramState(State);
   StateSet.InsertNode(newState, InsertPos);
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -408,7 +408,7 @@
 }
 else {
   // Allocate a new node.
-  V = (NodeTy*) getAllocator().Allocate();
+  V = getAllocator().Allocate();
 }
 
 ++NumNodes;
@@ -432,7 +432,7 @@
 ProgramStateRef State,
 int64_t Id,
 bool IsSink) {
-  NodeTy *V = (NodeTy *) getAllocator().Allocate();
+  NodeTy *V = getAllocator().Allocate();
   ne

[PATCH] D151730: [RISCV] Support target attribute for function

2023-05-30 Thread Piyou Chen via Phabricator via cfe-commits
BeMg created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
hiraditya, arichardson.
Herald added a project: All.
BeMg requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151730

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/riscv-func-attr-target.c
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp

Index: llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
===
--- llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -34,6 +34,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 
@@ -44,6 +45,10 @@
 STATISTIC(RISCVNumInstrsCompressed,
   "Number of RISC-V Compressed instructions emitted");
 
+namespace llvm {
+extern const SubtargetFeatureKV RISCVFeatureKV[RISCV::NumSubtargetFeatures];
+} // namespace llvm
+
 namespace {
 class RISCVAsmPrinter : public AsmPrinter {
   const RISCVSubtarget *STI;
@@ -82,6 +87,8 @@
   void emitEndOfAsmFile(Module &M) override;
 
   void emitFunctionEntryLabel() override;
+  void emitDirectiveOptionArch();
+  bool isSameAttribute();
 
 private:
   void emitAttributes();
@@ -232,11 +239,44 @@
   return false;
 }
 
+void RISCVAsmPrinter::emitDirectiveOptionArch() {
+  RISCVTargetStreamer &RTS =
+  static_cast(*OutStreamer->getTargetStreamer());
+  std::vector NeedEmitStdOption;
+  const MCSubtargetInfo &MCSTI = *TM.getMCSubtargetInfo();
+  for (auto Feature : RISCVFeatureKV) {
+if (STI->hasFeature(Feature.Value) && !MCSTI.hasFeature(Feature.Value) &&
+llvm::RISCVISAInfo::isSupportedExtensionFeature(Feature.Key))
+  NeedEmitStdOption.push_back(Feature.Key);
+  }
+
+  bool PrefixEmitted = false;
+  unsigned NeedEmitStdOptionSize = NeedEmitStdOption.size();
+  for (unsigned i = 0; i < NeedEmitStdOptionSize; i++) {
+RTS.emitDirectiveOptionArchPlus(NeedEmitStdOption[i], PrefixEmitted,
+i < NeedEmitStdOptionSize - 1);
+  }
+}
+
+bool RISCVAsmPrinter::isSameAttribute() {
+  const MCSubtargetInfo &MCSTI = *TM.getMCSubtargetInfo();
+  return MCSTI.getFeatureBits() == STI->getFeatureBits();
+}
+
 bool RISCVAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   STI = &MF.getSubtarget();
+  RISCVTargetStreamer &RTS =
+  static_cast(*OutStreamer->getTargetStreamer());
+  if (!isSameAttribute()) {
+RTS.emitDirectiveOptionPush();
+emitDirectiveOptionArch();
+  }
 
   SetupMachineFunction(MF);
   emitFunctionBody();
+
+  if (!isSameAttribute())
+RTS.emitDirectiveOptionPop();
   return false;
 }
 
Index: clang/test/CodeGen/RISCV/riscv-func-attr-target.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-func-attr-target.c
@@ -0,0 +1,35 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang -target riscv64 -march=rv64g -S %s -o - | FileCheck %s
+
+// clang-format off
+// CHECK: .option push
+// CHECK-NEXT: .optionarch,   +c, +v, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+// CHECK-LABEL: test1
+// CHECK: .option pop
+__attribute__((target("arch=rv64g+c+v"))) void test1 () {}
+
+// CHECK: .option push
+// CHECK-NEXT: .optionarch,   +c
+// CHECK-LABEL: test2
+// CHECK: .option pop
+__attribute__((target("arch=rv64gc"))) void test2 () {}
+
+// CHECK: .option push
+// CHECK-NEXT: .optionarch,   +c
+// CHECK-LABEL: test3
+// CHECK: .option pop
+__attribute__((target("arch=+c"))) void test3 () {}
+
+// CHECK: .option push
+// CHECK-NEXT: .optionarch,   +v, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+// CHECK-LABEL: test4
+// CHECK: .option pop
+__attribute__((target("arch=+v"))) void test4 () {}
+
+// CHECK: .option push
+// CHECK-NEXT: .optionarch,   +experimental-zihintntl
+// CHECK-LABEL: test5
+// CHECK: .option pop
+__attribute__((target("arch=+experimental-zihintntl"))) void test5 () {}
+
+// clang-format on
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -109,6 +109,8 @@
   void fillValidCPUList(SmallVectorImpl &Values) const override;
   bool isValidTuneCPUName(StringRef Name) const override;
   void f

[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23106
+class GlobalDeclRefChecker final
+: public ConstStmtVisitor {
+  SmallVector DeclVector;

Use just a StmtVisitor, if you still dropping const modifier.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23114
+  void VisitDeclRefExpr(const DeclRefExpr *Node) {
+if (auto *VD = const_cast(dyn_cast(Node->getDecl( {
+  VD->addAttr(A);

remove const_cast



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23131
+A = TD->getAttr();
+DeclVector.push_back(dyn_cast(TD));
+while (!DeclVector.empty()) {

You don't need to use dyn_cast here, use just cast


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

https://reviews.llvm.org/D146418

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


[clang] daa95c7 - [clang][analyzer][NFC] Remove unnecessary FALLTHROUGH markers

2023-05-30 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2023-05-30T18:16:35+02:00
New Revision: daa95c7de5b7d004bd6c48f5099b7b88f1f5d16d

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

LOG: [clang][analyzer][NFC] Remove unnecessary FALLTHROUGH markers

They are redundant with the [[fallthrough]]; attribute that follows.

Reviewed By: steakhal

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index ec28c1db207a..09ccb63dceeb 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5716,7 +5716,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   assert(unpaddedIndex == 0);
 Builder.CreateStore(elt, eltAddr);
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 

diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index bd5781a81bb5..194a592fc019 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2121,7 +2121,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
   }
 }
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 

diff  --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index fed17c77f03d..4fe828bdf768 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -395,7 +395,6 @@ std::optional SValBuilder::getConstantVal(const Expr 
*E) {
   return evalCast(*Val, CE->getType(), SE->getType());
 }
 }
-// FALLTHROUGH
 [[fallthrough]];
   }
 



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


[PATCH] D151723: [clang][analyzer][NFC] Remove unnecessary FALLTHROUGH markers

2023-05-30 Thread Dmitri Gribenko 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 rGdaa95c7de5b7: [clang][analyzer][NFC] Remove unnecessary 
FALLTHROUGH markers (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151723

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -395,7 +395,6 @@
   return evalCast(*Val, CE->getType(), SE->getType());
 }
 }
-// FALLTHROUGH
 [[fallthrough]];
   }
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2121,7 +2121,6 @@
   }
 }
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -5716,7 +5716,6 @@
   assert(unpaddedIndex == 0);
 Builder.CreateStore(elt, eltAddr);
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -395,7 +395,6 @@
   return evalCast(*Val, CE->getType(), SE->getType());
 }
 }
-// FALLTHROUGH
 [[fallthrough]];
   }
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2121,7 +2121,6 @@
   }
 }
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -5716,7 +5716,6 @@
   assert(unpaddedIndex == 0);
 Builder.CreateStore(elt, eltAddr);
   }
-  // FALLTHROUGH
   [[fallthrough]];
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >