[PATCH] D143971: [clang-tidy] Flag more buggy string constructor cases

2023-06-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:69
 void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
+  const auto SignedCharType = qualType(isAnyCharacter(), isSignedInteger());
   const auto ZeroExpr = expr(ignoringParenImpCasts(integerLiteral(equals(0;

this may incorrectly work also for signed char, we want it work only for char 
and wchat_t, not signed char, unsigned char, signed wchar_t, unsigned wchar_t.
So this still need some work. I would say new "isAnyCharacter" need to be 
created.



Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:96
+  const auto NonCharacterInteger =
+  qualType(isInteger(), unless(isAnyCharacter()));
+  const auto CharToIntCastExpr = implicitCastExpr(

Similar could be here, we consider std::uint8_t and std::sint8_t as integers, 
not as an characters, same with signed char, unsigned char


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143971

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


[PATCH] D150602: [clang-tidy] Move formatDereference to FixitHintUtils

2023-06-11 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe updated this revision to Diff 530384.
mikecrowe added a comment.

Rebase, no changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150602

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h

Index: clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
+++ clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
@@ -44,6 +44,9 @@
   DeclSpec::TQ Qualifier,
   QualifierTarget CT = QualifierTarget::Pointee,
   QualifierPolicy CP = QualifierPolicy::Left);
+
+// \brief Format a pointer to an expression
+std::string formatDereference(const Expr , const ASTContext );
 } // namespace clang::tidy::utils::fixit
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
Index: clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -9,7 +9,9 @@
 #include "FixItHintUtils.h"
 #include "LexerUtils.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
+#include "clang/Tooling/FixIt.h"
 #include 
 
 namespace clang::tidy::utils::fixit {
@@ -221,4 +223,46 @@
 
   return std::nullopt;
 }
+
+// Return true if expr needs to be put in parens when it is an argument of a
+// prefix unary operator, e.g. when it is a binary or ternary operator
+// syntactically.
+static bool needParensAfterUnaryOperator(const Expr ) {
+  if (isa() ||
+  isa()) {
+return true;
+  }
+  if (const auto *Op = dyn_cast()) {
+return Op->getNumArgs() == 2 && Op->getOperator() != OO_PlusPlus &&
+   Op->getOperator() != OO_MinusMinus && Op->getOperator() != OO_Call &&
+   Op->getOperator() != OO_Subscript;
+  }
+  return false;
+}
+
+// Format a pointer to an expression: prefix with '*' but simplify
+// when it already begins with '&'.  Return empty string on failure.
+std::string formatDereference(const Expr , const ASTContext ) {
+  if (const auto *Op = dyn_cast()) {
+if (Op->getOpcode() == UO_AddrOf) {
+  // Strip leading '&'.
+  return std::string(
+  tooling::fixit::getText(*Op->getSubExpr()->IgnoreParens(), Context));
+}
+  }
+  StringRef Text = tooling::fixit::getText(ExprNode, Context);
+
+  if (Text.empty())
+return std::string();
+
+  // Remove remaining '->' from overloaded operator call
+  Text.consume_back("->");
+
+  // Add leading '*'.
+  if (needParensAfterUnaryOperator(ExprNode)) {
+return (llvm::Twine("*(") + Text + ")").str();
+  }
+  return (llvm::Twine("*") + Text).str();
+}
+
 } // namespace clang::tidy::utils::fixit
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "RedundantStringCStrCheck.h"
+#include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
@@ -22,49 +23,6 @@
 
 namespace {
 
-// Return true if expr needs to be put in parens when it is an argument of a
-// prefix unary operator, e.g. when it is a binary or ternary operator
-// syntactically.
-bool needParensAfterUnaryOperator(const Expr ) {
-  if (isa() ||
-  isa()) {
-return true;
-  }
-  if (const auto *Op = dyn_cast()) {
-return Op->getNumArgs() == 2 && Op->getOperator() != OO_PlusPlus &&
-   Op->getOperator() != OO_MinusMinus && Op->getOperator() != OO_Call &&
-   Op->getOperator() != OO_Subscript;
-  }
-  return false;
-}
-
-// Format a pointer to an expression: prefix with '*' but simplify
-// when it already begins with '&'.  Return empty string on failure.
-std::string
-formatDereference(const ast_matchers::MatchFinder::MatchResult ,
-  const Expr ) {
-  if (const auto *Op = dyn_cast()) {
-if (Op->getOpcode() == UO_AddrOf) {
-  // Strip leading '&'.
-  return std::string(tooling::fixit::getText(
-  *Op->getSubExpr()->IgnoreParens(), *Result.Context));
-}
-  }
-  StringRef Text = tooling::fixit::getText(ExprNode, *Result.Context);
-
-  if (Text.empty())
-return std::string();
-
-  // Remove remaining '->' from overloaded operator call
-  Text.consume_back("->");
-
-  // Add leading '*'.
-  if (needParensAfterUnaryOperator(ExprNode)) {
-return (llvm::Twine("*(") + 

[PATCH] D152561: [AST] Always set dependent-type for the CallExpr for error-recovery in C.

2023-06-11 Thread Haojian Wu 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 rG752b97129789: [AST] Always set dependent-type for the 
CallExpr for error-recovery in C. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152561

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -93,7 +93,7 @@
   (*__builtin_classify_type)(1);
 
   extern void ext();
-  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK: CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
@@ -117,3 +117,12 @@
   // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
   if (__builtin_va_arg(undef, int) << 1);
 }
+
+void test6_GH50244() {
+  double array[16];
+  // CHECK:  UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' 
contains-errors sizeof
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'int ()'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
+  sizeof array / sizeof foo(undef);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7225,13 +7225,8 @@
 llvm::any_of(ArgExprs,
  [](clang::Expr *E) { return E->containsErrors(); })) 
&&
"should only occur in error-recovery path.");
-QualType ReturnType =
-llvm::isa_and_nonnull(NDecl)
-? cast(NDecl)->getCallResultType()
-: Context.DependentTy;
-return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
-Expr::getValueKindForType(ReturnType), RParenLoc,
-CurFPFeatureOverrides());
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -492,6 +492,9 @@
   (`See patch `_).
 - Fix crash when passing a value larger then 64 bits to the aligned attribute.
   (`#50534 `_).
+- CallExpr built for C error-recovery now is always type-dependent. Fixes a
+  crash when we encounter a unresolved TypoExpr during diagnostic emission.
+  (`#50244 _`).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -93,7 +93,7 @@
   (*__builtin_classify_type)(1);
 
   extern void ext();
-  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK: CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
@@ -117,3 +117,12 @@
   // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
   if (__builtin_va_arg(undef, int) << 1);
 }
+
+void test6_GH50244() {
+  double array[16];
+  // CHECK:  UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' contains-errors sizeof
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'int ()'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
+  sizeof array / sizeof foo(undef);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7225,13 +7225,8 @@
 llvm::any_of(ArgExprs,
  [](clang::Expr *E) { return E->containsErrors(); })) &&
"should only occur in error-recovery path.");
-QualType ReturnType =
-llvm::isa_and_nonnull(NDecl)
-? cast(NDecl)->getCallResultType()
-: Context.DependentTy;
-return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
-Expr::getValueKindForType(ReturnType), RParenLoc,
-CurFPFeatureOverrides());
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, 

[clang] 752b971 - [AST] Always set dependent-type for the CallExpr for error-recovery in C.

2023-06-11 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-06-12T07:04:39+02:00
New Revision: 752b97129789dec1c2b6093bcbf848d6efb14523

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

LOG: [AST] Always set dependent-type for the CallExpr for error-recovery in C.

When build CallExpr for error-recovery where we have any dependent
child nodes), we should set a dependent type for CallExpr to avoid
running into some unexpected following semantic analysis.

This also aligns with the C++ behavior.

This fixes the symptom crashes: 
https://github.com/llvm/llvm-project/issues/50244

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/AST/ast-dump-recovery.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dd31bc6bf3fa3..f0744c5c8310c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -492,6 +492,9 @@ Bug Fixes in This Version
   (`See patch `_).
 - Fix crash when passing a value larger then 64 bits to the aligned attribute.
   (`#50534 `_).
+- CallExpr built for C error-recovery now is always type-dependent. Fixes a
+  crash when we encounter a unresolved TypoExpr during diagnostic emission.
+  (`#50244 _`).
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b41dd0785dc80..ba5077e873c09 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7225,13 +7225,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
 llvm::any_of(ArgExprs,
  [](clang::Expr *E) { return E->containsErrors(); })) 
&&
"should only occur in error-recovery path.");
-QualType ReturnType =
-llvm::isa_and_nonnull(NDecl)
-? cast(NDecl)->getCallResultType()
-: Context.DependentTy;
-return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
-Expr::getValueKindForType(ReturnType), RParenLoc,
-CurFPFeatureOverrides());
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);

diff  --git a/clang/test/AST/ast-dump-recovery.c 
b/clang/test/AST/ast-dump-recovery.c
index 33f0f2ad3c996..969e0e7941244 100644
--- a/clang/test/AST/ast-dump-recovery.c
+++ b/clang/test/AST/ast-dump-recovery.c
@@ -93,7 +93,7 @@ void test3() {
   (*__builtin_classify_type)(1);
 
   extern void ext();
-  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK: CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
@@ -117,3 +117,12 @@ void test5_GH62711() {
   // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
   if (__builtin_va_arg(undef, int) << 1);
 }
+
+void test6_GH50244() {
+  double array[16];
+  // CHECK:  UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' 
contains-errors sizeof
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'int ()'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
+  sizeof array / sizeof foo(undef);
+}



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


[PATCH] D152561: [AST] Always set dependent-type for the CallExpr for error-recovery in C.

2023-06-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 530382.
hokein added a comment.

add release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152561

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -93,7 +93,7 @@
   (*__builtin_classify_type)(1);
 
   extern void ext();
-  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK: CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
@@ -117,3 +117,12 @@
   // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
   if (__builtin_va_arg(undef, int) << 1);
 }
+
+void test6_GH50244() {
+  double array[16];
+  // CHECK:  UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' 
contains-errors sizeof
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'int ()'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
+  sizeof array / sizeof foo(undef);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7225,13 +7225,8 @@
 llvm::any_of(ArgExprs,
  [](clang::Expr *E) { return E->containsErrors(); })) 
&&
"should only occur in error-recovery path.");
-QualType ReturnType =
-llvm::isa_and_nonnull(NDecl)
-? cast(NDecl)->getCallResultType()
-: Context.DependentTy;
-return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
-Expr::getValueKindForType(ReturnType), RParenLoc,
-CurFPFeatureOverrides());
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -492,6 +492,9 @@
   (`See patch `_).
 - Fix crash when passing a value larger then 64 bits to the aligned attribute.
   (`#50534 `_).
+- CallExpr built for C error-recovery now is always type-dependent. Fixes a
+  crash when we encounter a unresolved TypoExpr during diagnostic emission.
+  (`#50244 _`).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -93,7 +93,7 @@
   (*__builtin_classify_type)(1);
 
   extern void ext();
-  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK: CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
@@ -117,3 +117,12 @@
   // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
   if (__builtin_va_arg(undef, int) << 1);
 }
+
+void test6_GH50244() {
+  double array[16];
+  // CHECK:  UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' contains-errors sizeof
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'int ()'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
+  sizeof array / sizeof foo(undef);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7225,13 +7225,8 @@
 llvm::any_of(ArgExprs,
  [](clang::Expr *E) { return E->containsErrors(); })) &&
"should only occur in error-recovery path.");
-QualType ReturnType =
-llvm::isa_and_nonnull(NDecl)
-? cast(NDecl)->getCallResultType()
-: Context.DependentTy;
-return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
-Expr::getValueKindForType(ReturnType), RParenLoc,
-CurFPFeatureOverrides());
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);
Index: clang/docs/ReleaseNotes.rst
===

[PATCH] D152139: [6/6][Clang][RISCV] Replace indexed segment store with tuple type interfaces

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530374.
eopXD added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152139

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg3ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg3ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg3ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg3ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg4ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg4ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg4ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg4ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg5ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg5ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg5ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg5ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg6ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg6ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg6ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg6ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg7ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg7ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg7ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg7ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg8ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg8ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg8ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg8ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg3ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg3ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg3ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg3ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg4ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg4ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg4ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg4ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg5ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg5ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg5ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg5ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg6ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg6ei32.c
  

[PATCH] D152138: [5/6][Clang][RISCV] Replace indexed segment load with tuple type interfaces

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530373.
eopXD added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152138

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg3ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg3ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg3ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg3ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg4ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg4ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg4ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg4ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg5ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg5ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg5ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg5ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg6ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg6ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg6ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg6ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg7ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg7ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg7ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg7ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg8ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg8ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg8ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg8ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg3ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg3ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg3ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg3ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg4ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg4ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg4ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg4ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg5ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg5ei32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg5ei64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg5ei8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg6ei16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg6ei32.c
  

[PATCH] D152137: [4/6][Clang][RISCV] Replace strided segment store with tuple type interfaces

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530371.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152137

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg3e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg3e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg3e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg3e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg4e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg4e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg4e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg4e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg5e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg5e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg5e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg5e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg6e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg6e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg6e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg6e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg7e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg7e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg7e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg7e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg8e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg8e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg8e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg8e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg3e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg3e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg3e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg3e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg4e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg4e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg4e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg4e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg5e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg5e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg5e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg5e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg6e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg6e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg6e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg6e8.c
  

[PATCH] D152136: [3/6][Clang][RISCV] Replace strided segment load with tuple type interfaces

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530370.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152136

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg3e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg3e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg3e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg3e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg4e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg4e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg4e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg4e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg5e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg5e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg5e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg5e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg6e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg6e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg6e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg6e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg7e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg7e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg7e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg7e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg8e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg8e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg8e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg8e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg2e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg2e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg2e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg2e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg3e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg3e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg3e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg3e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg4e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg4e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg4e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg4e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg5e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg5e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg5e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg5e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg6e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg6e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg6e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vlsseg6e8.c
  

[PATCH] D152135: [2/6][Clang][RISCV] Replace unit-stride segment store with tuple type interfaces

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530369.
eopXD added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152135

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg3e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg3e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg3e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg3e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg4e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg4e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg4e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg4e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg5e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg5e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg5e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg5e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg6e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg6e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg6e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg6e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg7e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg7e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg7e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg7e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg8e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg8e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg8e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg8e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg3e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg3e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg3e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg3e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg4e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg4e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg4e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg4e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg5e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg5e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg5e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg5e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg6e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg6e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg6e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg6e8.c
  

[PATCH] D152134: [1/6][Clang][RISCV] Replace unit-stride (fault-first) segment load with tuple type interfaces

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530367.
eopXD added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152134

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e16ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e64ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e8ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e16ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e32ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e64ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg3e8ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e16ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e32ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e64ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg4e8ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e16ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e32ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e64ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg5e8ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e16ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e32ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e64ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg6e8ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg7e16.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg7e16ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg7e32.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg7e32ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg7e64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg7e64ff.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg7e8.c
  

[PATCH] D152079: [11/11][Clang][RISCV] Expand all variants for vset on tuple types

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530364.
eopXD added a comment.
Herald added a subscriber: arphaman.

Remove `vset_tuple.c`. Adjust test case under `vset-index-out-of-range.c`
since the suffix is fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152079

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vset.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c

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


[PATCH] D70401: [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs

2023-06-11 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

In D70401#4411560 , @david-sawatzke 
wrote:

> Thank you for the reply, I've compiled this with the most recent patch and 
> also didn't see a problem (but can't get it running with rustc). Building the 
> .ll with the older patch, the same issue also occurs, so I *do* think its the 
> old patch version?
> Here is the log output for the riscv32e
> F27886013: llvm_output 
>
> (and as a sanity check riscv32i)
> F27886014: llvm_output_riscv32i 
>
> The errant code seems to get introduced here:
>
>   # *** IR Dump After Prologue/Epilogue Insertion & Frame Finalization 
> (prologepilog) ***:
>   # Machine code for function _ZN13miscomp_repro4test17h065760f827b95d43E: 
> NoPHIs, TracksLiveness, NoVRegs, TiedOpsRewritten, TracksDebugUserValues
>   
>   bb.0.start:
> $x2 = frame-destroy ADDI $x8, 0
> PseudoRET

Thanks! It seems that the problem is that we do wrong FP adjustment here.
But, as you can see, this patch does almost nothing to `RISCVFrameLowering`. So 
I think the bug may have been fixed somewhere else (I do remember there is a 
bug fix but I can't remember the differential ID).
So I would suggest you to use newest patch or do some bitsecting to find the 
bug fix commit if you don't bother. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D152078: [10/11][Clang][RISCV] Expand all variants for vget on tuple types

2023-06-11 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530361.
eopXD added a comment.

Remove `vget_tuple.c`. The test cases are collected into `vget.c`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152078

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vget.c

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


[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2023-06-11 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 added a comment.

Hi @PiotrZSL, 
I have made the requested changes. If everything looks good to you would you 
mind committing this patch for me as I don't have commit access to the 
repository. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133244

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


[PATCH] D142388: [clang] Add builtin_nondeterministic_value

2023-06-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I have a concern with the name of this builtin. People are going to assume it 
produces a nondeterministic value, and use it for seeding random number 
generators and similar, and will be surprised when the value produced is 
actually deterministic, and, worse, might leak information on the stack that 
was left behind by some previous function call. Can we give this a name that 
doesn't suggest that it produces its value nondeterministically?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

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


[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2023-06-11 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 530360.
felix642 added a comment.

Updated documentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133244

Files:
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability/container-data-pointer.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- -isystem %clang_tidy_headers -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffixes=,CLASSIC %s readability-container-data-pointer %t -- -- -isystem %clang_tidy_headers -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffixes=,WITH-CONFIG %s readability-container-data-pointer %t -- -config="{CheckOptions: [{key: readability-container-data-pointer.IgnoredContainers, value: '::std::basic_string'}]}" -- -isystem %clang_tidy_headers -fno-delayed-template-parsing
+
 #include 
 
 typedef __SIZE_TYPE__ size_t;
@@ -50,13 +52,15 @@
 void h() {
   std::string s;
   f(&((s).operator[]((z;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
-  // CHECK-FIXES: {{^  }}f(s.data());{{$}}
+  // CHECK-MESSAGES-CLASSIC: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES-CLASSIC: {{^  }}f(s.data());{{$}}
+  // CHECK-MESSAGES-WITH-CONFIG-NOT: :[[@LINE-3]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
 
   std::wstring w;
   f(&((&(w))->operator[]((z;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
-  // CHECK-FIXES: {{^  }}f(w.data());{{$}}
+  // CHECK-MESSAGES-CLASSIC: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES-CLASSIC: {{^  }}f(w.data());{{$}}
+  // CHECK-MESSAGES-WITH-CONFIG-NOT: :[[@LINE-3]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
 }
 
 template ` check with new
+  `IgnoredContainers` option to ignore some containers.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
@@ -28,6 +28,7 @@
 return LO.CPlusPlus11;
   }
 
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
 
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
@@ -35,6 +36,9 @@
   std::optional getCheckTraversalKind() const override {
 return TK_IgnoreUnlessSpelledInSource;
   }
+
+private:
+  const std::vector IgnoredContainers;
 };
 } // namespace clang::tidy::readability
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -8,6 +8,8 @@
 
 #include "ContainerDataPointerCheck.h"
 
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -21,13 +23,22 @@
 "addr-of-container-expr";
 constexpr llvm::StringLiteral AddressOfName = "address-of";
 
+void ContainerDataPointerCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "IgnoredContainers",
+utils::options::serializeStringList(IgnoredContainers));
+}
+
 ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
  ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
+: ClangTidyCheck(Name, Context),
+

[PATCH] D142388: [clang] Add builtin_nondeterministic_value

2023-06-11 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added inline comments.



Comment at: clang/test/CodeGen/builtins-nondeterministic-value.c:26
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca double, align 8
+// CHECK: store double [[X:%.*]], ptr [[A]], align 8

ManuelJBrito wrote:
> zixuan-wu wrote:
> > hi, @ManuelJBrito , because double is 4 alignment in CSKY target, could you 
> > please update this with capture match pattern which makes it more adaptable?
> Hi, I'll make a patch dropping the alignment since it's not relevant for what 
> we are testing here.
Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

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


[clang] abe7ef6 - Make test more flexible for platforms that may emit extra arguments.

2023-06-11 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2023-06-11T17:55:18-07:00
New Revision: abe7ef60957f9d7e1b0fca4f59b4d256a798ba90

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

LOG: Make test more flexible for platforms that may emit extra arguments.

Added: 


Modified: 
clang/test/Driver/hip-options.hip

Removed: 




diff  --git a/clang/test/Driver/hip-options.hip 
b/clang/test/Driver/hip-options.hip
index 1da5ce15ea13c..7a6965caf5e00 100644
--- a/clang/test/Driver/hip-options.hip
+++ b/clang/test/Driver/hip-options.hip
@@ -23,7 +23,7 @@
 
 // Check -mprintf-kind=hostcall
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -mprintf-kind=hostcall  
%s -save-temps 2>&1 | FileCheck -check-prefix=HOSTC %s
-// HOSTC: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-mprintf-kind=hostcall" 
"-Werror=format-invalid-specifier" "-E" {{.*}}
+// HOSTC: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-mprintf-kind=hostcall" 
"-Werror=format-invalid-specifier"{{.*}}"-E" {{.*}}
 // HOSTC: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}} "-mprintf-kind=hostcall" 
"-Werror=format-invalid-specifier" {{.*}}"-x" "hip-cpp-output"
 // HOSTC: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}} "-mprintf-kind=hostcall" 
"-Werror=format-invalid-specifier" {{.*}}"-x" "ir"
 // HOSTC: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}} "-E" {{.*}}
@@ -31,7 +31,7 @@
 
 // Check -mprintf-kind=buffered
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -mprintf-kind=buffered  
%s -save-temps 2>&1 | FileCheck -check-prefix=BUFF %s
-// BUFF: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-mprintf-kind=buffered" 
"-Werror=format-invalid-specifier" "-E" {{.*}}
+// BUFF: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-mprintf-kind=buffered" 
"-Werror=format-invalid-specifier"{{.*}}"-E" {{.*}}
 // BUFF: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}} "-mprintf-kind=buffered" 
"-Werror=format-invalid-specifier" {{.*}}"-x" "hip-cpp-output"
 // BUFF: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}} "-mprintf-kind=buffered" 
"-Werror=format-invalid-specifier" {{.*}}"-x" "ir"
 // BUFF: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}} "-E" {{.*}}



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


[PATCH] D143971: [clang-tidy] Flag more buggy string constructor cases

2023-06-11 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

Thanks, fixed the first false positive example you gave. Let me think about the 
second example in your most recent post:

  char c = '\n';
  using Size = int;
  Size size = 10U;
  std::string str2(c, size);

This is my newly added case `swapped4`, where one of my original intents was to 
flag this code as "swapped."  I can see the the ambiguity. Worst case, 
"confusing string fill constructor arguments" is the fallback that I think is 
acceptable, and still achieves the goal of at least flagging the code as 
potentially buggy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143971

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


[PATCH] D143971: [clang-tidy] Flag more buggy string constructor cases

2023-06-11 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 530349.
ccotter added a comment.

- Exclude false positive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143971

Files:
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
@@ -5,12 +5,13 @@
 class allocator {};
 template 
 class char_traits {};
-template , typename A = std::allocator >
+template , typename A = std::allocator>
 struct basic_string {
   basic_string();
-  basic_string(const C*, unsigned int size);
-  basic_string(const C *, const A  = A());
-  basic_string(unsigned int size, C c);
+  basic_string(const basic_string&, unsigned int, unsigned int, const A & = A());
+  basic_string(const C*, unsigned int);
+  basic_string(const C*, const A& = A());
+  basic_string(unsigned int, C);
 };
 typedef basic_string string;
 typedef basic_string wstring;
@@ -18,7 +19,7 @@
 template >
 struct basic_string_view {
   basic_string_view();
-  basic_string_view(const C *, unsigned int size);
+  basic_string_view(const C *, unsigned int);
   basic_string_view(const C *);
 };
 typedef basic_string_view string_view;
@@ -28,20 +29,76 @@
 const char* kText = "";
 const char kText2[] = "";
 extern const char kText3[];
+char getChar();
+const char* getCharPtr();
+
+struct CharLikeObj {
+  operator char() const;
+};
+
+unsigned char getUChar();
 
 void Test() {
-  std::string str('x', 4);
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [bugprone-string-constructor]
-  // CHECK-FIXES: std::string str(4, 'x');
-  std::wstring wstr(L'x', 4);
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor parameters are probably swapped
-  // CHECK-FIXES: std::wstring wstr(4, L'x');
+  short sh;
+  int i;
+  int& ref_i = i;
+  char ch;
+  CharLikeObj char_like_obj;
+
+  std::string swapped('x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped(4, 'x');
+  std::wstring wswapped(L'x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::wstring wswapped(4, L'x');
+  std::string swapped2('x', i);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped2(i, 'x');
+  std::string swapped3(ch, 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped3(4, ch);
+  std::string swapped4(ch, i);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped4(i, ch);
+  std::string swapped5('x', (int)'x');
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped5((int)'x', 'x');
+  std::string swapped6(getChar(), 10);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped6(10, getChar());
+  std::string swapped7((('x')), ( i ));
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped7(( i ), (('x')));
+  std::string swapped8((ch), (i));
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped8((i), (ch));
+  std::string swapped9((getChar()), (i));
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments are probably swapped; expecting string(count, character) [bugprone-string-constructor]
+  // CHECK-FIXES: std::string swapped9((i), (getChar()));
   std::string s0(0, 'x');
   // CHECK-MESSAGES: [[@LINE-1]]:15: 

[PATCH] D152443: Add operator style options to clang-format

2023-06-11 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex updated this revision to Diff 530348.
KitsuneAlex marked 2 inline comments as done.
KitsuneAlex added a comment.

Fix broken style in TokenAnnotator.cpp. I don't know how i keep missing these, 
trying to get better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22885,6 +22885,130 @@
Spaces);
 }
 
+TEST_F(FormatTest, SpaceAfterOperatorCall) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool operator==() = default;", Style);
+  verifyFormat("bool Foo::operator==() = default;", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  verifyFormat("operator==();", Style);
+  verifyFormat("Foo::operator==();", Style);
+  verifyFormat("Bar{var, operator==()};", Style);
+  verifyFormat("Bar{var, Foo::operator==()};", Style);
+  verifyFormat("Bar(var, operator==());", Style);
+  verifyFormat("Bar(var, Foo::operator==());", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat(">operator==();", Style);
+  verifyFormat(">Foo::operator==();", Style);
+
+  Style.SpaceAfterOperatorCall = true;
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool operator==() = default;", Style);
+  verifyFormat("bool Foo::operator==() = default;", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator ==();", Style);
+  verifyFormat("foo.Foo::operator ==();", Style);
+  verifyFormat("foo->operator ==();", Style);
+  verifyFormat("foo->Foo::operator ==();", Style);
+  verifyFormat("operator ==();", Style);
+  verifyFormat("Foo::operator ==();", Style);
+  verifyFormat("Bar{var, operator ==()};", Style);
+  verifyFormat("Bar{var, Foo::operator ==()};", Style);
+  verifyFormat("Bar(var, operator ==());", Style);
+  verifyFormat("Bar(var, Foo::operator ==());", Style);
+  verifyFormat(" ==();", Style);
+  verifyFormat("::operator ==();", Style);
+  verifyFormat(" ==();", Style);
+  verifyFormat("::operator ==();", Style);
+  verifyFormat(">operator ==();", Style);
+  verifyFormat(">Foo::operator ==();", Style);
+}
+
+TEST_F(FormatTest, SpaceAfterOperatorOverload) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool operator==() = default;", Style);
+  verifyFormat("bool Foo::operator==() = default;", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  verifyFormat("operator==();", Style);
+  verifyFormat("Foo::operator==();", Style);
+  verifyFormat("Bar{var, operator==()};", Style);
+  verifyFormat("Bar{var, Foo::operator==()};", Style);
+  verifyFormat("Bar(var, operator==());", Style);
+  verifyFormat("Bar(var, Foo::operator==());", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat("==();", Style);
+  

[clang] 63bd6d9 - [Driver] Default to -fxray-function-index

2023-06-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-11T15:38:13-07:00
New Revision: 63bd6d9e644335c8138a59281aafbf65a82fc47a

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

LOG: [Driver] Default to -fxray-function-index

As explained by commit 849f1dd15e92fda2b83dbb6144e6b28b2cb946e0,
-fxray-function-index was the original default but was accidentally flipped by
commit d8a8e5d6240a1db809cd95106910358e69bbf299. Restore the previous behavior.

Originally reported by Oleksii Lozovskyi in D145848.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/XRayArgs.cpp
clang/test/CodeGen/xray-function-index.c
clang/test/Driver/xray-function-index.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index abb3254188aff..36baebed78099 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2216,9 +2216,9 @@ defm xray_ignore_loops : BoolFOption<"xray-ignore-loops",
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayFunctionIndex">, DefaultFalse,
-  PosFlag,
-  NegFlag, DefaultTrue,
+  PosFlag,
+  NegFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 89aeb20aa68cd..f15a91f1aba44 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -178,8 +178,8 @@ void XRayArgs::addArgs(const ToolChain , const ArgList 
,
 options::OPT_fno_xray_always_emit_typedevents);
   Args.addOptInFlag(CmdArgs, options::OPT_fxray_ignore_loops,
 options::OPT_fno_xray_ignore_loops);
-  Args.addOptInFlag(CmdArgs, options::OPT_fxray_function_index,
-options::OPT_fno_xray_function_index);
+  Args.addOptOutFlag(CmdArgs, options::OPT_fxray_function_index,
+ options::OPT_fno_xray_function_index);
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_fxray_instruction_threshold_EQ)) {

diff  --git a/clang/test/CodeGen/xray-function-index.c 
b/clang/test/CodeGen/xray-function-index.c
index bdaef655abcfc..0b18c2a530247 100644
--- a/clang/test/CodeGen/xray-function-index.c
+++ b/clang/test/CodeGen/xray-function-index.c
@@ -1,6 +1,6 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 -fxray-function-index %s -o - | FileCheck %s
-// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 %s -o - | FileCheck %s --check-prefix=NO
+// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 -fno-xray-function-index %s -o - | FileCheck %s 
--check-prefix=NO
 
 // CHECK: .section xray_fn_idx,"awo",@progbits,foo
 // NO-NOT: .section xray_fn_idx

diff  --git a/clang/test/Driver/xray-function-index.cpp 
b/clang/test/Driver/xray-function-index.cpp
index 550de3d17305a..6cc8d47c638c6 100644
--- a/clang/test/Driver/xray-function-index.cpp
+++ b/clang/test/Driver/xray-function-index.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang -### -c --target=x86_64 -fxray-instrument -fxray-function-index 
%s 2>&1 | FileCheck %s
-// RUN: %clang -### -c --target=x86_64 -fxray-instrument %s 2>&1 | FileCheck 
%s --check-prefix=DISABLED
+// RUN: %clang -### -c --target=x86_64 -fxray-instrument %s 2>&1 | FileCheck %s
+// RUN: %clang -### -c --target=x86_64 -fxray-instrument -fxray-function-index 
-fno-xray-function-index %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 
-// CHECK:  "-fxray-function-index"
-// DISABLED-NOT: "-fxray-function-index"
+// CHECK-NOT:  "-fxray-function-index"
+// DISABLED:   "-fno-xray-function-index"



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


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2219
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlaghttps://reviews.llvm.org/D145848/new/

https://reviews.llvm.org/D145848

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


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This option has undergone several refactorings and got inverted along the 
> way. The XRayOmitFunctionIndex flag governs codegen behavior, *omitting* 
> "xray_fn_idx" section if it is set. But the command-line flag behavior was 
> not adjusted at the time. Right now it's like this:

d8a8e5d6240a1db809cd95106910358e69bbf299 
 
accidentally omitted `xray_fn_idx` by default.
I pushed 849f1dd15e92fda2b83dbb6144e6b28b2cb946e0 
 to rename 
the confusing `XRayOmitFunctionIndex` and fix 
-fno-xray-function-index/-fxray-function-index.


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

https://reviews.llvm.org/D145848

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


[clang] 849f1dd - [XRay] Rename XRayOmitFunctionIndex to XRayFunctionIndex

2023-06-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-11T15:27:22-07:00
New Revision: 849f1dd15e92fda2b83dbb6144e6b28b2cb946e0

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

LOG: [XRay] Rename XRayOmitFunctionIndex to XRayFunctionIndex

Apply my post-commit comment on D81995. The negative name misguided commit
d8a8e5d6240a1db809cd95106910358e69bbf299 (`[clang][cli] Remove marshalling from
Opt{In,Out}FFlag`) to:

* accidentally flip the option to not emit the xray_fn_idx section.
* change -fno-xray-function-index (instead of -fxray-function-index) to emit 
xray_fn_idx

This patch renames XRayOmitFunctionIndex and makes -fxray-function-index emit
xray_fn_idx, but the default remains -fno-xray-function-index .

Added: 
clang/test/CodeGen/xray-function-index.c
clang/test/Driver/xray-function-index.cpp

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/XRayArgs.cpp
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/CommandFlags.cpp
llvm/test/CodeGen/AArch64/xray-omit-function-index.ll

Removed: 
clang/test/Driver/XRay/xray-function-index-flags.cpp



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 9cd911e7fce14..c45fb132685c2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -130,8 +130,8 @@ CODEGENOPT(XRayAlwaysEmitTypedEvents , 1, 0)
 ///< Set when -fxray-ignore-loops is enabled.
 CODEGENOPT(XRayIgnoreLoops , 1, 0)
 
-///< Set with -fno-xray-function-index to omit the index section.
-CODEGENOPT(XRayOmitFunctionIndex , 1, 0)
+///< Emit the XRay function index section.
+CODEGENOPT(XRayFunctionIndex , 1, 1)
 
 
 ///< Set the minimum number of instructions in a function to determine 
selective

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3a8b03c4159d1..abb3254188aff 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2216,10 +2216,10 @@ defm xray_ignore_loops : 
BoolFOption<"xray-ignore-loops",
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag,
-  PosFlag>;
+  CodeGenOpts<"XRayFunctionIndex">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index c736f38e01f65..73cd4a62f5d3e 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -429,7 +429,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
   Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
   Options.EnableAIXExtendedAltivecABI = LangOpts.EnableAIXExtendedAltivecABI;
-  Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
+  Options.XRayFunctionIndex = CodeGenOpts.XRayFunctionIndex;
   Options.LoopAlignment = CodeGenOpts.LoopAlignment;
   Options.DebugStrictDwarf = CodeGenOpts.DebugStrictDwarf;
   Options.ObjectFilenameForDebug = CodeGenOpts.ObjectFilenameForDebug;

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index f15a91f1aba44..89aeb20aa68cd 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -178,8 +178,8 @@ void XRayArgs::addArgs(const ToolChain , const ArgList 
,
 options::OPT_fno_xray_always_emit_typedevents);
   Args.addOptInFlag(CmdArgs, options::OPT_fxray_ignore_loops,
 options::OPT_fno_xray_ignore_loops);
-  Args.addOptOutFlag(CmdArgs, options::OPT_fxray_function_index,
- options::OPT_fno_xray_function_index);
+  Args.addOptInFlag(CmdArgs, options::OPT_fxray_function_index,
+options::OPT_fno_xray_function_index);
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_fxray_instruction_threshold_EQ)) {

diff  --git a/clang/test/CodeGen/xray-function-index.c 
b/clang/test/CodeGen/xray-function-index.c
new file mode 100644
index 0..bdaef655abcfc
--- /dev/null
+++ b/clang/test/CodeGen/xray-function-index.c
@@ -0,0 +1,8 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 -fxray-function-index %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 %s -o - | FileCheck %s --check-prefix=NO
+
+// CHECK: .section 

[PATCH] D152443: Add operator style options to clang-format

2023-06-11 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex updated this revision to Diff 530346.
KitsuneAlex marked 4 inline comments as done.
KitsuneAlex added a comment.

Added missing test case for default operator declarations as requested, as well 
as blank lines between the blocks inside the test functions
as visual separators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22885,6 +22885,130 @@
Spaces);
 }
 
+TEST_F(FormatTest, SpaceAfterOperatorCall) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool operator==() = default;", Style);
+  verifyFormat("bool Foo::operator==() = default;", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  verifyFormat("operator==();", Style);
+  verifyFormat("Foo::operator==();", Style);
+  verifyFormat("Bar{var, operator==()};", Style);
+  verifyFormat("Bar{var, Foo::operator==()};", Style);
+  verifyFormat("Bar(var, operator==());", Style);
+  verifyFormat("Bar(var, Foo::operator==());", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat(">operator==();", Style);
+  verifyFormat(">Foo::operator==();", Style);
+
+  Style.SpaceAfterOperatorCall = true;
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool operator==() = default;", Style);
+  verifyFormat("bool Foo::operator==() = default;", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator ==();", Style);
+  verifyFormat("foo.Foo::operator ==();", Style);
+  verifyFormat("foo->operator ==();", Style);
+  verifyFormat("foo->Foo::operator ==();", Style);
+  verifyFormat("operator ==();", Style);
+  verifyFormat("Foo::operator ==();", Style);
+  verifyFormat("Bar{var, operator ==()};", Style);
+  verifyFormat("Bar{var, Foo::operator ==()};", Style);
+  verifyFormat("Bar(var, operator ==());", Style);
+  verifyFormat("Bar(var, Foo::operator ==());", Style);
+  verifyFormat(" ==();", Style);
+  verifyFormat("::operator ==();", Style);
+  verifyFormat(" ==();", Style);
+  verifyFormat("::operator ==();", Style);
+  verifyFormat(">operator ==();", Style);
+  verifyFormat(">Foo::operator ==();", Style);
+}
+
+TEST_F(FormatTest, SpaceAfterOperatorOverload) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool operator==() = default;", Style);
+  verifyFormat("bool Foo::operator==() = default;", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  verifyFormat("operator==();", Style);
+  verifyFormat("Foo::operator==();", Style);
+  verifyFormat("Bar{var, operator==()};", Style);
+  verifyFormat("Bar{var, Foo::operator==()};", Style);
+  verifyFormat("Bar(var, operator==());", Style);
+  verifyFormat("Bar(var, Foo::operator==());", Style);
+  verifyFormat("==();", Style);
+  

[PATCH] D152443: Add operator style options to clang-format

2023-06-11 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex updated this revision to Diff 530343.
KitsuneAlex added a comment.

Revamped the formatting logic again and added the requested unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22885,6 +22885,120 @@
Spaces);
 }
 
+TEST_F(FormatTest, SpaceAfterOperatorCall) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  verifyFormat("operator==();", Style);
+  verifyFormat("Foo::operator==();", Style);
+  verifyFormat("Bar{var, operator==()};", Style);
+  verifyFormat("Bar{var, Foo::operator==()};", Style);
+  verifyFormat("Bar(var, operator==());", Style);
+  verifyFormat("Bar(var, Foo::operator==());", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat(">operator==();", Style);
+  verifyFormat(">Foo::operator==();", Style);
+  Style.SpaceAfterOperatorCall = true;
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator ==();", Style);
+  verifyFormat("foo.Foo::operator ==();", Style);
+  verifyFormat("foo->operator ==();", Style);
+  verifyFormat("foo->Foo::operator ==();", Style);
+  verifyFormat("operator ==();", Style);
+  verifyFormat("Foo::operator ==();", Style);
+  verifyFormat("Bar{var, operator ==()};", Style);
+  verifyFormat("Bar{var, Foo::operator ==()};", Style);
+  verifyFormat("Bar(var, operator ==());", Style);
+  verifyFormat("Bar(var, Foo::operator ==());", Style);
+  verifyFormat(" ==();", Style);
+  verifyFormat("::operator ==();", Style);
+  verifyFormat(" ==();", Style);
+  verifyFormat("::operator ==();", Style);
+  verifyFormat(">operator ==();", Style);
+  verifyFormat(">Foo::operator ==();", Style);
+}
+
+TEST_F(FormatTest, SpaceAfterOperatorOverload) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("bool *operator==();", Style);
+  verifyFormat("bool *Foo::operator==();", Style);
+  verifyFormat("bool ==();", Style);
+  verifyFormat("bool ::operator==();", Style);
+  verifyFormat("bool &==();", Style);
+  verifyFormat("bool &::operator==();", Style);
+  verifyFormat("std::vector operator==();", Style);
+  verifyFormat("std::vector Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  verifyFormat("operator==();", Style);
+  verifyFormat("Foo::operator==();", Style);
+  verifyFormat("Bar{var, operator==()};", Style);
+  verifyFormat("Bar{var, Foo::operator==()};", Style);
+  verifyFormat("Bar(var, operator==());", Style);
+  verifyFormat("Bar(var, Foo::operator==());", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat("==();", Style);
+  verifyFormat("::operator==();", Style);
+  verifyFormat(">operator==();", Style);
+  verifyFormat(">Foo::operator==();", Style);
+  Style.SpaceAfterOperatorOverload = true;
+  verifyFormat("bool operator ==();", Style);
+  verifyFormat("bool Foo::operator ==();", Style);
+  verifyFormat("bool *operator ==();", Style);
+  verifyFormat("bool *Foo::operator ==();", Style);
+  verifyFormat("bool  ==();", Style);
+  

[PATCH] D152658: [InstCombine] Change SimplifyDemandedVectorElts to use PoisonElts instead of UndefElts

2023-06-11 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added inline comments.



Comment at: llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp:3102-3105
   case Intrinsic::x86_sse4a_extrqi:
   case Intrinsic::x86_sse4a_insertq:
   case Intrinsic::x86_sse4a_insertqi:
+PoisonElts.setHighBits(VWidth / 2);

this change doesn't look correct. The bits are undefined, doesn't seem like you 
can use poison here.



Comment at: llvm/test/Transforms/InstCombine/vec_shuffle.ll:1301
 ; CHECK-LABEL: @fmul_splat_constant(
-; CHECK-NEXT:[[TMP1:%.*]] = fmul <2 x float> [[X:%.*]], 
-; CHECK-NEXT:[[R:%.*]] = shufflevector <2 x float> [[TMP1]], <2 x float> 
poison, <2 x i32> zeroinitializer
+  ; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x 
float> undef, <2 x i32> zeroinitializer
+; CHECK-NEXT:[[R:%.*]] = fmul <2 x float> [[TMP1]], 

Why does it regress here (goes from poison to undef)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152658

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


[PATCH] D152246: [clang][ThreadSafety] Analyze known function pointer values

2023-06-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

That's a tough one. The change seems to be correct, and makes more patterns 
visible. Of course I wonder how it comes that we see calls of a function 
pointer with a uniquely determined value, as that would seem like obfuscation. 
Maybe you can show an example how this might look like in practice?

Another issue (that of course you can't know about) is that I'm not sure about 
the `LocalVariableMap`. It's currently only used to find a try-acquire function 
return value from a branch, not in the core analysis and can apparently be 
quite expensive  for long 
functions with exception handling edges. I'd like to get rid of it, unless we 
decide to use it for resolving aliases more widely. But I'm wary of alias 
analysis, because we don't want to reimplement the static analyzer, and we also 
want to be more predictable, maybe even provide correctness guarantees. Alias 
analysis ends in undecidable territory quite early on, and using heuristics 
would sacrifice predictability.

The relatively strict "dumb" analysis that we're doing today seems to work well 
enough for the purpose of tracking locks, though we can look through local 
references. (Their pointee doesn't change. Though it doesn't always work 
.) My hope would be that we 
can leave it at that and don't build a fully-fledged alias analysis.

I'd like if we could address the issue here by moving to type attributes. These 
would of course be "sugar", i.e. dropped on canonicalization, as we don't want 
them to affect overloading etc. But that would still allow more than 
declaration attributes, like in this case, warning if we drop the attribute on 
assignment. Of course that's big project though, and it's not clear if it'll 
work out. The paper 

 by @delesley and @aaron.ballman briefly says that non-sugared attributes would 
probably not work, and there is a talk 
 where @delesley says basically 
"we'd really like to integrate this into the type system, but it would be quite 
difficult".


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

https://reviews.llvm.org/D152246

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


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

2023-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This is a kinda odd case. Normally we should enable the option in the driver 
when the feature actually works.
However, `Triple.isMacOSX()` is allowed before the feature actually works and 
`compiler-rt/test/xray/lit.cfg.py` tests it.

`clang/test/Driver/XRay/` is broken and does not follow the practice testing 
driver changes.
`clang/test/Driver` should not test code generation but `XRay/` tests do.

The targets aren't really enabled since `REQUIRES: aarch64 || x86_64 || 
x86_64h` lines specified lit features aren't available.




Comment at: clang/lib/Driver/XRayArgs.cpp:66
+default:
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());

The file was written in a non-conventional way. I just cleaned up the file a 
bit.


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

https://reviews.llvm.org/D145849

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


[clang] 706c442 - [CodeGen] Use DenseMapBase::lookup (NFC)

2023-06-11 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-06-11T13:19:26-07:00
New Revision: 706c442e72320a144da642aca8c59adb5bc2c858

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

LOG: [CodeGen] Use DenseMapBase::lookup (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index d52e560234bdf..319d6c52d1900 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -5293,12 +5293,7 @@ llvm::Constant *CGObjCCommonMac::GetClassName(StringRef 
RuntimeName) {
 }
 
 llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) 
{
-  llvm::DenseMap::iterator
-  I = MethodDefinitions.find(MD);
-  if (I != MethodDefinitions.end())
-return I->second;
-
-  return nullptr;
+  return MethodDefinitions.lookup(MD);
 }
 
 /// GetIvarLayoutName - Returns a unique constant for the given

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 74f8c19e1bc7e..84907bdd37630 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -485,10 +485,7 @@ class CheckVarsEscapingDeclContext final
   const FieldDecl *getFieldForGlobalizedVar(const ValueDecl *VD) const {
 assert(GlobalizedRD &&
"Record for globalized variables must be generated already.");
-auto I = MappedDeclsFields.find(VD);
-if (I == MappedDeclsFields.end())
-  return nullptr;
-return I->getSecond();
+return MappedDeclsFields.lookup(VD);
   }
 
   /// Returns the list of the escaped local variables/parameters.



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


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/xray-function-index.cpp:1
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -fxray-instrument  -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-ENABLED

We generally want to avoid assembly output tests in clang/test.

However, `CodeGenOpts.XRayOmitFunctionIndex` only affects 
`llvm::TargetOptions`, not LLVM IR, so I think this seems fine.

(Note: a lot of xray tests do not follow the best practice, and we should be 
careful for new tests, not necessarily copying the old xray testing practice.)



Comment at: clang/test/CodeGen/xray-function-index.cpp:2
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -fxray-instrument  -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-DISABLED

We don't usually do `   ` alignment  like this. You may place `-S` 
earlier to make the compile action (emit assembly) clearer.


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

https://reviews.llvm.org/D145848

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


[PATCH] D148088: [RFC][clangd] Move preamble index out of document open critical path

2023-06-11 Thread Kugan Vivekanandarajah via Phabricator via cfe-commits
kuganv updated this revision to Diff 530328.
kuganv marked 6 inline comments as done.
kuganv added a comment.

Updated based on the review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148088

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestWorkspace.cpp
  clang/include/clang/Frontend/CompilerInstance.h

Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Frontend/Utils.h"
@@ -233,6 +234,8 @@
 return *Invocation;
   }
 
+  std::shared_ptr getInvocationPtr() { return Invocation; }
+
   /// setInvocation - Replace the current invocation.
   void setInvocation(std::shared_ptr Value);
 
@@ -338,6 +341,11 @@
 return *Diagnostics;
   }
 
+  IntrusiveRefCntPtr getDiagnosticsPtr() const {
+assert(Diagnostics && "Compiler instance has no diagnostics!");
+return Diagnostics;
+  }
+
   /// setDiagnostics - Replace the current diagnostics engine.
   void setDiagnostics(DiagnosticsEngine *Value);
 
@@ -373,6 +381,11 @@
 return *Target;
   }
 
+  IntrusiveRefCntPtr getTargetPtr() const {
+assert(Target && "Compiler instance has no target!");
+return Target;
+  }
+
   /// Replace the current Target.
   void setTarget(TargetInfo *Value);
 
@@ -406,6 +419,11 @@
 return *FileMgr;
   }
 
+  IntrusiveRefCntPtr getFileManagerPtr() const {
+assert(FileMgr && "Compiler instance has no file manager!");
+return FileMgr;
+  }
+
   void resetAndLeakFileManager() {
 llvm::BuryPointer(FileMgr.get());
 FileMgr.resetWithoutRelease();
@@ -426,6 +444,11 @@
 return *SourceMgr;
   }
 
+  IntrusiveRefCntPtr getSourceManagerPtr() const {
+assert(SourceMgr && "Compiler instance has no source manager!");
+return SourceMgr;
+  }
+
   void resetAndLeakSourceManager() {
 llvm::BuryPointer(SourceMgr.get());
 SourceMgr.resetWithoutRelease();
@@ -466,6 +489,11 @@
 return *Context;
   }
 
+  IntrusiveRefCntPtr getASTContextPtr() const {
+assert(Context && "Compiler instance has no AST context!");
+return Context;
+  }
+
   void resetAndLeakASTContext() {
 llvm::BuryPointer(Context.get());
 Context.resetWithoutRelease();
Index: clang-tools-extra/clangd/unittests/TestWorkspace.cpp
===
--- clang-tools-extra/clangd/unittests/TestWorkspace.cpp
+++ clang-tools-extra/clangd/unittests/TestWorkspace.cpp
@@ -21,11 +21,14 @@
   continue;
 TU.Code = Input.second.Code;
 TU.Filename = Input.first().str();
-TU.preamble([&](ASTContext , Preprocessor ,
-const CanonicalIncludes ) {
-  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
-CanonIncludes);
-});
+TU.preamble(
+[&](CapturedASTCtx ASTCtx,
+const std::shared_ptr CanonIncludes) {
+  auto  = ASTCtx.getASTContext();
+  auto  = ASTCtx.getPreprocessor();
+  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
+*CanonIncludes);
+});
 ParsedAST MainAST = TU.build();
 Index->updateMain(testPath(Input.first()), MainAST);
   }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1129,9 +1129,9 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification )
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version,
-   const CompilerInvocation &, ASTContext ,
-   Preprocessor &, const CanonicalIncludes &) override {
+void
+onPreambleAST(PathRef Path, llvm::StringRef Version, CapturedASTCtx,
+  const std::shared_ptr) override {
   if (Version == BlockVersion)
 N.wait();
 }
@@ -1208,9 +1208,9 @@
 BlockPreambleThread(Notification , DiagsCB CB)
 

[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-06-11 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

After I came across some of my code, where I'd really like a feature like this, 
I'm back at wishing to align the colons. Same as in a bit field. And when you 
would do that I think there would be no open issue with empty statements, right?

So for my code I'd favor

  switch (level) {
  case log::info: return "info: ";
  case log::warning : return "warning:  ";
  case log::error   : return "error:";
  case log::critical: return "critical: ";
  default   : return "";
  }

over

  switch (level) {
  case log::info: return "info: ";
  case log::warning:  return "warning:  ";
  case log::error:return "error:";
  case log::critical: return "critical: ";
  default:return "";
  }

(For me actually there would always be at least one space before the colon.)
Maybe think about it?


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

https://reviews.llvm.org/D151761

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


[PATCH] D152443: Add SpaceAfterOperatorKeyword & SpaceAfterOperatorKeywordInCall style options for clang-format

2023-06-11 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D152443#4412069 , @KitsuneAlex 
wrote:

> This revision of the diff changes the names of the new style options to 
> **SpaceAfterOperatorOverload** and **SpaceAfterOperatorCall**, which 
> clarifies their scope a lot better i think.
> I also rewrote the logic to apply formatting that fits exactly what their 
> name implies respectively,
> the new tests i added should cover all common use cases (except i forgot some 
> again).

Two cases missing: `operator==()` (Calling within a class), and what happens 
when taking the address `==`? (With and without qualification.)




Comment at: clang/unittests/Format/FormatTest.cpp:22916
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);

Nice to check for that too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

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


[PATCH] D152547: [clang][NFC] Drop alignment in builtin-nondeterministic-value test

2023-06-11 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito updated this revision to Diff 530321.
ManuelJBrito added a comment.

Completely drop alignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152547

Files:
  clang/test/CodeGen/builtins-nondeterministic-value.c


Index: clang/test/CodeGen/builtins-nondeterministic-value.c
===
--- clang/test/CodeGen/builtins-nondeterministic-value.c
+++ clang/test/CodeGen/builtins-nondeterministic-value.c
@@ -5,8 +5,8 @@
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i32, align 4
-// CHECK: store i32 [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca i32
+// CHECK: store i32 [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i32 poison
 // CHECK: ret i32 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -14,8 +14,8 @@
 
 float clang_nondet_f( float x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca float, align 4
-// CHECK: store float [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca float
+// CHECK: store float [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze float poison
 // CHECK: ret float [[R]]
   return __builtin_nondeterministic_value(x);
@@ -23,8 +23,8 @@
 
 double clang_nondet_d( double x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca double, align 8
-// CHECK: store double [[X:%.*]], ptr [[A]], align 8
+// CHECK: [[A:%.*]] = alloca double
+// CHECK: store double [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze double poison
 // CHECK: ret double [[R]]
   return __builtin_nondeterministic_value(x);
@@ -32,9 +32,9 @@
 
 _Bool clang_nondet_b( _Bool x) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[B:%.*]] = zext i1 %x to i8
-// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: store i8 [[B]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i1 poison
 // CHECK: ret i1 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -42,19 +42,19 @@
 
 void clang_nondet_fv( ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca <4 x float>, align
+// CHECK: [[A:%.*]] = alloca <4 x float>
 // CHECK: [[R:%.*]] = freeze <4 x float> poison
-// CHECK: store <4 x float> [[R]], ptr [[A]], align
+// CHECK: store <4 x float> [[R]], ptr [[A]]
 // CHECK: ret void
   float4 x = __builtin_nondeterministic_value(x);
 }
 
 void clang_nondet_bv( ) {
-// CHECK: [[A:%.*]] = alloca i8, align
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[V:%.*]] = freeze <4 x i1> poison
 // CHECK: [[SV:%.*]] = shufflevector <4 x i1> [[V]], <4 x i1> poison, <8 x 
i32> 
 // CHECK: [[BC:%.*]] = bitcast <8 x i1> [[SV]] to i8
-// CHECK: store i8 [[BC]], ptr [[A]], align
+// CHECK: store i8 [[BC]], ptr [[A]]
 // CHECK: ret void
   bool4 x = __builtin_nondeterministic_value(x);
 }


Index: clang/test/CodeGen/builtins-nondeterministic-value.c
===
--- clang/test/CodeGen/builtins-nondeterministic-value.c
+++ clang/test/CodeGen/builtins-nondeterministic-value.c
@@ -5,8 +5,8 @@
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i32, align 4
-// CHECK: store i32 [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca i32
+// CHECK: store i32 [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i32 poison
 // CHECK: ret i32 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -14,8 +14,8 @@
 
 float clang_nondet_f( float x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca float, align 4
-// CHECK: store float [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca float
+// CHECK: store float [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze float poison
 // CHECK: ret float [[R]]
   return __builtin_nondeterministic_value(x);
@@ -23,8 +23,8 @@
 
 double clang_nondet_d( double x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca double, align 8
-// CHECK: store double [[X:%.*]], ptr [[A]], align 8
+// CHECK: [[A:%.*]] = alloca double
+// CHECK: store double [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze double poison
 // CHECK: ret double [[R]]
   return __builtin_nondeterministic_value(x);
@@ -32,9 +32,9 @@
 
 _Bool clang_nondet_b( _Bool x) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[B:%.*]] = zext i1 %x to i8
-// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: store i8 [[B]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i1 poison
 // CHECK: ret i1 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -42,19 +42,19 @@
 
 void clang_nondet_fv( ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca <4 x float>, align
+// CHECK: [[A:%.*]] = alloca <4 x float>
 // CHECK: [[R:%.*]] = freeze <4 x float> poison
-// CHECK: store <4 x float> [[R]], ptr [[A]], align
+// CHECK: store <4 x float> [[R]], ptr [[A]]
 // CHECK: ret void
   float4 x = __builtin_nondeterministic_value(x);

[PATCH] D148461: [clang-tidy] Support C++17/20 in bugprone-exception-escape

2023-06-11 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:306
+
+  if (From->isMemberPointerType() || To->isMemberPointerType())
 return false;

PiotrZSL wrote:
> isuckatcs wrote:
> > isuckatcs wrote:
> > > Please cover this line with both positive and negative test cases.
> > > 
> > > Also upon looking up both [[ 
> > > https://www.open-std.org/jtc1/sc22/wg21/docs/standards | N4849 ]] (C++ 20 
> > > draft) and [[ https://github.com/cplusplus/draft/releases | N4917]] (C++ 
> > > 23 draft), they both say for qualification conversion that 
> > > 
> > > 
> > > > each P_i is ... pointer to member of class C_i of type, ...
> > > 
> > > Why are we not allowing them if the standard is at least C++ 20?
> > Please resolve this thread.
> Positive case is tested by throw_basefn_catch_derivedfn test and 
> throw_derivedfn_catch_basefn.
> Negative is covered by throw_basefn_catch_basefn.
> 
> For members there are tests throw_basem_catch_basem, 
> throw_basem_catch_derivedm, throw_derivedm_catch_basem that also covers this 
> correctly.
> 
> Tested this with GCC, and behavior is proper and independent to C++ standard.
> Tested this with GCC, and behavior is proper and independent to C++ standard.

I don't know how to deal with this tbh. In a static analyzer we usually want to 
consider what the standard says and not what a specific compiler implementation 
does, as the compiler can still be buggy, lack the proper support for the 
standard, etc.

Maybe we can add a FIXME here that explains, why this check is here and that 
it's the opposite of what the standard says. Then later if it causes issues, it 
will be easy to see why that happens.

@xazax.hun do you have a prefered method to deal with these situations in the 
analyzer? If there is one, we could also try it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148461

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


[clang] c6e065e - [Driver] Simplify xray options

2023-06-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-11T12:03:08-07:00
New Revision: c6e065ef22c29a341dcc764f8f6ed9ab5ec1c57a

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

LOG: [Driver] Simplify xray options

Also add driver test missed by D87953 (-fxray-function-groups=).
(test/Driver/XRay/lit.local.cfg misunderstands how driver testing works.
We place the test in test/Driver instead.)

Added: 
clang/test/Driver/xray-function-groups.cpp

Modified: 
clang/include/clang/Driver/XRayArgs.h
clang/lib/Driver/XRayArgs.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index 5779da50a1a01..bdd3d979547ee 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -26,14 +26,7 @@ class XRayArgs {
   std::vector Modes;
   XRayInstrSet InstrumentationBundle;
   llvm::opt::Arg *XRayInstrument = nullptr;
-  int InstructionThreshold = 200;
-  bool XRayAlwaysEmitCustomEvents = false;
-  bool XRayAlwaysEmitTypedEvents = false;
   bool XRayRT = true;
-  bool XRayIgnoreLoops = false;
-  bool XRayFunctionIndex;
-  int XRayFunctionGroups = 1;
-  int XRaySelectedFunctionGroup = 0;
 
 public:
   /// Parses the XRay arguments from an argument list.

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index e975a72e4fe65..f15a91f1aba44 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -22,11 +22,7 @@ using namespace clang;
 using namespace clang::driver;
 using namespace llvm::opt;
 
-namespace {
-constexpr char XRayInstructionThresholdOption[] =
-"-fxray-instruction-threshold=";
-constexpr const char *const XRaySupportedModes[] = {"xray-fdr", "xray-basic"};
-} // namespace
+constexpr const char *XRaySupportedModes[] = {"xray-fdr", "xray-basic"};
 
 XRayArgs::XRayArgs(const ToolChain , const ArgList ) {
   const Driver  = TC.getDriver();
@@ -77,36 +73,10 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList 
) {
 D.Diag(diag::err_drv_argument_not_allowed_with)
 << XRayInstrument->getSpelling() << A->getSpelling();
 
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_fxray_instruction_threshold_EQ)) {
-StringRef S = A->getValue();
-if (S.getAsInteger(0, InstructionThreshold) || InstructionThreshold < 0)
-  D.Diag(clang::diag::err_drv_invalid_value) << A->getAsString(Args) << S;
-  }
-
-  // By default, the back-end will not emit the lowering for XRay customevent
-  // calls if the function is not instrumented. In the future we will change
-  // this default to be the reverse, but in the meantime we're going to
-  // introduce the new functionality behind a flag.
-  if (Args.hasFlag(options::OPT_fxray_always_emit_customevents,
-   options::OPT_fno_xray_always_emit_customevents, false))
-XRayAlwaysEmitCustomEvents = true;
-
-  if (Args.hasFlag(options::OPT_fxray_always_emit_typedevents,
-   options::OPT_fno_xray_always_emit_typedevents, false))
-XRayAlwaysEmitTypedEvents = true;
-
   if (!Args.hasFlag(options::OPT_fxray_link_deps,
 options::OPT_fnoxray_link_deps, true))
 XRayRT = false;
 
-  if (Args.hasFlag(options::OPT_fxray_ignore_loops,
-   options::OPT_fno_xray_ignore_loops, false))
-XRayIgnoreLoops = true;
-
-  XRayFunctionIndex = Args.hasFlag(options::OPT_fxray_function_index,
-   options::OPT_fno_xray_function_index, true);
-
   auto Bundles =
   Args.getAllArgValues(options::OPT_fxray_instrumentation_bundle);
   if (Bundles.empty())
@@ -185,21 +155,6 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList 
) {
   Modes.push_back(std::string(M));
 }
 
-  if (const Arg *A = Args.getLastArg(options::OPT_fxray_function_groups)) {
-StringRef S = A->getValue();
-if (S.getAsInteger(0, XRayFunctionGroups) || XRayFunctionGroups < 1)
-  D.Diag(clang::diag::err_drv_invalid_value) << A->getAsString(Args) << S;
-  }
-
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_fxray_selected_function_group)) {
-StringRef S = A->getValue();
-if (S.getAsInteger(0, XRaySelectedFunctionGroup) ||
-XRaySelectedFunctionGroup < 0 ||
-XRaySelectedFunctionGroup >= XRayFunctionGroups)
-  D.Diag(clang::diag::err_drv_invalid_value) << A->getAsString(Args) << S;
-  }
-
   // Then we want to sort and unique the modes we've collected.
   llvm::sort(Modes);
   Modes.erase(std::unique(Modes.begin(), Modes.end()), Modes.end());
@@ -209,34 +164,52 @@ void XRayArgs::addArgs(const ToolChain , const ArgList 
,
ArgStringList , types::ID InputType) const {
   if (!XRayInstrument)
 return;
-
+  const Driver  = TC.getDriver();
   

[clang] d25992e - [Driver] Simplify -fxray-instrument handling

2023-06-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-11T11:19:02-07:00
New Revision: d25992e70160dafcde4809bf97884e9dacd5058f

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

LOG: [Driver] Simplify -fxray-instrument handling

Added: 


Modified: 
clang/include/clang/Driver/XRayArgs.h
clang/lib/Driver/XRayArgs.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index 6ed99a127669b..5779da50a1a01 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -25,7 +25,7 @@ class XRayArgs {
   std::vector ExtraDeps;
   std::vector Modes;
   XRayInstrSet InstrumentationBundle;
-  bool XRayInstrument = false;
+  llvm::opt::Arg *XRayInstrument = nullptr;
   int InstructionThreshold = 200;
   bool XRayAlwaysEmitCustomEvents = false;
   bool XRayAlwaysEmitTypedEvents = false;

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index cf9b5780c4555..e975a72e4fe65 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -23,7 +23,6 @@ using namespace clang::driver;
 using namespace llvm::opt;
 
 namespace {
-constexpr char XRayInstrumentOption[] = "-fxray-instrument";
 constexpr char XRayInstructionThresholdOption[] =
 "-fxray-instruction-threshold=";
 constexpr const char *const XRaySupportedModes[] = {"xray-fdr", "xray-basic"};
@@ -35,6 +34,7 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList ) {
   if (!Args.hasFlag(options::OPT_fxray_instrument,
 options::OPT_fno_xray_instrument, false))
 return;
+  XRayInstrument = Args.getLastArg(options::OPT_fxray_instrument);
   if (Triple.getOS() == llvm::Triple::Linux) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:
@@ -48,14 +48,14 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList 
) {
 case llvm::Triple::mips64el:
   break;
 default:
-  D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << XRayInstrument->getSpelling() << Triple.str();
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
  Triple.isOSNetBSD() || Triple.isMacOSX()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
-  D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << XRayInstrument->getSpelling() << Triple.str();
 }
   } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
 switch (Triple.getArch()) {
@@ -63,21 +63,20 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList 
) {
 case llvm::Triple::aarch64:
   break;
 default:
-  D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << XRayInstrument->getSpelling() << Triple.str();
 }
   } else {
-D.Diag(diag::err_drv_clang_unsupported)
-<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< XRayInstrument->getSpelling() << Triple.str();
   }
 
   // Both XRay and -fpatchable-function-entry use
   // TargetOpcode::PATCHABLE_FUNCTION_ENTER.
   if (Arg *A = Args.getLastArg(options::OPT_fpatchable_function_entry_EQ))
 D.Diag(diag::err_drv_argument_not_allowed_with)
-<< "-fxray-instrument" << A->getSpelling();
+<< XRayInstrument->getSpelling() << A->getSpelling();
 
-  XRayInstrument = true;
   if (const Arg *A =
   Args.getLastArg(options::OPT_fxray_instruction_threshold_EQ)) {
 StringRef S = A->getValue();
@@ -211,7 +210,7 @@ void XRayArgs::addArgs(const ToolChain , const ArgList 
,
   if (!XRayInstrument)
 return;
 
-  CmdArgs.push_back(XRayInstrumentOption);
+  XRayInstrument->render(Args, CmdArgs);
 
   if (XRayAlwaysEmitCustomEvents)
 CmdArgs.push_back("-fxray-always-emit-customevents");



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


[PATCH] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

2023-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/include/clang/Driver/Options.td:2303
+  Group, Flags<[NoXarchOption, CC1Option, CoreOption]>,
+  HelpText<"Set the maximum number of source lines to show in a caret 
diagnostic">,
+  MarshallingInfoInt, 
"DiagnosticOptions::DefaultSnippetLineLimit">;

MaskRay wrote:
> Add ` (0 = no limit)` if useful
`NoXarchOption` emits an error if an option is used after `-Xarch_*`. The 
feature only applies to a small set of options (e.g. `-o`) and is not very 
useful for most options, but `NoXarchOption` was improperly named 
`DriverOption` and lured some contributors to add `NoXarchOption` to options 
that should not have the flag.

For `fcaret-diagnostics-max-lines=`, we should remove `NoXarchOption`.


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

https://reviews.llvm.org/D152090

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


[clang] ca4bb8d - [Driver] Place -ffixed-r19 and some -m* options in m_Group

2023-06-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-11T10:06:39-07:00
New Revision: ca4bb8d8820ab5c15a4700780651dd001662b22f

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

LOG: [Driver] Place -ffixed-r19 and some -m* options in m_Group

For these -m* options, there is no behavior difference other than
documentation difference (Target-dependent compilation options).

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index aed62677da692..3a8b03c4159d1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3487,9 +3487,9 @@ def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, 
RenderJoined]>,
 Group;
 def lazy__framework : Separate<["-"], "lazy_framework">, Flags<[LinkerInput]>;
 def lazy__library : Separate<["-"], "lazy_library">, Flags<[LinkerInput]>;
-def mlittle_endian : Flag<["-"], "mlittle-endian">, 
Flags<[NoXarchOption,TargetSpecific]>;
+def mlittle_endian : Flag<["-"], "mlittle-endian">, Group, 
Flags<[NoXarchOption,TargetSpecific]>;
 def EL : Flag<["-"], "EL">, Alias;
-def mbig_endian : Flag<["-"], "mbig-endian">, 
Flags<[NoXarchOption,TargetSpecific]>;
+def mbig_endian : Flag<["-"], "mbig-endian">, Group, 
Flags<[NoXarchOption,TargetSpecific]>;
 def EB : Flag<["-"], "EB">, Alias;
 def m16 : Flag<["-"], "m16">, Group, Flags<[NoXarchOption, 
CoreOption]>;
 def m32 : Flag<["-"], "m32">, Group, Flags<[NoXarchOption, 
CoreOption]>;
@@ -3549,7 +3549,7 @@ def mappletvos_version_min_EQ : Joined<["-"], 
"mappletvos-version-min=">, Alias<
 def mtvos_simulator_version_min_EQ : Joined<["-"], 
"mtvos-simulator-version-min=">;
 def mappletvsimulator_version_min_EQ : Joined<["-"], 
"mappletvsimulator-version-min=">, Alias;
 def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, 
Group;
-def mwatchos_simulator_version_min_EQ : Joined<["-"], 
"mwatchos-simulator-version-min=">;
+def mwatchos_simulator_version_min_EQ : Joined<["-"], 
"mwatchos-simulator-version-min=">, Group;
 def mwatchsimulator_version_min_EQ : Joined<["-"], 
"mwatchsimulator-version-min=">, Alias;
 } // let Flags = [TargetSpecific]
 def march_EQ : Joined<["-"], "march=">, Group, 
Flags<[CoreOption,TargetSpecific]>,
@@ -3610,11 +3610,10 @@ def mios_version_min_EQ : Joined<["-"], 
"mios-version-min=">,
   Group, HelpText<"Set iOS deployment target">;
 def : Joined<["-"], "miphoneos-version-min=">,
   Group, Alias;
-def mios_simulator_version_min_EQ : Joined<["-"], 
"mios-simulator-version-min=">;
+def mios_simulator_version_min_EQ : Joined<["-"], 
"mios-simulator-version-min=">, Group;
 def : Joined<["-"], "miphonesimulator-version-min=">, 
Alias;
 def mkernel : Flag<["-"], "mkernel">, Group;
-def mlinker_version_EQ : Joined<["-"], "mlinker-version=">,
-  Flags<[NoXarchOption]>;
+def mlinker_version_EQ : Joined<["-"], "mlinker-version=">, Group, 
Flags<[NoXarchOption]>;
 } // let Flags = [TargetSpecific]
 def mllvm : Separate<["-"], 
"mllvm">,Flags<[CC1Option,CC1AsOption,CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
@@ -4710,7 +4709,7 @@ def mhexagon_hvx_ieee_fp : Flag<["-"], "mhvx-ieee-fp">,
 def mno_hexagon_hvx_ieee_fp : Flag<["-"], "mno-hvx-ieee-fp">,
   Group,
   HelpText<"Disable Hexagon HVX IEEE floating-point">;
-def ffixed_r19: Flag<["-"], "ffixed-r19">,
+def ffixed_r19: Flag<["-"], "ffixed-r19">, Group,
   HelpText<"Reserve register r19 (Hexagon only)">;
 } // let Flags = [TargetSpecific]
 def mmemops : Flag<["-"], "mmemops">, Group,



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


[PATCH] D152650: [docs] Improve UndefinedBehaviorSanitizer.rst

2023-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: Sanitizers, vitalybuka.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Mention that -fsanitize= and -fno-sanitize= apply to check groups.
- Mention "all" can be used as a check group.
- Mention that -fsanitize-trap= and -fsanitize-recover= lead to no unused 
command line option warning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152650

Files:
  clang/docs/UndefinedBehaviorSanitizer.rst


Index: clang/docs/UndefinedBehaviorSanitizer.rst
===
--- clang/docs/UndefinedBehaviorSanitizer.rst
+++ clang/docs/UndefinedBehaviorSanitizer.rst
@@ -32,10 +32,11 @@
 Usage
 =
 
-Use ``clang++`` to compile and link your program with ``-fsanitize=undefined``
-flag. Make sure to use ``clang++`` (not ``ld``) as a linker, so that your
-executable is linked with proper UBSan runtime libraries. You can use ``clang``
-instead of ``clang++`` if you're compiling/linking C code.
+Use ``clang++`` to compile and link your program with the 
``-fsanitize=undefined``
+option. Make sure to use ``clang++`` (not ``ld``) as a linker, so that your
+executable is linked with proper UBSan runtime libraries, unless all enabled
+checks use the trap mode. You can use ``clang`` instead of ``clang++`` if 
you're
+compiling/linking C code.
 
 .. code-block:: console
 
@@ -49,28 +50,50 @@
   % ./a.out
   test.cc:3:5: runtime error: signed integer overflow: 2147483647 + 1 cannot 
be represented in type 'int'
 
-You can enable only a subset of :ref:`checks ` offered by UBSan,
-and define the desired behavior for each kind of check:
+You can use ``-fsanitize=...`` and ``-fno-sanitize=`` to enable and disable 
one check or one check group.
+
+.. code-block:: console
+
+  # Enable all checks in the "undefined" group, but disable "alignment".
+  % clang -fsanitize=undefined -fno-sanitize=alignment a.c
+
+  # Enable only "alignment".
+  # -fno-sanitize=undefined nullifies the previous -fsanitize=undefined.
+  % clang -fsanitize=undefined -fno-sanitize=undefined -fsanitize=alignment a.c
+
+For most checks (:ref:`checks `), the instrumented program prints
+a verbose error report and continues execution upon a failed check.
+You can use the following options to change the error reporting behavior:
 
-* ``-fsanitize=...``: print a verbose error report and continue execution 
(default);
 * ``-fno-sanitize-recover=...``: print a verbose error report and exit the 
program;
 * ``-fsanitize-trap=...``: execute a trap instruction (doesn't require UBSan 
run-time support).
-* ``-fno-sanitize=...``: disable any check, e.g., -fno-sanitize=alignment.
 
-Note that the ``trap`` / ``recover`` options do not enable the corresponding
-sanitizer, and in general need to be accompanied by a suitable ``-fsanitize=``
-flag.
-
-For example if you compile/link your program as:
+For example:
 
 .. code-block:: console
 
-  % clang++ -fsanitize=signed-integer-overflow,null,alignment 
-fno-sanitize-recover=null -fsanitize-trap=alignment
+  % clang++ -fsanitize=signed-integer-overflow,null,alignment 
-fno-sanitize-recover=null -fsanitize-trap=alignment a.cc
 
-the program will continue execution after signed integer overflows, exit after
+The program will continue execution after signed integer overflows, exit after
 the first invalid use of a null pointer, and trap after the first use of 
misaligned
 pointer.
 
+.. code-block:: console
+
+  % clang++ -fsanitize=undefined -fsanitize-trap=all a.cc
+
+All checks in the "undefined" group are put into trap mode. Since no check
+needs run-time support, the UBSan run-time library it not linked. Note that
+some other sanitizers also support trap mode and ``-fsanitize-trap=all``
+enables trap mode for them.
+
+.. code-block:: console
+
+  % clang -fsanitize-trap=undefined -fsanitize-recover=all a.c
+
+``-fsanitize-trap=`` and ``-fsanitize-recover=`` are a no-op in the absence of
+a ``-fsanitize=`` option. There is no unused command line option warning.
+
 .. _ubsan-checks:
 
 Available checks


Index: clang/docs/UndefinedBehaviorSanitizer.rst
===
--- clang/docs/UndefinedBehaviorSanitizer.rst
+++ clang/docs/UndefinedBehaviorSanitizer.rst
@@ -32,10 +32,11 @@
 Usage
 =
 
-Use ``clang++`` to compile and link your program with ``-fsanitize=undefined``
-flag. Make sure to use ``clang++`` (not ``ld``) as a linker, so that your
-executable is linked with proper UBSan runtime libraries. You can use ``clang``
-instead of ``clang++`` if you're compiling/linking C code.
+Use ``clang++`` to compile and link your program with the ``-fsanitize=undefined``
+option. Make sure to use ``clang++`` (not ``ld``) as a linker, so that your
+executable is linked with proper UBSan runtime libraries, unless all enabled
+checks use the trap mode. You can use 

[PATCH] D148461: [clang-tidy] Support C++17/20 in bugprone-exception-escape

2023-06-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:306
+
+  if (From->isMemberPointerType() || To->isMemberPointerType())
 return false;

isuckatcs wrote:
> isuckatcs wrote:
> > Please cover this line with both positive and negative test cases.
> > 
> > Also upon looking up both [[ 
> > https://www.open-std.org/jtc1/sc22/wg21/docs/standards | N4849 ]] (C++ 20 
> > draft) and [[ https://github.com/cplusplus/draft/releases | N4917]] (C++ 23 
> > draft), they both say for qualification conversion that 
> > 
> > 
> > > each P_i is ... pointer to member of class C_i of type, ...
> > 
> > Why are we not allowing them if the standard is at least C++ 20?
> Please resolve this thread.
Positive case is tested by throw_basefn_catch_derivedfn test and 
throw_derivedfn_catch_basefn.
Negative is covered by throw_basefn_catch_basefn.

For members there are tests throw_basem_catch_basem, 
throw_basem_catch_derivedm, throw_derivedm_catch_basem that also covers this 
correctly.

Tested this with GCC, and behavior is proper and independent to C++ standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148461

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


[PATCH] D148461: [clang-tidy] Support C++17/20 in bugprone-exception-escape

2023-06-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 530306.
PiotrZSL marked 2 inline comments as done.
PiotrZSL added a comment.

Add one test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148461

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -1,10 +1,9 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-escape %t -- \
+// RUN: %check_clang_tidy -std=c++11-or-later %s bugprone-exception-escape %t -- \
 // RUN: -config="{CheckOptions: [ \
 // RUN: {key: bugprone-exception-escape.IgnoredExceptions, value: 'ignored1,ignored2'}, \
 // RUN: {key: bugprone-exception-escape.FunctionsThatShouldNotThrow, value: 'enabled1,enabled2,enabled3'} \
 // RUN: ]}" \
 // RUN: -- -fexceptions
-// FIXME: Fix the checker to work in C++17 or later mode.
 
 struct throwing_destructor {
   ~throwing_destructor() {
@@ -152,7 +151,7 @@
 }
 
 // FIXME: In this case 'a' is convertible to the handler and should be caught
-// but in reality it's thrown. Note that clang doesn't report a warning for 
+// but in reality it's thrown. Note that clang doesn't report a warning for
 // this either.
 void throw_catch_multi_ptr_5() noexcept {
   try {
@@ -249,7 +248,7 @@
 void throw_derived_catch_base_ptr_c() noexcept {
   try {
 derived d;
-throw  
+throw 
   } catch(const base *) {
   }
 }
@@ -259,7 +258,7 @@
   try {
 derived d;
 const derived *p = 
-throw p; 
+throw p;
   } catch(base *) {
   }
 }
@@ -282,7 +281,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_private' which should not throw exceptions
   try {
 B b;
-throw b; 
+throw b;
   } catch(A) {
   }
 }
@@ -291,7 +290,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_private_ptr' which should not throw exceptions
   try {
 B b;
-throw  
+throw 
   } catch(A *) {
   }
 }
@@ -300,7 +299,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_protected' which should not throw exceptions
   try {
 C c;
-throw c; 
+throw c;
   } catch(A) {
   }
 }
@@ -309,7 +308,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_protected_ptr' which should not throw exceptions
   try {
 C c;
-throw  
+throw 
   } catch(A *) {
   }
 }
@@ -318,7 +317,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ambiguous' which should not throw exceptions
   try {
 E e;
-throw e; 
+throw e;
   } catch(A) {
   }
 }
@@ -327,7 +326,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ambiguous_ptr' which should not throw exceptions
   try {
 E e;
-throw e; 
+throw e;
   } catch(A) {
   }
 }
@@ -420,6 +419,7 @@
 struct baseMember {
 int *iptr;
 virtual void foo(){};
+void boo(){};
 };
 
 struct derivedMember : baseMember {
@@ -441,6 +441,21 @@
   }
 }
 
+void throw_derivedfn_catch_basefn() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derivedfn_catch_basefn' which should not throw exceptions
+  try {
+throw ::foo;
+  } catch(void(baseMember::*)()) {
+  }
+}
+
+void throw_basefn_via_derivedfn_catch_basefn() noexcept {
+  try {
+throw ::boo;
+  } catch(void(baseMember::*)()) {
+  }
+}
+
 void throw_basem_catch_basem_throw() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_basem_catch_basem_throw' which should not throw exceptions
   try {
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "ExceptionAnalyzer.h"
+#include 
 
 namespace clang::tidy::utils {
 
@@ -149,37 +150,27 @@
 }
 
 bool isFunctionPointerConvertible(QualType From, QualType To) {
-  if (!From->isFunctionPointerType() && !From->isFunctionType() &&
-  !From->isMemberFunctionPointerType())
-return false;
-
-  if (!To->isFunctionPointerType() && !To->isMemberFunctionPointerType())
+  ODRHash FromHash, ToHash;
+
+  if 

[PATCH] D152632: [Clang] Add warnings for CWG2521

2023-06-11 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao updated this revision to Diff 530304.
rZhBoYao added a comment.

Overhaul for `dr25xx.cpp`.

For each test case, tried to support as many language modes as possible.
Not sure what those `-triple x86_64-unknown-unknown` are for? I leave them 
there nonetheless.

`-Wdeprecated-literal-operator` is under `-Wdeprecated` which is not under 
`-Wpedantic` so is not triggered by `-pedantic-errors`. Does this need change? 
I imagine it would be pretty disruptive.  On the other hand, pedantic users 
might care about deprecation 樂️.


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

https://reviews.llvm.org/D152632

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr17xx.cpp
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
  clang/test/Parser/cxx0x-literal-operators.cpp
  clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.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
@@ -14933,7 +14933,7 @@
 https://cplusplus.github.io/CWG/issues/2521.html;>2521
 DR
 User-defined literals and reserved identifiers
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2522.html;>2522
Index: clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
===
--- clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
+++ clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
@@ -2,4 +2,4 @@
 
 #include 
 
-void operator "" bar(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" bar(long double); // expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
Index: clang/test/Parser/cxx0x-literal-operators.cpp
===
--- clang/test/Parser/cxx0x-literal-operators.cpp
+++ clang/test/Parser/cxx0x-literal-operators.cpp
@@ -3,6 +3,6 @@
 void operator "" (const char *); // expected-error {{expected identifier}}
 void operator "k" foo(const char *); // \
   expected-error {{string literal after 'operator' must be '""'}} \
-  expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+  expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
 void operator "" tester (const char *); // \
-  expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+  expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
Index: clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
===
--- clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
+++ clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -verify %s
 
 using size_t = decltype(sizeof(int));
-void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
-void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
+void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes containing '__' or not starting with '_' are reserved; no literal will invoke this operator}}
+void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes containing '__' or not starting with '_' are reserved; no literal will invoke this operator}}
 
 template
 void f() {
Index: clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
===
--- clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
+++ clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
 
-void operator "" p31(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" p31(long double); // expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
 void operator "" _p31(long double);
-long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
 
 float hexfloat = 0x1p31; // 

[clang] c8c28ac - [Driver] Place -mharden-sls= in m_Group

2023-06-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-11T08:59:42-07:00
New Revision: c8c28ac5caf875771f9a424e46255948004cbeab

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

LOG: [Driver] Place -mharden-sls= in m_Group

Fix https://github.com/llvm/llvm-project/issues/63237

With only a link action, we claim all CompileOnly_Group options (including -f*,
-m*, -i*, etc). -mharden-sls= is not in a Group and therefore not claimed,
leading to a spurious -Wunused-command-line-argument warning, and after
5548843d692a92a7840f14002debc3cebcb3cdc3, an error.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/x86-target-features.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 27a4bc080b8c0..aed62677da692 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3846,7 +3846,7 @@ def mbranch_protection_EQ : Joined<["-"], 
"mbranch-protection=">,
   Group,
   HelpText<"Enforce targets of indirect branches and function returns">;
 
-def mharden_sls_EQ : Joined<["-"], "mharden-sls=">,
+def mharden_sls_EQ : Joined<["-"], "mharden-sls=">, Group,
   HelpText<"Select straight-line speculation hardening scope (ARM/AArch64/X86"
" only).  must be: all, none, retbr(ARM/AArch64),"
" blr(ARM/AArch64), comdat(ARM/AArch64), nocomdat(ARM/AArch64),"

diff  --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index 6819c907f5c98..71bdd2a9c2981 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -364,3 +364,6 @@
 // SLS-IJMP-DAG: "-target-feature" "+harden-sls-ijmp"
 // NO-SLS-NOT: "+harden-sls-
 // BAD-SLS: unsupported argument '{{[^']+}}' to option '-mharden-sls='
+
+// RUN: touch %t.o
+// RUN: %clang -fdriver-only -Werror --target=x86_64-pc-linux-gnu 
-mharden-sls=all %t.o -o /dev/null 2>&1 | count 0



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


[PATCH] D152443: Add SpaceAfterOperatorKeyword & SpaceAfterOperatorKeywordInCall style options for clang-format

2023-06-11 Thread Alexander Hinze via Phabricator via cfe-commits
KitsuneAlex updated this revision to Diff 530303.
KitsuneAlex marked 2 inline comments as done.
KitsuneAlex removed reviewers: lattner, craig.topper, RKSimon, respindola, 
rymiel, owenpan.
KitsuneAlex added a comment.
Herald added reviewers: rymiel, owenpan.

This revision of the diff changes the names of the new style options to 
**SpaceAfterOperatorOverload** and **SpaceAfterOperatorCall**, which clarifies 
their scope a lot better i think.
I also rewrote the logic to apply formatting that fits exactly what their name 
implies respectively,
the new tests i added should cover all common use cases (except i forgot some 
again).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22901,8 +22901,43 @@
Spaces);
 }
 
+TEST_F(FormatTest, SpaceAfterOperatorOverload) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  Style.SpaceAfterOperatorOverload = true;
+  verifyFormat("bool operator ==();", Style);
+  verifyFormat("bool Foo::operator ==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+}
+
+TEST_F(FormatTest, SpaceAfterOperatorCall) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("foo.operator==();", Style);
+  verifyFormat("foo.Foo::operator==();", Style);
+  verifyFormat("foo->operator==();", Style);
+  verifyFormat("foo->Foo::operator==();", Style);
+  Style.SpaceAfterOperatorCall = true;
+  verifyFormat("bool operator==();", Style);
+  verifyFormat("bool Foo::operator==();", Style);
+  verifyFormat("foo.operator ==();", Style);
+  verifyFormat("foo.Foo::operator ==();", Style);
+  verifyFormat("foo->operator ==();", Style);
+  verifyFormat("foo->Foo::operator ==();", Style);
+}
+
 TEST_F(FormatTest, SpaceAfterTemplateKeyword) {
   FormatStyle Style = getLLVMStyle();
+  verifyFormat("template  void foo();", Style);
   Style.SpaceAfterTemplateKeyword = false;
   verifyFormat("template void foo();", Style);
 }
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -183,6 +183,8 @@
   CHECK_PARSE_BOOL(SpacesInContainerLiterals);
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
+  CHECK_PARSE_BOOL(SpaceAfterOperatorOverload);
+  CHECK_PARSE_BOOL(SpaceAfterOperatorCall);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
   CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4200,9 +4200,21 @@
 // Space in __attribute__((attr)) ::type.
 if (Left.is(TT_AttributeParen) && Right.is(tok::coloncolon))
   return true;
-
-if (Left.is(tok::kw_operator))
-  return Right.is(tok::coloncolon);
+if (Left.is(tok::kw_operator)) {
+  if (Left.hasWhitespaceBefore())
+return Style.SpaceAfterOperatorOverload || Right.is(tok::coloncolon);
+  if (!Left.Previous)
+return Right.is(tok::coloncolon);
+  FormatToken const *Previous = Left.Previous;
+  while (Previous) {
+if (!Previous->hasWhitespaceBefore()) {
+  Previous = Previous->Previous;
+  continue;
+}
+return Style.SpaceAfterOperatorOverload || Right.is(tok::coloncolon);
+  }
+  return Style.SpaceAfterOperatorCall || Right.is(tok::coloncolon);
+}
 if (Right.is(tok::l_brace) && Right.is(BK_BracedInit) &&
 !Left.opensScope() && Style.SpaceBeforeCpp11BracedList) {
   return true;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1000,6 +1000,9 @@
 IO.mapOptional("SortUsingDeclarations", 

[PATCH] D152330: [clang-tidy] Check functions called from catch blocks

2023-06-11 Thread Deniz Evrenci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdaac014fec42: [clang-tidy] Check functions called from catch 
blocks (authored by denizevrenci).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152330

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17,c++20 %s bugprone-exception-escape %t -- \
+// RUN: -- -fexceptions
+
+void rethrower() {
+throw;
+}
+
+void callsRethrower() {
+rethrower();
+}
+
+void callsRethrowerNoexcept() noexcept {
+rethrower();
+}
+
+int throwsAndCallsRethrower() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'throwsAndCallsRethrower' which should not throw exceptions
+try {
+throw 1;
+} catch(...) {
+rethrower();
+}
+}
+
+int throwsAndCallsCallsRethrower() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'throwsAndCallsCallsRethrower' which should not throw exceptions
+try {
+throw 1;
+} catch(...) {
+callsRethrower();
+}
+}
+
+void rethrowerNoexcept() noexcept {
+throw;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
@@ -36,17 +36,18 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Promise;
 
 template <
 typename T, bool ThrowInTaskConstructor = false,
 bool ThrowInPromiseConstructor = false, bool ThrowInInitialSuspend = false,
-bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false>
+bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false,
+bool RethrowInUnhandledException = false>
 struct Task {
   using promise_type =
   Promise;
+  ThrowInGetReturnObject, ThrowInUnhandledException, RethrowInUnhandledException>;
 
   explicit Task(promise_type ) {
 if constexpr (ThrowInTaskConstructor) {
@@ -67,13 +68,13 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Task {
+ThrowInUnhandledException, RethrowInUnhandledException> {
   using promise_type =
   Promise;
+  ThrowInGetReturnObject, ThrowInUnhandledException, RethrowInUnhandledException>;
 
   explicit Task(promise_type ) {
 if constexpr (ThrowInTaskConstructor) {
@@ -92,7 +93,7 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Promise {
   Promise() {
 if constexpr (ThrowInPromiseConstructor) {
@@ -130,6 +131,8 @@
   void unhandled_exception() {
 if constexpr (ThrowInUnhandledException) {
   throw 1;
+} else if constexpr (RethrowInUnhandledException) {
+  throw;
 }
   }
 
@@ -138,9 +141,9 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Promise {
+   ThrowInGetReturnObject, ThrowInUnhandledException, RethrowInUnhandledException> {
   Promise() {
 if constexpr (ThrowInPromiseConstructor) {
   throw 1;
@@ -170,6 +173,8 @@
   void unhandled_exception() {
 if constexpr (ThrowInUnhandledException) {
   throw 1;
+} else if constexpr (RethrowInUnhandledException) {
+  throw;
 }
   }
 
@@ -266,6 +271,33 @@
   co_return a / b;
 }
 
+Task
+i_ShouldNotDiag(const int a, const int b) {
+  co_return a / b;
+}
+
+Task
+i_ShouldNotDiagNoexcept(const int a, const int b) noexcept {
+  co_return a / b;
+}
+
+Task
+j_ShouldNotDiag(const int a, const int b) {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task
+j_ShouldDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: an exception may be thrown in function 'j_ShouldDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
 } // namespace coreturn
 
 namespace coyield {
@@ -347,6 +379,33 @@
   co_yield a / b;
 }
 
+Task
+i_ShouldNotDiag(const int a, const int b) {
+  co_yield a / b;
+}
+
+Task
+i_ShouldNotDiagNoexcept(const int a, const int b) noexcept {
+  co_yield a / b;
+}
+
+Task
+j_ShouldNotDiag(const int a, const int b) {
+  

[clang-tools-extra] daac014 - [clang-tidy] Check functions called from catch blocks

2023-06-11 Thread Deniz Evrenci via cfe-commits

Author: Deniz Evrenci
Date: 2023-06-11T16:40:29+01:00
New Revision: daac014fec427eda305f93da7891c0122a161bb3

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

LOG: [clang-tidy] Check functions called from catch blocks

These functions can rethrow a current exception that is caught by the
catch block. We can pass the currently caught excections to the function
declaration analyzer just like the statement analyzer to handle this
case.

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp

Modified: 
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h

clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index 690e771414a75..c3e9a13bb1ba2 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -419,21 +419,20 @@ void 
ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() {
 }
 
 ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
-const FunctionDecl *Func,
+const FunctionDecl *Func, const ExceptionInfo::Throwables ,
 llvm::SmallSet ) {
   if (CallStack.count(Func))
 return ExceptionInfo::createNonThrowing();
 
   if (const Stmt *Body = Func->getBody()) {
 CallStack.insert(Func);
-ExceptionInfo Result =
-throwsException(Body, ExceptionInfo::Throwables(), CallStack);
+ExceptionInfo Result = throwsException(Body, Caught, CallStack);
 
 // For a constructor, we also have to check the initializers.
 if (const auto *Ctor = dyn_cast(Func)) {
   for (const CXXCtorInitializer *Init : Ctor->inits()) {
-ExceptionInfo Excs = throwsException(
-Init->getInit(), ExceptionInfo::Throwables(), CallStack);
+ExceptionInfo Excs =
+throwsException(Init->getInit(), Caught, CallStack);
 Result.merge(Excs);
   }
 }
@@ -512,12 +511,12 @@ ExceptionAnalyzer::ExceptionInfo 
ExceptionAnalyzer::throwsException(
 Results.merge(Uncaught);
   } else if (const auto *Call = dyn_cast(St)) {
 if (const FunctionDecl *Func = Call->getDirectCallee()) {
-  ExceptionInfo Excs = throwsException(Func, CallStack);
+  ExceptionInfo Excs = throwsException(Func, Caught, CallStack);
   Results.merge(Excs);
 }
   } else if (const auto *Construct = dyn_cast(St)) {
 ExceptionInfo Excs =
-throwsException(Construct->getConstructor(), CallStack);
+throwsException(Construct->getConstructor(), Caught, CallStack);
 Results.merge(Excs);
   } else if (const auto *DefaultInit = dyn_cast(St)) {
 ExceptionInfo Excs =
@@ -525,14 +524,18 @@ ExceptionAnalyzer::ExceptionInfo 
ExceptionAnalyzer::throwsException(
 Results.merge(Excs);
   } else if (const auto *Coro = dyn_cast(St)) {
 for (const Stmt *Child : Coro->childrenExclBody()) {
-  ExceptionInfo Excs = throwsException(Child, Caught, CallStack);
-  Results.merge(Excs);
+  if (Child != Coro->getExceptionHandler()) {
+ExceptionInfo Excs = throwsException(Child, Caught, CallStack);
+Results.merge(Excs);
+  }
 }
 ExceptionInfo Excs = throwsException(Coro->getBody(), Caught, CallStack);
+Results.merge(throwsException(Coro->getExceptionHandler(),
+  Excs.getExceptionTypes(), CallStack));
 for (const Type *Throwable : Excs.getExceptionTypes()) {
   if (const auto ThrowableRec = Throwable->getAsCXXRecordDecl()) {
 ExceptionInfo DestructorExcs =
-throwsException(ThrowableRec->getDestructor(), CallStack);
+throwsException(ThrowableRec->getDestructor(), Caught, CallStack);
 Results.merge(DestructorExcs);
   }
 }
@@ -553,7 +556,8 @@ ExceptionAnalyzer::analyzeImpl(const FunctionDecl *Func) {
   const auto CacheEntry = FunctionCache.find(Func);
   if (CacheEntry == FunctionCache.end()) {
 llvm::SmallSet CallStack;
-ExceptionList = throwsException(Func, CallStack);
+ExceptionList =
+throwsException(Func, ExceptionInfo::Throwables(), CallStack);
 
 // Cache the result of the analysis. This is done prior to filtering
 // because it is best to keep as much information as possible.

diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
index a40149ac98d84..a1cb111aa3fbf 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h

[PATCH] D152632: [Clang] Add warnings for CWG2521

2023-06-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/test/CXX/drs/dr25xx.cpp:2
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-Wdeprecated-literal-operator
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-Wdeprecated
 

We avoid passing compiler options here, because it affects all the tests in the 
file. If you need to enable or disable a specific diagnostic, better wrap your 
test with
```
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wdeprecated-literal-operation" // or 
"ignored" instead of "warning"
// ...
#pragma clang diagnostic pop
```

That said, files containing newer DRs are not too well maintained at the moment 
(but I'll get to them at some point). This file in particular lacks RUN lines 
for all missing language modes, and `-pedantic-errors`. I guess the latter 
enables diagnostics that are needed for your test. You can use `dr5xx.cpp` as 
an example.


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

https://reviews.llvm.org/D152632

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


[PATCH] D152330: [clang-tidy] Check functions called from catch blocks

2023-06-11 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci updated this revision to Diff 530296.
denizevrenci added a comment.

Rebase on main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152330

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17,c++20 %s bugprone-exception-escape %t -- \
+// RUN: -- -fexceptions
+
+void rethrower() {
+throw;
+}
+
+void callsRethrower() {
+rethrower();
+}
+
+void callsRethrowerNoexcept() noexcept {
+rethrower();
+}
+
+int throwsAndCallsRethrower() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'throwsAndCallsRethrower' which should not throw exceptions
+try {
+throw 1;
+} catch(...) {
+rethrower();
+}
+}
+
+int throwsAndCallsCallsRethrower() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'throwsAndCallsCallsRethrower' which should not throw exceptions
+try {
+throw 1;
+} catch(...) {
+callsRethrower();
+}
+}
+
+void rethrowerNoexcept() noexcept {
+throw;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
@@ -36,17 +36,18 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Promise;
 
 template <
 typename T, bool ThrowInTaskConstructor = false,
 bool ThrowInPromiseConstructor = false, bool ThrowInInitialSuspend = false,
-bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false>
+bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false,
+bool RethrowInUnhandledException = false>
 struct Task {
   using promise_type =
   Promise;
+  ThrowInGetReturnObject, ThrowInUnhandledException, RethrowInUnhandledException>;
 
   explicit Task(promise_type ) {
 if constexpr (ThrowInTaskConstructor) {
@@ -67,13 +68,13 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Task {
+ThrowInUnhandledException, RethrowInUnhandledException> {
   using promise_type =
   Promise;
+  ThrowInGetReturnObject, ThrowInUnhandledException, RethrowInUnhandledException>;
 
   explicit Task(promise_type ) {
 if constexpr (ThrowInTaskConstructor) {
@@ -92,7 +93,7 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Promise {
   Promise() {
 if constexpr (ThrowInPromiseConstructor) {
@@ -130,6 +131,8 @@
   void unhandled_exception() {
 if constexpr (ThrowInUnhandledException) {
   throw 1;
+} else if constexpr (RethrowInUnhandledException) {
+  throw;
 }
   }
 
@@ -138,9 +141,9 @@
 
 template 
+  bool ThrowInUnhandledException, bool RethrowInUnhandledException>
 struct Promise {
+   ThrowInGetReturnObject, ThrowInUnhandledException, RethrowInUnhandledException> {
   Promise() {
 if constexpr (ThrowInPromiseConstructor) {
   throw 1;
@@ -170,6 +173,8 @@
   void unhandled_exception() {
 if constexpr (ThrowInUnhandledException) {
   throw 1;
+} else if constexpr (RethrowInUnhandledException) {
+  throw;
 }
   }
 
@@ -266,6 +271,33 @@
   co_return a / b;
 }
 
+Task
+i_ShouldNotDiag(const int a, const int b) {
+  co_return a / b;
+}
+
+Task
+i_ShouldNotDiagNoexcept(const int a, const int b) noexcept {
+  co_return a / b;
+}
+
+Task
+j_ShouldNotDiag(const int a, const int b) {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task
+j_ShouldDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: an exception may be thrown in function 'j_ShouldDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
 } // namespace coreturn
 
 namespace coyield {
@@ -347,6 +379,33 @@
   co_yield a / b;
 }
 
+Task
+i_ShouldNotDiag(const int a, const int b) {
+  co_yield a / b;
+}
+
+Task
+i_ShouldNotDiagNoexcept(const int a, const int b) noexcept {
+  co_yield a / b;
+}
+
+Task
+j_ShouldNotDiag(const int a, const int b) {
+  if (b == 0)
+throw b;
+
+  co_yield a / b;
+}
+
+Task
+j_ShouldDiag(const int a, const 

[PATCH] D152435: [analyzer][CStringChecker] Adjust the invalidation operation on the super region of the destination buffer during string copy

2023-06-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I left my comment at https://github.com/llvm/llvm-project/issues/55019


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152435

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


[PATCH] D152632: [Clang] Add warnings for CWG2521

2023-06-11 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao updated this revision to Diff 530292.
rZhBoYao added a comment.

Addressed comments.
Thanks for letting me know how to structure tests for DRs.


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

https://reviews.llvm.org/D152632

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr17xx.cpp
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
  clang/test/Parser/cxx0x-literal-operators.cpp
  clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.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
@@ -14933,7 +14933,7 @@
 https://cplusplus.github.io/CWG/issues/2521.html;>2521
 DR
 User-defined literals and reserved identifiers
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2522.html;>2522
Index: clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
===
--- clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
+++ clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
@@ -2,4 +2,4 @@
 
 #include 
 
-void operator "" bar(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" bar(long double); // expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
Index: clang/test/Parser/cxx0x-literal-operators.cpp
===
--- clang/test/Parser/cxx0x-literal-operators.cpp
+++ clang/test/Parser/cxx0x-literal-operators.cpp
@@ -3,6 +3,6 @@
 void operator "" (const char *); // expected-error {{expected identifier}}
 void operator "k" foo(const char *); // \
   expected-error {{string literal after 'operator' must be '""'}} \
-  expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+  expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
 void operator "" tester (const char *); // \
-  expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+  expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
Index: clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
===
--- clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
+++ clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -verify %s
 
 using size_t = decltype(sizeof(int));
-void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
-void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
+void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes containing '__' or not starting with '_' are reserved; no literal will invoke this operator}}
+void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes containing '__' or not starting with '_' are reserved; no literal will invoke this operator}}
 
 template
 void f() {
Index: clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
===
--- clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
+++ clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
 
-void operator "" p31(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" p31(long double); // expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
 void operator "" _p31(long double);
-long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes containing '__' or not starting with '_' are reserved}}
 
 float hexfloat = 0x1p31; // allow hexfloats
Index: clang/test/CXX/drs/dr25xx.cpp
===
--- clang/test/CXX/drs/dr25xx.cpp
+++ clang/test/CXX/drs/dr25xx.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -Wdeprecated-literal-operator
+// 

[PATCH] D143971: [clang-tidy] Flag more buggy string constructor cases

2023-06-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL requested changes to this revision.
PiotrZSL added a comment.
This revision now requires changes to proceed.

I run into false positive with this example:

  using UInt8 = unsigned char;
  UInt8 size = 5U;
  std::string str2(size, 'x');  //  warning: string constructor arguments are 
probably swapped; expecting string(count, character) 
[bugprone-string-constructor]

This is due to change in CharExpr, simply isAnyCharacter is too wide, as it 
also match signed/unsigned characters, and your tests does not cover those.
Probably for this we need to be more strict, and accept only non 
signed/unsigned characters.

Other issue is with this:

  char c = '\n';
  using Size = int;
  Size size = 10U;
  std::string str2(c, size);

Even that in AST we got double implicit casts, it's detected as `warning: 
string constructor arguments are probably swapped; expecting string(count, 
character) [bugprone-string-constructor]`.
Instead of being detected as 'confusing string fill constructor arguments'. 
This probably could be fixed by matching those double casts first, instead of 
last.

  | `-VarDecl 0x56436ceb0520  col:15 str2 
'std::string':'std::basic_string' callinit
  |   `-CXXConstructExpr 0x56436ceb0650  
'std::string':'std::basic_string' 'void (unsigned int, char)'
  | |-ImplicitCastExpr 0x56436ceb0608  'unsigned int' 

  | | `-ImplicitCastExpr 0x56436ceb05f0  'char' 
  | |   `-DeclRefExpr 0x56436ceb0588  'char' lvalue Var 
0x56436ceb0280 'c' 'char'
  | `-ImplicitCastExpr 0x56436ceb0638  'char':'char' 

  |   `-ImplicitCastExpr 0x56436ceb0620  'Size':'int' 

  | `-DeclRefExpr 0x56436ceb05a8  'Size':'int' lvalue Var 
0x56436ceb0420 'size' 'Size':'int'

Except above 2 change looks OK to me. My main concern is false-positive, simply 
because in project that I work for we use lot of std::uint8_t as size, to save 
bytes in struct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143971

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D152436#4408811 , @balazske wrote:

> In D152436#4408301 , @steakhal 
> wrote:
>
>> I looked at the TPs, and if the violation was introduced by an assumption 
>> (instead of an assignment), then it's really hard to spot which assumption 
>> is important for the bug.
>> I wonder if we could add the `TrackConstraintBRVisitor` to the bugreport to 
>> "highlight" that particular assumption/place.
>
> The question is first if this problem must be fixed before the checker comes 
> out of alpha state. If yes I try to make another patch with this fix. I tried 
> this previously but do not remember exactly what the problem was.

WIthout an explicit note message there, I don't see how could we advertise this 
as a "mature" checker.




Comment at: clang/docs/analyzer/checkers.rst:922
+
+unix.StdCLibraryFunctions (C)
+"

balazske wrote:
> This is applicable to C++ too?
Yes it's applicable to c++ if they use these C APIs.
However, I would prefer not to extend it with C++. IMO that would only raise 
confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

2023-06-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy updated this revision to Diff 530285.
ilammy added a comment.

Addressing feedback by  @MaskRay:

- Moved `// REQUIRES:` directive to the top of the test file
- Replaced legacy `-target` option with proper `--target` in tests
- Also rebased on updated trunk


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

https://reviews.llvm.org/D145849

Files:
  clang/lib/Driver/XRayArgs.cpp
  clang/test/Driver/XRay/xray-instrument-macos.c
  clang/test/Driver/XRay/xray-instrument-os.c


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, 
target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, 
target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
-// RUN: %clang -o /dev/null -v -fxray-instrument -target 
x86_64-apple-macos10.11 -c %s
-// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 
-c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
+// RUN: %clang -o /dev/null -v -fxray-instrument --target 
aarch64-apple-darwin20 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target 
x86_64-apple-macos10.11 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target 
x86_64-apple-darwin15 -c %s
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
   } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
-// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-macos10.11 -c %s
-// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 -c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
+// RUN: %clang -o /dev/null -v -fxray-instrument --target aarch64-apple-darwin20 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target x86_64-apple-macos10.11 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target x86_64-apple-darwin15 -c %s
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  

[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-06-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy updated this revision to Diff 530284.
ilammy added a comment.

Addressing feedback by @MaskRay:

- Moved `// REQUIRES:` directive to the top of the test file


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

https://reviews.llvm.org/D145848

Files:
  clang/include/clang/Driver/Options.td
  clang/test/CodeGen/xray-function-index.cpp


Index: clang/test/CodeGen/xray-function-index.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -fxray-instrument  -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-DISABLED
+
+[[clang::xray_always_instrument]] void foo() {}
+
+// CHECK-LABEL: .section xray_instr_map,"ao",@progbits,_Z3foov
+// CHECK-ENABLED: .section xray_fn_idx,"awo",@progbits,_Z3foov
+// CHECK-DISABLED-NOT: .section xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2216,10 +2216,10 @@
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,


Index: clang/test/CodeGen/xray-function-index.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -fxray-instrument  -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DISABLED
+
+[[clang::xray_always_instrument]] void foo() {}
+
+// CHECK-LABEL: .section xray_instr_map,"ao",@progbits,_Z3foov
+// CHECK-ENABLED: .section xray_fn_idx,"awo",@progbits,_Z3foov
+// CHECK-DISABLED-NOT: .section xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2216,10 +2216,10 @@
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152645: [clangd] Handle DependentNameType in HeuristicResolver::resolveTypeToRecordDecl()

2023-06-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/HeuristicResolver.cpp:38
+  if (const auto *TD = dyn_cast(Decls[0])) {
+return Ctx.getTypeDeclType(TD).getTypePtr();
+  }

I wanted to call out the change on this line which is easy to overlook due to 
the code move:

We were previously calling 
[TypeDecl::getTypeForDecl()](https://searchfox.org/llvm/rev/5b657f50b8e8dc5836fb80e566ca7569fd04c26f/clang/include/clang/AST/Decl.h#3301),
 but that's actually a low-level accessor for a cached value. The function that 
also populates the value if needed is `ASTContext::getTypeDeclType()`, hence I 
switch to using that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152645

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


[PATCH] D152645: [clangd] Handle DependentNameType in HeuristicResolver::resolveTypeToRecordDecl()

2023-06-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Depends on D152500 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152645

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


[PATCH] D152645: [clangd] Handle DependentNameType in HeuristicResolver::resolveTypeToRecordDecl()

2023-06-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added reviewers: hokein, sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152645

Files:
  clang-tools-extra/clangd/HeuristicResolver.cpp
  clang-tools-extra/clangd/HeuristicResolver.h
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -877,6 +877,22 @@
 }
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
+
+  Code = R"cpp(
+template 
+struct Waldo {
+  void find();
+};
+template 
+struct MetaWaldo {
+  using Type = Waldo;
+};
+template 
+void foo(typename MetaWaldo::Type w) {
+  w.[[find]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.h
===
--- clang-tools-extra/clangd/HeuristicResolver.h
+++ clang-tools-extra/clangd/HeuristicResolver.h
@@ -94,6 +94,14 @@
   // `E`.
   const Type *resolveExprToType(const Expr *E) const;
   std::vector resolveExprToDecls(const Expr *E) const;
+
+  // Helper function for HeuristicResolver::resolveDependentMember()
+  // which takes a possibly-dependent type `T` and heuristically
+  // resolves it to a CXXRecordDecl in which we can try name lookup.
+  CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) const;
+
+  const Type *
+  resolveDeclsToType(const std::vector ) const;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/Type.h"
 
 namespace clang {
 namespace clangd {
@@ -29,15 +30,35 @@
   return isa(D);
 };
 
+const Type *HeuristicResolver::resolveDeclsToType(
+const std::vector ) const {
+  if (Decls.size() != 1) // Names an overload set -- just bail.
+return nullptr;
+  if (const auto *TD = dyn_cast(Decls[0])) {
+return Ctx.getTypeDeclType(TD).getTypePtr();
+  }
+  if (const auto *VD = dyn_cast(Decls[0])) {
+return VD->getType().getTypePtrOrNull();
+  }
+  return nullptr;
+}
+
 // Helper function for HeuristicResolver::resolveDependentMember()
 // which takes a possibly-dependent type `T` and heuristically
 // resolves it to a CXXRecordDecl in which we can try name lookup.
-CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
+CXXRecordDecl *HeuristicResolver::resolveTypeToRecordDecl(const Type *T) const {
   assert(T);
 
   // Unwrap type sugar such as type aliases.
   T = T->getCanonicalTypeInternal().getTypePtr();
 
+  if (const auto *DNT = T->getAs()) {
+T = resolveDeclsToType(resolveDependentNameType(DNT));
+if (!T)
+  return nullptr;
+T = T->getCanonicalTypeInternal().getTypePtr();
+  }
+
   if (const auto *RT = T->getAs())
 return dyn_cast(RT->getDecl());
 
@@ -185,18 +206,6 @@
   DTST->getIdentifier(), TemplateFilter);
 }
 
-const Type *resolveDeclsToType(const std::vector ) {
-  if (Decls.size() != 1) // Names an overload set -- just bail.
-return nullptr;
-  if (const auto *TD = dyn_cast(Decls[0])) {
-return TD->getTypeForDecl();
-  }
-  if (const auto *VD = dyn_cast(Decls[0])) {
-return VD->getType().getTypePtrOrNull();
-  }
-  return nullptr;
-}
-
 std::vector
 HeuristicResolver::resolveExprToDecls(const Expr *E) const {
   if (const auto *ME = dyn_cast(E)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142630: [clang][Interp] Implement virtual function calls

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



Comment at: clang/test/AST/Interp/records.cpp:650
+};
+#endif

aaron.ballman wrote:
> We should also have test cases for calling virtual functions from within a 
> constructor and a destructor, as that has special semantics. e.g., 
> https://godbolt.org/z/snaj1zfM5
That's broken right now of course. I'l add the test and adjust the expected 
output. I'll probably have to save a few bits for "things we're currently 
doing" (like evaluating a constructor), but in a later patch.

FWIW, I expanded your test a bit: https://godbolt.org/z/vq5xT3xvq and it only 
fails in clang - with a reference:
```
  // CWG issue 1517: we're constructing a base class of the object described by
  // 'This', so that object has not yet begun its period of construction and
  // any polymorphic operation on it results in undefined behavior.
```


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

https://reviews.llvm.org/D142630

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


[PATCH] D152632: [Clang] Add warnings for CWG2521

2023-06-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill requested changes to this revision.
Endill added a comment.
This revision now requires changes to proceed.

Thank you for working on this!

In D152632#4411587 , @rZhBoYao wrote:

> Few questions:
> I think this applies to all the language modes?

Yes, we rarely limit the scope of DRs, and I'm looking forward to get rid of 
exceptions from this approach (grep "since" in cxx_dr_status.html 
).

> Somehow, https://wg21.link/CWG2521 is not redirecting to 
> https://cplusplus.github.io/CWG/issues/2521.html. Is this normal?

It happens, especially with recently updated DRs. I see it in CWG index 
, so you can 
ignore broken wg21.link.




Comment at: clang/www/cxx_dr_status.html:14936
 User-defined literals and reserved identifiers
-Unknown
+Clang 17
   

This file shouldn't be edited manually. You should write a test in 
`clang/test/CXX/drs/dr25xx.cpp`, and then run `clang/www/make_cxx_dr_status` 
script that updates `cxx_dr_status.html`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152632

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


[PATCH] D152500: [clangd] Handle alias template in HeuristicResolver::resolveTypeToRecordDecl()

2023-06-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: jeroen.dobbelaere, kadircet, arphaman.
Herald added a project: All.
nridge updated this revision to Diff 530279.
nridge added a comment.
nridge published this revision for review.
nridge added reviewers: hokein, sammccall.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Make the approach more general


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152500

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


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -863,6 +863,20 @@
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr",
"template  T convert() const");
+
+  Code = R"cpp(
+template 
+struct Waldo {
+  void find();
+};
+template 
+using Wally = Waldo;
+template 
+void foo(Wally w) {
+  w.[[find]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -35,6 +35,9 @@
 CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
   assert(T);
 
+  // Unwrap type sugar such as type aliases.
+  T = T->getCanonicalTypeInternal().getTypePtr();
+
   if (const auto *RT = T->getAs())
 return dyn_cast(RT->getDecl());
 


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -863,6 +863,20 @@
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr",
"template  T convert() const");
+
+  Code = R"cpp(
+template 
+struct Waldo {
+  void find();
+};
+template 
+using Wally = Waldo;
+template 
+void foo(Wally w) {
+  w.[[find]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -35,6 +35,9 @@
 CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
   assert(T);
 
+  // Unwrap type sugar such as type aliases.
+  T = T->getCanonicalTypeInternal().getTypePtr();
+
   if (const auto *RT = T->getAs())
 return dyn_cast(RT->getDecl());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits