[PATCH] D154290: [WIP][Clang] Implement P2741R3 - user-generated static_assert messages

2023-07-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 536570.
cor3ntin edited the summary of this revision.
cor3ntin added a comment.

Add feature test macro and complete ODRDiagsEmitter change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -140,7 +140,7 @@
  
   User-generated static_assert messages
   https://wg21.link/P2741R3";>P2741R3
-  No
+  Clang 17
  
  
   Placeholder variables with no name
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
 return true;
-  if (StringLiteral *Message = D->getMessage())
+  if (auto *Message = dyn_cast(D->getMessage()))
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -std=c++2c -fsyntax-only %s -verify
+
+static_assert(true, "");
+static_assert(true, 0); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct Empty{};
+static_assert(true, Empty{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct NoData {
+unsigned long size() const;
+};
+struct NoSize {
+const char* data() const;
+};
+static_assert(true, NoData{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+static_assert(true, NoSize{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+
+struct InvalidSize {
+const char* size() const;
+const char* data() const;
+};
+static_assert(true, InvalidSize{}); // expected-error {{the message in a static_assert declaration must have a size() member function returning an object convertible to std::size_t}} \
+// expected-error {{value of type 'const char *' is not implicitly convertible to 'unsigned long'}}
+struct InvalidData {
+unsigned long size() const;
+unsigned long data() const;
+};
+static_assert(true, InvalidData{}); // expected-error {{the message in a static_assert declaration must have a data() member function returning an object convertible to const char*}} \
+// expected-error {{value of type 'unsigned long' is not implicitly convertible to 'const char *'}}
+
+struct NonConstexprSize {
+unsigned long size() const; // expected-note {{declared here}}
+constexpr const char* data() const;
+};
+
+static_assert(true, NonConstexprSize{});
+static_assert(false, NonConstexprSize{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'size' cannot be used in a constant expression}}
+
+struct NonConstexprData {
+constexpr unsigned long size() const {
+return 32;
+}
+const char* data() const;  // expected-note {{declared here}}
+};
+
+static_assert(true, NonConstexprData{});
+static_assert(false, NonConstexprData{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'data' cannot be used in a constant expression}}
+
+struct string_view {
+int S;
+c

[PATCH] D154209: [X86] Add missing features for ivybridge, sandybridge and knl in X86TargetParser.def.

2023-07-01 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

In D154209#4466304 , @RKSimon wrote:

> LGTM - but it would be good to fix silvermont / westmere cases as well with 
> suitable test coverage

Thanks review! After D151696  landed, they 
can be both fixed and there will be more tests cover such missing like 
clang/test/Preprocessor/predefined-arch-macros.c. And about cpu_specific test 
coverage, I'll consider a way to refine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154209

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


[clang] 381e805 - [clang][Sema][NFC] Make worklist in CheckForIntOverflow const

2023-07-01 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-02T06:49:55+02:00
New Revision: 381e8052d0966a247f811cfc301059393d3c650a

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

LOG: [clang][Sema][NFC] Make worklist in CheckForIntOverflow const

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4cb02f31b6514f..eed23e5ba99c89 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13745,7 +13745,7 @@ class Sema final {
 private:
   void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
   void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
-  void CheckForIntOverflow(Expr *E);
+  void CheckForIntOverflow(const Expr *E);
   void CheckUnsequencedOperations(const Expr *E);
 
   /// Perform semantic checks on a completed expression. This will either

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 09ce790f7b5ca1..294d9bfac73a5c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -15189,39 +15189,39 @@ void Sema::CheckBoolLikeConversion(Expr *E, 
SourceLocation CC) {
 
 /// Diagnose when expression is an integer constant expression and its 
evaluation
 /// results in integer overflow
-void Sema::CheckForIntOverflow (Expr *E) {
+void Sema::CheckForIntOverflow (const Expr *E) {
   // Use a work list to deal with nested struct initializers.
-  SmallVector Exprs(1, E);
+  SmallVector Exprs(1, E);
 
   do {
-Expr *OriginalE = Exprs.pop_back_val();
-Expr *E = OriginalE->IgnoreParenCasts();
+const Expr *OriginalE = Exprs.pop_back_val();
+const Expr *E = OriginalE->IgnoreParenCasts();
 
 if (isa(E)) {
   E->EvaluateForOverflow(Context);
   continue;
 }
 
-if (auto InitList = dyn_cast(OriginalE))
+if (const auto *InitList = dyn_cast(OriginalE))
   Exprs.append(InitList->inits().begin(), InitList->inits().end());
 else if (isa(OriginalE))
   E->EvaluateForOverflow(Context);
-else if (auto Call = dyn_cast(E))
+else if (const auto *Call = dyn_cast(E))
   Exprs.append(Call->arg_begin(), Call->arg_end());
-else if (auto Message = dyn_cast(E))
+else if (const auto *Message = dyn_cast(E))
   Exprs.append(Message->arg_begin(), Message->arg_end());
-else if (auto Construct = dyn_cast(E))
+else if (const auto *Construct = dyn_cast(E))
   Exprs.append(Construct->arg_begin(), Construct->arg_end());
-else if (auto Temporary = dyn_cast(E))
+else if (const auto *Temporary = dyn_cast(E))
   Exprs.push_back(Temporary->getSubExpr());
-else if (auto Array = dyn_cast(E))
+else if (const auto *Array = dyn_cast(E))
   Exprs.push_back(Array->getIdx());
-else if (auto Compound = dyn_cast(E))
+else if (const auto *Compound = dyn_cast(E))
   Exprs.push_back(Compound->getInitializer());
-else if (auto New = dyn_cast(E)) {
-  if (New->isArray())
-if (auto ArraySize = New->getArraySize())
-  Exprs.push_back(*ArraySize);
+else if (const auto *New = dyn_cast(E);
+ New && New->isArray()) {
+  if (auto ArraySize = New->getArraySize())
+Exprs.push_back(*ArraySize);
 }
   } while (!Exprs.empty());
 }



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


[PATCH] D154290: [WIP][Clang] Implement P2741R3 - user-generated static_assert messages

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



Comment at: clang/lib/AST/ExprConstant.cpp:16384
+   Expr *SizeExpression,
+   Expr *PtrExpression, ASTContext &Ctx,
+   EvalResult &Status) const {

Any reason the `Expr*` pointers here can't be `const`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

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


[PATCH] D153017: [analyzer] Fix false negative when using a nullable parameter directly without binding to a variable

2023-07-01 Thread tripleCC via Phabricator via cfe-commits
tripleCC marked an inline comment as done.
tripleCC added a comment.

In D153017#4428432 , @steakhal wrote:

> LGTM; I'll commit this on Monday.

Hi steakhal again, sorry to bother you. Do you mind committing the revision for 
me ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153017

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


[clang] 0a9d2fa - [clang][Interp][NFC] Fix a test to actually test something

2023-07-01 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-02T06:49:55+02:00
New Revision: 0a9d2fa9ac9ec12eb4d50674d40fc73510fef405

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

LOG: [clang][Interp][NFC] Fix a test to actually test something

This was always meant to test the values of c2, not c.

Added: 


Modified: 
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/test/AST/Interp/records.cpp 
b/clang/test/AST/Interp/records.cpp
index 68d902a66e3ca2..8d976551cdf59b 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -111,8 +111,8 @@ static_assert(c.a == 100, "");
 static_assert(c.b == 200, "");
 
 constexpr C c2 = C().get();
-static_assert(c.a == 100, "");
-static_assert(c.b == 200, "");
+static_assert(c2.a == 100, "");
+static_assert(c2.b == 200, "");
 
 constexpr int getB() {
   C c;



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


[PATCH] D154221: [analyzer] Fix false negative when pass implicit cast nil to nonnull

2023-07-01 Thread tripleCC via Phabricator via cfe-commits
tripleCC added a comment.

I don't have commit access, would you mind committing the revision for me ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154221

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


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-01 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added a project: All.
HaohaiWen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

D154070  has added /dwodir to lld/COFF to 
tells LTO backend to create dwo
directory and files. This patch makes clang to emit /dwodir to lld when
user specify -gsplit-dwarf with LTO. This behavior is simiar to DWARF
fission with LTO for ELF.

A simple use case:
$clang-cl -c -flto -gdwarf main.c -o main.o
$clang-cl -c -flto -gdwarf a.c -o a.o
$clang-cl -flto -fuse-ld=lld -gdwarf -gsplit-dwarf main.o a.o

This'll generate a dwo file: main.exe_dwo/0.dwo


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154295

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/lto-dwo.c


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ clang/test/Driver/lto-dwo.c
@@ -1,6 +1,9 @@
 // Confirm that -gsplit-dwarf=DIR is passed to linker
 
 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf 
-o a.out 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s
+// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto 
-gsplit-dwarf -o a.out -- %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s
 //
-// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-ELF-DWO-DIR-DEFAULT:  "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   else if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
-  if (Linker == "lld-link")
+  if (Linker == "lld-link") {
 for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
   CmdArgs.push_back(
   Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
 
+if (C.getDriver().isUsingLTO() &&
+Args.hasFlag(options::OPT_gsplit_dwarf, options::OPT_gno_split_dwarf,
+ false))
+  CmdArgs.push_back(Args.MakeArgString(Twine("/dwodir:") +
+   Output.getFilename() + "_dwo"));
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ clang/test/Driver/lto-dwo.c
@@ -1,6 +1,9 @@
 // Confirm that -gsplit-dwarf=DIR is passed to linker
 
 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf -o a.out 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s
+// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto -gsplit-dwarf -o a.out -- %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s
 //
-// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-ELF-DWO-DIR-DEFAULT:  "-plugin-opt=dwo_dir=a.out_dwo"
+// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   else if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
-  if (Linker == "lld-link")
+  if (Linker == "lld-link") {
 for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
   CmdArgs.push_back(
   Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
 
+if (C.getDriver().isUsingLTO() &&
+Args.hasFlag(options::OPT_gsplit_dwarf, options::OPT_gno_split_dwarf,
+ false))
+  CmdArgs.push_back(Args.MakeArgString(Twine("/dwodir:") +
+   Output.getFilename() + "_dwo"));
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154184: [clang-format] Correctly annotate */&/&& in operator function calls

2023-07-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 536566.
owenpan added a comment.

Re-annotate */&/&& only if `isCpp()` is true.


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

https://reviews.llvm.org/D154184

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -594,61 +594,59 @@
 TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) {
   auto Tokens = annotate("x.operator+()");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::plus, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator=()");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::equal, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator+=()");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::plusequal, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator,()");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::comma, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator()()");
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::r_paren, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator[]()");
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   // EXPECT_TOKEN(Tokens[3], tok::l_square, TT_OverloadedOperator);
   // EXPECT_TOKEN(Tokens[4], tok::r_square, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator\"\"_a()");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator\"\" _a()");
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
-  // FIXME
-  // EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator\"\"if()");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator\"\"s()");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
   Tokens = annotate("x.operator\"\" s()");
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
-  // FIXME
-  // EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
   EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
   EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
 
@@ -678,20 +676,44 @@
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_OverloadedOperatorLParen);
   EXPECT_TOKEN(Tokens[8], tok::star, TT_PointerOrReference);
 
+  Tokens = annotate("class Foo {\n"
+"  int c = operator+(a * b);\n"
+

[clang] 289828b - [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread via cfe-commits

Author: Haohai Wen
Date: 2023-07-02T09:29:09+08:00
New Revision: 289828b1c0a6bc6eed8a634376a5152adae2283b

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

LOG: [Driver][MSVC] Move lld specific flags before inputs

Check linker earlier so that lld specific flags can be append before
inputs. Just like position of other flags. The intention is to make
expanded cmd more consistent and elegent so that user can easily
look for inputs when using -###.

Reviewed By: mstorsjo

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/msvc-link.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 2ffe0d56835c57..6b2eaef1f2e7d1 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@ void visualstudio::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker = "lld-link";
+
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@ void visualstudio::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-Linker = "lld-link";
-
-  if (Linker == "lld-link")
-for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
-
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install

diff  --git a/clang/test/Driver/msvc-link.c b/clang/test/Driver/msvc-link.c
index b0bc837d57a62d..64e099ea63042f 100644
--- a/clang/test/Driver/msvc-link.c
+++ b/clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"



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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread 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 rG289828b1c0a6: [Driver][MSVC] Move lld specific flags before 
inputs (authored by HaohaiWen, committed by hh ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/msvc-link.c


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker = "lld-link";
+
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-Linker = "lld-link";
-
-  if (Linker == "lld-link")
-for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
-
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker = "lld-link";
+
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-Linker = "lld-link";
-
-  if (Linker == "lld-link")
-for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
-
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] c0e23bc - [clang] P1816R0 and P2082R1 should work for cxx20 and after only

2023-07-01 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2023-07-01T17:23:41-07:00
New Revision: c0e23bcdfb743f4d7d05e215fb60c987f629498d

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

LOG: [clang] P1816R0 and P2082R1 should work for cxx20 and after only

For commit 632dd6a4ca0036009f

Added: 


Modified: 
clang/lib/Sema/SemaInit.cpp
clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 90c1bfa8f6d1fa..b893d358dfe790 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10675,7 +10675,7 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
   TD, FoundDecl, /*ExplicitArgs=*/nullptr, TmpInits, Candidates,
   SuppressUserConversions,
   /*PartialOverloading=*/false, AllowExplicit, ADLCallKind::NotADL,
-  /*PO=*/{}, /*AggregateCandidateDeduction=*/true);
+  /*PO=*/{}, AllowAggregateDeductionCandidate);
 } else {
   AddOverloadCandidate(GD, FoundDecl, Inits, Candidates,
SuppressUserConversions,
@@ -10772,7 +10772,7 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
 //   parenthesized expression-list, and there are no deduction-guides for
 //   C, the set contains an additional function template, called the
 //   aggregate deduction candidate, defined as follows.
-if (!HasAnyDeductionGuide) {
+if (getLangOpts().CPlusPlus20 && !HasAnyDeductionGuide) {
   if (ListInit && ListInit->getNumInits()) {
 SynthesizeAggrGuide(ListInit);
   } else if (PL && PL->getNumExprs()) {

diff  --git a/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp 
b/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
index 4bec1a8d4c48a6..71189be0762364 100644
--- a/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
+++ b/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -1,15 +1,16 @@
-// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types 
-ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+// RUN: %clang_cc1 -std=c++17 -verify=expected,cxx17 %s
+// RUN: %clang_cc1 -std=c++20 -verify=expected,cxx20 -ast-dump 
-ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s 
--strict-whitespace
 
 namespace Basic {
-  template struct A {
+  template struct A { // cxx17-note 6 {{candidate}}
 T x;
 T y;
   };
 
-  A a1 = {3.0, 4.0};
-  A a2 = {.x = 3.0, .y = 4.0};
+  A a1 = {3.0, 4.0}; // cxx17-error {{no viable}}
+  A a2 = {.x = 3.0, .y = 4.0}; // cxx17-error {{no viable}}
 
-  A a3(3.0, 4.0);
+  A a3(3.0, 4.0); // cxx17-error {{no viable}}
 
   // CHECK-LABEL: Dumping Basic:::
   // CHECK: FunctionTemplateDecl {{.*}} implicit 
@@ -30,31 +31,31 @@ namespace Basic {
   // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
   // CHECK:   `-TemplateTypeParm {{.*}} 'T'
 
-  template  struct S { // expected-note 2 {{candidate}}
+  template  struct S { // cxx20-note 2 {{candidate}}
 T x;
 T y;
   };
 
-  template  struct C { // expected-note 10 {{candidate}}
+  template  struct C { // cxx20-note 10 {{candidate}} cxx17-note 
12 {{candidate}}
 S s;
 T t;
   };
 
-  template  struct D { // expected-note 6 {{candidate}}
+  template  struct D { // cxx20-note 6 {{candidate}} cxx17-note 8 
{{candidate}}
 S s;
 T t;
   };
 
   C c1 = {1, 2}; // expected-error {{no viable}}
   C c2 = {1, 2, 3}; // expected-error {{no viable}}
-  C c3 = {{1u, 2u}, 3};
+  C c3 = {{1u, 2u}, 3}; // cxx17-error {{no viable}}
 
   C c4(1, 2);// expected-error {{no viable}}
   C c5(1, 2, 3); // expected-error {{no viable}}
-  C c6({1u, 2u}, 3);
+  C c6({1u, 2u}, 3); // cxx17-error {{no viable}}
 
   D d1 = {1, 2}; // expected-error {{no viable}}
-  D d2 = {1, 2, 3};
+  D d2 = {1, 2, 3}; // cxx17-error {{no viable}}
 
   D d3(1, 2); // expected-error {{no viable}}
   // CTAD succeed but brace elision is not allowed for parenthesized aggregate 
init. 
@@ -98,14 +99,14 @@ namespace Basic {
   // CHECK:   |-ClassTemplateSpecialization {{.*}} 'S'
   // CHECK:   `-BuiltinType {{.*}} 'int'
 
-  template  struct E {
+  template  struct E { // cxx17-note 4 {{candidate}}
 T t;
 decltype(t) t2;
   };
 
-  E e1 = {1, 2};
+  E e1 = {1, 2}; // cxx17-error {{no viable}}
 
-  E e2(1, 2);
+  E e2(1, 2); // cxx17-error {{no viable}}
 
   // CHECK-LABEL: Dumping Basic:::
   // CHECK: FunctionTemplateDecl {{.*}} implicit 
@@ -132,12 +133,12 @@ namespace Basic {
   };
 
   template 
-  struct F {
+  struct F { // cxx17-note 2 {{candidate}}
 typename I::type i;
 T t;
   };
 
-  F f1 = {1, 2};
+  F f1 = {1, 2}; // cxx17-error {{no viable}}
 
   // CHECK-LABEL: Dumping Basic:::
   // CHECK: FunctionTemp

[PATCH] D154290: [WIP][Clang] Implement P2741R3 - user-generated static_assert messages Note that a few test fails because this patch depends on https://reviews.llvm.org/D105759 There are some issue

2023-07-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

...data are evaluated in the same 
evaluation context and that cleanup occurs once the message is produced
https://github.com/cplusplus/CWG/issues/350


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154290

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -140,7 +140,7 @@
  
   User-generated static_assert messages
   https://wg21.link/P2741R3";>P2741R3
-  No
+  Clang 17
  
  
   Placeholder variables with no name
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
 return true;
-  if (StringLiteral *Message = D->getMessage())
+  if (auto *Message = dyn_cast(D->getMessage()))
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -std=c++2c -fsyntax-only %s -verify
+
+static_assert(true, "");
+static_assert(true, 0); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct Empty{};
+static_assert(true, Empty{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct NoData {
+unsigned long size() const;
+};
+struct NoSize {
+const char* data() const;
+};
+static_assert(true, NoData{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+static_assert(true, NoSize{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+
+struct InvalidSize {
+const char* size() const;
+const char* data() const;
+};
+static_assert(true, InvalidSize{}); // expected-error {{the message in a static_assert declaration must have a size() member function returning an object convertible to std::size_t}} \
+// expected-error {{value of type 'const char *' is not implicitly convertible to 'unsigned long'}}
+struct InvalidData {
+unsigned long size() const;
+unsigned long data() const;
+};
+static_assert(true, InvalidData{}); // expected-error {{the message in a static_assert declaration must have a data() member function returning an object convertible to const char*}} \
+// expected-error {{value of type 'unsigned long' is not implicitly convertible to 'const char *'}}
+
+struct NonConstexprSize {
+unsigned long size() const; // expected-note {{declared here}}
+constexpr const char* data() const;
+};
+
+static_assert(true, NonConstexprSize{});
+static_assert(false, NonConstexprSize{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'size' cannot be used in a constant expression}}
+
+struct NonConstexprData {
+constexpr unsigned long size() const {
+return 32;
+}
+const char* data() const;  // expected-note {{declared here}}
+};
+
+static_assert(true, NonConstexprData{});
+static_assert(false, NonConstexprData{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'data' cannot be used in a constant expression}}
+

[PATCH] D154093: [clang-format] Break long strings in Verilog

2023-07-01 Thread sstwcw via Phabricator via cfe-commits
sstwcw added inline comments.



Comment at: clang/include/clang/Format/Format.h:1914
   ///const char* x =
-  ///  "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
+  ///"veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
   /// \endcode

It looks like they made a mistake in this example.  The second line gets 
indented by a continuation indentation both before and after this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154093

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


[PATCH] D154093: [clang-format] Break long strings in Verilog

2023-07-01 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked 2 inline comments as done.
sstwcw added a comment.

In D154093#4466246 , 
@HazardyKnusperkeks wrote:

> I'd really prefer you put what you need to modify `mutable` instead of 
> removing the `const` from everything else. But that's just my opinion.

Why should the `insertBreak` method be const?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154093

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


[PATCH] D154093: [clang-format] Break long strings in Verilog

2023-07-01 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 536555.
sstwcw added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154093

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/BreakableToken.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTestVerilog.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1770,6 +1770,24 @@
   EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_Unknown);
   EXPECT_TOKEN(Tokens[5], tok::comma, TT_Unknown);
   EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown);
+
+  // String literals in concatenation.
+  Tokens = Annotate("x = {\"\"};");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_VerilogStringInConcatenation);
+  Tokens = Annotate("x = {\"\", \"\"};");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_VerilogStringInConcatenation);
+  EXPECT_TOKEN(Tokens[5], tok::string_literal, TT_VerilogStringInConcatenation);
+  // Cases where the string should not be annotated that type.  Fix the
+  // `TT_Unknown` if needed in the future.
+  Tokens = Annotate("x = {\"\" == \"\"};");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_Unknown);
+  EXPECT_TOKEN(Tokens[5], tok::string_literal, TT_Unknown);
+  Tokens = Annotate("x = '{\"\"};");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::string_literal, TT_Unknown);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandConstructors) {
Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -1155,6 +1155,66 @@
   verifyFormat("{< 0 && Changes[i - 1].OriginalWhitespaceRange.getBegin() ==
- C.OriginalWhitespaceRange.getBegin()) {
-  // Do not generate two replacements for the same location.
-  continue;
+if (i > 0) {
+  auto Last = Changes[i - 1].OriginalWhitespaceRange;
+  auto New = Changes[i].OriginalWhitespaceRange;
+  // Do not generate two replacements for the same location.  As a special
+  // case, it is allowed if there is a replacement for the empty range
+  // between 2 tokens and another non-empty range at the start of the second
+  // token.
+  if (Last.getBegin() == New.getBegin() &&
+  (Last.getEnd() != Last.getBegin() ||
+   New.getEnd() == New.getBegin())) {
+continue;
+  }
 }
 if (C.CreateReplacement) {
   std::string ReplacementText = C.PreviousLinePostfix;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -867,6 +867,11 @@
 OpeningBrace.Previous->is(TT_JsTypeColon)) {
   Contexts.back().IsExpression = false;
 }
+if (Style.isVerilog() &&
+(!OpeningBrace.getPreviousNonComment() ||
+ OpeningBrace.getPreviousNonComment()->isNot(Keywords.kw_apostrophe))) {
+  Contexts.back().VerilogMayBeConcatenation = true;
+}
 
 unsigned CommaCount = 0;
 while (CurrentToken) {
@@ -1741,6 +1746,9 @@
 bool InCpp11AttributeSpecifier = false;
 bool InCSharpAttributeSpecifier = false;
 bool VerilogAssignmentFound = false;
+// Whether the braces may mean concatenation instead of structure or array
+// literal.
+bool VerilogMayBeConcatenation = false;
 enum {
   Unknown,
   // Like the part after `:` in a constructor.
@@ -2073,6 +2081,14 @@
   } else {
 Current.setType(TT_LineComment);
   }
+} else if (Current.is(tok::string_literal)) {
+  if (Style.isVerilog() && Contexts.back().VerilogMayBeConcatenation &&
+  Current.getPreviousNonComment() &&
+  Current.getPreviousNonComment()->isOneOf(tok::comma, tok::l_brace) &&
+  Current.getNextNonComment() &&
+  Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
+Current.setType(TT_VerilogStringInConcatenation);
+  }
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -163,6 +163,8 @@
   TYPE(Ver

[PATCH] D154285: [clang] Remove CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 updated this revision to Diff 536554.
JOE1994 added a comment.

- Add back in refactorings that either drop existing calls to 
CreateElementBitCast, or merge to Address creation.

- Update commit message to clarify that we're employing 3 different methods to 
remove existing calls to CreateElementBitCast


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp

Index: clang/lib/CodeGen/Targets/RISCV.cpp
===
--- clang/lib/CodeGen/Targets/RISCV.cpp
+++ clang/lib/CodeGen/Targets/RISCV.cpp
@@ -462,10 +462,8 @@
 
   // Empty records are ignored for parameter passing purposes.
   if (isEmptyRecord(getContext(), Ty, true)) {
-Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
-   getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
-return Addr;
+return Address(CGF.Builder.CreateLoad(VAListAddr),
+   CGF.ConvertTypeForMem(Ty), SlotSize);
   }
 
   auto TInfo = getContext().getTypeInfoInChars(Ty);
Index: clang/lib/CodeGen/Targets/CSKY.cpp
===
--- clang/lib/CodeGen/Targets/CSKY.cpp
+++ clang/lib/CodeGen/Targets/CSKY.cpp
@@ -63,10 +63,8 @@
 
   // Empty records are ignored for parameter passing purposes.
   if (isEmptyRecord(getContext(), Ty, true)) {
-Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
-   getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
-return Addr;
+return Address(CGF.Builder.CreateLoad(VAListAddr),
+   CGF.ConvertTypeForMem(Ty), SlotSize);
   }
 
   auto TInfo = getContext().getTypeInfoInChars(Ty);
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -809,12 +809,9 @@
 
   CGBuilderTy &Builder = CGF.Builder;
 
-  // Cast to char*.
-  Base = Builder.CreateElementBitCast(Base, CGF.Int8Ty);
-
   // Apply the offset, which we assume is non-null.
-  return Builder.CreateInBoundsGEP(Base.getElementType(), Base.getPointer(),
-   MemPtr, "memptr.offset");
+  return Builder.CreateInBoundsGEP(CGF.Int8Ty, Base.getPointer(), MemPtr,
+   "memptr.offset");
 }
 
 /// Perform a bitcast, derived-to-base, or base-to-derived member pointer
@@ -2043,7 +2040,7 @@
   if (!NonVirtualAdjustment && !VirtualAdjustment)
 return InitialPtr.getPointer();
 
-  Address V = CGF.Builder.CreateElementBitCast(InitialPtr, CGF.Int8Ty);
+  Address V = InitialPtr.withElementType(CGF.Int8Ty);
 
   // In a base-to-derived cast, the non-virtual adjustment is applied first.
   if (NonVirtualAdjustment && !IsReturnAdjustment) {
@@ -2054,7 +2051,7 @@
   // Perform the virtual adjustment if we have one.
   llvm::Value *ResultPtr;
   if (VirtualAdjustment) {
-Address VTablePtrPtr = CGF.Builder.CreateElementBitCast(V, CGF.Int8PtrTy);
+Address VTablePtrPtr = V.withElementType(CGF.Int8PtrTy);
 llvm::Value *VTablePtr = CGF.Builder.CreateLoad(VTablePtrPtr);
 
 llvm::Value *Offset;
@@ -2151,8 +2148,7 @@
 CookiePtr = CGF.Builder.CreateConstInBoundsByteGEP(CookiePtr, CookieOffset);
 
   // Write the number of elements into the appropriate slot.
-  Address NumElementsPtr =
-  CGF.Builder.CreateElementBitCast(CookiePtr, CGF.SizeTy);
+  Address NumElementsPtr = CookiePtr.withElementType(CGF.SizeTy);
   llvm::Instruction *SI = CGF.Builder.CreateStore(NumElements, NumElementsPtr);
 
   // Handle the array cookie specially in ASan.
@@ -2184,7 +2180,7 @@
   CGF.Builder.CreateConstInBoundsByteGEP(numElementsPtr, numElementsOffset);
 
   unsigned AS = allocPtr.getAddressSpace();
-  numElementsPtr = CGF.Builder.CreateElementBitCast(numElementsPtr, CGF.SizeTy);
+  numElementsPtr = numElementsPtr.withElementType(CGF.SizeTy);
   if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) || AS != 0)
 return CGF.Builder.CreateLoad(numElementsPtr);
   // In asan mode emit a function call instead of a regular load and let the
@@ -2223,7 +2219,7 @@
   Address cookie = newPtr;
 
   // The first element is the element size.
-  cookie = CGF.Builder.CreateElementBitCast(cookie, CGF.SizeTy);
+  cookie = cookie.withElementType(CGF.SizeTy);
   llvm::Value *elementSize = llvm::ConstantInt::get(CGF.SizeTy,
  getContext().getTypeSizeInChars(eleme

[PATCH] D154285: [clang] Remove CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Nikita Popov via Phabricator via cfe-commits
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

The entire change is NFC cleanup, it makes no sense to separate it. Please 
revert to previous patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Remove CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 accepted this revision.
jrtc27 added a comment.

Thanks for the updated diff (would have also been happy with having a new 
commit *before* this one that does the non-trivial changes, but this works too 
and can be followed up with the cleanups you were making if you want to)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Remove CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 added inline comments.



Comment at: clang/lib/CodeGen/CGBuilder.h:158
 
   /// This method is to be deprecated. Use `Address::withElementType` instead.
+  [[deprecated("Use `Address::withElementType` instead.")]]

jrtc27 wrote:
> jrtc27 wrote:
> > JOE1994 wrote:
> > > nikic wrote:
> > > > JOE1994 wrote:
> > > > > 
> > > > This is a private method, so simply delete it instead of deprecating.
> > > It seems like this method is listed as "public" member functions in 
> > > https://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CGBuilderTy.html .
> > > 
> > > I see the `public` specifier on line 50.
> > It's public in the sense of its access specifier, i.e. that it can be used 
> > outside of CGBuiltin, but it's private in the sense that this header is in 
> > clang/lib/CodeGen and thus only used within Clang itself, not exposed as a 
> > Clang API, so if Clang isn't using it any more, nothing is.
> Uh, CGBuilderTy, not CGBuiltin
Thanks for the clarification! I got rid of the method in the updated revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 updated this revision to Diff 536552.
JOE1994 added a comment.

- Undo some refactorings to make the diff more consistent with commit message 
(following feedback from @jrtc27)

- Remove method CreateElementBitCast (following feedback from @nikic)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp

Index: clang/lib/CodeGen/Targets/RISCV.cpp
===
--- clang/lib/CodeGen/Targets/RISCV.cpp
+++ clang/lib/CodeGen/Targets/RISCV.cpp
@@ -464,7 +464,7 @@
   if (isEmptyRecord(getContext(), Ty, true)) {
 Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
+Addr = Addr.withElementType(CGF.ConvertTypeForMem(Ty));
 return Addr;
   }
 
Index: clang/lib/CodeGen/Targets/CSKY.cpp
===
--- clang/lib/CodeGen/Targets/CSKY.cpp
+++ clang/lib/CodeGen/Targets/CSKY.cpp
@@ -65,7 +65,7 @@
   if (isEmptyRecord(getContext(), Ty, true)) {
 Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
+Addr = Addr.withElementType(CGF.ConvertTypeForMem(Ty));
 return Addr;
   }
 
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -810,7 +810,7 @@
   CGBuilderTy &Builder = CGF.Builder;
 
   // Cast to char*.
-  Base = Builder.CreateElementBitCast(Base, CGF.Int8Ty);
+  Base = Base.withElementType(CGF.Int8Ty);
 
   // Apply the offset, which we assume is non-null.
   return Builder.CreateInBoundsGEP(Base.getElementType(), Base.getPointer(),
@@ -2043,7 +2043,7 @@
   if (!NonVirtualAdjustment && !VirtualAdjustment)
 return InitialPtr.getPointer();
 
-  Address V = CGF.Builder.CreateElementBitCast(InitialPtr, CGF.Int8Ty);
+  Address V = InitialPtr.withElementType(CGF.Int8Ty);
 
   // In a base-to-derived cast, the non-virtual adjustment is applied first.
   if (NonVirtualAdjustment && !IsReturnAdjustment) {
@@ -2054,7 +2054,7 @@
   // Perform the virtual adjustment if we have one.
   llvm::Value *ResultPtr;
   if (VirtualAdjustment) {
-Address VTablePtrPtr = CGF.Builder.CreateElementBitCast(V, CGF.Int8PtrTy);
+Address VTablePtrPtr = V.withElementType(CGF.Int8PtrTy);
 llvm::Value *VTablePtr = CGF.Builder.CreateLoad(VTablePtrPtr);
 
 llvm::Value *Offset;
@@ -2151,8 +2151,7 @@
 CookiePtr = CGF.Builder.CreateConstInBoundsByteGEP(CookiePtr, CookieOffset);
 
   // Write the number of elements into the appropriate slot.
-  Address NumElementsPtr =
-  CGF.Builder.CreateElementBitCast(CookiePtr, CGF.SizeTy);
+  Address NumElementsPtr = CookiePtr.withElementType(CGF.SizeTy);
   llvm::Instruction *SI = CGF.Builder.CreateStore(NumElements, NumElementsPtr);
 
   // Handle the array cookie specially in ASan.
@@ -2184,7 +2183,7 @@
   CGF.Builder.CreateConstInBoundsByteGEP(numElementsPtr, numElementsOffset);
 
   unsigned AS = allocPtr.getAddressSpace();
-  numElementsPtr = CGF.Builder.CreateElementBitCast(numElementsPtr, CGF.SizeTy);
+  numElementsPtr = numElementsPtr.withElementType(CGF.SizeTy);
   if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) || AS != 0)
 return CGF.Builder.CreateLoad(numElementsPtr);
   // In asan mode emit a function call instead of a regular load and let the
@@ -2223,7 +,7 @@
   Address cookie = newPtr;
 
   // The first element is the element size.
-  cookie = CGF.Builder.CreateElementBitCast(cookie, CGF.SizeTy);
+  cookie = cookie.withElementType(CGF.SizeTy);
   llvm::Value *elementSize = llvm::ConstantInt::get(CGF.SizeTy,
  getContext().getTypeSizeInChars(elementType).getQuantity());
   CGF.Builder.CreateStore(elementSize, cookie);
@@ -2246,7 +2245,7 @@
   Address numElementsPtr
 = CGF.Builder.CreateConstInBoundsByteGEP(allocPtr, CGF.getSizeSize());
 
-  numElementsPtr = CGF.Builder.CreateElementBitCast(numElementsPtr, CGF.SizeTy);
+  numElementsPtr = numElementsPtr.withElementType(CGF.SizeTy);
   return CGF.Builder.CreateLoad(numElementsPtr);
 }
 
@@ -2415,7 +2414,7 @@
   if (!threadsafe || MaxInlineWidthInBits) {
 // Load the first byte of the guard variable.
 llvm::LoadInst *LI =
-Builder.CreateLoad(Builder.CreateElementBitCast(guardAddr, CGM.Int8Ty));
+  

[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/CodeGen/CGBuilder.h:158
 
   /// This method is to be deprecated. Use `Address::withElementType` instead.
+  [[deprecated("Use `Address::withElementType` instead.")]]

jrtc27 wrote:
> JOE1994 wrote:
> > nikic wrote:
> > > JOE1994 wrote:
> > > > 
> > > This is a private method, so simply delete it instead of deprecating.
> > It seems like this method is listed as "public" member functions in 
> > https://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CGBuilderTy.html .
> > 
> > I see the `public` specifier on line 50.
> It's public in the sense of its access specifier, i.e. that it can be used 
> outside of CGBuiltin, but it's private in the sense that this header is in 
> clang/lib/CodeGen and thus only used within Clang itself, not exposed as a 
> Clang API, so if Clang isn't using it any more, nothing is.
Uh, CGBuilderTy, not CGBuiltin


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/CodeGen/CGBuilder.h:158
 
   /// This method is to be deprecated. Use `Address::withElementType` instead.
+  [[deprecated("Use `Address::withElementType` instead.")]]

JOE1994 wrote:
> nikic wrote:
> > JOE1994 wrote:
> > > 
> > This is a private method, so simply delete it instead of deprecating.
> It seems like this method is listed as "public" member functions in 
> https://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CGBuilderTy.html .
> 
> I see the `public` specifier on line 50.
It's public in the sense of its access specifier, i.e. that it can be used 
outside of CGBuiltin, but it's private in the sense that this header is in 
clang/lib/CodeGen and thus only used within Clang itself, not exposed as a 
Clang API, so if Clang isn't using it any more, nothing is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 added inline comments.



Comment at: clang/lib/CodeGen/CGBuilder.h:158
 
   /// This method is to be deprecated. Use `Address::withElementType` instead.
+  [[deprecated("Use `Address::withElementType` instead.")]]

nikic wrote:
> JOE1994 wrote:
> > 
> This is a private method, so simply delete it instead of deprecating.
It seems like this method is listed as "public" member functions in 
https://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CGBuilderTy.html .

I see the `public` specifier on line 50.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3896
 llvm::Type *OrigBaseElemTy = Addr.getElementType();
-Addr = Builder.CreateElementBitCast(Addr, Int8Ty);
 

JOE1994 wrote:
> barannikov88 wrote:
> > jrtc27 wrote:
> > > This one isn't a direct substitution, although appears to be refactoring 
> > > the code to not need withElementType in the first place? Probably best to 
> > > separate that change out from the very mechanical substitution.
> > It will be difficult to find all such places later.
> @jrtc27 Thank you for taking the time to review this revision.
> 
> This isn't a direct substitution.
> In this revision overall, I did refactoring to get rid of unnecessary calls 
> to `withElementType()` when possible.
> 
> Since these are relatively small & local refactorings, I'd prefer to keep 
> them in this revision.
> But if you're strongly against including such refactorings in this revision, 
> I can separate them out to a new revision.
It's easier to review when the non-trivial changes (direct substitution) are 
kept separate from the trivial ones. That way it's also extremely clear what's 
intended to be different vs what was accidentally made different. You *at 
least* need to fix the commit message to say that you're not just replacing the 
in-tree uses, you're also refactoring some uses to not need it (currently your 
commit message is in direct contradiction with the diff), but the fact that the 
commit then does two things that can be reasonably separated out suggests that 
they should be. And I would much rather see that happen, especially from the 
perspective of maintaining a significant downstream fork.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

In D154176#4466230 , @HaohaiWen wrote:

> In D154176#4466190 , @mstorsjo 
> wrote:
>
>> In D154176#4466186 , @mstorsjo 
>> wrote:
>>
>>> Ok, thanks for clarifying. However I still don’t understand the “why” 
>>> aspect here. You’re writing
>>>
 so that lld specific flags can be append before inputs
>>>
>>> Are you planning on adding such flags in a later patch, position dependent 
>>> flags that need to be supplied before input files?
>>>
>>> Or does the change in order of command line arguments have an effect on the 
>>> behavior of the linker in this case?
>>
>> Ok, on second thought, I guess that parsing the vfsoverlay option before the 
>> inputs makes it have an effect where it didn’t before. Is that right? (Most 
>> flags in lld aren’t very order dependent since it just checks for any 
>> occurrence of a flag anywhere among the arguments.)
>
> I'm planing to add /dwodir to linker when user specify -gsplit-dwarf and 
> using lld and lto.
> The order does not matter.

Ok, thanks for clarifying that - since I didn't quite understand how this 
change would be needed for that option.

> I just want it looks more consistent and elegent since most flags are before 
> inputs so that user can easily look for inputs when using -###.

Ok, that sounds reasonable. Please clarify that intent in the commit message, 
and this seems ok to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3896
 llvm::Type *OrigBaseElemTy = Addr.getElementType();
-Addr = Builder.CreateElementBitCast(Addr, Int8Ty);
 

barannikov88 wrote:
> jrtc27 wrote:
> > This one isn't a direct substitution, although appears to be refactoring 
> > the code to not need withElementType in the first place? Probably best to 
> > separate that change out from the very mechanical substitution.
> It will be difficult to find all such places later.
@jrtc27 Thank you for taking the time to review this revision.

This isn't a direct substitution.
In this revision overall, I did refactoring to get rid of unnecessary calls to 
`withElementType()` when possible.

Since these are relatively small & local refactorings, I'd prefer to keep them 
in this revision.
But if you're strongly against including such refactorings in this revision, I 
can separate them out to a new revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3954
 Function *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_setjmp);
-Buf = Builder.CreateElementBitCast(Buf, Int8Ty);
 return RValue::get(Builder.CreateCall(F, Buf.getPointer()));

barannikov88 wrote:
> jrtc27 wrote:
> > Missed `Buf = Buf.withElementType(Int8Ty);`? According to the comment 
> > above, Buf is a `void **` not a `void *`/`char *`.
> It would be a dead code because only the pointer is used down below.
> 
ElementType associated with `Buf` is never referenced,
so I intentionally omitted `Buf = Buf.withElementType(Int8Ty);`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154287: [clang-tidy] Add modernize-use-std-format check

2023-07-01 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe created this revision.
mikecrowe added a reviewer: PiotrZSL.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Add a new clang-tidy check that converts absl::StrFormat (and similar
functions) to std::format (and similar functions.)

Separate the configuration of FormatStringConverter out to a separate
Configuration class so that we don't risk confusion by passing two
boolean configuration parameters into the constructor. Add
AllowTrailingNewlineRemoval option since we never want to remove
trailing newlines in this check.

Depends on D154283 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154287

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
  clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
  clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
  clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-custom.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp
@@ -0,0 +1,75 @@
+// RUN: %check_clang_tidy \
+// RUN:   -std=c++20 %s modernize-use-std-format %t -- \
+// RUN:   -config="{CheckOptions: [{key: StrictMode, value: true}]}" \
+// RUN:   -- -isystem %clang_tidy_headers
+// RUN: %check_clang_tidy \
+// RUN:   -std=c++20 %s modernize-use-std-format %t -- \
+// RUN:   -config="{CheckOptions: [{key: StrictMode, value: false}]}" \
+// RUN:   -- -isystem %clang_tidy_headers
+#include 
+// CHECK-FIXES: #include 
+
+namespace absl
+{
+// Use const char * for the format since the real type is hard to mock up.
+template 
+std::string StrFormat(const char *format, const Args&... args);
+} // namespace absl
+
+std::string StrFormat_simple() {
+  return absl::StrFormat("Hello");
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("Hello");
+}
+
+std::string StrFormat_complex(const char *name, double value) {
+  return absl::StrFormat("'%s'='%f'", name, value);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("'{}'='{:f}'", name, value);
+}
+
+std::string StrFormat_integer_conversions() {
+  return absl::StrFormat("int:%d int:%d char:%c char:%c", 65, 'A', 66, 'B');
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("int:{} int:{:d} char:{:c} char:{}", 65, 'A', 66, 'B');
+}
+
+// FormatConverter is capable of removing newlines from the end of the format
+// string. Ensure that isn't incorrectly happening for std::format.
+std::string StrFormat_no_newline_removal() {
+  return absl::StrFormat("a line\n");
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("a line\n");
+}
+
+// FormatConverter is capable of removing newlines from the end of the format
+// string. Ensure that isn't incorrectly happening for std::format.
+std::string StrFormat_cstr_removal(const std::string &s1, const std::string *s2) {
+  return absl::StrFormat("%s %s %s %s", s1.c_str(), s1.data(), s2->c_str(), s2->data());
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("{} {} {} {}", s1, s1, *s2, *s2);
+}
+
+std::string StrFormat_strict_conversion() {
+  const unsigned char uc = 'A';
+  return absl::StrFormat("Integer %hhd from unsigned char\n", uc);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'std::format' instead of 'StrFormat' [modernize-use-std-format]
+  // CHECK-FIXES: return std::format("Integer {} from unsigned char\n", uc);
+}
+
+std::string StrFormat_field_width_and_precision() {
+  auto s1 = absl::StrFormat("width only:%*d width and precision:%*.*f precision only:%.*f", 3, 42, 4, 2, 3.14159265358979323846, 5, 2.718);
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use 'std::format' ins

[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 accepted this revision.
barannikov88 added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3954
 Function *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_setjmp);
-Buf = Builder.CreateElementBitCast(Buf, Int8Ty);
 return RValue::get(Builder.CreateCall(F, Buf.getPointer()));

jrtc27 wrote:
> Missed `Buf = Buf.withElementType(Int8Ty);`? According to the comment above, 
> Buf is a `void **` not a `void *`/`char *`.
It would be a dead code because only the pointer is used down below.




Comment at: clang/lib/CodeGen/CGExpr.cpp:3896
 llvm::Type *OrigBaseElemTy = Addr.getElementType();
-Addr = Builder.CreateElementBitCast(Addr, Int8Ty);
 

jrtc27 wrote:
> This one isn't a direct substitution, although appears to be refactoring the 
> code to not need withElementType in the first place? Probably best to 
> separate that change out from the very mechanical substitution.
It will be difficult to find all such places later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/CodeGen/CGBuilder.h:158
 
   /// This method is to be deprecated. Use `Address::withElementType` instead.
+  [[deprecated("Use `Address::withElementType` instead.")]]

JOE1994 wrote:
> 
This is a private method, so simply delete it instead of deprecating.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3954
 Function *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_setjmp);
-Buf = Builder.CreateElementBitCast(Buf, Int8Ty);
 return RValue::get(Builder.CreateCall(F, Buf.getPointer()));

Missed `Buf = Buf.withElementType(Int8Ty);`? According to the comment above, 
Buf is a `void **` not a `void *`/`char *`.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3896
 llvm::Type *OrigBaseElemTy = Addr.getElementType();
-Addr = Builder.CreateElementBitCast(Addr, Int8Ty);
 

This one isn't a direct substitution, although appears to be refactoring the 
code to not need withElementType in the first place? Probably best to separate 
that change out from the very mechanical substitution.



Comment at: clang/lib/CodeGen/CGObjCRuntime.cpp:111
+  Address Addr =
+  Address(V, llvm::Type::getIntNTy(CGF.getLLVMContext(), 
Info->StorageSize),
+  Alignment);

Ditto



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:813
-  // Cast to char*.
-  Base = Builder.CreateElementBitCast(Base, CGF.Int8Ty);
-

Ditto



Comment at: clang/lib/CodeGen/Targets/CSKY.cpp:66
   if (isEmptyRecord(getContext(), Ty, true)) {
-Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
-   getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
-return Addr;
+return Address(CGF.Builder.CreateLoad(VAListAddr),
+   CGF.ConvertTypeForMem(Ty), SlotSize);

Ditto



Comment at: clang/lib/CodeGen/Targets/RISCV.cpp:465
   if (isEmptyRecord(getContext(), Ty, true)) {
-Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
-   getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
-return Addr;
+return Address(CGF.Builder.CreateLoad(VAListAddr),
+   CGF.ConvertTypeForMem(Ty), SlotSize);

Ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 added inline comments.



Comment at: clang/lib/CodeGen/CGBuilder.h:158
 
   /// This method is to be deprecated. Use `Address::withElementType` instead.
+  [[deprecated("Use `Address::withElementType` instead.")]]




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154285

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


[PATCH] D154285: [clang] Deprecate CGBuilderTy::CreateElementBitCast

2023-07-01 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 created this revision.
JOE1994 added reviewers: barannikov88, nikic.
Herald added subscribers: luke, StephenFan, frasercrmck, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb.
Herald added a project: All.
JOE1994 requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, MaskRay.
Herald added a project: clang.

`CGBuilderTy::CreateElementBitCast()` no longer does what its name
suggests. Replace remaining in-tree uses with
`Address::withElementType()` and deprecate CreateElementBitCast.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154285

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp

Index: clang/lib/CodeGen/Targets/RISCV.cpp
===
--- clang/lib/CodeGen/Targets/RISCV.cpp
+++ clang/lib/CodeGen/Targets/RISCV.cpp
@@ -462,10 +462,8 @@
 
   // Empty records are ignored for parameter passing purposes.
   if (isEmptyRecord(getContext(), Ty, true)) {
-Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
-   getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
-return Addr;
+return Address(CGF.Builder.CreateLoad(VAListAddr),
+   CGF.ConvertTypeForMem(Ty), SlotSize);
   }
 
   auto TInfo = getContext().getTypeInfoInChars(Ty);
Index: clang/lib/CodeGen/Targets/CSKY.cpp
===
--- clang/lib/CodeGen/Targets/CSKY.cpp
+++ clang/lib/CodeGen/Targets/CSKY.cpp
@@ -63,10 +63,8 @@
 
   // Empty records are ignored for parameter passing purposes.
   if (isEmptyRecord(getContext(), Ty, true)) {
-Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
-   getVAListElementType(CGF), SlotSize);
-Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
-return Addr;
+return Address(CGF.Builder.CreateLoad(VAListAddr),
+   CGF.ConvertTypeForMem(Ty), SlotSize);
   }
 
   auto TInfo = getContext().getTypeInfoInChars(Ty);
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -809,12 +809,9 @@
 
   CGBuilderTy &Builder = CGF.Builder;
 
-  // Cast to char*.
-  Base = Builder.CreateElementBitCast(Base, CGF.Int8Ty);
-
   // Apply the offset, which we assume is non-null.
-  return Builder.CreateInBoundsGEP(Base.getElementType(), Base.getPointer(),
-   MemPtr, "memptr.offset");
+  return Builder.CreateInBoundsGEP(CGF.Int8Ty, Base.getPointer(), MemPtr,
+   "memptr.offset");
 }
 
 /// Perform a bitcast, derived-to-base, or base-to-derived member pointer
@@ -2043,7 +2040,7 @@
   if (!NonVirtualAdjustment && !VirtualAdjustment)
 return InitialPtr.getPointer();
 
-  Address V = CGF.Builder.CreateElementBitCast(InitialPtr, CGF.Int8Ty);
+  Address V = InitialPtr.withElementType(CGF.Int8Ty);
 
   // In a base-to-derived cast, the non-virtual adjustment is applied first.
   if (NonVirtualAdjustment && !IsReturnAdjustment) {
@@ -2054,7 +2051,7 @@
   // Perform the virtual adjustment if we have one.
   llvm::Value *ResultPtr;
   if (VirtualAdjustment) {
-Address VTablePtrPtr = CGF.Builder.CreateElementBitCast(V, CGF.Int8PtrTy);
+Address VTablePtrPtr = V.withElementType(CGF.Int8PtrTy);
 llvm::Value *VTablePtr = CGF.Builder.CreateLoad(VTablePtrPtr);
 
 llvm::Value *Offset;
@@ -2151,8 +2148,7 @@
 CookiePtr = CGF.Builder.CreateConstInBoundsByteGEP(CookiePtr, CookieOffset);
 
   // Write the number of elements into the appropriate slot.
-  Address NumElementsPtr =
-  CGF.Builder.CreateElementBitCast(CookiePtr, CGF.SizeTy);
+  Address NumElementsPtr = CookiePtr.withElementType(CGF.SizeTy);
   llvm::Instruction *SI = CGF.Builder.CreateStore(NumElements, NumElementsPtr);
 
   // Handle the array cookie specially in ASan.
@@ -2184,7 +2180,7 @@
   CGF.Builder.CreateConstInBoundsByteGEP(numElementsPtr, numElementsOffset);
 
   unsigned AS = allocPtr.getAddressSpace();
-  numElementsPtr = CGF.Builder.CreateElementBitCast(numElementsPtr, CGF.SizeTy);
+  numElementsPtr = numElementsPtr.withElementType(CGF.SizeTy);
   if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) || AS != 0)
 return CGF.Builder.CreateLoad(numElementsPtr);
   // In asan mode emit a function call instead of a regular load and let the
@@ -2223,7 +2219,7 @@
   Address cookie = ne

[PATCH] D152054: [OpenMP] Codegen support for thread_limit on target directive

2023-07-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: openmp/runtime/test/target/target_thread_limit.cpp:28
+// OMP51: target: parallel
+// OMP51: target: parallel
+

This doesn't check much. You need to verify a 5th or print the team size. Same 
for the rest



Comment at: openmp/runtime/test/target/target_thread_limit.cpp:35
+// OMP51: target: parallel num_threads(2)
+
+// check whether thread_limit is honoured when there is a conflicting

Verify that the user can use the omp_set_ functions and see consistent behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152054

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


[PATCH] D154284: [C11] Correct global atomic pointer initialization from an integer constant

2023-07-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: efriedma, rjmccall.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

This is a follow-up to 2e275e24355cb224981f9beb2b026a3169fc7232 
 and 
1395cde24b3641e284bb1daae7d56c189a2635e3 
 which 
corrects a missed case: initializing an `_Atomic(T *)` from a null pointer 
constant in the form of the integer literal `0`.

(Note: a release note is unnecessary for this change as it's correcting an 
issue introduced during this cycle.)

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154284

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGen/atomic.c


Index: clang/test/CodeGen/atomic.c
===
--- clang/test/CodeGen/atomic.c
+++ clang/test/CodeGen/atomic.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
 
 // CHECK: @[[GLOB_POINTER:.+]] = internal global ptr null
+// CHECK: @[[GLOB_POINTER_FROM_INT:.+]] = internal global ptr null
 // CHECK: @[[GLOB_INT:.+]] = internal global i32 0
 // CHECK: @[[GLOB_FLT:.+]] = internal global float {{[0e\+-\.]+}}, align
 
@@ -125,6 +126,7 @@
 
 // Ensure that global initialization of atomics is correct.
 static _Atomic(int *) glob_pointer = (void *)0;
+static _Atomic(int *) glob_pointer_from_int = 0;
 static _Atomic int glob_int = 0;
 static _Atomic float glob_flt = 0.0f;
 
@@ -132,6 +134,9 @@
   (void)glob_pointer;
   // CHECK: %[[LOCAL_INT:.+]] = load atomic i32, ptr @[[GLOB_POINTER]] seq_cst
   // CHECK-NEXT: inttoptr i32 %[[LOCAL_INT]] to ptr
+  (void)glob_pointer_from_int;
+  // CHECK: %[[LOCAL_INT_2:.+]] = load atomic i32, ptr 
@[[GLOB_POINTER_FROM_INT]] seq_cst
+  // CHECK-NEXT: inttoptr i32 %[[LOCAL_INT_2]] to ptr
   (void)glob_int;
   // CHECK: load atomic i32, ptr @[[GLOB_INT]] seq_cst
   (void)glob_flt;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -14896,6 +14896,8 @@
 default:
   return ExprEvaluatorBaseTy::VisitCastExpr(E);
 case CK_NullToPointer:
+  VisitIgnoredValue(E->getSubExpr());
+  return ZeroInitialization(E);
 case CK_NonAtomicToAtomic:
   return This ? EvaluateInPlace(Result, Info, *This, E->getSubExpr())
   : Evaluate(Result, Info, E->getSubExpr());


Index: clang/test/CodeGen/atomic.c
===
--- clang/test/CodeGen/atomic.c
+++ clang/test/CodeGen/atomic.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
 
 // CHECK: @[[GLOB_POINTER:.+]] = internal global ptr null
+// CHECK: @[[GLOB_POINTER_FROM_INT:.+]] = internal global ptr null
 // CHECK: @[[GLOB_INT:.+]] = internal global i32 0
 // CHECK: @[[GLOB_FLT:.+]] = internal global float {{[0e\+-\.]+}}, align
 
@@ -125,6 +126,7 @@
 
 // Ensure that global initialization of atomics is correct.
 static _Atomic(int *) glob_pointer = (void *)0;
+static _Atomic(int *) glob_pointer_from_int = 0;
 static _Atomic int glob_int = 0;
 static _Atomic float glob_flt = 0.0f;
 
@@ -132,6 +134,9 @@
   (void)glob_pointer;
   // CHECK: %[[LOCAL_INT:.+]] = load atomic i32, ptr @[[GLOB_POINTER]] seq_cst
   // CHECK-NEXT: inttoptr i32 %[[LOCAL_INT]] to ptr
+  (void)glob_pointer_from_int;
+  // CHECK: %[[LOCAL_INT_2:.+]] = load atomic i32, ptr @[[GLOB_POINTER_FROM_INT]] seq_cst
+  // CHECK-NEXT: inttoptr i32 %[[LOCAL_INT_2]] to ptr
   (void)glob_int;
   // CHECK: load atomic i32, ptr @[[GLOB_INT]] seq_cst
   (void)glob_flt;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -14896,6 +14896,8 @@
 default:
   return ExprEvaluatorBaseTy::VisitCastExpr(E);
 case CK_NullToPointer:
+  VisitIgnoredValue(E->getSubExpr());
+  return ZeroInitialization(E);
 case CK_NonAtomicToAtomic:
   return This ? EvaluateInPlace(Result, Info, *This, E->getSubExpr())
   : Evaluate(Result, Info, E->getSubExpr());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154283: [clang-tidy] Fix width/precision argument order in modernize-use-std-print

2023-07-01 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe created this revision.
mikecrowe added a reviewer: PiotrZSL.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Victor Zverovich pointed out[1] that printf takes the field width and
precision arguments before the value to be printed whereas std::print
takes the value first (unless positional arguments are used.) Many of
the test cases in use-std-print.cpp were incorrect.

Teach the check to rotate the arguments when required to correct
this. Correct the test cases and add more.

[1] https://github.com/fmtlib/fmt/pull/3515#issuecomment-1615259893


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154283

Files:
  clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
  clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
@@ -1024,7 +1024,7 @@
 
   printf("Right-justified integer with field width argument %*d after\n", 5, 424242);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
-  // CHECK-FIXES: std::println("Right-justified integer with field width argument {:{}} after", 5, 424242);
+  // CHECK-FIXES: std::println("Right-justified integer with field width argument {:{}} after", 424242, 5);
 
   printf("Right-justified integer with field width argument %2$*1$d after\n", 5, 424242);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
@@ -1061,7 +1061,7 @@
 
   printf("Left-justified integer with field width argument %-*d after\n", 5, 424242);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
-  // CHECK-FIXES: std::println("Left-justified integer with field width argument {:<{}} after", 5, 424242);
+  // CHECK-FIXES: std::println("Left-justified integer with field width argument {:<{}} after", 424242, 5);
 
   printf("Left-justified integer with field width argument %2$-*1$d after\n", 5, 424242);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
@@ -1087,15 +1087,15 @@
 
   printf("Hello %.*f after\n", 10, 3.14159265358979323846);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
-  // CHECK-FIXES: std::println("Hello {:.{}f} after", 10, 3.14159265358979323846);
+  // CHECK-FIXES: std::println("Hello {:.{}f} after", 3.14159265358979323846, 10);
 
   printf("Hello %10.*f after\n", 3, 3.14159265358979323846);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
-  // CHECK-FIXES: std::println("Hello {:10.{}f} after", 3, 3.14159265358979323846);
+  // CHECK-FIXES: std::println("Hello {:10.{}f} after", 3.14159265358979323846, 3);
 
   printf("Hello %*.*f after\n", 10, 4, 3.14159265358979323846);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
-  // CHECK-FIXES: std::println("Hello {:{}.{}f} after", 10, 4, 3.14159265358979323846);
+  // CHECK-FIXES: std::println("Hello {:{}.{}f} after", 3.14159265358979323846, 10, 4);
 
   printf("Hello %1$.*2$f after\n", 3.14159265358979323846, 4);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
@@ -1112,9 +1112,33 @@
 }
 
 void printf_field_width_and_precision() {
-  printf("Hello %1$*2$.*3$f after\n", 3.14159265358979323846, 4, 2);
+  printf("width only:%*d width and precision:%*.*f precision only:%.*f\n", 3, 42, 4, 2, 3.14159265358979323846, 5, 2.718);
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
-  // CHECK-FIXES: std::println("Hello {0:{1}.{2}f} after", 3.14159265358979323846, 4, 2);
+  // CHECK-FIXES: std::println("width only:{:{}} width and precision:{:{}.{}f} precision only:{:.{}f}", 42, 3, 3.14159265358979323846, 4, 2, 2.718, 5);
+
+  printf("width and precision positional:%1$*2$.*3$f after\n", 3.14159265358979323846, 4, 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print]
+  // CHECK-FIXES: std::println("width and precision positional:{0:{1}.{2}f} after", 3.14159265358979323846, 4, 2);
+
+  const int width = 10, precision = 3;
+  printf("width only:%3$*1$d width and precision:%4$*1$.*2$f precision only:%5$.*2$f\n", width, precision, 42, 3.1415926, 2.718);
+  // CHECK-MESSAG

[PATCH] D152713: [clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1dc914a8ca2: [clang-tidy] Correct sizeof/alignas handling 
in misc-redundant-expression (authored by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152713

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
@@ -843,3 +843,15 @@
 
   return 2;
 }
+
+namespace PR63096 {
+
+struct alignas(sizeof(int)) X {
+  int x;
+};
+
+static_assert(alignof(X) == sizeof(X));
+static_assert(sizeof(X) == sizeof(X));
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: both sides of operator are 
equivalent
+
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -360,6 +360,10 @@
   ` to avoid warning on
   declarations inside anonymous namespaces.
 
+- Fixed false-positive in :doc:`misc-redundant-expression
+  ` check where expressions like
+  ``alignof`` or ``sizeof`` were incorrectly flagged as identical.
+
 - Improved :doc:`misc-unused-parameters
   ` check with new `IgnoreVirtual`
   option to optionally ignore virtual methods.
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -144,8 +144,9 @@
 const auto *RightUnaryExpr =
 cast(Right);
 if (LeftUnaryExpr->isArgumentType() && RightUnaryExpr->isArgumentType())
-  return LeftUnaryExpr->getArgumentType() ==
- RightUnaryExpr->getArgumentType();
+  return LeftUnaryExpr->getKind() == RightUnaryExpr->getKind() &&
+ LeftUnaryExpr->getArgumentType() ==
+ RightUnaryExpr->getArgumentType();
 if (!LeftUnaryExpr->isArgumentType() && !RightUnaryExpr->isArgumentType())
   return areEquivalentExpr(LeftUnaryExpr->getArgumentExpr(),
RightUnaryExpr->getArgumentExpr());


Index: clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
@@ -843,3 +843,15 @@
 
   return 2;
 }
+
+namespace PR63096 {
+
+struct alignas(sizeof(int)) X {
+  int x;
+};
+
+static_assert(alignof(X) == sizeof(X));
+static_assert(sizeof(X) == sizeof(X));
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: both sides of operator are equivalent
+
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -360,6 +360,10 @@
   ` to avoid warning on
   declarations inside anonymous namespaces.
 
+- Fixed false-positive in :doc:`misc-redundant-expression
+  ` check where expressions like
+  ``alignof`` or ``sizeof`` were incorrectly flagged as identical.
+
 - Improved :doc:`misc-unused-parameters
   ` check with new `IgnoreVirtual`
   option to optionally ignore virtual methods.
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -144,8 +144,9 @@
 const auto *RightUnaryExpr =
 cast(Right);
 if (LeftUnaryExpr->isArgumentType() && RightUnaryExpr->isArgumentType())
-  return LeftUnaryExpr->getArgumentType() ==
- RightUnaryExpr->getArgumentType();
+  return LeftUnaryExpr->getKind() == RightUnaryExpr->getKind() &&
+ LeftUnaryExpr->getArgumentType() ==
+ RightUnaryExpr->getArgumentType();
 if (!LeftUnaryExpr->isArgumentType() && !RightUnaryExpr->isArgumentType())
   return areEquivalentExpr(LeftUnaryExpr->getArgumentExpr(),
RightUnaryExpr->getArgumentExpr());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] c1dc914 - [clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

2023-07-01 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-07-01T16:20:38Z
New Revision: c1dc914a8ca240650d7411d25c75ad7e2a5974e9

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

LOG: [clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

Fixed issue with the comparison of UnaryExprOrTypeTraitExpr
objects in which only the argument type was checked, without
considering the kind of expression. This led to false positives when
using sizeof(x) and alignof(x) expressions, as only the
comparison x = x was performed without checking if sizeof
was equal to alignof.

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

Reviewed By: Izaron

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index b5028074f017c4..4850440329bc15 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -144,8 +144,9 @@ static bool areEquivalentExpr(const Expr *Left, const Expr 
*Right) {
 const auto *RightUnaryExpr =
 cast(Right);
 if (LeftUnaryExpr->isArgumentType() && RightUnaryExpr->isArgumentType())
-  return LeftUnaryExpr->getArgumentType() ==
- RightUnaryExpr->getArgumentType();
+  return LeftUnaryExpr->getKind() == RightUnaryExpr->getKind() &&
+ LeftUnaryExpr->getArgumentType() ==
+ RightUnaryExpr->getArgumentType();
 if (!LeftUnaryExpr->isArgumentType() && !RightUnaryExpr->isArgumentType())
   return areEquivalentExpr(LeftUnaryExpr->getArgumentExpr(),
RightUnaryExpr->getArgumentExpr());

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 726ec41f6a7369..84333f6cb347bf 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -360,6 +360,10 @@ Changes in existing checks
   ` to avoid warning on
   declarations inside anonymous namespaces.
 
+- Fixed false-positive in :doc:`misc-redundant-expression
+  ` check where expressions like
+  ``alignof`` or ``sizeof`` were incorrectly flagged as identical.
+
 - Improved :doc:`misc-unused-parameters
   ` check with new `IgnoreVirtual`
   option to optionally ignore virtual methods.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
index 6597d05e449664..895a1666757ff4 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
@@ -843,3 +843,15 @@ int TestAssignSideEffect(int i) {
 
   return 2;
 }
+
+namespace PR63096 {
+
+struct alignas(sizeof(int)) X {
+  int x;
+};
+
+static_assert(alignof(X) == sizeof(X));
+static_assert(sizeof(X) == sizeof(X));
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: both sides of operator are 
equivalent
+
+}



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


[PATCH] D152713: [clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

2023-07-01 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron accepted this revision.
Izaron added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152713

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


[PATCH] D153458: [clang-tidy] Model noexcept more properly in bugprone-exception-escape

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153458

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


[PATCH] D144135: [clang-tidy] Add performance-enum-size check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144135

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


[PATCH] D144429: [clang-tidy] Add bugprone-chained-comparison check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144429

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


[PATCH] D144748: [clang-tidy] Add bugprone-empty-catch check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144748

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


[PATCH] D146368: [clang-tidy] Add readability-reference-to-constructed-temporary check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146368

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


[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147357

___
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-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


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] D149015: [clang-tidy] Added bugprone-inc-dec-in-conditions check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149015

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


[PATCH] D149084: [clang-tidy] Added bugprone-multi-level-implicit-pointer-conversion check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149084

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


[PATCH] D151495: [clang-tidy] Improve build-in type handling in bugprone-swapped-arguments

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151495

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


[PATCH] D152713: [clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152713

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


[PATCH] D153298: [clang-tidy] Extend bugprone-exception-escape diagnostics

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153298

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


[PATCH] D153423: [clang-tidy] Allow explicit throwing in bugprone-exception-escape for special functions

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153423

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


[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

2023-07-01 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 536531.
sstwcw added a comment.

- Add tests for newline outside of column limit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14815,6 +14815,33 @@
 "\"/and\"",
 format("\"some/tex/and\"", getLLVMStyleWithColumns(6)));
 
+  // Escape sequences should be recognized.
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\n"
+" text";)",
+   R"(x = "some\n text";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(13));
+  // A newline outside of the column limit should not cause a break.
+  verifyFormat(R"(x = "something "
+"so\nshort";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(16));
+  verifyFormat(R"(x = "something "
+"so\nshort";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(19));
+  verifyFormat(R"(x = "something so\n"
+"short";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(20));
+
   EXPECT_EQ("variable =\n"
 "\"long string \"\n"
 "\"literal\";",
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -176,13 +176,15 @@
   if (ColumnLimit <= UsedColumns)
 return BreakableToken::Split(StringRef::npos, 0);
   unsigned MaxSplit = ColumnLimit - UsedColumns;
-  StringRef::size_type SpaceOffset = 0;
+  StringRef::size_type NewLine = 0;
+  StringRef::size_type AfterSpace = 0;
   StringRef::size_type SlashOffset = 0;
   StringRef::size_type WordStartOffset = 0;
   StringRef::size_type SplitPoint = 0;
   for (unsigned Chars = 0;;) {
 unsigned Advance;
-if (Text[0] == '\\') {
+bool EscapeSequence = Text[0] == '\\';
+if (EscapeSequence) {
   Advance = encoding::getEscapeSequenceLength(Text);
   Chars += Advance;
 } else {
@@ -194,8 +196,21 @@
 if (Chars > MaxSplit || Text.size() <= Advance)
   break;
 
+if (EscapeSequence && Advance == 2) {
+  switch (Text[1]) {
+  case 'n':
+NewLine = SplitPoint + 2;
+break;
+  case 'f':
+  case 'r':
+  case 't':
+  case 'v':
+AfterSpace = SplitPoint + 2;
+break;
+  }
+}
 if (IsBlank(Text[0]))
-  SpaceOffset = SplitPoint;
+  AfterSpace = SplitPoint + 1;
 if (Text[0] == '/')
   SlashOffset = SplitPoint;
 if (Advance == 1 && !isAlphanumeric(Text[0]))
@@ -205,8 +220,10 @@
 Text = Text.substr(Advance);
   }
 
-  if (SpaceOffset != 0)
-return BreakableToken::Split(SpaceOffset + 1, 0);
+  if (NewLine != 0)
+return BreakableToken::Split(NewLine, 0);
+  if (AfterSpace >= 2)
+return BreakableToken::Split(AfterSpace, 0);
   if (SlashOffset != 0)
 return BreakableToken::Split(SlashOffset + 1, 0);
   if (WordStartOffset != 0)


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14815,6 +14815,33 @@
 "\"/and\"",
 format("\"some/tex/and\"", getLLVMStyleWithColumns(6)));
 
+  // Escape sequences should be recognized.
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\n"
+"text";)",
+   R"(x = "some\ntext";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\n"
+" text";)",
+   R"(x = "some\n text";)", getLLVMStyleWithColumns(13));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(12));
+  verifyFormat(R"(x = "some\t"
+"text";)",
+   R"(x = "some\ttext";)", getLLVMStyleWithColumns(13));
+  // A newline outside of the column limit should not cause a break.
+  verifyFormat(R"(x = "something "
+"so\nshort";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(16));
+  verifyFormat(R"(x = "something "
+"so\nshort";)",
+   R"(x = "something so\nshort";)", getLLVMStyleWithColumns(19));
+  ver

[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

2023-07-01 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked 2 inline comments as done.
sstwcw added inline comments.



Comment at: clang/lib/Format/BreakableToken.cpp:223
 
-  if (SpaceOffset != 0)
-return BreakableToken::Split(SpaceOffset + 1, 0);
+  if (NewLine != 0)
+return BreakableToken::Split(NewLine, 0);

HazardyKnusperkeks wrote:
> What if the new line is after the limit?
Then the loop will exit on line 197.  I added a test for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

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


[PATCH] D154209: [X86] Add missing features for ivybridge, sandybridge and knl in X86TargetParser.def.

2023-07-01 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - but it would be good to fix silvermont / westmere cases as well with 
suitable test coverage


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154209

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


[PATCH] D89918: Fix issue: clang-format result is not consistent if "// clang-format off" is followed by macro definition.

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

Give the author some time is okay, but I think we can and should commandeer at 
some point and abandon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89918

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


[PATCH] D153741: [Tooling][Rewriter] Remove the redundant AtomicallyMovedFile Implementation.

2023-07-01 Thread Alexey Lapshin via Phabricator via cfe-commits
avl accepted this revision.
avl added a comment.
This revision is now accepted and ready to land.

LGTM. please pay attention to the clang format issues reported during pre-merge 
build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153741

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


[PATCH] D154093: [clang-format] Break long strings in Verilog

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

I'd really prefer you put what you need to modify `mutable` instead of removing 
the `const` from everything else. But that's just my opinion.




Comment at: clang/include/clang/Format/Format.h:1905
+  ///
+  /// In C:
   /// \code

It definitely works in C++, and I'd suspect C# and Java too.



Comment at: clang/lib/Format/BreakableToken.h:310
+  // The braces along with the quotes they replace.  Depending on the style.
+  const StringRef LeftBraceQuote, RightBraceQuote;
+  // Width added to the left.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154093

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


[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

2023-07-01 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/BreakableToken.cpp:223
 
-  if (SpaceOffset != 0)
-return BreakableToken::Split(SpaceOffset + 1, 0);
+  if (NewLine != 0)
+return BreakableToken::Split(NewLine, 0);

What if the new line is after the limit?



Comment at: clang/lib/Format/BreakableToken.cpp:225
+return BreakableToken::Split(NewLine, 0);
+  if (AfterSpace >= 2)
+return BreakableToken::Split(AfterSpace, 0);

sstwcw wrote:
> Should I change the threshold from 2 to 1?
> 
> It is set to 2 because it is the old behavior.  There is already a test.
> 
> ```
> already in the test:
> "some"
> " tex"
> "t"
> 
> I expect:
> "some"
> " "
> "text"
> ```
Since it was explicit, I'd keep it that way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added a comment.

In D154176#4466190 , @mstorsjo wrote:

> In D154176#4466186 , @mstorsjo 
> wrote:
>
>> Ok, thanks for clarifying. However I still don’t understand the “why” aspect 
>> here. You’re writing
>>
>>> so that lld specific flags can be append before inputs
>>
>> Are you planning on adding such flags in a later patch, position dependent 
>> flags that need to be supplied before input files?
>>
>> Or does the change in order of command line arguments have an effect on the 
>> behavior of the linker in this case?
>
> Ok, on second thought, I guess that parsing the vfsoverlay option before the 
> inputs makes it have an effect where it didn’t before. Is that right? (Most 
> flags in lld aren’t very order dependent since it just checks for any 
> occurrence of a flag anywhere among the arguments.)

I'm planing to add /dwodir to linker when user specify -gsplit-dwarf and using 
lld and lto.
The order does not matter.
I just want it looks more consistent and elegent since most flags are before 
inputs so that user can easily look for inputs when using -###.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

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


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-07-01 Thread Iain Sandoe via Phabricator via cfe-commits
iains planned changes to this revision.
iains added a comment.

changes are needed to address review comments - but this revision is needed as 
a parent to other work (so might need to be rebased from time to time)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145965

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


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-07-01 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 536524.
iains added a comment.

rebased, fixed some format issues; again to support p1815 work only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145965

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/CXX/module/basic/basic.def.odr/p4.cppm
  clang/test/CXX/module/basic/basic.link/p2.cppm
  clang/test/CXX/module/module.import/p2.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/module/module.interface/p7.cpp
  clang/test/CXX/module/module.reach/ex1.cpp
  clang/test/CXX/module/module.reach/p2.cpp
  clang/test/CXX/module/module.reach/p5.cpp
  clang/test/Modules/Reachability-template-default-arg.cpp
  clang/test/Modules/cxx20-10-1-ex2.cpp
  clang/test/Modules/deduction-guide3.cppm
  clang/test/Modules/diagnose-missing-import.m
  clang/test/Modules/pr61601.cpp

Index: clang/test/Modules/pr61601.cpp
===
--- /dev/null
+++ clang/test/Modules/pr61601.cpp
@@ -0,0 +1,30 @@
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// All of the following should build without diagnostics.
+//
+// RUN: %clang_cc1 -std=c++20 %t/Part1.cpp -emit-module-interface -o %t/TheMod-Part1.pcm
+//
+// RUN: %clang_cc1 -std=c++20 %t/Part2.cpp -emit-module-interface -o %t/TheMod-Part2.pcm
+//
+// RUN: %clang_cc1 -std=c++20 %t/TheMod.cpp -emit-module-interface -o %t/TheMod.pcm \
+// RUN: -fprebuilt-module-path=%t
+
+//--- Part1.cpp
+
+export module TheMod:Part1;
+static int loog = 1;
+
+//--- Part2.cpp
+
+export module TheMod:Part2;
+static int loog = 2;
+
+//--- TheMod.cpp
+
+export module TheMod;
+export import :Part1;
+export import :Part2;
+
+static int loog = 3;
+export int V = loog;
Index: clang/test/Modules/diagnose-missing-import.m
===
--- clang/test/Modules/diagnose-missing-import.m
+++ clang/test/Modules/diagnose-missing-import.m
@@ -6,9 +6,9 @@
 
 void foo(void) {
   XYZLogEvent(xyzRiskyCloseOpenParam, xyzRiskyCloseOpenParam); // expected-error {{call to undeclared function 'XYZLogEvent'; ISO C99 and later do not support implicit function declarations}} \
-  expected-error {{declaration of 'XYZLogEvent' must be imported}} \
-  expected-error {{declaration of 'xyzRiskyCloseOpenParam' must be imported from module 'NCI.A'}} \
-  expected-error {{declaration of 'xyzRiskyCloseOpenParam' must be imported from module 'NCI.A'}}
+  expected-error {{declaration of 'XYZLogEvent' is internal to 'NCI.A'}} \
+  expected-error {{declaration of 'xyzRiskyCloseOpenParam' is internal to 'NCI.A'}} \
+  expected-error {{declaration of 'xyzRiskyCloseOpenParam' is internal to 'NCI.A'}}
 }
 
 // expected-note@Inputs/diagnose-missing-import/a.h:5 {{declaration here is not visible}}
Index: clang/test/Modules/deduction-guide3.cppm
===
--- clang/test/Modules/deduction-guide3.cppm
+++ clang/test/Modules/deduction-guide3.cppm
@@ -19,8 +19,8 @@
 //--- Use.cpp
 import Templ;
 void func() {
-Templ t(5); // expected-error {{declaration of 'Templ' must be imported from module 'Templ' before it is required}}
+Templ t(5); // expected-error {{declaration of 'Templ' is private to module 'Templ'}}
 // expected-error@-1 {{unknown type name 'Templ'}}
-// expected-n...@templ.cppm:3 {{declaration here is not visible}}
+// expected-n...@templ.cppm:3 {{export the declaration to make it available}}
 }
 
Index: clang/test/Modules/cxx20-10-1-ex2.cpp
===
--- clang/test/Modules/cxx20-10-1-ex2.cpp
+++ clang/test/Modules/cxx20-10-1-ex2.cpp
@@ -54,8 +54,8 @@
 //--- std10-1-ex2-tu6.cpp
 import B;
 // error, n is module-local and this is not a module.
-int &c = n; // expected-error {{declaration of 'n' must be imported}}
-// expected-note@* {{declaration here is not visible}}
+int &c = n; // expected-error {{declaration of 'n' is private to module 'B'}}
+// expected-note@* {{export the declaration to make it available}}
 
 //--- std10-1-ex2-tu7.cpp
 // expected-no-diagnostics
Index: clang/test/Modules/Reachability-template-default-arg.cpp
===
--- clang/test/Mo

[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D154176#4466186 , @mstorsjo wrote:

> Ok, thanks for clarifying. However I still don’t understand the “why” aspect 
> here. You’re writing
>
>> so that lld specific flags can be append before inputs
>
> Are you planning on adding such flags in a later patch, position dependent 
> flags that need to be supplied before input files?
>
> Or does the change in order of command line arguments have an effect on the 
> behavior of the linker in this case?

Ok, on second thought, I guess that parsing the vfsoverlay option before the 
inputs makes it have an effect where it didn’t before. Is that right? (Most 
flags in lld aren’t very order dependent since it just checks for any 
occurrence of a flag anywhere among the arguments.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

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


[PATCH] D154151: [clang-tidy] Improve documentation for modernize-use-std-print check

2023-07-01 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8fdbc8712c5b: [clang-tidy] Improve documentation for 
modernize-use-std-print check (authored by mikecrowe, committed by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154151

Files:
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst


Index: clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
@@ -9,21 +9,25 @@
 The replaced and replacement functions can be customised by configuration
 options. Each argument that is the result of a call to 
``std::string::c_str()`` and
 ``std::string::data()`` will have that now-unnecessary call removed in a
-similar manner to the readability-redundant-string-cstr check.
+similar manner to the `readability-redundant-string-cstr` check.
 
-In other words, it turns lines like::
+In other words, it turns lines like:
 
 .. code-block:: c++
 
   fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
 
-into::
+into:
 
 .. code-block:: c++
 
   std::println(stderr, "The {} is {:3}", description, value);
 
-It doesn't do a bad job, but it's not perfect. In particular:
+If the `ReplacementPrintFunction` or `ReplacementPrintlnFunction` options
+are left, or assigned to their default values then this check is only
+enabled with `-std=c++23` or later.
+
+The check doesn't do a bad job, but it's not perfect. In particular:
 
 - It assumes that the format string is correct for the arguments. If you
   get any warnings when compiling with `-Wformat` then misbehaviour is
@@ -35,7 +39,7 @@
   handled. Although it's possible for the check to automatically put the
   escapes back, they may not be exactly as they were written (e.g.
   ``"\x0a"`` will become ``"\n"`` and ``"ab" "cd"`` will become
-  ``"abcd"``.) This is helpful since it means that the PRIx macros from
+  ``"abcd"``.) This is helpful since it means that the ``PRIx`` macros from
    are removed correctly.
 
 - It supports field widths, precision, positional arguments, leading zeros,
@@ -78,7 +82,7 @@
   signedness will be wrapped in an approprate ``static_cast`` if `StrictMode`
   is enabled.
 - any arguments that end in a call to ``std::string::c_str()`` or
-  ``std::string_data()`` will have that call removed.
+  ``std::string::data()`` will have that call removed.
 
 Options
 ---
@@ -99,7 +103,7 @@
 unsigned int u = 0x;
 printf("%d %u\n", i, u);
 
-  would be converted to::
+  would be converted to:
 
   .. code-block:: c++
 


Index: clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
@@ -9,21 +9,25 @@
 The replaced and replacement functions can be customised by configuration
 options. Each argument that is the result of a call to ``std::string::c_str()`` and
 ``std::string::data()`` will have that now-unnecessary call removed in a
-similar manner to the readability-redundant-string-cstr check.
+similar manner to the `readability-redundant-string-cstr` check.
 
-In other words, it turns lines like::
+In other words, it turns lines like:
 
 .. code-block:: c++
 
   fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
 
-into::
+into:
 
 .. code-block:: c++
 
   std::println(stderr, "The {} is {:3}", description, value);
 
-It doesn't do a bad job, but it's not perfect. In particular:
+If the `ReplacementPrintFunction` or `ReplacementPrintlnFunction` options
+are left, or assigned to their default values then this check is only
+enabled with `-std=c++23` or later.
+
+The check doesn't do a bad job, but it's not perfect. In particular:
 
 - It assumes that the format string is correct for the arguments. If you
   get any warnings when compiling with `-Wformat` then misbehaviour is
@@ -35,7 +39,7 @@
   handled. Although it's possible for the check to automatically put the
   escapes back, they may not be exactly as they were written (e.g.
   ``"\x0a"`` will become ``"\n"`` and ``"ab" "cd"`` will become
-  ``"abcd"``.) This is helpful since it means that the PRIx macros from
+  ``"abcd"``.) This is helpful since it means that the ``PRIx`` macros from
    are removed correctly.
 
 - It supports field widths, precision, positional arguments, leading zeros,
@@ -78,7 +82,7 @@
   signedness will be wrapped in an approprate ``static_cast`` if `StrictMode`
   is enabled.
 - any arguments that end in a call to ``std::string::c_str()`` or
-  ``std::string_data()`` will have that call removed.
+  ``std::string::data()`` will have th

[clang-tools-extra] 8fdbc87 - [clang-tidy] Improve documentation for modernize-use-std-print check

2023-07-01 Thread Piotr Zegar via cfe-commits

Author: Mike Crowe
Date: 2023-07-01T08:40:21Z
New Revision: 8fdbc8712c5b65617331b3de43bedd302e9cdbc1

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

LOG: [clang-tidy] Improve documentation for modernize-use-std-print check

Remove incorrect use of double colons so that the code blocks are
rendered correctly to HTML.

Wrap the name of another check in single backticks. Wrap the name of a
macro in double backticks.

Explain that with the default settings the check is only enabled with
C++23 or later standards.

Correct std::string_data() to std::string::data().

Reviewed By: PiotrZSL

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

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst 
b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
index 8034238bea90ef..ec17b6fbd48f20 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
@@ -9,21 +9,25 @@ Converts calls to ``printf``, ``fprintf``, ``absl::PrintF`` 
and
 The replaced and replacement functions can be customised by configuration
 options. Each argument that is the result of a call to 
``std::string::c_str()`` and
 ``std::string::data()`` will have that now-unnecessary call removed in a
-similar manner to the readability-redundant-string-cstr check.
+similar manner to the `readability-redundant-string-cstr` check.
 
-In other words, it turns lines like::
+In other words, it turns lines like:
 
 .. code-block:: c++
 
   fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
 
-into::
+into:
 
 .. code-block:: c++
 
   std::println(stderr, "The {} is {:3}", description, value);
 
-It doesn't do a bad job, but it's not perfect. In particular:
+If the `ReplacementPrintFunction` or `ReplacementPrintlnFunction` options
+are left, or assigned to their default values then this check is only
+enabled with `-std=c++23` or later.
+
+The check doesn't do a bad job, but it's not perfect. In particular:
 
 - It assumes that the format string is correct for the arguments. If you
   get any warnings when compiling with `-Wformat` then misbehaviour is
@@ -35,7 +39,7 @@ It doesn't do a bad job, but it's not perfect. In particular:
   handled. Although it's possible for the check to automatically put the
   escapes back, they may not be exactly as they were written (e.g.
   ``"\x0a"`` will become ``"\n"`` and ``"ab" "cd"`` will become
-  ``"abcd"``.) This is helpful since it means that the PRIx macros from
+  ``"abcd"``.) This is helpful since it means that the ``PRIx`` macros from
    are removed correctly.
 
 - It supports field widths, precision, positional arguments, leading zeros,
@@ -78,7 +82,7 @@ If the call is deemed suitable for conversion then:
   signedness will be wrapped in an approprate ``static_cast`` if `StrictMode`
   is enabled.
 - any arguments that end in a call to ``std::string::c_str()`` or
-  ``std::string_data()`` will have that call removed.
+  ``std::string::data()`` will have that call removed.
 
 Options
 ---
@@ -99,7 +103,7 @@ Options
 unsigned int u = 0x;
 printf("%d %u\n", i, u);
 
-  would be converted to::
+  would be converted to:
 
   .. code-block:: c++
 



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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ok, thanks for clarifying. However I still don’t understand the “why” aspect 
here. You’re writing

> so that lld specific flags can be append before

inputs

Are you planning on adding such flags in a later patch, position dependent 
flags that need to be supplied before input files?

Or does the change in order of command line arguments have an effect on the 
behavior of the linker in this case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 536518.
HaohaiWen added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/msvc-link.c


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker = "lld-link";
+
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-Linker = "lld-link";
-
-  if (Linker == "lld-link")
-for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
-
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker = "lld-link";
+
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-Linker = "lld-link";
-
-  if (Linker == "lld-link")
-for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
-
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits