[PATCH] D128621: [clangd] Do not try to use $0 as a placeholder in completion snippets

2022-07-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 447112.
nridge added a comment.

Address final review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128621

Files:
  clang-tools-extra/clangd/CodeCompletionStrings.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
@@ -150,7 +150,7 @@
 
   // When completing a pattern, the last placeholder holds the cursor position.
   computeSignature(MakeCCS(), /*CompletingPattern=*/true);
-  EXPECT_EQ(Snippet, " ${1:name} = ${0:target};");
+  EXPECT_EQ(Snippet, " ${1:name} = $0;");
 }
 
 TEST_F(CompletionStringTest, IgnoreInformativeQualifier) {
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3137,9 +3137,8 @@
 
   // Last placeholder in code patterns should be $0 to put the cursor there.
   EXPECT_THAT(Results.Completions,
-  Contains(AllOf(
-  named("while"),
-  snippetSuffix(" (${1:condition}) {\n${0:statements}\n}";
+  Contains(AllOf(named("while"),
+ snippetSuffix(" (${1:condition}) {\n$0\n}";
   // However, snippets for functions must *not* end with $0.
   EXPECT_THAT(Results.Completions,
   Contains(AllOf(named("while_foo"),
Index: clang-tools-extra/clangd/CodeCompletionStrings.cpp
===
--- clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -192,11 +192,15 @@
 case CodeCompletionString::CK_Placeholder:
   *Signature += Chunk.Text;
   ++SnippetArg;
-  *Snippet +=
-  "${" +
-  std::to_string(SnippetArg == CursorSnippetArg ? 0 : SnippetArg) + 
':';
-  appendEscapeSnippet(Chunk.Text, Snippet);
-  *Snippet += '}';
+  if (SnippetArg == CursorSnippetArg) {
+// We'd like to make $0 a placeholder too, but vscode does not support
+// this (https://github.com/microsoft/vscode/issues/152837).
+*Snippet += "$0";
+  } else {
+*Snippet += "${" + std::to_string(SnippetArg) + ':';
+appendEscapeSnippet(Chunk.Text, Snippet);
+*Snippet += '}';
+  }
   break;
 case CodeCompletionString::CK_Informative:
   HadInformativeChunks = true;


Index: clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
@@ -150,7 +150,7 @@
 
   // When completing a pattern, the last placeholder holds the cursor position.
   computeSignature(MakeCCS(), /*CompletingPattern=*/true);
-  EXPECT_EQ(Snippet, " ${1:name} = ${0:target};");
+  EXPECT_EQ(Snippet, " ${1:name} = $0;");
 }
 
 TEST_F(CompletionStringTest, IgnoreInformativeQualifier) {
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3137,9 +3137,8 @@
 
   // Last placeholder in code patterns should be $0 to put the cursor there.
   EXPECT_THAT(Results.Completions,
-  Contains(AllOf(
-  named("while"),
-  snippetSuffix(" (${1:condition}) {\n${0:statements}\n}";
+  Contains(AllOf(named("while"),
+ snippetSuffix(" (${1:condition}) {\n$0\n}";
   // However, snippets for functions must *not* end with $0.
   EXPECT_THAT(Results.Completions,
   Contains(AllOf(named("while_foo"),
Index: clang-tools-extra/clangd/CodeCompletionStrings.cpp
===
--- clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -192,11 +192,15 @@
 case CodeCompletionString::CK_Placeholder:
   *Signature += Chunk.Text;
   ++SnippetArg;
-  *Snippet +=
-  "${" +
-  std::to_string(SnippetArg == CursorSnippetArg ? 0 : SnippetArg) + ':';
-  appendEscapeSnippet(Chunk.Text, Snippet);
-  *Snippet += '}';
+  if (SnippetArg == CursorSnippetArg) {
+// We'd like to make $0 a placeholder too, but vscode does not support
+// this (https:

[clang-tools-extra] 2eba08f - [clangd] Do not try to use $0 as a placeholder in completion snippets

2022-07-24 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2022-07-24T03:01:18-04:00
New Revision: 2eba08fd9a5f42efb64ee8cc5ee0edebd8ce4bc0

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

LOG: [clangd] Do not try to use $0 as a placeholder in completion snippets

$0 can only be used as a tab stop, not as a placeholder (e.g.
`${0:expression}` is not valid)

Fixes https://github.com/clangd/clangd/issues/1190

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeCompletionStrings.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeCompletionStrings.cpp 
b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
index 1832ee14f2d85..21f83451f7014 100644
--- a/clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -192,11 +192,15 @@ void getSignature(const CodeCompletionString &CCS, 
std::string *Signature,
 case CodeCompletionString::CK_Placeholder:
   *Signature += Chunk.Text;
   ++SnippetArg;
-  *Snippet +=
-  "${" +
-  std::to_string(SnippetArg == CursorSnippetArg ? 0 : SnippetArg) + 
':';
-  appendEscapeSnippet(Chunk.Text, Snippet);
-  *Snippet += '}';
+  if (SnippetArg == CursorSnippetArg) {
+// We'd like to make $0 a placeholder too, but vscode does not support
+// this (https://github.com/microsoft/vscode/issues/152837).
+*Snippet += "$0";
+  } else {
+*Snippet += "${" + std::to_string(SnippetArg) + ':';
+appendEscapeSnippet(Chunk.Text, Snippet);
+*Snippet += '}';
+  }
   break;
 case CodeCompletionString::CK_Informative:
   HadInformativeChunks = true;

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 9291bb7595be0..5050ab203b8db 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3231,9 +3231,8 @@ TEST(CompletionTest, CursorInSnippets) {
 
   // Last placeholder in code patterns should be $0 to put the cursor there.
   EXPECT_THAT(Results.Completions,
-  Contains(AllOf(
-  named("while"),
-  snippetSuffix(" (${1:condition}) {\n${0:statements}\n}";
+  Contains(AllOf(named("while"),
+ snippetSuffix(" (${1:condition}) {\n$0\n}";
   // However, snippets for functions must *not* end with $0.
   EXPECT_THAT(Results.Completions,
   Contains(AllOf(named("while_foo"),

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
index 7aace938b70cb..329a213c66984 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
@@ -150,7 +150,7 @@ TEST_F(CompletionStringTest, SnippetsInPatterns) {
 
   // When completing a pattern, the last placeholder holds the cursor position.
   computeSignature(MakeCCS(), /*CompletingPattern=*/true);
-  EXPECT_EQ(Snippet, " ${1:name} = ${0:target};");
+  EXPECT_EQ(Snippet, " ${1:name} = $0;");
 }
 
 TEST_F(CompletionStringTest, IgnoreInformativeQualifier) {



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


[PATCH] D128621: [clangd] Do not try to use $0 as a placeholder in completion snippets

2022-07-24 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2eba08fd9a5f: [clangd] Do not try to use $0 as a placeholder 
in completion snippets (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128621

Files:
  clang-tools-extra/clangd/CodeCompletionStrings.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
@@ -150,7 +150,7 @@
 
   // When completing a pattern, the last placeholder holds the cursor position.
   computeSignature(MakeCCS(), /*CompletingPattern=*/true);
-  EXPECT_EQ(Snippet, " ${1:name} = ${0:target};");
+  EXPECT_EQ(Snippet, " ${1:name} = $0;");
 }
 
 TEST_F(CompletionStringTest, IgnoreInformativeQualifier) {
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3231,9 +3231,8 @@
 
   // Last placeholder in code patterns should be $0 to put the cursor there.
   EXPECT_THAT(Results.Completions,
-  Contains(AllOf(
-  named("while"),
-  snippetSuffix(" (${1:condition}) {\n${0:statements}\n}";
+  Contains(AllOf(named("while"),
+ snippetSuffix(" (${1:condition}) {\n$0\n}";
   // However, snippets for functions must *not* end with $0.
   EXPECT_THAT(Results.Completions,
   Contains(AllOf(named("while_foo"),
Index: clang-tools-extra/clangd/CodeCompletionStrings.cpp
===
--- clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -192,11 +192,15 @@
 case CodeCompletionString::CK_Placeholder:
   *Signature += Chunk.Text;
   ++SnippetArg;
-  *Snippet +=
-  "${" +
-  std::to_string(SnippetArg == CursorSnippetArg ? 0 : SnippetArg) + 
':';
-  appendEscapeSnippet(Chunk.Text, Snippet);
-  *Snippet += '}';
+  if (SnippetArg == CursorSnippetArg) {
+// We'd like to make $0 a placeholder too, but vscode does not support
+// this (https://github.com/microsoft/vscode/issues/152837).
+*Snippet += "$0";
+  } else {
+*Snippet += "${" + std::to_string(SnippetArg) + ':';
+appendEscapeSnippet(Chunk.Text, Snippet);
+*Snippet += '}';
+  }
   break;
 case CodeCompletionString::CK_Informative:
   HadInformativeChunks = true;


Index: clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
@@ -150,7 +150,7 @@
 
   // When completing a pattern, the last placeholder holds the cursor position.
   computeSignature(MakeCCS(), /*CompletingPattern=*/true);
-  EXPECT_EQ(Snippet, " ${1:name} = ${0:target};");
+  EXPECT_EQ(Snippet, " ${1:name} = $0;");
 }
 
 TEST_F(CompletionStringTest, IgnoreInformativeQualifier) {
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3231,9 +3231,8 @@
 
   // Last placeholder in code patterns should be $0 to put the cursor there.
   EXPECT_THAT(Results.Completions,
-  Contains(AllOf(
-  named("while"),
-  snippetSuffix(" (${1:condition}) {\n${0:statements}\n}";
+  Contains(AllOf(named("while"),
+ snippetSuffix(" (${1:condition}) {\n$0\n}";
   // However, snippets for functions must *not* end with $0.
   EXPECT_THAT(Results.Completions,
   Contains(AllOf(named("while_foo"),
Index: clang-tools-extra/clangd/CodeCompletionStrings.cpp
===
--- clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -192,11 +192,15 @@
 case CodeCompletionString::CK_Placeholder:
   *Signature += Chunk.Text;
   ++SnippetArg;
-  *Snippet +=
-  "${" +
-  std::to_string(SnippetArg == CursorSnippetArg ? 0 : SnippetArg) + ':';
-  appendEscapeSnippet(Chunk.Text, Snippet);
-  *Snippet +=

[PATCH] D130299: [clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas

2022-07-24 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin updated this revision to Diff 447115.
denis-fatkulin added a comment.

Test cases for `auto &` and `auto *` are added


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

https://reviews.llvm.org/D130299

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -747,6 +747,21 @@
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
   EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
   EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]() -> auto {}");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
+  EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]() -> auto & {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
+  EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]() -> auto * {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
+  EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
 }
 
 } // namespace
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2108,6 +2108,7 @@
 case tok::l_square:
   parseSquare();
   break;
+case tok::kw_auto:
 case tok::kw_class:
 case tok::kw_template:
 case tok::kw_typename:


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -747,6 +747,21 @@
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
   EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
   EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]() -> auto {}");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
+  EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]() -> auto & {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
+  EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]() -> auto * {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
+  EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
 }
 
 } // namespace
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2108,6 +2108,7 @@
 case tok::l_square:
   parseSquare();
   break;
+case tok::kw_auto:
 case tok::kw_class:
 case tok::kw_template:
 case tok::kw_typename:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130417: [clang-format] Missing space between trailing return type 'auto' and left brace

2022-07-24 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin updated this revision to Diff 447116.
denis-fatkulin added a comment.

Test cases for `auto &` and `auto *` are added


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

https://reviews.llvm.org/D130417

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23550,6 +23550,16 @@
   verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
 }
 
+TEST_F(FormatTest, TrailingReturnTypeAuto) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("[]() -> auto { return Val; }", Style);
+  verifyFormat("[]() -> auto * { return Val; }", Style);
+  verifyFormat("[]() -> auto & { return Val; }", Style);
+  verifyFormat("auto foo() -> auto { return Val; }", Style);
+  verifyFormat("auto foo() -> auto * { return Val; }", Style);
+  verifyFormat("auto foo() -> auto & { return Val; }", Style);
+}
+
 TEST_F(FormatTest, SpacesInConditionalStatement) {
   FormatStyle Spaces = getLLVMStyle();
   Spaces.IfMacros.clear();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3310,6 +3310,11 @@
 }
   }
 
+  // trailing return type 'auto': []() -> auto {}, auto foo() -> auto {}
+  if (Left.is(tok::kw_auto) &&
+  Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace))
+return true;
+
   // auto{x} auto(x)
   if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
 return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23550,6 +23550,16 @@
   verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
 }
 
+TEST_F(FormatTest, TrailingReturnTypeAuto) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("[]() -> auto { return Val; }", Style);
+  verifyFormat("[]() -> auto * { return Val; }", Style);
+  verifyFormat("[]() -> auto & { return Val; }", Style);
+  verifyFormat("auto foo() -> auto { return Val; }", Style);
+  verifyFormat("auto foo() -> auto * { return Val; }", Style);
+  verifyFormat("auto foo() -> auto & { return Val; }", Style);
+}
+
 TEST_F(FormatTest, SpacesInConditionalStatement) {
   FormatStyle Spaces = getLLVMStyle();
   Spaces.IfMacros.clear();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3310,6 +3310,11 @@
 }
   }
 
+  // trailing return type 'auto': []() -> auto {}, auto foo() -> auto {}
+  if (Left.is(tok::kw_auto) &&
+  Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace))
+return true;
+
   // auto{x} auto(x)
   if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130437: [clang] Fix incorrect constant folding of `if consteval`

2022-07-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 447118.
cor3ntin added a comment.

Fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130437

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp


Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -26,3 +26,30 @@
 void g() {
   f();
 }
+
+namespace GH55638 {
+
+constexpr bool is_constant_evaluated() noexcept {
+  if consteval { return true; } else { return false; }
+}
+
+constexpr int compiletime(int) {
+   return 2;
+}
+
+constexpr int runtime(int) {
+   return 1;
+}
+
+constexpr int test(int x) {
+  if(is_constant_evaluated())
+return compiletime(x);  // CHECK-NOT: call {{.*}}compiletime
+   return runtime(x);  // CHECK: call {{.*}}runtime
+}
+
+int f(int x) {
+  x = test(x);
+  return x;
+}
+
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -5266,10 +5266,14 @@
   }
 }
 bool Cond;
-if (IS->isConsteval())
+if (IS->isConsteval()) {
   Cond = IS->isNonNegatedConsteval();
-else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
-   Cond))
+  // If we are not in a constant context, if consteval should not evaluate
+  // to true.
+  if (!Info.InConstantContext)
+Cond = !Cond;
+} else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
+ Cond))
   return ESR_Failed;
 
 if (const Stmt *SubStmt = Cond ? IS->getThen() : IS->getElse()) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -194,6 +194,8 @@
   move assignment operator. Fixes `Issue 56456 
`_.
 - Fixed a crash when a variable with a bool enum type that has no definition
   used in comparison operators. Fixes `Issue 56560 
`_.
+- Fix that ``if consteval`` could evaluate to ``true`` at runtime because it 
was incorrectly
+  constant folded. Fixes `Issue 55638 
`_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -26,3 +26,30 @@
 void g() {
   f();
 }
+
+namespace GH55638 {
+
+constexpr bool is_constant_evaluated() noexcept {
+  if consteval { return true; } else { return false; }
+}
+
+constexpr int compiletime(int) {
+   return 2;
+}
+
+constexpr int runtime(int) {
+   return 1;
+}
+
+constexpr int test(int x) {
+  if(is_constant_evaluated())
+return compiletime(x);  // CHECK-NOT: call {{.*}}compiletime
+   return runtime(x);  // CHECK: call {{.*}}runtime
+}
+
+int f(int x) {
+  x = test(x);
+  return x;
+}
+
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -5266,10 +5266,14 @@
   }
 }
 bool Cond;
-if (IS->isConsteval())
+if (IS->isConsteval()) {
   Cond = IS->isNonNegatedConsteval();
-else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
-   Cond))
+  // If we are not in a constant context, if consteval should not evaluate
+  // to true.
+  if (!Info.InConstantContext)
+Cond = !Cond;
+} else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
+ Cond))
   return ESR_Failed;
 
 if (const Stmt *SubStmt = Cond ? IS->getThen() : IS->getElse()) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -194,6 +194,8 @@
   move assignment operator. Fixes `Issue 56456 `_.
 - Fixed a crash when a variable with a bool enum type that has no definition
   used in comparison operators. Fixes `Issue 56560 `_.
+- Fix that ``if consteval`` could evaluate to ``true`` at runtime because it was incorrectly
+  constant folded. Fixes `Issue 55638 `_.
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mai

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

2022-07-24 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 447120.
v.g.vassilev retitled this revision from "[WIP] [clang-repl] Support statements 
on global scope in incremental mode." to "[clang-repl] Support statements on 
global scope in incremental mode.".
v.g.vassilev edited the summary of this revision.
v.g.vassilev added a comment.

Move one level deeper in CodeGen the handling of statements.


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

https://reviews.llvm.org/D127284

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

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -120,12 +120,7 @@
 
   // FIXME: Add support for wrapping and running statements.
   auto R2 = Interp->Parse("var1++; printf(\"var1 value %d\\n\", var1);");
-  EXPECT_FALSE(!!R2);
-  using ::testing::HasSubstr;
-  EXPECT_THAT(DiagnosticsOS.str(),
-  HasSubstr("error: unknown type name 'var1'"));
-  auto Err = R2.takeError();
-  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+  EXPECT_TRUE(!!R2);
 }
 
 TEST(InterpreterTest, UndoCommand) {
Index: clang/test/Interpreter/execute-stmts.cpp
===
--- /dev/null
+++ clang/test/Interpreter/execute-stmts.cpp
@@ -0,0 +1,26 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+
+int i = 1;
+++i;
+extern "C" int printf(const char*,...);
+printf("i = %d\n", i);
+// CHECK: i = 2
+
+namespace Ns { void f(){ i++; } }
+Ns::f();
+
+void g() { ++i; }
+g();
+
+printf("i = %d\n", i);
+// CHECK-NEXT: i = 4
+
+for (; i > 3; --i) printf("i = %d\n", i);
+// CHECK-NEXT: i = 4
+
+int j = i; printf("j = %d\n", j);
+// CHECK-NEXT: j = 3
+
+%quit
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -582,13 +582,14 @@
 ///
 /// Note that in C, it is an error if there is no first declaration.
 bool Parser::ParseFirstTopLevelDecl(DeclGroupPtrTy &Result,
-Sema::ModuleImportState &ImportState) {
+Sema::ModuleImportState &ImportState,
+StmtVector *Stmts) {
   Actions.ActOnStartOfTranslationUnit();
 
   // For C++20 modules, a module decl must be the first in the TU.  We also
   // need to track module imports.
   ImportState = Sema::ModuleImportState::FirstDecl;
-  bool NoTopLevelDecls = ParseTopLevelDecl(Result, ImportState);
+  bool NoTopLevelDecls = ParseTopLevelDecl(Result, ImportState, Stmts);
 
   // C11 6.9p1 says translation units must have at least one top-level
   // declaration. C++ doesn't have this restriction. We also don't want to
@@ -609,7 +610,8 @@
 ///   declaration
 /// [C++20]   module-import-declaration
 bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,
-   Sema::ModuleImportState &ImportState) {
+   Sema::ModuleImportState &ImportState,
+   StmtVector *Stmts /*=nullptr*/) {
   DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
 
   // Skip over the EOF token, flagging end of previous input for incremental
@@ -724,6 +726,23 @@
   ParsedAttributes attrs(AttrFactory);
   MaybeParseCXX11Attributes(attrs);
 
+  // FIXME: Remove the incremental processing pre-condition and verify clang
+  // still can pass its test suite, which will harden `isDeclarationStatement`.
+  // It is known to have several weaknesses, for example in
+  // isConstructorDeclarator, infinite loop in c-index-test, etc..
+  // Parse a block of top-level-stmts.
+  while (PP.isIncrementalProcessingEnabled() && Stmts &&
+ !isDeclarationStatement(/*DisambiguatingWithExpression=*/true)) {
+// isStmtExpr ? ParsedStmtContext::InStmtExpr : ParsedStmtContext()
+ParsedStmtContext SubStmtCtx = ParsedStmtContext();
+auto R = ParseStatementOrDeclaration(*Stmts, SubStmtCtx);
+if (!R.isUsable())
+  return true;
+Stmts->push_back(R.get());
+if (Tok.is(tok::eof))
+  return false;
+  }
+
   Result = ParseExternalDeclaration(attrs);
   // An empty Result might mean a line with ';' or some parsing error, ignore
   // it.
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTenta

[PATCH] D129891: [test-suite] Update the test suite for changes to -Wint-conversion

2022-07-24 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@aaron.ballman It looks like this broke the clang-ppc64-aix buildbot 
https://lab.llvm.org/buildbot/#/builders/214

  
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/test/sandbox/test-suite/tools/timeit
 --summary MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o.time 
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/clang 
-DNDEBUG  -D_XOPEN_SOURCE=700 -O3 -DNDEBUG   -w -Werror=date-time 
-ffp-contract=off -Wno-implicit-function-declaration -Wno-implicit-int 
-D__USE_MISC -D__USE_GNU -D__USE_SVID -D__USE_XOPEN_EXTENDED -D__USE_XOPEN 
-Dunix -MD -MT MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o -MF 
MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o.d -o 
MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o   -c 
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/test/test-suite/MultiSource/Applications/siod/slibu.c
  
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/test/test-suite/MultiSource/Applications/siod/slibu.c:1799:9:
 error: incompatible integer to pointer conversion assigning to 'char *' from 
'int' [-Wint-conversion]
   result = getpass(NULLP(lprompt) ? "" : get_c_string(lprompt));
  ^ 


Repository:
  rT test-suite

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

https://reviews.llvm.org/D129891

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


[clang] 94c3b16 - Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6

2022-07-24 Thread David Chisnall via cfe-commits

Author: David Chisnall
Date: 2022-07-24T13:59:45+01:00
New Revision: 94c3b169785c0a0ae650c724dcf2c22ff65f5e24

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

LOG: Fix crash in ObjC codegen introduced with 
5ab6ee75994d645725264e757d67bbb1c96fb2b6

5ab6ee75994d645725264e757d67bbb1c96fb2b6 assumed that if `RValue::isScalar()` 
returns true then `RValue::getScalarVal` will return a valid value.  This is 
not the case when the return value is `void` and so void message returns would 
crash if they hit this path.  This is triggered only for cases where the 
nil-handling path needs to do something non-trivial (destroy arguments that 
should be consumed by the callee).

Reviewed By: triplef

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

Added: 
clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm

Modified: 
clang/lib/CodeGen/CGObjCGNU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index ec459f07f307d..7bbe9af7ed593 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2837,11 +2837,13 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF,
 // Enter the continuation block and emit a phi if required.
 CGF.EmitBlock(continueBB);
 if (msgRet.isScalar()) {
-  llvm::Value *v = msgRet.getScalarVal();
-  llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
-  phi->addIncoming(v, nonNilPathBB);
-  phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
-  msgRet = RValue::get(phi);
+  // If the return type is void, do nothing
+  if (llvm::Value *v = msgRet.getScalarVal()) {
+llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
+phi->addIncoming(v, nonNilPathBB);
+phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
+msgRet = RValue::get(phi);
+  }
 } else if (msgRet.isAggregate()) {
   // Aggregate zeroing is handled in nilCleanupBB when it's required.
 } else /* isComplex() */ {

diff  --git a/clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm 
b/clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm
new file mode 100644
index 0..a7de79bf79940
--- /dev/null
+++ b/clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknow-windows-msvc -S -emit-llvm 
-fobjc-runtime=gnustep-2.0 -o - %s 
+
+// Regression test.  Ensure that C++ arguments with non-trivial destructors
+// don't crash the compiler.
+
+struct X
+{
+  int a;
+  ~X();
+};
+
+@protocol Y
+- (void)foo: (X)bar;
+@end
+
+
+void test(id obj)
+{
+  X a{12};
+  [obj foo: a];
+}
+



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


[PATCH] D123898: Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6

2022-07-24 Thread David Chisnall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94c3b169785c: Fix crash in ObjC codegen introduced with… 
(authored by theraven).

Changed prior to commit:
  https://reviews.llvm.org/D123898?vs=423241&id=447127#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123898

Files:
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm


Index: clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm
===
--- /dev/null
+++ clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknow-windows-msvc -S -emit-llvm 
-fobjc-runtime=gnustep-2.0 -o - %s 
+
+// Regression test.  Ensure that C++ arguments with non-trivial destructors
+// don't crash the compiler.
+
+struct X
+{
+  int a;
+  ~X();
+};
+
+@protocol Y
+- (void)foo: (X)bar;
+@end
+
+
+void test(id obj)
+{
+  X a{12};
+  [obj foo: a];
+}
+
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2837,11 +2837,13 @@
 // Enter the continuation block and emit a phi if required.
 CGF.EmitBlock(continueBB);
 if (msgRet.isScalar()) {
-  llvm::Value *v = msgRet.getScalarVal();
-  llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
-  phi->addIncoming(v, nonNilPathBB);
-  phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
-  msgRet = RValue::get(phi);
+  // If the return type is void, do nothing
+  if (llvm::Value *v = msgRet.getScalarVal()) {
+llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
+phi->addIncoming(v, nonNilPathBB);
+phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
+msgRet = RValue::get(phi);
+  }
 } else if (msgRet.isAggregate()) {
   // Aggregate zeroing is handled in nilCleanupBB when it's required.
 } else /* isComplex() */ {


Index: clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm
===
--- /dev/null
+++ clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknow-windows-msvc -S -emit-llvm -fobjc-runtime=gnustep-2.0 -o - %s 
+
+// Regression test.  Ensure that C++ arguments with non-trivial destructors
+// don't crash the compiler.
+
+struct X
+{
+  int a;
+  ~X();
+};
+
+@protocol Y
+- (void)foo: (X)bar;
+@end
+
+
+void test(id obj)
+{
+  X a{12};
+  [obj foo: a];
+}
+
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2837,11 +2837,13 @@
 // Enter the continuation block and emit a phi if required.
 CGF.EmitBlock(continueBB);
 if (msgRet.isScalar()) {
-  llvm::Value *v = msgRet.getScalarVal();
-  llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
-  phi->addIncoming(v, nonNilPathBB);
-  phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
-  msgRet = RValue::get(phi);
+  // If the return type is void, do nothing
+  if (llvm::Value *v = msgRet.getScalarVal()) {
+llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
+phi->addIncoming(v, nonNilPathBB);
+phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
+msgRet = RValue::get(phi);
+  }
 } else if (msgRet.isAggregate()) {
   // Aggregate zeroing is handled in nilCleanupBB when it's required.
 } else /* isComplex() */ {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128190: [WinEH] Apply funclet operand bundles to nounwind intrinsics that lower to function calls

2022-07-24 Thread David Chisnall via Phabricator via cfe-commits
theraven accepted this revision.
theraven added a comment.
This revision is now accepted and ready to land.

LGTM, a couple of extra comments would help.




Comment at: llvm/include/llvm/IR/IntrinsicInst.h:110
 
+  // Check if this intrinsic might lower into a regular function call
+  static bool mayLowerToFunctionCall(Intrinsic::ID IID);

Minor nit, should be /// for a doc comment.



Comment at: llvm/lib/IR/IntrinsicInst.cpp:61
+  case Intrinsic::objc_sync_enter:
+  case Intrinsic::objc_sync_exit:
+return true;

I'm curious why memcpy and friends don't need to be on this list.  Do they get 
expanded at a different point?  Or is it that the front end inserts a memcpy 
call and the optimiser that turns them into intrinsics and back preserves 
operand bundles?  It would be a good idea to have a comment explaining why 
these specific ones are on the list and not other libc (or math library) 
functions that may appear in cleanup blocks.  From the code in 
`InlineFunction.cpp`, it looks as if this is a problem only for intrinsics that 
may throw, which excludes most of the C standard ones?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128190

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


[PATCH] D129891: [test-suite] Update the test suite for changes to -Wint-conversion

2022-07-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D129891#3674373 , @RKSimon wrote:

> @aaron.ballman It looks like this broke the clang-ppc64-aix buildbot 
> https://lab.llvm.org/buildbot/#/builders/214
>
>   
> /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/test/sandbox/test-suite/tools/timeit
>  --summary MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o.time 
> /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/clang 
> -DNDEBUG  -D_XOPEN_SOURCE=700 -O3 -DNDEBUG   -w -Werror=date-time 
> -ffp-contract=off -Wno-implicit-function-declaration -Wno-implicit-int 
> -D__USE_MISC -D__USE_GNU -D__USE_SVID -D__USE_XOPEN_EXTENDED -D__USE_XOPEN 
> -Dunix -MD -MT MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o 
> -MF MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o.d -o 
> MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o   -c 
> /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/test/test-suite/MultiSource/Applications/siod/slibu.c
>   
> /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/test/test-suite/MultiSource/Applications/siod/slibu.c:1799:9:
>  error: incompatible integer to pointer conversion assigning to 'char *' from 
> 'int' [-Wint-conversion]
>result = getpass(NULLP(lprompt) ? "" : get_c_string(lprompt));
>   ^ 

Thanks for the notice, I've fixed that in 
f47d83408790e3558e5fdb871ba66996b1b1183d 
; I'll 
watch the AIX bot to make sure this was the only failure that needs fixing.


Repository:
  rT test-suite

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

https://reviews.llvm.org/D129891

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


[PATCH] D129881: [C] Strengthen -Wint-conversion to default to an error

2022-07-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D129881#3674159 , @augusto2112 
wrote:

> Actually, never mind, I think I can fix the tests.

Thank you for the fix, and sorry for the trouble!

In D129881#3674157 , @augusto2112 
wrote:

> Hi @aaron.ballman, it looks like this broke 2 tests in the lldb test suite 
> (https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45560/). Can we 
> revert this to keep CI green?

FWIW, this is not a situation where I think a revert would be reasonable. Clang 
changed in a standards conforming way; if lldb is sensitive to a change in 
diagnostics like that, I believe the lldb maintainers should be addressing the 
situation, not the Clang maintainers. However, we of course should collaborate 
and not cause headaches for one another, so if it was a highly disruptive 
conforming change or we made a nonconforming change, that's a different story. 
Thank you for asking about the revert, but thank you even more for helping to 
fix forward (this helps us keep `git blame` useful without having to wade 
through churn commits, too)!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129881

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


[PATCH] D130421: [Clang] De-deprecate volatile compound operations

2022-07-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/docs/ReleaseNotes.rst:519-523
 - Implemented `P2290 Delimited escape sequences `_.
   This feature is available as an extension in all C and C++ language modes.
 - Implemented `P2071 Named universal character escapes 
`_.
   This feature is available as an extension in all C and C++ language modes.
+- Implemented `P2327 De-deprecating volatile compound operations 
`_

NFC nit: we should add the revision number to the link titles as well, as done 
above. (Feel free to land as an NFC change if you want).



Comment at: clang/lib/Sema/SemaExpr.cpp:13943-13944
   //   [Compound-assignment] expressions are deprecated if E1 has
   //   volatile-qualified type
-  Diag(Loc, diag::warn_deprecated_compound_assign_volatile) << LHSType;
+  //   and op is not one of the bitwise operators |, &, ˆ
+  switch (Opc) {

re-flowing the comment somewhat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130421

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


[PATCH] D130437: [clang] Fix incorrect constant folding of `if consteval`

2022-07-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130437

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


[clang] 0ba128f - [Clang] De-deprecate volatile compound operations

2022-07-24 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-07-24T16:16:52+02:00
New Revision: 0ba128f7c8c2b6c0842cdfebcc1db0d11ce57dd9

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

LOG: [Clang] De-deprecate volatile compound operations

As per P2327R1,

|=, &= and ^= are no longer deprecated in all languages mode.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/deprecated.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6d6faa32e458e..ac6c5bb543121 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -520,6 +520,7 @@ C++2b Feature Support
   This feature is available as an extension in all C and C++ language modes.
 - Implemented `P2071 Named universal character escapes 
`_.
   This feature is available as an extension in all C and C++ language modes.
+- Implemented `P2327R1 De-deprecating volatile compound operations 
`_
 
 CUDA/HIP Language Changes in Clang
 --

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a33d85cc954d0..de9bde6841f7d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12170,7 +12170,8 @@ class Sema final {
   // For simple assignment, pass both expressions and a null converted type.
   // For compound assignment, pass both expressions and the converted type.
   QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
-Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType);
+  Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType 
CompoundType,
+  BinaryOperatorKind Opc);
 
   ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc,
  UnaryOperatorKind Opcode, Expr *Op);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index cd5cdbde7f3f0..0f79978b0911c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13824,7 +13824,8 @@ static void CheckIdentityFieldAssignment(Expr *LHSExpr, 
Expr *RHSExpr,
 // C99 6.5.16.1
 QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
SourceLocation Loc,
-   QualType CompoundType) {
+   QualType CompoundType,
+   BinaryOperatorKind Opc) {
   assert(!LHSExpr->hasPlaceholderType(BuiltinType::PseudoObject));
 
   // Verify that LHS is a modifiable lvalue, and emit error if not.
@@ -13937,10 +13938,18 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, 
ExprResult &RHS,
   //   expression or an unevaluated operand
   ExprEvalContexts.back().VolatileAssignmentLHSs.push_back(LHSExpr);
 } else {
-  // C++2a [expr.ass]p6:
+  // C++20 [expr.ass]p6:
   //   [Compound-assignment] expressions are deprecated if E1 has
-  //   volatile-qualified type
-  Diag(Loc, diag::warn_deprecated_compound_assign_volatile) << LHSType;
+  //   volatile-qualified type and op is not one of the bitwise
+  //   operators |, &, ˆ.
+  switch (Opc) {
+  case BO_OrAssign:
+  case BO_AndAssign:
+  case BO_XorAssign:
+break;
+  default:
+Diag(Loc, diag::warn_deprecated_compound_assign_volatile) << LHSType;
+  }
 }
   }
 
@@ -14879,7 +14888,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation 
OpLoc,
 
   switch (Opc) {
   case BO_Assign:
-ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, QualType());
+ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, QualType(), Opc);
 if (getLangOpts().CPlusPlus &&
 LHS.get()->getObjectKind() != OK_ObjCProperty) {
   VK = LHS.get()->getValueKind();
@@ -14976,32 +14985,37 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation 
OpLoc,
Opc == BO_DivAssign);
 CompLHSTy = CompResultTy;
 if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
-  ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy, Opc);
 break;
   case BO_RemAssign:
 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc, true);
 CompLHSTy = CompResultTy;
 if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
-  ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpL

[PATCH] D130421: [Clang] De-deprecate volatile compound operations

2022-07-24 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ba128f7c8c2: [Clang] De-deprecate volatile compound 
operations (authored by cor3ntin).

Changed prior to commit:
  https://reviews.llvm.org/D130421?vs=447109&id=447133#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130421

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/deprecated.cpp

Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -184,6 +184,9 @@
 n *= 3; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
 n /= 2; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
 n %= 42; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
+n &= 2; // undeprecated as a DR in C++23
+n |= 2; // undeprecated as a DR in C++23
+n ^= 2; // undeprecated as a DR in C++23
 
 (void)__is_trivially_assignable(volatile int&, int); // no warning
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13824,7 +13824,8 @@
 // C99 6.5.16.1
 QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
SourceLocation Loc,
-   QualType CompoundType) {
+   QualType CompoundType,
+   BinaryOperatorKind Opc) {
   assert(!LHSExpr->hasPlaceholderType(BuiltinType::PseudoObject));
 
   // Verify that LHS is a modifiable lvalue, and emit error if not.
@@ -13937,10 +13938,18 @@
   //   expression or an unevaluated operand
   ExprEvalContexts.back().VolatileAssignmentLHSs.push_back(LHSExpr);
 } else {
-  // C++2a [expr.ass]p6:
+  // C++20 [expr.ass]p6:
   //   [Compound-assignment] expressions are deprecated if E1 has
-  //   volatile-qualified type
-  Diag(Loc, diag::warn_deprecated_compound_assign_volatile) << LHSType;
+  //   volatile-qualified type and op is not one of the bitwise
+  //   operators |, &, ˆ.
+  switch (Opc) {
+  case BO_OrAssign:
+  case BO_AndAssign:
+  case BO_XorAssign:
+break;
+  default:
+Diag(Loc, diag::warn_deprecated_compound_assign_volatile) << LHSType;
+  }
 }
   }
 
@@ -14879,7 +14888,7 @@
 
   switch (Opc) {
   case BO_Assign:
-ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, QualType());
+ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, QualType(), Opc);
 if (getLangOpts().CPlusPlus &&
 LHS.get()->getObjectKind() != OK_ObjCProperty) {
   VK = LHS.get()->getValueKind();
@@ -14976,32 +14985,37 @@
Opc == BO_DivAssign);
 CompLHSTy = CompResultTy;
 if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
-  ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy, Opc);
 break;
   case BO_RemAssign:
 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc, true);
 CompLHSTy = CompResultTy;
 if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
-  ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy, Opc);
 break;
   case BO_AddAssign:
 ConvertHalfVec = true;
 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
 if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
-  ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy, Opc);
 break;
   case BO_SubAssign:
 ConvertHalfVec = true;
 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
 if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
-  ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy, Opc);
 break;
   case BO_ShlAssign:
   case BO_ShrAssign:
 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc, true);
 CompLHSTy = CompResultTy;
 if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
-  ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
+  Resu

[clang] c68baa7 - [clang] Fix incorrect constant folding of `if consteval`

2022-07-24 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-07-24T16:18:12+02:00
New Revision: c68baa73eb437556cd8abe40902182a6034930ac

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

LOG: [clang] Fix incorrect constant folding of `if consteval`

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

`if consteval` was evaluated incorrectly when in a
non-constant context that could be constant-folded.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenCXX/cxx2b-consteval-if.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac6c5bb543121..af64152666757 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -194,6 +194,8 @@ Bug Fixes
   move assignment operator. Fixes `Issue 56456 
`_.
 - Fixed a crash when a variable with a bool enum type that has no definition
   used in comparison operators. Fixes `Issue 56560 
`_.
+- Fix that ``if consteval`` could evaluate to ``true`` at runtime because it 
was incorrectly
+  constant folded. Fixes `Issue 55638 
`_.
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 6ffb65d8e71d3..9d92c848ccb84 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -5266,10 +5266,14 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, 
EvalInfo &Info,
   }
 }
 bool Cond;
-if (IS->isConsteval())
+if (IS->isConsteval()) {
   Cond = IS->isNonNegatedConsteval();
-else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
-   Cond))
+  // If we are not in a constant context, if consteval should not evaluate
+  // to true.
+  if (!Info.InConstantContext)
+Cond = !Cond;
+} else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
+ Cond))
   return ESR_Failed;
 
 if (const Stmt *SubStmt = Cond ? IS->getThen() : IS->getElse()) {

diff  --git a/clang/test/CodeGenCXX/cxx2b-consteval-if.cpp 
b/clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
index 2e38ce0e63639..a69a2271f661b 100644
--- a/clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
+++ b/clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -26,3 +26,30 @@ constexpr void f() {
 void g() {
   f();
 }
+
+namespace GH55638 {
+
+constexpr bool is_constant_evaluated() noexcept {
+  if consteval { return true; } else { return false; }
+}
+
+constexpr int compiletime(int) {
+   return 2;
+}
+
+constexpr int runtime(int) {
+   return 1;
+}
+
+constexpr int test(int x) {
+  if(is_constant_evaluated())
+return compiletime(x);  // CHECK-NOT: call {{.*}}compiletime
+   return runtime(x);  // CHECK: call {{.*}}runtime
+}
+
+int f(int x) {
+  x = test(x);
+  return x;
+}
+
+}



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


[PATCH] D130437: [clang] Fix incorrect constant folding of `if consteval`

2022-07-24 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc68baa73eb43: [clang] Fix incorrect constant folding of `if 
consteval` (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130437

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp


Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -26,3 +26,30 @@
 void g() {
   f();
 }
+
+namespace GH55638 {
+
+constexpr bool is_constant_evaluated() noexcept {
+  if consteval { return true; } else { return false; }
+}
+
+constexpr int compiletime(int) {
+   return 2;
+}
+
+constexpr int runtime(int) {
+   return 1;
+}
+
+constexpr int test(int x) {
+  if(is_constant_evaluated())
+return compiletime(x);  // CHECK-NOT: call {{.*}}compiletime
+   return runtime(x);  // CHECK: call {{.*}}runtime
+}
+
+int f(int x) {
+  x = test(x);
+  return x;
+}
+
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -5266,10 +5266,14 @@
   }
 }
 bool Cond;
-if (IS->isConsteval())
+if (IS->isConsteval()) {
   Cond = IS->isNonNegatedConsteval();
-else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
-   Cond))
+  // If we are not in a constant context, if consteval should not evaluate
+  // to true.
+  if (!Info.InConstantContext)
+Cond = !Cond;
+} else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
+ Cond))
   return ESR_Failed;
 
 if (const Stmt *SubStmt = Cond ? IS->getThen() : IS->getElse()) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -194,6 +194,8 @@
   move assignment operator. Fixes `Issue 56456 
`_.
 - Fixed a crash when a variable with a bool enum type that has no definition
   used in comparison operators. Fixes `Issue 56560 
`_.
+- Fix that ``if consteval`` could evaluate to ``true`` at runtime because it 
was incorrectly
+  constant folded. Fixes `Issue 55638 
`_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -26,3 +26,30 @@
 void g() {
   f();
 }
+
+namespace GH55638 {
+
+constexpr bool is_constant_evaluated() noexcept {
+  if consteval { return true; } else { return false; }
+}
+
+constexpr int compiletime(int) {
+   return 2;
+}
+
+constexpr int runtime(int) {
+   return 1;
+}
+
+constexpr int test(int x) {
+  if(is_constant_evaluated())
+return compiletime(x);  // CHECK-NOT: call {{.*}}compiletime
+   return runtime(x);  // CHECK: call {{.*}}runtime
+}
+
+int f(int x) {
+  x = test(x);
+  return x;
+}
+
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -5266,10 +5266,14 @@
   }
 }
 bool Cond;
-if (IS->isConsteval())
+if (IS->isConsteval()) {
   Cond = IS->isNonNegatedConsteval();
-else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
-   Cond))
+  // If we are not in a constant context, if consteval should not evaluate
+  // to true.
+  if (!Info.InConstantContext)
+Cond = !Cond;
+} else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
+ Cond))
   return ESR_Failed;
 
 if (const Stmt *SubStmt = Cond ? IS->getThen() : IS->getElse()) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -194,6 +194,8 @@
   move assignment operator. Fixes `Issue 56456 `_.
 - Fixed a crash when a variable with a bool enum type that has no definition
   used in comparison operators. Fixes `Issue 56560 `_.
+- Fix that ``if consteval`` could evaluate to ``true`` at runtime because it was incorrectly
+  constant folded. Fixes `Issue 55638 

[clang] fa8a189 - [Clang] Add missing paper revisions in the release notes [NFC]

2022-07-24 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-07-24T16:24:11+02:00
New Revision: fa8a1896a784a771153d60cdf05da0fdff86d23c

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

LOG: [Clang] Add missing paper revisions in the release notes [NFC]

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index af6415266675..317fd250b193 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -518,9 +518,9 @@ C++2b Feature Support
 - Implemented `P0849R8: auto(x): decay-copy in the language 
`_.
 - Implemented `P2242R3: Non-literal variables (and labels and gotos) in 
constexpr functions`_.
 - Implemented `LWG3659: Consider ATOMIC_FLAG_INIT undeprecation 
`_.
-- Implemented `P2290 Delimited escape sequences `_.
+- Implemented `P2290R3 Delimited escape sequences 
`_.
   This feature is available as an extension in all C and C++ language modes.
-- Implemented `P2071 Named universal character escapes 
`_.
+- Implemented `P2071R2 Named universal character escapes 
`_.
   This feature is available as an extension in all C and C++ language modes.
 - Implemented `P2327R1 De-deprecating volatile compound operations 
`_
 



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


[PATCH] D130421: [Clang] De-deprecate volatile compound operations

2022-07-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman Thanks a lot for the review. I made a separate nfc commit to 
address the missing revision numbers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130421

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


[PATCH] D130419: Use `` with MSVC and C++

2022-07-24 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Can you add a dummy file in the libc++ subdirectory? That should trigger the 
libc++ pre-commit CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130419

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


[clang] 46ae26e - [clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

2022-07-24 Thread Jonas Toth via cfe-commits

Author: Jonas Toth
Date: 2022-07-24T19:37:54+02:00
New Revision: 46ae26e7eb7095faeda6d6c15470c256f9294c48

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

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

This patch connects the check for const-correctness with the new general
utility to add `const` to variables.
The code-transformation is only done, if the detected variable for const-ness
is not part of a group-declaration.

The check allows to control multiple facets of adding `const`, e.g. if pointers 
themself should be
marked as `const` if they are not changed.

Reviewed By: njames93

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

Added: 
clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-cxx17.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-pointer-as-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-unaligned.cpp
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-wrong-config.cpp

Modified: 
clang-tools-extra/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index cdd66b189e6f3..04172db29ea5e 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -22,6 +22,7 @@ add_custom_command(
 add_custom_target(genconfusable DEPENDS Confusables.inc)
 
 add_clang_library(clangTidyMiscModule
+  ConstCorrectnessCheck.cpp
   DefinitionsInHeadersCheck.cpp
   ConfusableIdentifierCheck.cpp
   MiscTidyModule.cpp
@@ -42,6 +43,7 @@ add_clang_library(clangTidyMiscModule
   UnusedUsingDeclsCheck.cpp
 
   LINK_LIBS
+  clangAnalysis
   clangTidy
   clangTidyUtils
 

diff  --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
new file mode 100644
index 0..83111a1c752b0
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -0,0 +1,208 @@
+//===--- ConstCorrectnessCheck.cpp - clang-tidy -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ConstCorrectnessCheck.h"
+#include "../utils/FixItHintUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+// FIXME: This matcher exists in some other code-review as well.
+// It should probably move to ASTMatchers.
+AST_MATCHER(VarDecl, isLocal) { return Node.isLocalVarDecl(); }
+AST_MATCHER_P(DeclStmt, containsAnyDeclaration,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  return ast_matchers::internal::matchesFirstInPointerRange(
+ InnerMatcher, Node.decl_begin(), Node.decl_end(), Finder,
+ Builder) != Node.decl_end();
+}
+AST_MATCHER(ReferenceType, isSpelledAsLValue) {
+  return Node.isSpelledAsLValue();
+}
+AST_MATCHER(Type, isDependentType) { return Node.isDependentType(); }
+} // namespace
+
+ConstCorrectnessCheck::ConstCorrectnessCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AnalyzeValues(Options.get("AnalyzeValues", true)),
+  AnalyzeReferences(Options.get("AnalyzeReferences", true)),
+  WarnPointersAsValues(Options.get("WarnPointersAsValues", false)),
+  TransformValues(Options.get("TransformValues", true)),
+  TransformReferences(Options.get("TransformReferences", true)

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

2022-07-24 Thread Jonas Toth via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46ae26e7eb70: [clang-tidy] implement new check 
'misc-const-correctness' to add 'const' to… (authored by 
JonasToth).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
  clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-unaligned.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-wrong-config.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1251,13 +1251,13 @@
   AST =
   buildASTFromCode("void f() { int* x[2]; for (int* e : x) e = nullptr; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_TRUE(isMutated(Results, AST.get()));
 
   AST = buildASTFromCode(
   "typedef int* IntPtr;"
   "void f() { int* x[2]; for (IntPtr e : x) e = nullptr; }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_TRUE(isMutated(Results, AST.get()));
 }
 
 TEST(ExprMutationAnalyzerTest, RangeForArrayByConstRef) {
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -455,14 +455,16 @@
   // array is considered modified if the loop-variable is a non-const reference.
   const auto DeclStmtToNonRefToArray = declStmt(hasSingleDecl(varDecl(hasType(
   hasUnqualifiedDesugaredType(referenceType(pointee(arrayType(;
-  const auto RefToArrayRefToElements = match(
-  findAll(stmt(cxxForRangeStmt(
-   hasLoopVariable(varDecl(hasType(nonConstReferenceType()))
-   .bind(NodeID::value)),
-   hasRangeStmt(DeclStmtToNonRefToArray),
-   hasRangeInit(canResolveToExpr(equalsNode(Exp)
-  .bind("stmt")),
-  Stm, Context);
+  const auto RefToArrayRefToElements =
+  match(findAll(stmt(cxxForRangeStmt(
+ hasLoopVariable(
+ varDecl(anyOf(hasType(nonConstReferenceType()),
+   hasType(nonConstPointerType(
+ .bind(NodeID::value)),
+ hasRangeStmt(DeclStmtToNonRefToArray),
+ hasRangeInit(canResolveToExpr(equalsNode(Exp)
+.bind("stmt")),
+Stm, Context);
 
   if (const auto *BadRangeInitFromArray =
   selectFirst("stmt", RefToArrayRefToElements))
Index: clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-wrong-config.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-wrong-config.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s misc-const-correctness %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: "misc-const-correctness.AnalyzeValues", value: false},\
+// RUN:   {key: "misc-const-correctness.AnalyzeReferences", value: false},\
+// RUN:  ]}' -- -fno-delayed-template-parsing
+
+// CHECK-MESSAGES: warning: The check 'misc-const-correctness' will not perform any analysis because both 'AnalyzeValues' and 'AnalyzeReferences' are false. [clang-tidy-config]
+
+void g() {
+  int p_local0 = 42;
+  // CHECK-FIXES-NOT: int const p_local0 = 42;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/misc/const-

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

2022-07-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Thank you very much for all you patience, reviews and tests!
I hope that the following improvements are now simpler to integrate and that 
the test matures well. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[clang] 92df59c - [Driver] Enable some sanitizers on FreeBSD AArch64

2022-07-24 Thread Fangrui Song via cfe-commits

Author: Andrew Turner
Date: 2022-07-24T10:41:21-07:00
New Revision: 92df59c83d0de3d963a61ddc39dc3cd2c44e8304

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

LOG: [Driver] Enable some sanitizers on FreeBSD AArch64

They have been ported and tested to work on AArch64
(see D125883, D125758, and D125873).

Reviewed By: dim, MaskRay

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index e5451c20a00c8..e49e8b0bf7d1b 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -489,12 +489,14 @@ SanitizerMask FreeBSD::getSupportedSanitizers() const {
   Res |= SanitizerKind::PointerCompare;
   Res |= SanitizerKind::PointerSubtract;
   Res |= SanitizerKind::Vptr;
-  if (IsX86_64 || IsMIPS64) {
+  if (IsAArch64 || IsX86_64 || IsMIPS64) {
 Res |= SanitizerKind::Leak;
 Res |= SanitizerKind::Thread;
   }
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Function;
+  }
+  if (IsAArch64 || IsX86 || IsX86_64) {
 Res |= SanitizerKind::SafeStack;
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
@@ -502,8 +504,6 @@ SanitizerMask FreeBSD::getSupportedSanitizers() const {
   if (IsAArch64 || IsX86_64) {
 Res |= SanitizerKind::KernelAddress;
 Res |= SanitizerKind::KernelMemory;
-  }
-  if (IsX86_64) {
 Res |= SanitizerKind::Memory;
   }
   return Res;



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


[PATCH] D130063: [Driver] Enable sanitizers on FreeBSD AArch64

2022-07-24 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92df59c83d0d: [Driver] Enable some sanitizers on FreeBSD 
AArch64 (authored by andrew, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130063

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp


Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -489,12 +489,14 @@
   Res |= SanitizerKind::PointerCompare;
   Res |= SanitizerKind::PointerSubtract;
   Res |= SanitizerKind::Vptr;
-  if (IsX86_64 || IsMIPS64) {
+  if (IsAArch64 || IsX86_64 || IsMIPS64) {
 Res |= SanitizerKind::Leak;
 Res |= SanitizerKind::Thread;
   }
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Function;
+  }
+  if (IsAArch64 || IsX86 || IsX86_64) {
 Res |= SanitizerKind::SafeStack;
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
@@ -502,8 +504,6 @@
   if (IsAArch64 || IsX86_64) {
 Res |= SanitizerKind::KernelAddress;
 Res |= SanitizerKind::KernelMemory;
-  }
-  if (IsX86_64) {
 Res |= SanitizerKind::Memory;
   }
   return Res;


Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -489,12 +489,14 @@
   Res |= SanitizerKind::PointerCompare;
   Res |= SanitizerKind::PointerSubtract;
   Res |= SanitizerKind::Vptr;
-  if (IsX86_64 || IsMIPS64) {
+  if (IsAArch64 || IsX86_64 || IsMIPS64) {
 Res |= SanitizerKind::Leak;
 Res |= SanitizerKind::Thread;
   }
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Function;
+  }
+  if (IsAArch64 || IsX86 || IsX86_64) {
 Res |= SanitizerKind::SafeStack;
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
@@ -502,8 +504,6 @@
   if (IsAArch64 || IsX86_64) {
 Res |= SanitizerKind::KernelAddress;
 Res |= SanitizerKind::KernelMemory;
-  }
-  if (IsX86_64) {
 Res |= SanitizerKind::Memory;
   }
   return Res;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130443: [CGDebugInfo] Access the current working directory from the `VFS`

2022-07-24 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi created this revision.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

...instead of calling `llvm::sys::fs::current_path()` directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130443

Files:
  clang/include/clang/CodeGen/ModuleBuilder.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/unittests/CodeGen/TestCompiler.h
  clang/unittests/Frontend/CodeGenActionTest.cpp

Index: clang/unittests/Frontend/CodeGenActionTest.cpp
===
--- clang/unittests/Frontend/CodeGenActionTest.cpp
+++ clang/unittests/Frontend/CodeGenActionTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/CodeGen/BackendUtil.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -76,4 +77,40 @@
   bool Success = Compiler.ExecuteAction(Action);
   EXPECT_TRUE(Success);
 }
+
+TEST(CodeGenTest, DebugInfoCWDCodeGen) {
+  // Check that debug info is accessing the current working directory from the
+  // VFS instead of calling \p llvm::sys::fs::current_path() directly.
+
+  auto VFS = std::make_unique();
+  VFS->setCurrentWorkingDirectory("/in-memory-fs-cwd");
+  auto Sept = llvm::sys::path::get_separator();
+  std::string TestPath =
+  std::string(llvm::formatv("{0}in-memory-fs-cwd{0}test.cpp", Sept));
+  VFS->addFile(TestPath, 0, llvm::MemoryBuffer::getMemBuffer("int x;\n"));
+
+  auto Invocation = std::make_shared();
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile("test.cpp", Language::CXX));
+  Invocation->getFrontendOpts().ProgramAction = EmitLLVM;
+  Invocation->getTargetOpts().Triple = "x86_64-unknown-linux-gnu";
+  Invocation->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
+  CompilerInstance Compiler;
+
+  SmallString<256> IRBuffer;
+  Compiler.setOutputStream(std::make_unique(IRBuffer));
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+  Compiler.createFileManager(std::move(VFS));
+
+  EmitLLVMAction Action;
+  bool Success = Compiler.ExecuteAction(Action);
+  EXPECT_TRUE(Success);
+
+  SmallString<128> RealCWD;
+  llvm::sys::fs::current_path(RealCWD);
+  EXPECT_TRUE(!RealCWD.empty());
+  EXPECT_FALSE(IRBuffer.str().contains(RealCWD));
+  EXPECT_TRUE(IRBuffer.str().contains("in-memory-fs-cwd"));
+}
 }
Index: clang/unittests/CodeGen/TestCompiler.h
===
--- clang/unittests/CodeGen/TestCompiler.h
+++ clang/unittests/CodeGen/TestCompiler.h
@@ -56,12 +56,10 @@
 
 compiler.createASTContext();
 
-CG.reset(CreateLLVMCodeGen(compiler.getDiagnostics(),
-   "main-module",
-   compiler.getHeaderSearchOpts(),
-   compiler.getPreprocessorOpts(),
-   compiler.getCodeGenOpts(),
-   Context));
+CG.reset(CreateLLVMCodeGen(
+compiler.getDiagnostics(), "main-module",
+&compiler.getVirtualFileSystem(), compiler.getHeaderSearchOpts(),
+compiler.getPreprocessorOpts(), compiler.getCodeGenOpts(), Context));
   }
 
   void init(const char *TestProgram,
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -230,8 +230,9 @@
 llvm::LLVMContext &LLVMCtx) {
   StringRef ModuleName("$__module");
   return std::unique_ptr(CreateLLVMCodeGen(
-  CI.getDiagnostics(), ModuleName, CI.getHeaderSearchOpts(),
-  CI.getPreprocessorOpts(), CI.getCodeGenOpts(), LLVMCtx));
+  CI.getDiagnostics(), ModuleName, &CI.getVirtualFileSystem(),
+  CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
+  LLVMCtx));
 }
 } // namespace init_convenience
 
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -45,6 +45,7 @@
   const std::string OutputFileName;
   ASTContext *Ctx;
   ModuleMap &MMap;
+  IntrusiveRefCntPtr FS;
   const HeaderSearchOptions &HeaderSearchOpts;
   const PreprocessorOptions &PreprocessorOpts;
   CodeGenOptions CodeGenOpts;
@@ -144,6 +145,7 @@
   : Diags(CI.getDiagnostics()), MainFileName(MainFileName),
 OutputFileName(Outpu

[clang-tools-extra] 87d627b - Remove redundant string initialization (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T12:27:11-07:00
New Revision: 87d627b623eb392610c073e6334782982373959a

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

LOG: Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
mlir/lib/Pass/Pass.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
index f2f2cf674fa7a..30ff058619550 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
@@ -40,7 +40,7 @@ static std::string getTypeStr(const QualType &OrigT, const 
Decl &D,
   QualType T = OrigT;
   PrintingPolicy Policy(D.getASTContext().getLangOpts());
   Policy.SuppressStrongLifetime = true;
-  std::string Prefix = "";
+  std::string Prefix;
   // If the nullability is specified via a property attribute, use the shorter
   // `nullable` form for the method parameter.
   if (PropertyAttributes & ObjCPropertyAttribute::kind_nullability) {

diff  --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index c33d9233474f9..a3deafdc7a79e 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -90,7 +90,7 @@ struct OpPassManagerImpl {
   : name(name == OpPassManager::getAnyOpAnchorName() ? "" : name.str()),
 initializationGeneration(0), nesting(nesting) {}
   OpPassManagerImpl(OpPassManager::Nesting nesting)
-  : name(""), initializationGeneration(0), nesting(nesting) {}
+  : initializationGeneration(0), nesting(nesting) {}
   OpPassManagerImpl(const OpPassManagerImpl &rhs)
   : name(rhs.name), opName(rhs.opName),
 initializationGeneration(rhs.initializationGeneration),



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


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

2022-07-24 Thread Mark de Wever via Phabricator via cfe-commits
Mordante accepted this revision.
Mordante added a comment.
This revision is now accepted and ready to land.

In D129048#3674500 , @Codesbyusman 
wrote:

> updated the libcxx all files

FYI for libcxx you can ignore the red format CI step. So the libcxx build is 
green :-)

I had a look at your libc++ changes and they look good, thanks.
So LGTM for the libc++ part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


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

2022-07-24 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman added a comment.

In D129048#3674582 , @Mordante wrote:

> In D129048#3674500 , @Codesbyusman 
> wrote:
>
>> updated the libcxx all files
>
> FYI for libcxx you can ignore the red format CI step. So the libcxx build is 
> green :-)
>
> I had a look at your libc++ changes and they look good, thanks.
> So LGTM for the libc++ part.

That's great :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D130299: [clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas

2022-07-24 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

Do you have commit access, or do you want to apply for it, or do you need 
someone to push the change(s)? If the latter we need a name and mail for the 
commit.


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

https://reviews.llvm.org/D130299

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


[PATCH] D130417: [clang-format] Missing space between trailing return type 'auto' and left brace

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

You should mark comments as done, if so.


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

https://reviews.llvm.org/D130417

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


[PATCH] D130299: [clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas

2022-07-24 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin added a comment.

In D130299#3674586 , 
@HazardyKnusperkeks wrote:

> Do you have commit access, or do you want to apply for it, or do you need 
> someone to push the change(s)? If the latter we need a name and mail for the 
> commit.

I haven't access for merging changes to code base. So, I need support from 
community for doing this.

My name and mail:
Name: **Denis Fatkulin**
Mail: **fatkulin.de...@huawei.com**

Thank you!

PS. Related patch should be merged too. D130417 



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

https://reviews.llvm.org/D130299

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


[PATCH] D130417: [clang-format] Missing space between trailing return type 'auto' and left brace

2022-07-24 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin marked 2 inline comments as done.
denis-fatkulin added a comment.

They marked done. Thanks!




Comment at: clang/unittests/Format/FormatTest.cpp:23555-23556
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("[]() -> auto { return Val; }", Style);
+  verifyFormat("auto foo() -> auto { return Val; }", Style);
+}

curdeius wrote:
> owenpan wrote:
> > Should we add test cases with an `&` between `auto` and `{`?
> :+1:
Then it's better to add the case not only for `auto &`, but for `auto *` too.
But actually these cases are hadled correctly without this patch.


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

https://reviews.llvm.org/D130417

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


[clang] 9e88cbc - Use any_of (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T14:48:11-07:00
New Revision: 9e88cbcc403bdf82f29259ad60ff60a8fc4434a1

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

LOG: Use any_of (NFC)

Added: 


Modified: 
clang/lib/Edit/EditedSource.cpp
clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/tools/llvm-xray/xray-graph.cpp
mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp

Removed: 




diff  --git a/clang/lib/Edit/EditedSource.cpp b/clang/lib/Edit/EditedSource.cpp
index ee57660b8c72c..a3386b2489b07 100644
--- a/clang/lib/Edit/EditedSource.cpp
+++ b/clang/lib/Edit/EditedSource.cpp
@@ -84,11 +84,11 @@ bool EditedSource::canInsertInOffset(SourceLocation 
OrigLoc, FileOffset Offs) {
 deconstructMacroArgLoc(OrigLoc, ExpLoc, ArgUse);
 auto I = ExpansionToArgMap.find(ExpLoc);
 if (I != ExpansionToArgMap.end() &&
-find_if(I->second, [&](const MacroArgUse &U) {
+llvm::any_of(I->second, [&](const MacroArgUse &U) {
   return ArgUse.Identifier == U.Identifier &&
  std::tie(ArgUse.ImmediateExpansionLoc, ArgUse.UseLoc) !=
  std::tie(U.ImmediateExpansionLoc, U.UseLoc);
-}) != I->second.end()) {
+})) {
   // Trying to write in a macro argument input that has already been
   // written by a previous commit for another expansion of the same macro
   // argument name. For example:

diff  --git a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
index cddf206728b1a..27fd40a441fad 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -182,7 +182,7 @@ class PaddingChecker : public 
Checker> {
   return false;
 };
 
-if (std::any_of(RD->field_begin(), RD->field_end(), IsTrickyField))
+if (llvm::any_of(RD->fields(), IsTrickyField))
   return true;
 return false;
   }

diff  --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp 
b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 0c23d7c1435f3..3af8f800adcb8 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -2200,8 +2200,7 @@ static int showInstrProfile(const std::string &Filename, 
bool ShowCounts,
 Builder.addRecord(Func);
 
 if (ShowCovered) {
-  if (std::any_of(Func.Counts.begin(), Func.Counts.end(),
-  [](uint64_t C) { return C; }))
+  if (llvm::any_of(Func.Counts, [](uint64_t C) { return C; }))
 OS << Func.Name << "\n";
   continue;
 }

diff  --git a/llvm/tools/llvm-xray/xray-graph.cpp 
b/llvm/tools/llvm-xray/xray-graph.cpp
index 39d2c5c153ef1..ff47eb64e9473 100644
--- a/llvm/tools/llvm-xray/xray-graph.cpp
+++ b/llvm/tools/llvm-xray/xray-graph.cpp
@@ -232,10 +232,11 @@ Error GraphRenderer::accountRecord(const XRayRecord 
&Record) {
   if (!DeduceSiblingCalls)
 return make_error("No matching ENTRY record",

make_error_code(errc::invalid_argument));
-  auto Parent = std::find_if(
-  ThreadStack.rbegin(), ThreadStack.rend(),
-  [&](const FunctionAttr &A) { return A.FuncId == Record.FuncId; });
-  if (Parent == ThreadStack.rend())
+  bool FoundParent =
+  llvm::any_of(llvm::reverse(ThreadStack), [&](const FunctionAttr &A) {
+return A.FuncId == Record.FuncId;
+  });
+  if (!FoundParent)
 return make_error(
 "No matching Entry record in stack",
 make_error_code(errc::invalid_argument)); // There is no matching

diff  --git a/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp 
b/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
index 8c3dc07cd97ed..265797bc61bf2 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
@@ -182,7 +182,7 @@ LogicalResult 
transform::TransformState::checkAndRecordHandleInvalidation(
   return isa(effect.getEffect()) &&
  effect.getValue() == target.get();
 };
-if (llvm::find_if(effects, consumesTarget) != effects.end())
+if (llvm::any_of(effects, consumesTarget))
   recordHandleInvalidation(target);
   }
   return success();



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


[PATCH] D129138: [clang] [docs] Update the changes of C++20 Modules in clang15

2022-07-24 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D129138#3670708 , @ChuanqiXu wrote:

> @iains I'm going to land this in next Monday if all the dependent patch 
> landed. Do you feel good with this?

I am not sure if we will get p1815 part 1 landed (effectively today) - and, of 
course, we have also some other patches in-flight that will improve the C++20 
implementation, but extremely unlikely to be landed today.


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

https://reviews.llvm.org/D129138

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


[PATCH] D122768: [Clang][C++20] Support capturing structured bindings in lambdas

2022-07-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/StmtPrinter.cpp:2166
 
 if (Node->isInitCapture(C)) {
+  VarDecl *D = cast(C->getCapturedVar());

I wonder if it is worth commenting that only a `VarDecl` can be an init capture 
and therefore we can unconditionally cast to `VarDecl`?



Comment at: clang/lib/Sema/SemaInit.cpp:7851
+bool InitCapture =
+isa(VD) && cast(VD)->isInitCapture();
 Diag(Elem.Capture->getLocation(), 
diag::note_lambda_capture_initializer)

cor3ntin wrote:
> shafik wrote:
> > I see we are doing this kind of check to see if we have a `VarDecl` and 
> > then check if it is an init capture and I wish there was a way not to 
> > repeat this but I don't see it.
> I considered having a function In ValueDecl, what do you think?
I thought about that but when I looked at `ValueDecl` it seemed pretty 
lightweight.

@aaron.ballman wdyt is `ValueDecl` the right place or is this code repetition 
ok? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122768

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


[PATCH] D125272: [clang] Add -fcheck-new support

2022-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.
Herald added a subscriber: StephenFan.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4117
+  if (const Arg *A = Args.getLastArg(OPT_fcheck_new))
+Opts.CheckNew = true;
+

Use `CodeGenOpts<"CheckNew">` and avoid change to this file. CodeGenOpts seems 
more suitable than LangOpts.



Comment at: clang/test/CodeGenCXX/fcheck-new.cpp:3
+// RUN: %clang_cc1 -fcheck-new -triple x86_64-linux-gnu -S -disable-O0-optnone 
\
+// RUN: -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+

Please remove `opt`. Optimizations should be tested in the llvm/ layer, not in 
clang codegen.

If utils/update_cc_test_checks.py does not generate good looking IR, write it 
by hand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125272

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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-24 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

Thanks for the explanation. I am more clear now about the background.




Comment at: clang/include/clang/Driver/Options.td:3611
   HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only 
volatile vector registers.">;
+def maix_quadword_atomics : Flag<["-"], "maix64-quadword-atomics">,
+  Group, Flags<[CC1Option]>,

lkail wrote:
> shchenz wrote:
> > amyk wrote:
> > > Would it be better if we called this `maix64-quadword-atomics` instead? 
> > Do we need to change the backend check below too?
> > ```
> > bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
> >   // TODO: 16-byte atomic type support for AIX is in progress; we should be 
> > able
> >   // to inline 16-byte atomic ops on AIX too in the future.
> >   return Subtarget.isPPC64() &&
> >  (EnableQuadwordAtomics || !Subtarget.getTargetTriple().isOSAIX()) 
> > &&
> >  Subtarget.hasQuadwordAtomics();
> > }
> > ```
> We don't need to change this yet. When we are compiling a quadword lock free 
> libatomic, we use options `-mabi=quadword-atomics -mllvm 
> -ppc-quadword-atomics` to enforce generating quadword lock-free code on AIX.
This makes me confuse. We need to two different options to control the frontend 
and backend behavior?

Is it the final usage? Or we will add a follow up patch to map the backend one 
to the FE one? IMO finally we only need the driver option 
`-mabi=quadword-atomics` to control the final code generation for 128 bit 
atomic operations, right?



Comment at: clang/lib/Basic/Targets/PPC.cpp:854
+  HasQuadwordAtomics)
+MaxAtomicInlineWidth = 128;
 }

lkail wrote:
> shchenz wrote:
> > Can we set `MaxAtomicInlineWidth` in 
> > `PPC64TargetInfo::setMaxAtomicWidth()`? There is a `TODO` there
> The `TODO` marks our roadmap towards enabling quardword lock free atomics on 
> AIX too. Putting adjustment here is implementation reason: we don't context 
> of `LanguageOptions` in `PPC64TargetInfo::PPC64TargetInfo`.
OK, fair enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D130419: Use `` with MSVC and C++

2022-07-24 Thread Igor Zhukov via Phabricator via cfe-commits
fsb4000 updated this revision to Diff 447163.
fsb4000 added a comment.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

added a dummy.txt in libcxx directory


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130419

Files:
  clang/lib/Headers/stdatomic.h
  libcxx/dummy.txt


Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -17,7 +17,8 @@
  * explicitly disallows `stdatomic.h` in the C mode via an `#error`.  Fallback
  * to the clang resource header until that is fully supported.
  */
-#if __STDC_HOSTED__ && __has_include_next() && !defined(_MSC_VER)
+#if __STDC_HOSTED__ && 
\
+__has_include_next() && !(defined(_MSC_VER) && 
!defined(__cplusplus))
 # include_next 
 #else
 


Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -17,7 +17,8 @@
  * explicitly disallows `stdatomic.h` in the C mode via an `#error`.  Fallback
  * to the clang resource header until that is fully supported.
  */
-#if __STDC_HOSTED__ && __has_include_next() && !defined(_MSC_VER)
+#if __STDC_HOSTED__ && \
+__has_include_next() && !(defined(_MSC_VER) && !defined(__cplusplus))
 # include_next 
 #else
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130446: [apinotes] Upstream changes to `APINotesYAMLCompiler.cpp`.

2022-07-24 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
zoecarver added a reviewer: compnerd.
Herald added a project: All.
zoecarver requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130446

Files:
  clang/lib/APINotes/APINotesYAMLCompiler.cpp


Index: clang/lib/APINotes/APINotesYAMLCompiler.cpp
===
--- clang/lib/APINotes/APINotesYAMLCompiler.cpp
+++ clang/lib/APINotes/APINotesYAMLCompiler.cpp
@@ -289,6 +289,7 @@
   StringRef SwiftName;
   StringRef Type;
   StringRef ResultType;
+  Optional ImportAs;
 };
 
 typedef std::vector FunctionsSeq;
@@ -311,6 +312,7 @@
 IO.mapOptional("SwiftPrivate", F.SwiftPrivate);
 IO.mapOptional("SwiftName", F.SwiftName, StringRef(""));
 IO.mapOptional("ResultType", F.ResultType, StringRef(""));
+IO.mapOptional("ImportAs", F.ImportAs);
   }
 };
 } // namespace yaml
@@ -417,6 +419,10 @@
   Optional EnumExtensibility;
   Optional FlagEnum;
   Optional EnumConvenienceKind;
+  Optional ImportAs;
+  Optional RetainOp;
+  Optional ReleaseOp;
+  FunctionsSeq MemberFuncs;
 };
 
 typedef std::vector TagsSeq;
@@ -447,6 +453,10 @@
 IO.mapOptional("EnumExtensibility", T.EnumExtensibility);
 IO.mapOptional("FlagEnum", T.FlagEnum);
 IO.mapOptional("EnumKind", T.EnumConvenienceKind);
+IO.mapOptional("ImportAs", T.ImportAs);
+IO.mapOptional("Retain", T.RetainOp);
+IO.mapOptional("Release", T.ReleaseOp);
+IO.mapOptional("Methods", T.MemberFuncs);
   }
 };
 } // namespace yaml


Index: clang/lib/APINotes/APINotesYAMLCompiler.cpp
===
--- clang/lib/APINotes/APINotesYAMLCompiler.cpp
+++ clang/lib/APINotes/APINotesYAMLCompiler.cpp
@@ -289,6 +289,7 @@
   StringRef SwiftName;
   StringRef Type;
   StringRef ResultType;
+  Optional ImportAs;
 };
 
 typedef std::vector FunctionsSeq;
@@ -311,6 +312,7 @@
 IO.mapOptional("SwiftPrivate", F.SwiftPrivate);
 IO.mapOptional("SwiftName", F.SwiftName, StringRef(""));
 IO.mapOptional("ResultType", F.ResultType, StringRef(""));
+IO.mapOptional("ImportAs", F.ImportAs);
   }
 };
 } // namespace yaml
@@ -417,6 +419,10 @@
   Optional EnumExtensibility;
   Optional FlagEnum;
   Optional EnumConvenienceKind;
+  Optional ImportAs;
+  Optional RetainOp;
+  Optional ReleaseOp;
+  FunctionsSeq MemberFuncs;
 };
 
 typedef std::vector TagsSeq;
@@ -447,6 +453,10 @@
 IO.mapOptional("EnumExtensibility", T.EnumExtensibility);
 IO.mapOptional("FlagEnum", T.FlagEnum);
 IO.mapOptional("EnumKind", T.EnumConvenienceKind);
+IO.mapOptional("ImportAs", T.ImportAs);
+IO.mapOptional("Retain", T.RetainOp);
+IO.mapOptional("Release", T.ReleaseOp);
+IO.mapOptional("Methods", T.MemberFuncs);
   }
 };
 } // namespace yaml
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-24 Thread Kai Luo via Phabricator via cfe-commits
lkail added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3611
   HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only 
volatile vector registers.">;
+def maix_quadword_atomics : Flag<["-"], "maix64-quadword-atomics">,
+  Group, Flags<[CC1Option]>,

shchenz wrote:
> lkail wrote:
> > shchenz wrote:
> > > amyk wrote:
> > > > Would it be better if we called this `maix64-quadword-atomics` instead? 
> > > Do we need to change the backend check below too?
> > > ```
> > > bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
> > >   // TODO: 16-byte atomic type support for AIX is in progress; we should 
> > > be able
> > >   // to inline 16-byte atomic ops on AIX too in the future.
> > >   return Subtarget.isPPC64() &&
> > >  (EnableQuadwordAtomics || 
> > > !Subtarget.getTargetTriple().isOSAIX()) &&
> > >  Subtarget.hasQuadwordAtomics();
> > > }
> > > ```
> > We don't need to change this yet. When we are compiling a quadword lock 
> > free libatomic, we use options `-mabi=quadword-atomics -mllvm 
> > -ppc-quadword-atomics` to enforce generating quadword lock-free code on AIX.
> This makes me confuse. We need to two different options to control the 
> frontend and backend behavior?
> 
> Is it the final usage? Or we will add a follow up patch to map the backend 
> one to the FE one? IMO finally we only need the driver option 
> `-mabi=quadword-atomics` to control the final code generation for 128 bit 
> atomic operations, right?
> This makes me confuse. We need to two different options to control the 
> frontend and backend behavior?

This is multi-lang support consideration. clang is not the only frontend we 
have using LLVM as backend on AIX. If other language frontend generates `store 
atomic i128, ...`, the backend is supposed to generate libcalls into libatomic 
currently.

> Is it the final usage?
No. We finally want to achieve `-mabi=quadword-atomics` by default and generate 
inline atomic code for cpu above pwr7 by default(no need to take OS into 
consideration).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D128955: [WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes

2022-07-24 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 447170.
aeubanks marked an inline comment as done.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128955

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/cfi-mfcall.cpp
  clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp
  clang/test/CodeGenCXX/thinlto_public_type_test_distributed.ll
  clang/test/CodeGenCXX/type-metadata.cpp
  lld/test/ELF/lto/update_public_type_test.ll
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Analysis/TypeMetadataUtils.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/LTO/X86/public-type-test.ll
  llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
  llvm/test/ThinLTO/X86/public-type-test.ll
  llvm/tools/llvm-lto/llvm-lto.cpp

Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -261,6 +261,10 @@
  cl::desc("Print pass management debugging information"),
  cl::cat(LTOCategory));
 
+static cl::opt
+LTOSaveBeforeOpt("lto-save-before-opt", cl::init(false),
+ cl::desc("Save the IR before running optimizations"));
+
 namespace {
 
 struct ModuleInfo {
@@ -1069,6 +1073,9 @@
 CodeGen.setFileType(*FT);
 
   if (!OutputFilename.empty()) {
+if (LTOSaveBeforeOpt)
+  CodeGen.setSaveIRBeforeOptPath(OutputFilename + ".preopt.bc");
+
 if (SaveLinkedModuleFile) {
   std::string ModuleFilename = OutputFilename;
   ModuleFilename += ".linked.bc";
Index: llvm/test/ThinLTO/X86/public-type-test.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/public-type-test.ll
@@ -0,0 +1,25 @@
+; Test to ensure that the legacy LTO API lowers @llvm.public.type.test.
+
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t.bc --thinlto-save-temps=%t2
+; RUN: llvm-dis -o - %t20.2.internalized.bc | FileCheck %s --check-prefix=PUBLIC
+; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t.bc --thinlto-save-temps=%t2 --whole-program-visibility
+; RUN: llvm-dis -o - %t20.2.internalized.bc | FileCheck %s --check-prefix=HIDDEN
+
+; PUBLIC-NOT: call {{.*}}@llvm.public.type.test
+; PUBLIC-NOT: call {{.*}}@llvm.type.test
+; HIDDEN-NOT: call {{.*}}@llvm.public.type.test
+; HIDDEN: call {{.*}}@llvm.type.test
+
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.9"
+
+define i32 @main(ptr %vtable) {
+entry:
+  %p = call i1 @llvm.public.type.test(ptr %vtable, metadata !"_ZTS1A")
+  call void @llvm.assume(i1 %p)
+  ret i32 0
+}
+
+declare void @llvm.assume(i1)
+declare i1 @llvm.public.type.test(ptr, metadata)
Index: llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
===
--- llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
+++ llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
@@ -10,6 +10,7 @@
 ; RUN:   -whole-program-visibility \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t2.o,test,px \
+; RUN:   -r=%t2.o,test_public,px \
 ; RUN:   -r=%t2.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
@@ -17,6 +18,7 @@
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
 ; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; Hybrid WPD
@@ -26,6 +28,7 @@
 ; RUN:   -whole-program-visibility \
 ; RUN:   -o %t3 \
 ; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,test_public,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t.o,_ZN1C1fEi,p \
@@ -40,6 +43,7 @@
 ; RUN:   -r=%t.o,_ZTV1B,px \
 ; RUN:   -r=%t.o,_ZTV1C,px \
 ; RUN:   -r=%t.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK --dump-input=fail
+; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; Regular LTO WPD
@@ -48,6 +52,7 @@
 ; RUN:   -whole-program-visibility \
 ; RUN:   -o %t5 \
 ; RUN:   -r=%t4.o,test,px \
+; RUN:   -r=%t4.o,test_public,px \
 ; RUN:   -

[PATCH] D128955: [WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes

2022-07-24 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

random question, if the old API is "legacy", are there any plans to remove it?




Comment at: llvm/test/LTO/X86/public-type-test.ll:3
+
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t.bc 
--thinlto-save-temps=%t2

tejohnson wrote:
> The new version switched this from a regular LTO to ThinLTO test. I think we 
> need both. Can you move the new version into llvm/test/ThinLTO/X86 and make 
> this version back to testing the regular LTO old API handling, but with 
> checks?
done, had to add a new flag to dump IR right before optimizations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128955

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


[PATCH] D129174: [C++20][Modules] Update ADL to handle basic.lookup.argdep p4 [P1815R2 part 1]

2022-07-24 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:3864-3878
+  for (auto *E : AssociatedClasses) {
+// and have the same innermost enclosing non-inline namespace
+// scope as a declaration of an associated entity attached to M
+if (!E->hasOwningModule() || E->getOwningModule() != FM)
+  continue;
+// TODO: maybe this could be cached when generating the
+// associated namespaces / entities.

iains wrote:
> ChuanqiXu wrote:
> > iains wrote:
> > > ChuanqiXu wrote:
> > > > nit: how do you think about the suggested style? (not required)
> > > I guess it's a little shorter, and roughly the same in readability,
> > > 
> > The current implementation skips a `break` of the outer loop.
> I'm not sure exactly what you are referring to here (maybe I missed 
> something) - 
hmmm, sorry, I misread something. It should be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129174

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


[PATCH] D125272: [clang] Add -fcheck-new support

2022-07-24 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/test/CodeGenCXX/fcheck-new.cpp:3
+// RUN: %clang_cc1 -fcheck-new -triple x86_64-linux-gnu -S -disable-O0-optnone 
\
+// RUN: -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+

MaskRay wrote:
> Please remove `opt`. Optimizations should be tested in the llvm/ layer, not 
> in clang codegen.
> 
> If utils/update_cc_test_checks.py does not generate good looking IR, write it 
> by hand.
Disagree. This is a pattern that is extremely useful for testing Clang's IR 
generation whilst cleaning up the alloca so the IR is readable. This is not 
about the generated checks, this is about alloca/load/store everywhere being a 
pain to inspect, whereas a simple mem2reg cleans this up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125272

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


[PATCH] D130331: [C++20] [Modules] Disable preferred_name when writing a C++20 Module interface

2022-07-24 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 447185.
ChuanqiXu added a comment.

Add more tests.


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

https://reviews.llvm.org/D130331

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/preferred_name.cppm

Index: clang/test/Modules/preferred_name.cppm
===
--- /dev/null
+++ clang/test/Modules/preferred_name.cppm
@@ -0,0 +1,50 @@
+// Tests that the ODR check wouldn't produce false-positive result for preferred_name attribute.
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use1.cpp -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use2.cpp -verify -fsyntax-only
+//
+//--- foo.h
+template
+class foo_templ;
+
+typedef foo_templ foo;
+
+template
+class
+__attribute__((__preferred_name__(foo)))
+foo_templ {
+public:
+foo_templ() {}
+};
+
+inline foo_templ bar()
+{
+  return foo_templ();
+}
+
+//--- A.cppm
+module;
+#include "foo.h"
+export module A;
+
+//--- Use.cppm
+// expected-no-diagnostics
+module;
+#include "foo.h"
+export module Use;
+import A;
+
+//--- Use1.cpp
+import A; // expected-warning@foo.h:8 {{attribute declaration must precede definition}}
+#include "foo.h"  // expected-note@foo.h:9 {{previous definition is here}}
+
+//--- Use2.cpp
+// expected-no-diagnostics
+#include "foo.h"
+import A;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -4347,8 +4347,12 @@
 
 void ASTRecordWriter::AddAttr(const Attr *A) {
   auto &Record = *this;
-  if (!A)
+  // FIXME: Clang can't handle the serialization/deserialization of
+  // preferred_name properly now. See
+  // https://github.com/llvm/llvm-project/issues/56490 for example.
+  if (!A || (isa(A) && Writer->isWritingNamedModules()))
 return Record.push_back(0);
+
   Record.push_back(A->getKind() + 1); // FIXME: stable encoding, target attrs
 
   Record.AddIdentifierRef(A->getAttrName());
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2922,7 +2922,8 @@
 /// Reads attributes from the current stream position.
 void ASTRecordReader::readAttributes(AttrVec &Attrs) {
   for (unsigned I = 0, E = readInt(); I != E; ++I)
-Attrs.push_back(readAttr());
+if (auto *Attr = readAttr())
+  Attrs.push_back(Attr);
 }
 
 //===--===//
Index: clang/include/clang/Serialization/ASTWriter.h
===
--- clang/include/clang/Serialization/ASTWriter.h
+++ clang/include/clang/Serialization/ASTWriter.h
@@ -703,6 +703,10 @@
   bool hasChain() const { return Chain; }
   ASTReader *getChain() const { return Chain; }
 
+  bool isWritingNamedModules() const {
+return WritingModule && WritingModule->isModulePurview();
+  }
+
 private:
   // ASTDeserializationListener implementation
   void ReaderInitialized(ASTReader *Reader) override;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130331: [C++20] [Modules] Disable preferred_name when writing a C++20 Module interface

2022-07-24 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:2925-2926
   for (unsigned I = 0, E = readInt(); I != E; ++I)
-Attrs.push_back(readAttr());
+if (auto *Attr = readAttr())
+  Attrs.push_back(Attr);
 }

tahonermann wrote:
> Interesting, this looks like a pre-existing issue. It looks like 
> `readBTFTypeTagAttr()` in 
> `clang/include/clang/Serialization/ASTRecordReader.h` has an assumption that 
> `readAttr()` always returns non-null. I wonder if that should be modified to 
> use `cast_or_null` rather than `cast`. I don't see any need to address that 
> issue (if it actually exists) in this review though.
Yeah, it surprises me too.



Comment at: clang/lib/Serialization/ASTWriter.cpp:4353
+  // https://github.com/llvm/llvm-project/issues/56490 for example.
+  if (!A || (isa(A) && Writer->isWritingNamedModules()))
 return Record.push_back(0);

tahonermann wrote:
> ChuanqiXu wrote:
> > The `Writer->isWritingNamedModules()` part is necessary. Otherwise we would 
> > break the 
> > https://github.com/llvm/llvm-project/blob/main/clang/test/PCH/decl-attrs.cpp
> >  test. The reason why the bug is not found by the user of PCH or clang 
> > modules is that a header generally would be guarded by `#ifndef ... 
> > #define` fashion. And if we remove the guard, the compiler would emit an 
> > error for duplicated definition. So the problem only lives in C++20 Named 
> > Modules.
> Correct me if I'm mistaken, but I think this issue only occurs because, in 
> the test, both modules have the problematic declarations in the global module 
> fragment; thus creating duplicate definitions that have to be merged which 
> then exposes the ODR mismatch.
> 
> I'm suspicious that this actually fixes all possible scenarios. For example:
>   //--- X1.cpp
>   #include "foo.h"
>   import A;
> 
>   //--- X2.cpp
>   import A;
>   #include "foo.h"
> 
> I would expect the proposed change to cause an ODR issue in these scenarios 
> since the definition from the module still needs to be merged in non-modular 
> TUs, but now the imported module will lack the attribute present in the 
> non-modular TUs.
> Correct me if I'm mistaken, but I think this issue only occurs because, in 
> the test, both modules have the problematic declarations in the global module 
> fragment; thus creating duplicate definitions that have to be merged which 
> then exposes the ODR mismatch.

I am not sure if I followed. If you are referring to why this problem only 
exists in C++20 Named Modules, I think you are correct. Other modules (Clang 
modules, C++20 Header units) don't have global modules.

> I'm suspicious that this actually fixes all possible scenarios. For example:

I've added the two examples below. I understand this is confusing at the first 
sight. There are two cases.
(1) For `X1.cpp`, we do ODR checks in ASTReaders by calling 
`ASTContext::isSameEntity.` And  `ASTContext::isSameEntity` wouldn't check for 
attributes.  (Another defect?)
(2) For `X2.cpp`, we do ODR checks in Sema. And it would emit a warning as the 
tests shows.

So as a conclusion, the current implementation works 'not bad' currently. But I 
agree that it might bad in the future. Especially WG21 are going to disallow 
the compilers to ignore the semantics of attributes.



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

https://reviews.llvm.org/D130331

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


[clang] edaae25 - [clang] better error message for while loops outside of control flow

2022-07-24 Thread via cfe-commits

Author: inclyc
Date: 2022-07-25T11:48:24+08:00
New Revision: edaae251cca07c34c55905c424a8f677623d0bd0

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

LOG: [clang] better error message for while loops outside of control flow

report an error when encountering 'while' token parsing declarator

```
clang/test/Parser/while-loop-outside-function.c:3:1: error: while loop outside 
of a function
while // expected-error {{while loop outside of a function}}
^
clang/test/Parser/while-loop-outside-function.c:7:1: error: while loop outside 
of a function
while // expected-error {{while loop outside of a function}}
^
```

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

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

Added: 
clang/test/Parser/while-loop-outside-function.c
clang/test/Parser/while-loop-outside-function.cpp

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseDecl.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 352a050ba5cf1..bad6c094cde10 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -538,6 +538,8 @@ def err_invalid_operator_on_type : Error<
   "cannot use %select{dot|arrow}0 operator on a type">;
 def err_expected_unqualified_id : Error<
   "expected %select{identifier|unqualified-id}0">;
+def err_while_loop_outside_of_a_function : Error<
+  "while loop outside of a function">; 
 def err_brackets_go_after_unqualified_id : Error<
   "brackets are not allowed here; to declare an array, "
   "place the brackets after the %select{identifier|name}0">;

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 2f21b7b2fef00..aef9909a7c971 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -6344,23 +6344,27 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
diag::err_expected_member_name_or_semi)
   << (D.getDeclSpec().isEmpty() ? SourceRange()
 : D.getDeclSpec().getSourceRange());
-} else if (getLangOpts().CPlusPlus) {
-  if (Tok.isOneOf(tok::period, tok::arrow))
-Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
-  else {
-SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();
-if (Tok.isAtStartOfLine() && Loc.isValid())
-  Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
-  << getLangOpts().CPlusPlus;
-else
-  Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
-   diag::err_expected_unqualified_id)
-  << getLangOpts().CPlusPlus;
-  }
 } else {
-  Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
-   diag::err_expected_either)
-  << tok::identifier << tok::l_paren;
+  if (Tok.getKind() == tok::TokenKind::kw_while) {
+Diag(Tok, diag::err_while_loop_outside_of_a_function);
+  } else if (getLangOpts().CPlusPlus) {
+if (Tok.isOneOf(tok::period, tok::arrow))
+  Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
+else {
+  SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();
+  if (Tok.isAtStartOfLine() && Loc.isValid())
+Diag(PP.getLocForEndOfToken(Loc), 
diag::err_expected_unqualified_id)
+<< getLangOpts().CPlusPlus;
+  else
+Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
+ diag::err_expected_unqualified_id)
+<< getLangOpts().CPlusPlus;
+}
+  } else {
+Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
+ diag::err_expected_either)
+<< tok::identifier << tok::l_paren;
+  }
 }
 D.SetIdentifier(nullptr, Tok.getLocation());
 D.setInvalidType(true);

diff  --git a/clang/test/Parser/while-loop-outside-function.c 
b/clang/test/Parser/while-loop-outside-function.c
new file mode 100644
index 0..2e747dd3f8b15
--- /dev/null
+++ b/clang/test/Parser/while-loop-outside-function.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+while // expected-error {{while loop outside of a function}}
+(1) {};
+
+// without semicolon
+while // expected-error {{while loop outside of a function}}
+(1) {}
+
+int overload_return(); // expected-note {{previous declaration is here}}
+
+void overload_return() // expected-error {{conflicting types for 
'overload_return'}}
+{ 
+while(1) {};
+while(1);
+}
+
+while // expected-error {{while loop outside of a function}}
+(1); 
+
+void correct();
+
+void correct() {
+while(1) {};
+while(1);
+}

diff  --gi

[PATCH] D129573: [clang] better error message for while loops outside of control flow

2022-07-24 Thread YingChi Long via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGedaae251cca0: [clang] better error message for while loops 
outside of control flow (authored by inclyc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129573

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/while-loop-outside-function.c
  clang/test/Parser/while-loop-outside-function.cpp

Index: clang/test/Parser/while-loop-outside-function.cpp
===
--- /dev/null
+++ clang/test/Parser/while-loop-outside-function.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+while // expected-error {{while loop outside of a function}}
+(true) {};
+
+// without semicolon
+while // expected-error {{while loop outside of a function}}
+(true) {}
+
+do { // expected-error {{expected unqualified-id}}
+int some_var = 1;
+some_var += 3;
+} 
+while // expected-error {{while loop outside of a function}}
+(true); 
+
+void someFunction() {
+while(true) {};
+}
+
+class SomeClass {
+public:
+while(true) {} // expected-error {{expected member name or ';' after declaration specifiers}}
+void some_fn() {
+while(true) {}
+}
+};
Index: clang/test/Parser/while-loop-outside-function.c
===
--- /dev/null
+++ clang/test/Parser/while-loop-outside-function.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+while // expected-error {{while loop outside of a function}}
+(1) {};
+
+// without semicolon
+while // expected-error {{while loop outside of a function}}
+(1) {}
+
+int overload_return(); // expected-note {{previous declaration is here}}
+
+void overload_return() // expected-error {{conflicting types for 'overload_return'}}
+{ 
+while(1) {};
+while(1);
+}
+
+while // expected-error {{while loop outside of a function}}
+(1); 
+
+void correct();
+
+void correct() {
+while(1) {};
+while(1);
+}
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6344,23 +6344,27 @@
diag::err_expected_member_name_or_semi)
   << (D.getDeclSpec().isEmpty() ? SourceRange()
 : D.getDeclSpec().getSourceRange());
-} else if (getLangOpts().CPlusPlus) {
-  if (Tok.isOneOf(tok::period, tok::arrow))
-Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
-  else {
-SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();
-if (Tok.isAtStartOfLine() && Loc.isValid())
-  Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
-  << getLangOpts().CPlusPlus;
-else
-  Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
-   diag::err_expected_unqualified_id)
-  << getLangOpts().CPlusPlus;
-  }
 } else {
-  Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
-   diag::err_expected_either)
-  << tok::identifier << tok::l_paren;
+  if (Tok.getKind() == tok::TokenKind::kw_while) {
+Diag(Tok, diag::err_while_loop_outside_of_a_function);
+  } else if (getLangOpts().CPlusPlus) {
+if (Tok.isOneOf(tok::period, tok::arrow))
+  Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
+else {
+  SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();
+  if (Tok.isAtStartOfLine() && Loc.isValid())
+Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
+<< getLangOpts().CPlusPlus;
+  else
+Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
+ diag::err_expected_unqualified_id)
+<< getLangOpts().CPlusPlus;
+}
+  } else {
+Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
+ diag::err_expected_either)
+<< tok::identifier << tok::l_paren;
+  }
 }
 D.SetIdentifier(nullptr, Tok.getLocation());
 D.setInvalidType(true);
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -538,6 +538,8 @@
   "cannot use %select{dot|arrow}0 operator on a type">;
 def err_expected_unqualified_id : Error<
   "expected %select{identifier|unqualified-id}0">;
+def err_while_loop_outside_of_a_function : Error<
+  "while loop outside of a function">; 
 def err_brackets_go_after_unqualified_id : Error<
   "brackets are not allowed here; to declare an array, "
   "place the brackets after the %s

[clang] 3650615 - [clang] Remove unused forward declarations (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T20:51:06-07:00
New Revision: 3650615fb28aad3730c33cc26d23a6836743e305

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

LOG: [clang] Remove unused forward declarations (NFC)

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/include/clang/Lex/PreprocessingRecord.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/lib/CodeGen/SanitizerMetadata.h
clang/lib/Interpreter/IncrementalExecutor.h

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 774eac613a100..0781d476ec4a0 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -44,9 +44,7 @@ typedef SmallVector InputInfoList;
 
 class Command;
 class Compilation;
-class JobList;
 class JobAction;
-class SanitizerArgs;
 class ToolChain;
 
 /// Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.

diff  --git a/clang/include/clang/Lex/PreprocessingRecord.h 
b/clang/include/clang/Lex/PreprocessingRecord.h
index 063929dd8f963..c97ca8628e14b 100644
--- a/clang/include/clang/Lex/PreprocessingRecord.h
+++ b/clang/include/clang/Lex/PreprocessingRecord.h
@@ -49,7 +49,6 @@ void operator delete(void *ptr, clang::PreprocessingRecord 
&PR,
 
 namespace clang {
 
-class FileEntry;
 class IdentifierInfo;
 class MacroInfo;
 class SourceManager;

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 8fc24c7310358..79454b5addead 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -67,7 +67,6 @@ namespace clang {
 class CodeCompletionHandler;
 class CommentHandler;
 class DirectoryEntry;
-class DirectoryLookup;
 class EmptylineHandler;
 class ExternalPreprocessorSource;
 class FileEntry;

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
index 1092d1292255d..9927b63407938 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -55,8 +55,6 @@ template  struct ProgramStateTrait {
   }
 };
 
-class RangeSet;
-
 /// \class ProgramState
 /// ProgramState - This class encapsulates:
 ///

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index c9c21fcf230ef..2ae811ee33653 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -40,7 +40,6 @@ class LabelDecl;
 
 namespace ento {
 
-class BasicValueFactory;
 class CompoundValData;
 class LazyCompoundValData;
 class MemRegion;

diff  --git a/clang/lib/CodeGen/SanitizerMetadata.h 
b/clang/lib/CodeGen/SanitizerMetadata.h
index bcad32ce31df0..f5dd0e503cc00 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.h
+++ b/clang/lib/CodeGen/SanitizerMetadata.h
@@ -20,7 +20,6 @@
 namespace llvm {
 class GlobalVariable;
 class Instruction;
-class MDNode;
 } // namespace llvm
 
 namespace clang {

diff  --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index f11ec0aa9e758..5b0f982b62ddf 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -21,7 +21,6 @@
 
 namespace llvm {
 class Error;
-class Module;
 namespace orc {
 class LLJIT;
 class ThreadSafeContext;



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


[PATCH] D129311: [clang-format] Update return code

2022-07-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/tools/clang-format/git-clang-format:201
   if opts.diff:
-print_diff(old_tree, new_tree)
-  elif opts.diffstat:
-print_diffstat(old_tree, new_tree)
-  else:
-changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
-if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
-  print('changed files:')
-  for filename in changed_files:
-print('%s' % filename)
+return print_diff(old_tree, new_tree)
+  if opts.diffstat:

Actually, doesn't line 175 make sure it will return 0 if there is no diff? Can 
you open an issue at https://github.com/llvm/llvm-project/issues and give an 
example where this isn't true?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129311

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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-24 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3611
   HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only 
volatile vector registers.">;
+def maix_quadword_atomics : Flag<["-"], "maix64-quadword-atomics">,
+  Group, Flags<[CC1Option]>,

lkail wrote:
> shchenz wrote:
> > lkail wrote:
> > > shchenz wrote:
> > > > amyk wrote:
> > > > > Would it be better if we called this `maix64-quadword-atomics` 
> > > > > instead? 
> > > > Do we need to change the backend check below too?
> > > > ```
> > > > bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
> > > >   // TODO: 16-byte atomic type support for AIX is in progress; we 
> > > > should be able
> > > >   // to inline 16-byte atomic ops on AIX too in the future.
> > > >   return Subtarget.isPPC64() &&
> > > >  (EnableQuadwordAtomics || 
> > > > !Subtarget.getTargetTriple().isOSAIX()) &&
> > > >  Subtarget.hasQuadwordAtomics();
> > > > }
> > > > ```
> > > We don't need to change this yet. When we are compiling a quadword lock 
> > > free libatomic, we use options `-mabi=quadword-atomics -mllvm 
> > > -ppc-quadword-atomics` to enforce generating quadword lock-free code on 
> > > AIX.
> > This makes me confuse. We need to two different options to control the 
> > frontend and backend behavior?
> > 
> > Is it the final usage? Or we will add a follow up patch to map the backend 
> > one to the FE one? IMO finally we only need the driver option 
> > `-mabi=quadword-atomics` to control the final code generation for 128 bit 
> > atomic operations, right?
> > This makes me confuse. We need to two different options to control the 
> > frontend and backend behavior?
> 
> This is multi-lang support consideration. clang is not the only frontend we 
> have using LLVM as backend on AIX. If other language frontend generates 
> `store atomic i128, ...`, the backend is supposed to generate libcalls into 
> libatomic currently.
> 
> > Is it the final usage?
> No. We finally want to achieve `-mabi=quadword-atomics` by default and 
> generate inline atomic code for cpu above pwr7 by default(no need to take OS 
> into consideration).
I know what you mean. But I assume the driver option `-mabi=quadword-atomics` 
will impact the assembly instead of just impact the frontend, right? Using 
`-mllvm` option is not right as the final solution.

There are some driver options example, like `-gstrict-dwarf`, Frontend can 
control the backend behavior and the backend can also change this option by 
`-strict-dwarf`.

Could you please explain:
1: how the backend will handle `-mabi=quadword-atomics` in future?
2: on what condition, we can start to remove below TODOs:
```
bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
// TODO: 16-byte atomic type support for AIX is in progress;
}
```

```
PPC64TargetInfo::setMaxAtomicWidth() {
// TODO: We should allow AIX to inline quadword atomics in the future.
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-24 Thread Kai Luo via Phabricator via cfe-commits
lkail added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3611
   HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only 
volatile vector registers.">;
+def maix_quadword_atomics : Flag<["-"], "maix64-quadword-atomics">,
+  Group, Flags<[CC1Option]>,

shchenz wrote:
> lkail wrote:
> > shchenz wrote:
> > > lkail wrote:
> > > > shchenz wrote:
> > > > > amyk wrote:
> > > > > > Would it be better if we called this `maix64-quadword-atomics` 
> > > > > > instead? 
> > > > > Do we need to change the backend check below too?
> > > > > ```
> > > > > bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
> > > > >   // TODO: 16-byte atomic type support for AIX is in progress; we 
> > > > > should be able
> > > > >   // to inline 16-byte atomic ops on AIX too in the future.
> > > > >   return Subtarget.isPPC64() &&
> > > > >  (EnableQuadwordAtomics || 
> > > > > !Subtarget.getTargetTriple().isOSAIX()) &&
> > > > >  Subtarget.hasQuadwordAtomics();
> > > > > }
> > > > > ```
> > > > We don't need to change this yet. When we are compiling a quadword lock 
> > > > free libatomic, we use options `-mabi=quadword-atomics -mllvm 
> > > > -ppc-quadword-atomics` to enforce generating quadword lock-free code on 
> > > > AIX.
> > > This makes me confuse. We need to two different options to control the 
> > > frontend and backend behavior?
> > > 
> > > Is it the final usage? Or we will add a follow up patch to map the 
> > > backend one to the FE one? IMO finally we only need the driver option 
> > > `-mabi=quadword-atomics` to control the final code generation for 128 bit 
> > > atomic operations, right?
> > > This makes me confuse. We need to two different options to control the 
> > > frontend and backend behavior?
> > 
> > This is multi-lang support consideration. clang is not the only frontend we 
> > have using LLVM as backend on AIX. If other language frontend generates 
> > `store atomic i128, ...`, the backend is supposed to generate libcalls into 
> > libatomic currently.
> > 
> > > Is it the final usage?
> > No. We finally want to achieve `-mabi=quadword-atomics` by default and 
> > generate inline atomic code for cpu above pwr7 by default(no need to take 
> > OS into consideration).
> I know what you mean. But I assume the driver option `-mabi=quadword-atomics` 
> will impact the assembly instead of just impact the frontend, right? Using 
> `-mllvm` option is not right as the final solution.
> 
> There are some driver options example, like `-gstrict-dwarf`, Frontend can 
> control the backend behavior and the backend can also change this option by 
> `-strict-dwarf`.
> 
> Could you please explain:
> 1: how the backend will handle `-mabi=quadword-atomics` in future?
> 2: on what condition, we can start to remove below TODOs:
> ```
> bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
> // TODO: 16-byte atomic type support for AIX is in progress;
> }
> ```
> 
> ```
> PPC64TargetInfo::setMaxAtomicWidth() {
> // TODO: We should allow AIX to inline quadword atomics in the future.
> }
> ```
1, 2 can be answered together. After we ship new libatomic to users(I assume 
that that isn't in near future, since this requires AIX OS upgrade), we can 
enable quadword lock free atomics in both clang and llvm backend by default. 
Backend isn't aware of `-mabi=quadword-atomics`. This option changes layout of 
quadword atomic types(align to 16 byte), and generate atomic LLVM IR rather 
than generating libcalls in LLVM IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[clang] a210f40 - [clang] Remove redundant virtual specifies (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T22:02:58-07:00
New Revision: a210f404da04ff4db60cdf1a7f4060c82c59c360

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

LOG: [clang] Remove redundant virtual specifies (NFC)

Identified with modernize-use-override.

Added: 


Modified: 
clang/lib/Basic/Targets/CSKY.h
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp

clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/CSKY.h b/clang/lib/Basic/Targets/CSKY.h
index 7e932e7c86b1c..6edd035d9eb84 100644
--- a/clang/lib/Basic/Targets/CSKY.h
+++ b/clang/lib/Basic/Targets/CSKY.h
@@ -71,7 +71,7 @@ class LLVM_LIBRARY_VISIBILITY CSKYTargetInfo : public 
TargetInfo {
 
   bool isValidCPUName(StringRef Name) const override;
 
-  virtual unsigned getMinGlobalAlign(uint64_t) const override;
+  unsigned getMinGlobalAlign(uint64_t) const override;
 
   ArrayRef getTargetBuiltins() const override;
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index ef673ae41a3dc..5897e5096461a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -240,7 +240,7 @@ class StdLibraryFunctionsChecker
 ArgNo OtherArgN;
 
   public:
-virtual StringRef getName() const override { return "Comparison"; };
+StringRef getName() const override { return "Comparison"; };
 ComparisonConstraint(ArgNo ArgN, BinaryOperator::Opcode Opcode,
  ArgNo OtherArgN)
 : ValueConstraint(ArgN), Opcode(Opcode), OtherArgN(OtherArgN) {}

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index 38e69e81d8006..cd91fa9b090c3 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -57,19 +57,17 @@ class RegularField final : public FieldNode {
 public:
   RegularField(const FieldRegion *FR) : FieldNode(FR) {}
 
-  virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
+  void printNoteMsg(llvm::raw_ostream &Out) const override {
 Out << "uninitialized field ";
   }
 
-  virtual void printPrefix(llvm::raw_ostream &Out) const override {}
+  void printPrefix(llvm::raw_ostream &Out) const override {}
 
-  virtual void printNode(llvm::raw_ostream &Out) const override {
+  void printNode(llvm::raw_ostream &Out) const override {
 Out << getVariableName(getDecl());
   }
 
-  virtual void printSeparator(llvm::raw_ostream &Out) const override {
-Out << '.';
-  }
+  void printSeparator(llvm::raw_ostream &Out) const override { Out << '.'; }
 };
 
 /// Represents that the FieldNode that comes after this is declared in a base
@@ -85,20 +83,20 @@ class BaseClass final : public FieldNode {
 assert(T->getAsCXXRecordDecl());
   }
 
-  virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
+  void printNoteMsg(llvm::raw_ostream &Out) const override {
 llvm_unreachable("This node can never be the final node in the "
  "fieldchain!");
   }
 
-  virtual void printPrefix(llvm::raw_ostream &Out) const override {}
+  void printPrefix(llvm::raw_ostream &Out) const override {}
 
-  virtual void printNode(llvm::raw_ostream &Out) const override {
+  void printNode(llvm::raw_ostream &Out) const override {
 Out << BaseClassT->getAsCXXRecordDecl()->getName() << "::";
   }
 
-  virtual void printSeparator(llvm::raw_ostream &Out) const override {}
+  void printSeparator(llvm::raw_ostream &Out) const override {}
 
-  virtual bool isBase() const override { return true; }
+  bool isBase() const override { return true; }
 };
 
 } // end of anonymous namespace

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
index a6e81b3657a2a..f5bd765ff679e 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
@@ -34,20 +34,20 @@ class LocField final : public FieldNode {
   LocField(const FieldRegion *FR, const bool IsDereferenced = true)
   : FieldNode(FR), IsDereferenced(IsDereferenced) {}
 
-  virtual void printNoteMsg(llvm::raw_ostrea

[clang] 95a932f - Remove redundaunt override specifiers (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T22:28:11-07:00
New Revision: 95a932fb15960e66fdc43dc9821685addd5ee44d

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

LOG: Remove redundaunt override specifiers (NFC)

Identified with modernize-use-override.

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
clang/include/clang/Frontend/Utils.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h
clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
lld/MachO/SyntheticSections.h
llvm/include/llvm/Analysis/DDG.h
llvm/lib/Target/SystemZ/SystemZRegisterInfo.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
index def04c917bbc9..d00afecd495de 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -34,12 +34,11 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
   /// class will do the matching and call the derived class'
   /// getDeclFailureInfo() and getMacroFailureInfo() for determining whether a
   /// given identifier passes or fails the check.
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
-  void
-  check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) final;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
-   Preprocessor *ModuleExpanderPP) override final;
-  void onEndOfTranslationUnit() override final;
+   Preprocessor *ModuleExpanderPP) final;
+  void onEndOfTranslationUnit() final;
 
   /// Derived classes that override this function should call this method from
   /// the overridden method.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index b9998711f52e4..edbb1722ae38e 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -788,7 +788,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
 
   void ProcessCodeCompleteResults(class Sema &S, CodeCompletionContext Context,
   CodeCompletionResult *InResults,
-  unsigned NumResults) override final {
+  unsigned NumResults) final {
 // Results from recovery mode are generally useless, and the callback after
 // recovery (if any) is usually more interesting. To make sure we handle 
the
 // future callback from sema, we just ignore all callbacks in recovery 
mode,

diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
index 1383560ad4656..2a34e43f980ba 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
@@ -23,7 +23,7 @@ namespace {
 ///   void /* entity.name.function.cpp */ f() { int /* variable.cpp */ abc; }
 class AnnotateHighlightings : public Tweak {
 public:
-  const char *id() const override final;
+  const char *id() const final;
 
   bool prepare(const Selection &Inputs) override { return true; }
   Expected apply(const Selection &Inputs) override;

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
in

[clang-tools-extra] 95a932f - Remove redundaunt override specifiers (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T22:28:11-07:00
New Revision: 95a932fb15960e66fdc43dc9821685addd5ee44d

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

LOG: Remove redundaunt override specifiers (NFC)

Identified with modernize-use-override.

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
clang/include/clang/Frontend/Utils.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h
clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
lld/MachO/SyntheticSections.h
llvm/include/llvm/Analysis/DDG.h
llvm/lib/Target/SystemZ/SystemZRegisterInfo.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
index def04c917bbc9..d00afecd495de 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -34,12 +34,11 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
   /// class will do the matching and call the derived class'
   /// getDeclFailureInfo() and getMacroFailureInfo() for determining whether a
   /// given identifier passes or fails the check.
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
-  void
-  check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) final;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
-   Preprocessor *ModuleExpanderPP) override final;
-  void onEndOfTranslationUnit() override final;
+   Preprocessor *ModuleExpanderPP) final;
+  void onEndOfTranslationUnit() final;
 
   /// Derived classes that override this function should call this method from
   /// the overridden method.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index b9998711f52e4..edbb1722ae38e 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -788,7 +788,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
 
   void ProcessCodeCompleteResults(class Sema &S, CodeCompletionContext Context,
   CodeCompletionResult *InResults,
-  unsigned NumResults) override final {
+  unsigned NumResults) final {
 // Results from recovery mode are generally useless, and the callback after
 // recovery (if any) is usually more interesting. To make sure we handle 
the
 // future callback from sema, we just ignore all callbacks in recovery 
mode,

diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
index 1383560ad4656..2a34e43f980ba 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
@@ -23,7 +23,7 @@ namespace {
 ///   void /* entity.name.function.cpp */ f() { int /* variable.cpp */ abc; }
 class AnnotateHighlightings : public Tweak {
 public:
-  const char *id() const override final;
+  const char *id() const final;
 
   bool prepare(const Selection &Inputs) override { return true; }
   Expected apply(const Selection &Inputs) override;

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
in

[PATCH] D125693: [DebugInfo] Support types, imports and static locals declared in a lexical block (3/5)

2022-07-24 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added a comment.

In D125693#3653631 , @dblaikie wrote:

> In D125693#3648942 , @krisb wrote:
>
>> In D125693#3644029 , @dblaikie 
>> wrote:
>>
>>> In D125693#3641742 , @krisb wrote:
>>>
 @dblaikie, could you please take a look at this and/or D113741 
 ? Do you see any ways to proceed?
>>>
>>> My concern with this direction is that anything that adds lists to the IR 
>>> metadata makes it difficult for that data to be dropped when it becomes 
>>> unused (the type graph, apart from the "retained types" on the CU, is 
>>> structured so that if a variable, say, gets optimized away, or a function 
>>> gets optimized away and its parameters along with it, the types get dropped 
>>> too - similarly with function descriptions, they aren't in a list (they 
>>> used to be) and are instead referenced from the `llvm::Function` ensuring 
>>> that if the function is optimized away entirely, the debug info for that 
>>> goes away too). Admittedly function-local things are handled somewhat 
>>> differently, for instance there is a list on the `DISubprogram` of the 
>>> local variables to ensure they are retained through optimizations so name 
>>> lookup does the right things at function-scope. So /maybe/ it's OK to move 
>>> in that direction here, but it might look more like that, add these other 
>>> function-local things to the `DISubprogram`-scoped list (rename the list to 
>>> generalize over more than just variables), rather than adding per-scope 
>>> lists?
>>
>> Initially, I made the dedicated per-scope list of local static 
>> vars/imports/types to make possible to remove unused entities if their 
>> parent scope gets optimized out. This doesn't fully resolve your concern 
>> about local types that might be emitted even if they are not used, but this 
>> makes the things a bit better. Moreover, such local entities as well as 
>> variables/labels are not going to be emitted to a final DWARF if their scope 
>> was optimized away. Currently, to emit any local entity we need its scope to 
>> have LexicalScope defined. If there are no DILocations in such a scope (so 
>> that it may be considered as optimized out), it will not have LexicalScope 
>> defined for it, thus no variables/labels/other local things will be emitted 
>> for it. So, if we are not going to change this design in a near future, it 
>> might be worse to consider switching local variables/labels to per-scope 
>> list as well.
>>
>> What about merging variables/labels/other entities to a single list, I fully 
>> support this idea (it would require some additional checks in the backend, 
>> but would look more consistent).
>
> Ah, fair point about implicitly dropping some debug info if it's in a dead 
> scope. & yeah, maybe moving the existing optimized local variables list into 
> a per-scope list might be a nice improvement regardless.

Well, this isn't as good as I thought. We are skipping optimized scopes and 
entities belong to them iff the scope is concrete (either inline or 
out-of-line). But we never skip abstract scopes; instead we create 
LexicalScope's just before constructing an abstract tree (see 
`DwarfDebug::ensureAbstractEntityIsCreated()`) if there are some retained nodes 
in them (currently, local variables or labels).

I was a bit confused by assert in `DwarfDebug::endFunctionImpl()`:

  assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes
 && "ensureAbstractEntityIsCreated inserted abstract scopes");

It checks that `DwarfDebug::ensureAbstractEntityIsCreated()` doesn't create any 
scopes, but this check is for subprogram scopes only, it doesn't guard against 
creation of lexical block scope. And we do create LexicalScope's for 
DILexicalBlock if there is a retained node belong to it. I tried to restore the 
same behavior with per-scope retained nodes approach, but it significantly 
affects compile time (22.6% geomean on CTMark). 
So, I agree with your first suggestion to reuse retainedNodes field of 
DISuprogram to track other local entities. 
I'll update this patch soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125693

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


[PATCH] D128667: [WIP] Add Zstd ELF support

2022-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp:1015
+  } else {
+if (Config.DecompressDebugSections && !compression::zstd::isAvailable())
+  return createStringError(

For --decompress-debug-sections, the zstd error should be reported only when a 
compressed debug section using zstd is found. zlib is similar.

I cleaned up legacy zdebug code from llvm-objcopy, fixed an uninitialized 
ch_reserved bug. Created D130458 as an alternative patch.


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

https://reviews.llvm.org/D128667

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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-24 Thread ChenZheng via Phabricator via cfe-commits
shchenz accepted this revision as: shchenz.
shchenz added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D119792: [Clang] [P2025] Analyze only potential scopes for NRVO

2022-07-24 Thread Roman Rusyaev via Phabricator via cfe-commits
rusyaev-roman added a comment.

@ChuanqiXu  , could you take a look again? I've updated the original 
implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119792

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