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

2022-07-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin marked 3 inline comments as done.
cor3ntin added a comment.

@shafik I just realized i forgot to submit a bunch of replies i had to your 
comments, sorry about that


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] D130421: [Clang] De-deprecate volatile compound operations

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

@shafik Thanks for the review!




Comment at: clang/docs/ReleaseNotes.rst:523
   This feature is available as an extension in all C and C++ language modes.
+- Implemented `P2327 De-deprecating volatile compound operations 
`_
 

shafik wrote:
> `R3` did not work for me but `R1` did.
You are right it is R1 (I double checked on the straw polls page). Thanks for 
catching that!


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] D130421: [Clang] De-deprecate volatile compound operations

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

Fix paper number in release notes.


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 ,
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;
+  //   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, );
 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, );
 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);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy, Opc);
 break;
   case BO_AndAssign:
   case BO_OrAssign: // fallthrough
@@ -15011,7 +15025,8 @@
 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
 CompLHSTy = CompResultTy;

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

2022-07-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:752
 
+TEST_F(TokenAnnotatorTest, UnderstandsTrailingReturnTypeAutoInLabmdas) {
+  auto Tokens = annotate("[]() -> auto {}");

owenpan wrote:
> HazardyKnusperkeks wrote:
> > I'd just merge it with the test above.
> > I'd just merge it with the test above.
> 
> +1.



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-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added inline comments.



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

owenpan wrote:
> Should we add test cases with an `&` between `auto` and `{`?
:+1:


Repository:
  rG LLVM Github Monorepo

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] D130411: [clang-format] Fix a hang when formatting C# $@ string literals

2022-07-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added inline comments.



Comment at: clang/lib/Format/FormatTokenLexer.cpp:536
+  // $"{x ?? "null"}"
+  // should not be split into $"{x ?? ", null, "}" but should treated as a
+  // single string-literal.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130411

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


[PATCH] D101070: [llvm][cmake] Make `install_symlink` robust to absolute dirs.

2022-07-23 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 447108.
Ericson2314 added a comment.

Rebase to retrigger CI

I think it tried to cherry-pick an already-landed patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101070

Files:
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/LLVMInstallSymlink.cmake


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -2,21 +2,22 @@
 # DESTDIR environment variable may be unset at configuration time.
 # See PR8397.
 
-include(GNUInstallDirs)
+include(ExtendPath)
 
 function(install_symlink name target outdir)
   set(DESTDIR $ENV{DESTDIR})
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+  extend_path(outdir_abs "${CMAKE_INSTALL_PREFIX}" "${outdir}")
+  set(outdir_abs "${DESTDIR}${outdir_abs}")
 
   message(STATUS "Creating ${name}")
 
   execute_process(
 COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
-WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
+WORKING_DIRECTORY "${outdir_abs}" ERROR_VARIABLE has_err)
   if(CMAKE_HOST_WIN32 AND has_err)
 execute_process(
   COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
-  WORKING_DIRECTORY "${bindir}")
+  WORKING_DIRECTORY "${outdir_abs}")
   endif()
 
 endfunction()
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2006,7 +2006,7 @@
 
   set(output_dir lib${LLVM_LIBDIR_SUFFIX})
   if(WIN32 AND "${type}" STREQUAL "SHARED")
-set(output_dir bin)
+set(output_dir "${CMAKE_INSTALL_LIBDIR}")
   endif()
 
   install(SCRIPT ${INSTALL_SYMLINK}


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -2,21 +2,22 @@
 # DESTDIR environment variable may be unset at configuration time.
 # See PR8397.
 
-include(GNUInstallDirs)
+include(ExtendPath)
 
 function(install_symlink name target outdir)
   set(DESTDIR $ENV{DESTDIR})
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+  extend_path(outdir_abs "${CMAKE_INSTALL_PREFIX}" "${outdir}")
+  set(outdir_abs "${DESTDIR}${outdir_abs}")
 
   message(STATUS "Creating ${name}")
 
   execute_process(
 COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
-WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
+WORKING_DIRECTORY "${outdir_abs}" ERROR_VARIABLE has_err)
   if(CMAKE_HOST_WIN32 AND has_err)
 execute_process(
   COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
-  WORKING_DIRECTORY "${bindir}")
+  WORKING_DIRECTORY "${outdir_abs}")
   endif()
 
 endfunction()
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2006,7 +2006,7 @@
 
   set(output_dir lib${LLVM_LIBDIR_SUFFIX})
   if(WIN32 AND "${type}" STREQUAL "SHARED")
-set(output_dir bin)
+set(output_dir "${CMAKE_INSTALL_LIBDIR}")
   endif()
 
   install(SCRIPT ${INSTALL_SYMLINK}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101070: [llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs.

2022-07-23 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 447107.
Ericson2314 added a comment.

Rebase, hopefully fix, and also fix stray GNUInstallDirs violation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101070

Files:
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/LLVMInstallSymlink.cmake


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -2,21 +2,22 @@
 # DESTDIR environment variable may be unset at configuration time.
 # See PR8397.
 
-include(GNUInstallDirs)
+include(ExtendPath)
 
 function(install_symlink name target outdir)
   set(DESTDIR $ENV{DESTDIR})
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+  extend_path(outdir_abs "${CMAKE_INSTALL_PREFIX}" "${outdir}")
+  set(outdir_abs "${DESTDIR}${outdir_abs}")
 
   message(STATUS "Creating ${name}")
 
   execute_process(
 COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
-WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
+WORKING_DIRECTORY "${outdir_abs}" ERROR_VARIABLE has_err)
   if(CMAKE_HOST_WIN32 AND has_err)
 execute_process(
   COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
-  WORKING_DIRECTORY "${bindir}")
+  WORKING_DIRECTORY "${outdir_abs}")
   endif()
 
 endfunction()
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2006,7 +2006,7 @@
 
   set(output_dir lib${LLVM_LIBDIR_SUFFIX})
   if(WIN32 AND "${type}" STREQUAL "SHARED")
-set(output_dir bin)
+set(output_dir "${CMAKE_INSTALL_LIBDIR}")
   endif()
 
   install(SCRIPT ${INSTALL_SYMLINK}


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -2,21 +2,22 @@
 # DESTDIR environment variable may be unset at configuration time.
 # See PR8397.
 
-include(GNUInstallDirs)
+include(ExtendPath)
 
 function(install_symlink name target outdir)
   set(DESTDIR $ENV{DESTDIR})
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+  extend_path(outdir_abs "${CMAKE_INSTALL_PREFIX}" "${outdir}")
+  set(outdir_abs "${DESTDIR}${outdir_abs}")
 
   message(STATUS "Creating ${name}")
 
   execute_process(
 COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
-WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
+WORKING_DIRECTORY "${outdir_abs}" ERROR_VARIABLE has_err)
   if(CMAKE_HOST_WIN32 AND has_err)
 execute_process(
   COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
-  WORKING_DIRECTORY "${bindir}")
+  WORKING_DIRECTORY "${outdir_abs}")
   endif()
 
 endfunction()
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2006,7 +2006,7 @@
 
   set(output_dir lib${LLVM_LIBDIR_SUFFIX})
   if(WIN32 AND "${type}" STREQUAL "SHARED")
-set(output_dir bin)
+set(output_dir "${CMAKE_INSTALL_LIBDIR}")
   endif()
 
   install(SCRIPT ${INSTALL_SYMLINK}
___
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-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



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

Should we add test cases with an `&` between `auto` and `{`?


Repository:
  rG LLVM Github Monorepo

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-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:752
 
+TEST_F(TokenAnnotatorTest, UnderstandsTrailingReturnTypeAutoInLabmdas) {
+  auto Tokens = annotate("[]() -> auto {}");

HazardyKnusperkeks wrote:
> I'd just merge it with the test above.
> I'd just merge it with the test above.

+1.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:753-756
+  auto 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);

Should we add a test case with an `&` between `auto` and `{`?


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] D130421: [Clang] De-deprecate volatile compound operations

2022-07-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM but I will let Aaron accept it.




Comment at: clang/docs/ReleaseNotes.rst:523
   This feature is available as an extension in all C and C++ language modes.
+- Implemented `P2327 De-deprecating volatile compound operations 
`_
 

`R3` did not work for me but `R1` did.


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] D125272: [clang] Add -fcheck-new support

2022-07-23 Thread Pedro Falcato via Phabricator via cfe-commits
heatd added a comment.

In D125272#3531836 , @heatd wrote:

> In D125272#3515874 , @heatd wrote:
>
>> In D125272#3504113 , @heatd wrote:
>>
>>> Adjusted the driver code to use addOptInFlag, adjusted the test, fixed the 
>>> comment.
>>
>> Ping.
>
> Ping.

Could someone please review it or tell me what needs to be done before pushing 
this? Thanks.


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] D130422: [clang-repl] Fix incorrect return code

2022-07-23 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 447103.
junaire added a comment.

Use `not`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130422

Files:
  clang/test/Interpreter/fail.cpp
  clang/tools/clang-repl/ClangRepl.cpp


Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -50,7 +50,7 @@
 
 // If we are running with -verify a reported has to be returned as unsuccess.
 // This is relevant especially for the test suite.
-static int checkDiagErrors(const clang::CompilerInstance *CI) {
+static int checkDiagErrors(const clang::CompilerInstance *CI, bool HasError) {
   unsigned Errs = CI->getDiagnostics().getClient()->getNumErrors();
   if (CI->getDiagnosticOpts().VerifyDiagnostics) {
 // If there was an error that came from the verifier we must return 1 as
@@ -62,7 +62,7 @@
 // The interpreter expects BeginSourceFile/EndSourceFiles to be balanced.
 Client->BeginSourceFile(CI->getLangOpts(), >getPreprocessor());
   }
-  return Errs ? EXIT_FAILURE : EXIT_SUCCESS;
+  return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 llvm::ExitOnError ExitOnErr;
@@ -105,6 +105,8 @@
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   }
 
+  bool HasError = false;
+
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
@@ -112,13 +114,17 @@
   if (*Line == R"(%quit)")
 break;
   if (*Line == R"(%undo)") {
-if (auto Err = Interp->Undo())
+if (auto Err = Interp->Undo()) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
 continue;
   }
 
-  if (auto Err = Interp->ParseAndExecute(*Line))
+  if (auto Err = Interp->ParseAndExecute(*Line)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+HasError = true;
+  }
 }
   }
 
@@ -129,5 +135,5 @@
 
   llvm::llvm_shutdown();
 
-  return checkDiagErrors(Interp->getCompilerInstance());
+  return checkDiagErrors(Interp->getCompilerInstance(), HasError);
 }
Index: clang/test/Interpreter/fail.cpp
===
--- /dev/null
+++ clang/test/Interpreter/fail.cpp
@@ -0,0 +1,13 @@
+// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | not clang-repl | FileCheck %s
+BOOM!
+extern "C" int printf(const char *, ...);
+int i = 42;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 42
+%quit


Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -50,7 +50,7 @@
 
 // If we are running with -verify a reported has to be returned as unsuccess.
 // This is relevant especially for the test suite.
-static int checkDiagErrors(const clang::CompilerInstance *CI) {
+static int checkDiagErrors(const clang::CompilerInstance *CI, bool HasError) {
   unsigned Errs = CI->getDiagnostics().getClient()->getNumErrors();
   if (CI->getDiagnosticOpts().VerifyDiagnostics) {
 // If there was an error that came from the verifier we must return 1 as
@@ -62,7 +62,7 @@
 // The interpreter expects BeginSourceFile/EndSourceFiles to be balanced.
 Client->BeginSourceFile(CI->getLangOpts(), >getPreprocessor());
   }
-  return Errs ? EXIT_FAILURE : EXIT_SUCCESS;
+  return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 llvm::ExitOnError ExitOnErr;
@@ -105,6 +105,8 @@
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   }
 
+  bool HasError = false;
+
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
@@ -112,13 +114,17 @@
   if (*Line == R"(%quit)")
 break;
   if (*Line == R"(%undo)") {
-if (auto Err = Interp->Undo())
+if (auto Err = Interp->Undo()) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
 continue;
   }
 
-  if (auto Err = Interp->ParseAndExecute(*Line))
+  if (auto Err = Interp->ParseAndExecute(*Line)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+HasError = true;
+  }
 }
   }
 
@@ -129,5 +135,5 @@
 
   llvm::llvm_shutdown();
 
-  return checkDiagErrors(Interp->getCompilerInstance());
+  return checkDiagErrors(Interp->getCompilerInstance(), HasError);
 }
Index: 

[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-23 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 447102.
pscoro added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:not r4, r4
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:not r3, r3
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -10695,6 +10695,67 @@
Op.getOperand(0)),
 0);
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+// If SafeStack or !StackProtector, kill_canary is not supported.
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0));
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+// The new stored canary word should never be the same as the canary word
+// before corruption, so we XOR the canary word with all 1 bits.
+const uint64_t XORWord = 0x;
+
+// Linux uses LOAD_STACK_GUARD node instead of a canary global value.
+if (useLoadStackGuardNode()) {
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  // Frame index used to determine stack guard location if
+  // LOAD_STACK_GUARD is used.
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex();
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  Store = DAG.getStore(
+  Op->getOperand(0), DL,
+  DAG.getNode(ISD::XOR, DL, VT, Load, DAG.getConstant(XORWord, DL, VT)),
+  DAG.getNode(ISD::ADD, DL, VT, FIN, DAG.getConstant(SPI, DL, VT)),
+  

[clang] 944cb96 - clang/include/clang/module.modulemap: Mark `Tooling/Inclusions/*.inc` as textual.

2022-07-23 Thread NAKAMURA Takumi via cfe-commits

Author: NAKAMURA Takumi
Date: 2022-07-24T09:32:34+09:00
New Revision: 944cb96429b874e5bf9c672e0013914573227fcd

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

LOG: clang/include/clang/module.modulemap: Mark `Tooling/Inclusions/*.inc` as 
textual.

Fixes llvmorg-15-init-917-g46a6f5ae148a

Added: 


Modified: 
clang/include/clang/module.modulemap

Removed: 




diff  --git a/clang/include/clang/module.modulemap 
b/clang/include/clang/module.modulemap
index 56c40ab0b001d..01bce77718b35 100644
--- a/clang/include/clang/module.modulemap
+++ b/clang/include/clang/module.modulemap
@@ -189,5 +189,8 @@ module Clang_ToolingCore {
 
 module Clang_ToolingInclusions {
   requires cplusplus
-  umbrella "Tooling/Inclusions" module * { export * }
+  umbrella "Tooling/Inclusions"
+  textual header "Tooling/Inclusions/CSymbolMap.inc"
+  textual header "Tooling/Inclusions/StdSymbolMap.inc"
+  module * { export * }
 }



___
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-23 Thread Augusto Noronha via Phabricator via cfe-commits
augusto2112 added a comment.

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


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] D129881: [C] Strengthen -Wint-conversion to default to an error

2022-07-23 Thread Augusto Noronha via Phabricator via cfe-commits
augusto2112 added a comment.

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?


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] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-23 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:17875
+return true;
+  if (!Context.hasSameType(M1->getParamDecl(0)->getType(),
+   M2->getParamDecl(0)->getType()))

shafik wrote:
> What happens if we have further parameters with default arguments? Unless I 
> am missing something they are still special member functions but the proposal 
> does not seem to cover them.
That's an excellent question.

I'm not sure what to do about default arguments. In a context where the 
additional parameters matter, you're not using them as constructors anymore, 
right? So why would this affect the type traits?
On the one hand [over.match.best] is against this idea of comparing constraints 
when the parameters differ. So also every context where this actually matters 
the overload resolution would probably be ambiguous anyway?

@BRevzin, what do you think? Is the wording intentional to include copy/move 
constructors with default arguments as well?

I checked with GCC and they seem to handle default arguments separately: 
https://godbolt.org/z/1ch3M7MjP



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128619

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


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

2022-07-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/CodeGen/ModuleBuilder.cpp:179
+bool
+HandleTopLevelStmts(const llvm::SmallVectorImpl ) override {
+  if (Diags.hasErrorOccurred())

Hi @rjmccall, this patch tries to add support for statements on the global 
scope. Essentially we'd like to support something like:

```

int i = 0;
for (; i < 10; i++) {
  ...
}

namespace N {...}

i++;
```

This patch sends statements between two top-level declarations in blocks to 
CodeGen. I doubt we'd like to dissect CodeGen too much to expose API which can 
take a statement and put it in the `__cxx_global_var_init`.

The only way I see to minimize the changes to clang is to wrap these statements 
into a `FunctionDecl` and/or the expression statements into a `VarDecl` 
initializer and then use CodeGen to emit the relevant code. My hesitation is 
that if we form the `FunctionDecl` without entering function scope in the 
frontend, would there be a clean way to instruct CodeGen to run this function 
as part of the initializer lists.


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

https://reviews.llvm.org/D127284

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


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

2022-07-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 447098.
v.g.vassilev added a comment.

Keep the patch minimal, exclude opencl, etc for now.


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/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,20 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+
+int i = 12;
+++i;
+extern "C" int printf(const char*,...);
+printf("i = %d\n", i);
+// CHECK: i = 13
+
+namespace Ns { int f(){ return i++; } }
+Ns::f();
+
+int g() { return ++i; }
+g();
+
+printf("i = %d\n", i);
+// CHECK: i = 15
+
+%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 ,
-Sema::ModuleImportState ) {
+Sema::ModuleImportState ,
+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 ,
-   Sema::ModuleImportState ) {
+   Sema::ModuleImportState ,
+   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(/*IsParsingDecl=*/false)) {
+// 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/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -46,7 +46,8 @@
 ///   'using' 'namespace' '::'[opt] nested-name-specifier[opt]
 /// namespace-name ';'
 ///
-bool Parser::isCXXDeclarationStatement() {
+bool Parser::isCXXDeclarationStatement(
+bool DisambiguatingWithExpression /*=false*/) {
   switch (Tok.getKind()) {
 // asm-definition
   case tok::kw_asm:
@@ -59,7 +60,20 @@
   case tok::kw_static_assert:
   case tok::kw__Static_assert:
 return true;
+
+  case 

[PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D129377#3673237 , @mib wrote:

> In D129377#3673204 , @mstorsjo 
> wrote:
>
>> This broke building of Clang, when it's set up by symlinking 
>> `llvm-project/clang` into `llvm-project/llvm/tools`. In that case, cmake 
>> configure errors out like this:
>>
>>   -- Configuring done 
>>   CMake Error in tools/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt:
>> Target "clangHandleCXX" INTERFACE_INCLUDE_DIRECTORIES property contains
>> path:
>>
>>   
>> "/home/martin/code/llvm-project/llvm/tools/clang/tools/clang-fuzzer/handle-cxx/."
>>  
>>   
>> which is prefixed in the source directory.
>>
>> See e.g. 
>> https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
>>  for some discussion on the issue.
>>
>> Can we revert this commit until this has been sorted out?
>
> @mstorsjo I reverted Chelsea's patch in b797834748f1 
> , since 
> she's offline now. Do you have a link to a bot failure that would help us 
> investigate the issue ?

So in short, I think this would work if you'd simply remove the newly added 
`target_include_directories(clangHandleCXX PUBLIC .)` in 
`clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt` and 
`target_include_directories(clangProtoToCXX PUBLIC .)` and 
`target_include_directories(clangLoopProtoToCXX PUBLIC .)` in 
`clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt`.

To reproduce the issue - instead of configuring llvm+clang+lldb by passing 
`-DLLVM_ENABLE_PROJECTS="clang;lldb"` make symlinks in 
`llvm-project/llvm/tools` pointing to `llvm-project/clang` and 
`llvm-project/lldb`. (I.e., `cd llvm-project/llvm/tools; ln -s ../../clang .; 
ln -s ../../lldb .`) This slightly affects the effective path at where CMake 
sees the clang files, which causes CMake to report the unexpected path overlap 
issue here.

I've tried to build all these fuzzers - I haven't really managed to build it 
all, but I think I'm fairly close. Anyway, I tried removing those 
`target_include_directories()` in that setup, and it didn't change anything, 
but maybe it only makes a difference if one gets further than what I got. 
(Changing `PUBLIC` into `PRIVATE` in those lines avoided the issue too.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

___
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-23 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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-23 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

Thanks for the changes.




Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:752
 
+TEST_F(TokenAnnotatorTest, UnderstandsTrailingReturnTypeAutoInLabmdas) {
+  auto Tokens = annotate("[]() -> auto {}");

I'd just merge it with the test above.


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


[clang-tools-extra] c730f9a - Convert for_each to range-based for loops (NFC)

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

Author: Kazu Hirata
Date: 2022-07-23T12:17:27-07:00
New Revision: c730f9a164eacc30fdd0f6ae202211ef8a63b64a

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

LOG: Convert for_each to range-based for loops (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
lld/COFF/DebugTypes.cpp
lld/COFF/PDB.cpp
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 46d884578d462..83df990d35cd9 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -768,9 +768,8 @@ llvm::Expected rename(const RenameInputs 
) {
   RenameResult Result;
   Result.Target = CurrentIdentifier;
   Edit MainFileEdits = Edit(MainFileCode, std::move(*MainFileRenameEdit));
-  llvm::for_each(MainFileEdits.asTextEdits(), [](const TextEdit ) {
+  for (const TextEdit  : MainFileEdits.asTextEdits())
 Result.LocalChanges.push_back(TE.range);
-  });
 
   // return the main file edit if this is a within-file rename or the symbol
   // being renamed is function local.

diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 5878386aeb934..800b40f343aa9 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -1126,9 +1126,8 @@ void TypeMerger::mergeTypesWithGHash() {
   }
 
   // In parallel, remap all types.
-  for_each(dependencySources, [&](TpiSource *source) {
+  for (TpiSource *source : dependencySources)
 source->remapTpiWithGHashes();
-  });
   parallelForEach(objectSources, [&](TpiSource *source) {
 source->remapTpiWithGHashes();
   });

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 2ceb4fb98031c..87b6bb55d6101 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -296,14 +296,14 @@ static void addGHashTypeInfo(COFFLinkerContext ,
   // Start the TPI or IPI stream header.
   builder.getTpiBuilder().setVersionHeader(pdb::PdbTpiV80);
   builder.getIpiBuilder().setVersionHeader(pdb::PdbTpiV80);
-  for_each(ctx.tpiSourceList, [&](TpiSource *source) {
+  for (TpiSource *source : ctx.tpiSourceList) {
 builder.getTpiBuilder().addTypeRecords(source->mergedTpi.recs,
source->mergedTpi.recSizes,
source->mergedTpi.recHashes);
 builder.getIpiBuilder().addTypeRecords(source->mergedIpi.recs,
source->mergedIpi.recSizes,
source->mergedIpi.recHashes);
-  });
+  }
 }
 
 static void
@@ -1134,7 +1134,8 @@ void PDBLinker::addObjectsToPDB() {
   ScopedTimer t1(ctx.addObjectsTimer);
 
   // Create module descriptors
-  for_each(ctx.objFileInstances, [&](ObjFile *obj) { createModuleDBI(obj); });
+  for (ObjFile *obj : ctx.objFileInstances)
+createModuleDBI(obj);
 
   // Reorder dependency type sources to come first.
   tMerger.sortDependencies();
@@ -1144,9 +1145,10 @@ void PDBLinker::addObjectsToPDB() {
 tMerger.mergeTypesWithGHash();
 
   // Merge dependencies and then regular objects.
-  for_each(tMerger.dependencySources,
-   [&](TpiSource *source) { addDebug(source); });
-  for_each(tMerger.objectSources, [&](TpiSource *source) { addDebug(source); 
});
+  for (TpiSource *source : tMerger.dependencySources)
+addDebug(source);
+  for (TpiSource *source : tMerger.objectSources)
+addDebug(source);
 
   builder.getStringTableBuilder().setStrings(pdbStrTab);
   t1.stop();
@@ -1163,10 +1165,10 @@ void PDBLinker::addObjectsToPDB() {
   t2.stop();
 
   if (config->showSummary) {
-for_each(ctx.tpiSourceList, [&](TpiSource *source) {
+for (TpiSource *source : ctx.tpiSourceList) {
   nbTypeRecords += source->nbTypeRecords;
   nbTypeRecordsBytes += source->nbTypeRecordsBytes;
-});
+}
   }
 }
 

diff  --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp 
b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
index cf4f96dbcf6a6..6bcceb6ed08a5 100644
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -880,9 +880,8 @@ struct UnrollTransferReadConversion
   void getInsertionIndices(TransferReadOp xferOp,
SmallVector ) const {
 if (auto insertOp = getInsertOp(xferOp)) {
-  llvm::for_each(insertOp.getPosition(), [&](Attribute attr) {
+  for (Attribute attr : insertOp.getPosition())
 indices.push_back(attr.dyn_cast().getInt());
-  });
 }
   }
 
@@ -1008,9 +1007,8 @@ struct 

[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-07-23 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 447094.
iains added a comment.

rebase, update testcases for upstream changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/AST/ast-dump-decl.c
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/CXX/class/class.friend/p7-cxx20.cpp
  clang/test/CXX/class/class.mfct/p1-cxx20.cpp
  clang/test/CXX/module/module.global.frag/cxx20-10-4-ex2.cpp
  clang/test/CXX/module/module.global.frag/p3-p4.cpp
  clang/test/Modules/cxx-templates.cpp

Index: clang/test/Modules/cxx-templates.cpp
===
--- clang/test/Modules/cxx-templates.cpp
+++ clang/test/Modules/cxx-templates.cpp
@@ -252,7 +252,7 @@
 // CHECK-DUMP:  ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}>  col:{{.*}} in cxx_templates_common SomeTemplate
 // CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate
 // CHECK-DUMP-NEXT: TemplateArgument type 'char[2]'
-// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition
+// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTemplate Visible definition
 // CHECK-DUMP-NEXT: DefinitionData
 // CHECK-DUMP-NEXT:   DefaultConstructor
 // CHECK-DUMP-NEXT:   CopyConstructor
@@ -263,7 +263,7 @@
 // CHECK-DUMP-NEXT: TemplateArgument type 'char[2]'
 // CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate
 // CHECK-DUMP-NEXT: TemplateArgument type 'char[1]'
-// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition
+// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTemplate Visible definition
 // CHECK-DUMP-NEXT: DefinitionData
 // CHECK-DUMP-NEXT:   DefaultConstructor
 // CHECK-DUMP-NEXT:   CopyConstructor
Index: clang/test/CXX/module/module.global.frag/p3-p4.cpp
===
--- /dev/null
+++ clang/test/CXX/module/module.global.frag/p3-p4.cpp
@@ -0,0 +1,54 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 M.cpp -emit-module-interface -o M.pcm
+// RUN: %clang_cc1 -std=c++20 M.cpp -ast-dump | FileCheck --match-full-lines %s
+// RUN: %clang_cc1 -std=c++20 M-impl.cpp -fmodule-file=M.pcm -fsyntax-only -verify
+
+//--- p3-p4.h
+int f();
+int g();
+int h();
+int j();
+typedef int GMFInt;
+
+//--- M.cpp
+module;
+#include "p3-p4.h"
+
+export module M;
+
+export int use_f() { return f(); }
+
+export using ::h;
+
+namespace N {
+export using ::j;
+}
+
+GMFInt k(int);
+
+// CHECK: |-FunctionDecl {{.*}} <./p3-p4.h:1:1, col:7> col:5 in M. hidden used f 'int ()' ReachableWhenImported
+// CHECK: |-FunctionDecl {{.*}}  col:5 in M. hidden g 'int ()' ModuleDiscardable
+// CHECK: |-FunctionDecl {{.*}}  col:5 in M. hidden h 'int ()' ReachableWhenImported
+// CHECK: |-FunctionDecl {{.*}}  col:5 in M. hidden j 'int ()' ReachableWhenImported
+// CHECK: |-TypedefDecl {{.*}}  col:13 in M. hidden referenced GMFInt 'int' ReachableWhenImported
+
+// CHECK: |-ExportDecl {{.*}}  col:1 in M
+// CHECK-NEXT: | `-FunctionDecl {{.*}}  col:12 in M hidden use_f 'int ()' VisibleWhenImported
+
+// CHECK: |-ExportDecl {{.*}}  col:1 in M
+// CHECK-NEXT: | |-UsingDecl {{.*}}  col:16 in M hidden ::h VisibleWhenImported
+// CHECK-NEXT: | `-UsingShadowDecl {{.*}}  col:16 in M hidden implicit Function {{.*}} 'h' 'int ()' VisibleWhenImported
+
+// CHECK: |-NamespaceDecl {{.*}}  line:10:11 in M hidden N
+// CHECK-NEXT: | `-ExportDecl {{.*}}  col:1 in M
+// CHECK-NEXT: |   |-UsingDecl {{.*}}  col:16 in M hidden ::j VisibleWhenImported
+// CHECK-NEXT: |   `-UsingShadowDecl {{.*}}  col:16 in M hidden implicit Function {{.*}} 'j' 'int ()' VisibleWhenImported
+
+//--- M-impl.cpp
+import M;
+int a = j();// expected-error {{missing '#include'; 'j' must be declared before it is used}}
+// expected-note@p3-p4.h:4 {{declaration here is not visible}}
+int b = N::j(); // should be OK, UsingShadowDecl is visible
Index: clang/test/CXX/module/module.global.frag/cxx20-10-4-ex2.cpp
===
--- /dev/null
+++ clang/test/CXX/module/module.global.frag/cxx20-10-4-ex2.cpp
@@ -0,0 +1,60 @@
+// RUN: rm -rf %t
+// RUN: split-file %s 

[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

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



Comment at: clang/lib/Basic/Targets/LoongArch.h:24
+
+class LoongArchTargetInfo : public TargetInfo {
+protected:

LLVM_LIBRARY_VISIBILITY



Comment at: clang/lib/Basic/Targets/LoongArch.h:35
+SuitableAlign = 128;
+WIntType = UnsignedInt;
+  }

Define `WCharType`



Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.h:15
+#include "llvm/Option/Option.h"
+#include 
+#include 

Delete unused ` `



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:305
 return "cskyelf_linux";
+  case llvm::Triple::loongarch32:
+return "elf32loongarch";

Can be added before mips. Seems that some cases are unsorted. Just ignore them.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2226
 
+  static const char *const LoongArch64LibDirs[] = {"/lib64", "/lib"};
+  static const char *const LoongArch64Triples[] = {

I don't know which of /lib64, /lib has been used. For purity, I'd hope that we 
just have /lib, no multilib style /lib64



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2478
+  // TODO: Handle loongarch32.
+  case llvm::Triple::loongarch64:
+LibDirs.append(begin(LoongArch64LibDirs), end(LoongArch64LibDirs));

Just add loongarch32 in this patch. It is trivial



Comment at: clang/test/Driver/loongarch64-toolchain.c:20
+// C-LA64-LINUX-MULTI-LP64D: "-dynamic-linker" 
"/lib64/ld-linux-loongarch-lp64d.so.1"
+// C-LA64-LINUX-MULTI-LP64D: 
"{{.*}}/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/crtbegin.o"
+// C-LA64-LINUX-MULTI-LP64D: 
"-L{{.*}}/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0"

Not using NEXT is somewhat brittle.

Perhaps add `loongarch-toolchain.c` instead. `riscv*-toolchain.c` are not good 
examples to follow. You may check out linux-cross.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

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


[PATCH] D130308: [clang] extend getCommonSugaredType to merge sugar nodes

2022-07-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447091.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130308

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugar-common-types.cpp

Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix -triple i686-pc-win32
 
 enum class N {};
 
@@ -38,3 +38,77 @@
 N t7 = X4() + Y4(); // expected-error {{rvalue of type 'B4'}}
 N t8 = X4() * Y4(); // expected-error {{rvalue of type 'B4'}}
 N t9 = X5() * Y5(); // expected-error {{rvalue of type 'A4 __attribute__((matrix_type(3, 3)))'}}
+
+template  struct S1 {
+  template  struct S2 {};
+};
+
+N t10 = 0 ? S1() : S1(); // expected-error {{from 'S1' (aka 'S1')}}
+N t11 = 0 ? S1::S2() : S1::S2(); // expected-error {{from 'S1::S2' (aka 'S2')}}
+
+template  using Al = S1;
+
+N t12 = 0 ? Al() : Al(); // expected-error {{from 'Al' (aka 'S1')}}
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(1)))
+using AS1X1 = AS1 B1;
+using AS1Y1 = AS1 B1;
+using AS2Y1 = AS2 B1;
+N t13 = 0 ? (AS1X1){} : (AS1Y1){}; // expected-error {{rvalue of type 'AS1 B1' (aka '__attribute__((address_space(1))) int')}}
+N t14 = 0 ? (AS1X1){} : (AS2Y1){}; // expected-error {{rvalue of type '__attribute__((address_space(1))) B1' (aka '__attribute__((address_space(1))) int')}}
+
+using FX1 = X1 ();
+using FY1 = Y1 ();
+N t15 = 0 ? (FX1*){} : (FY1*){}; // expected-error {{rvalue of type 'B1 (*)()' (aka 'int (*)()')}}
+
+struct SS1 {};
+using SB1 = SS1;
+using SX1 = SB1;
+using SY1 = SB1;
+
+using MFX1 = X1 SX1::*();
+using MFY1 = Y1 SY1::*();
+
+N t16 = 0 ? (MFX1*){} : (MFY1*){}; // expected-error {{rvalue of type 'B1 SB1::*(*)()'}}
+
+N t17 = 0 ? (FX1 SX1::*){} : (FY1 SY1::*){}; // expected-error {{rvalue of type 'B1 (SB1::*)() __attribute__((thiscall))'}}
+
+N t18 = 0 ? (__typeof(X1*)){} : (__typeof(Y1*)){}; // expected-error {{rvalue of type 'typeof(B1 *)' (aka 'int *')}}
+
+struct Enums {
+  enum X : B1;
+  enum Y : ::B1;
+};
+using EnumsB = Enums;
+using EnumsX = EnumsB;
+using EnumsY = EnumsB;
+
+N t19 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::Y)){};
+// expected-error@-1 {{rvalue of type 'B1' (aka 'int')}}
+
+N t20 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::X)){};
+// expected-error@-1 {{rvalue of type '__underlying_type(Enums::X)' (aka 'int')}}
+
+using SBTF1 = SS1 [[clang::btf_type_tag("1")]];
+using SBTF2 = ::SS1 [[clang::btf_type_tag("1")]];
+using SBTF3 = ::SS1 [[clang::btf_type_tag("2")]];
+
+N t21 = 0 ? (SBTF1){} : (SBTF3){}; // expected-error {{from 'SS1'}}
+N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 btf_type_tag(1)' (aka 'SS1')}}
+
+using QX = const SB1 *;
+using QY = const ::SB1 *;
+N t23 = 0 ? (QX){} : (QY){}; // expected-error {{rvalue of type 'const SB1 *' (aka 'const SS1 *')}}
+
+template  using Alias = short;
+N t24 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'Alias' (aka 'short')}}
+N t25 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'short'}}
+
+template  concept C1 = true;
+template  concept C2 = true;
+C1 auto t26_1 = (SB1){};
+C1 auto t26_2 = (::SB1){};
+C2 auto t26_3 = (::SB1){};
+N t26 = 0 ? t26_1 : t26_2; // expected-error {{from 'SB1' (aka 'SS1')}}
+N t27 = 0 ? t26_1 : t26_3; // expected-error {{from 'SB1' (aka 'SS1')}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3776,13 +3776,11 @@
 //   - If A is an array type, the pointer type produced by the
 // array-to-pointer standard conversion (4.2) is used in place of
 // A for type deduction; otherwise,
-if (ArgType->isArrayType())
-  ArgType = S.Context.getArrayDecayedType(ArgType);
 //   - If A is a function type, the pointer type produced by the
 // function-to-pointer standard conversion (4.3) is used in place
 // of A for type deduction; otherwise,
-else if (ArgType->isFunctionType())
-  ArgType = S.Context.getPointerType(ArgType);
+if (ArgType->canDecayToPointerType())
+  ArgType = S.Context.getDecayedType(ArgType);
 else {
   // - If A is a cv-qualified type, the top level cv-qualifiers of A's
   //   type are ignored for type deduction.
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3329,6 

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

2022-07-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:5247-5248
+  // ObjC
+  case tok::at:
+return getLangOpts().ObjC;
+

rsmith wrote:
> In Objective-C, both declarations and expressions can start with `@`. In 
> general we'd need to look at the next token to see what we have. But I'm not 
> sure if there are any ObjC decl specifiers that use `@`-prefixed keywords.
Ok, let's worry about Objective-C after this patch.


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

https://reviews.llvm.org/D127284

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


[PATCH] D130422: [clang-repl] Fix incorrect return code

2022-07-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/test/Interpreter/fail.cpp:6
+// UNSUPPORTED: system-aix
+// XFAIL: *
+// CHECK-DRIVER: i = 10

Why this is marked as XFAIL? If it is only for the return code we can add the 
`not` command in front to make the error code succeed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130422

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


[PATCH] D130420: [CodeGen] Consider MangleCtx when move lazy emission States

2022-07-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added reviewers: rsmith, rjmccall.
v.g.vassilev added a comment.

Let's add more reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130420

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D111509#3168178 , @shafik wrote:

> Changing how types are printed can effect LLDB expression parsing tests. I 
> ran the LLDB test suite with this change:
>
>   ninja check-lldb
>
> and it changes to the results for `TestScalarURem.py` which can be run using:
>
>   llvm-lit -sv lldb/test --filter TestScalarURem.py
>
> The change looks expected.

Fixed now, thanks. (And also 
API/commands/expression/rdar44436068/Test128BitsInteger.py).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447087.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME
  lldb/test/API/commands/expression/rdar42038760/main.c
  lldb/test/API/commands/expression/rdar44436068/main.c

Index: lldb/test/API/commands/expression/rdar44436068/main.c
===
--- lldb/test/API/commands/expression/rdar44436068/main.c
+++ lldb/test/API/commands/expression/rdar44436068/main.c
@@ -3,6 +3,6 @@
 __int128_t n = 1;
 n = n + n;
 return n; //%self.expect("p n", substrs=['(__int128_t) $0 = 2'])
-  //%self.expect("p n + 6", substrs=['(__int128) $1 = 8'])
-  //%self.expect("p n + n", substrs=['(__int128) $2 = 4'])
+  //%self.expect("p n + 6", substrs=['(__int128_t) $1 = 8'])
+  //%self.expect("p n + n", substrs=['(__int128_t) $2 = 4'])
 }
Index: lldb/test/API/commands/expression/rdar42038760/main.c
===
--- lldb/test/API/commands/expression/rdar42038760/main.c
+++ lldb/test/API/commands/expression/rdar42038760/main.c
@@ -10,7 +10,7 @@
   struct S0 l_19;
   l_19.f2 = 419;
   uint32_t l_4037 = 4294967295UL;
-  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
+  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(uint32_t) $0 = 358717883'])
 }
 int main()
 {
Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D111283
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp

[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447086.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/SemaCXX/deduced-return-void.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++20 -fms-extensions -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec -Wno-c++17-compat-mangling
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++14 -fms-extensions -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec -Wno-c++17-compat-mangling
+
+namespace std {
+template struct initializer_list {
+  const T *begin, *end;
+  initializer_list();
+};
+} // namespace std
 
 enum class N {};
 
@@ -9,6 +17,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -25,6 +53,9 @@
 N t4 = x4; // expected-error {{lvalue of type 'Man' (aka 'int')}}
 N t5 = x5; // expected-error {{lvalue of type 'Dog' (aka 'int')}}
 
+auto x6 = { Man(), Dog() };
+N t6 = x6; // expected-error {{from 'std::initializer_list' (aka 'initializer_list')}}
+
 } // namespace variable
 
 namespace function_basic {
@@ -41,3 +72,160 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  static_assert(__is_same(A, B), ""); \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  static_assert(__is_same(A, B), ""); \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // 

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 447085.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/QualTypeNames.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/ast-dump-using-template.cpp
  clang/test/AST/ast-dump-using.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
  clang/test/Analysis/lambdas.cpp
  

[PATCH] D130362: Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR`

2022-07-23 Thread John Ericson 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 rG32560211c620: Fix one stray `{LLVM - 
CLANG}_TOOLS_INSTALL_DIR` (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130362

Files:
  clang/utils/hmaptool/CMakeLists.txt


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -1,4 +1,4 @@
-install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT 
hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${CLANG_TOOLS_INSTALL_DIR}" COMPONENT 
hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -1,4 +1,4 @@
-install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${CLANG_TOOLS_INSTALL_DIR}" COMPONENT hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3256021 - Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR`

2022-07-23 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2022-07-23T16:26:32Z
New Revision: 32560211c6206a7c63224a52200f41d17652fb0d

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

LOG: Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR`

Follow up to D117977, where I missed this new usage after one rebase.

Thanks @tsteller in https://reviews.llvm.org/D117977#3670919 for
noticing.

Reviewed By: mstorsjo

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

Added: 


Modified: 
clang/utils/hmaptool/CMakeLists.txt

Removed: 




diff  --git a/clang/utils/hmaptool/CMakeLists.txt 
b/clang/utils/hmaptool/CMakeLists.txt
index 72915ec665044..511268069bd1c 100644
--- a/clang/utils/hmaptool/CMakeLists.txt
+++ b/clang/utils/hmaptool/CMakeLists.txt
@@ -1,4 +1,4 @@
-install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT 
hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${CLANG_TOOLS_INSTALL_DIR}" COMPONENT 
hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 



___
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-23 Thread Igor Zhukov via Phabricator via cfe-commits
fsb4000 added a comment.

Good. Thanks!


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


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

2022-07-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D130419#3673877 , @fsb4000 wrote:

> Why did x64 debian tests fail?

openmp build is broken on linux pre-commit CI right now. Not related to your 
patch.


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


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

2022-07-23 Thread Igor Zhukov via Phabricator via cfe-commits
fsb4000 added a comment.

Why did x64 debian tests fail?


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


[PATCH] D130423: [clang][dataflow] Rename iterators from IT to It

2022-07-23 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 447067.
gribozavr added a comment.

Reverted an unintended edit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130423

Files:
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -47,9 +47,9 @@
   : CFCtx(CFCtx), BlockToState(BlockToState) {}
 
   const Environment *getEnvironment(const Stmt ) const override {
-auto BlockIT = CFCtx.getStmtToBlock().find((S));
-assert(BlockIT != CFCtx.getStmtToBlock().end());
-const auto  = BlockToState[BlockIT->getSecond()->getBlockID()];
+auto BlockIt = CFCtx.getStmtToBlock().find((S));
+assert(BlockIt != CFCtx.getStmtToBlock().end());
+const auto  = BlockToState[BlockIt->getSecond()->getBlockID()];
 assert(State);
 return ().Env;
   }
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -564,11 +564,11 @@
 Env.setValue(Loc, *Val);
 
 if (Type->isStructureOrClassType()) {
-  for (auto IT : llvm::zip(Type->getAsRecordDecl()->fields(), S->inits())) {
-const FieldDecl *Field = std::get<0>(IT);
+  for (auto It : llvm::zip(Type->getAsRecordDecl()->fields(), S->inits())) {
+const FieldDecl *Field = std::get<0>(It);
 assert(Field != nullptr);
 
-const Expr *Init = std::get<1>(IT);
+const Expr *Init = std::get<1>(It);
 assert(Init != nullptr);
 
 if (Value *InitVal = Env.getValue(*Init, SkipPast::None))
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -352,16 +352,16 @@
 }
   }
 
-  auto IT = MemberLocToStruct.find();
-  if (IT != MemberLocToStruct.end()) {
+  auto It = MemberLocToStruct.find();
+  if (It != MemberLocToStruct.end()) {
 // `Loc` is the location of a struct member so we need to also update the
 // value of the member in the corresponding `StructValue`.
 
-assert(IT->second.first != nullptr);
-StructValue  = *IT->second.first;
+assert(It->second.first != nullptr);
+StructValue  = *It->second.first;
 
-assert(IT->second.second != nullptr);
-const ValueDecl  = *IT->second.second;
+assert(It->second.second != nullptr);
+const ValueDecl  = *It->second.second;
 
 StructVal.setChild(Member, Val);
   }
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -199,18 +199,18 @@
   if (!Res.second)
 return;
 
-  auto ConstraintsIT = FlowConditionConstraints.find();
-  if (ConstraintsIT == FlowConditionConstraints.end()) {
+  auto ConstraintsIt = FlowConditionConstraints.find();
+  if (ConstraintsIt == FlowConditionConstraints.end()) {
 Constraints.insert();
   } else {
 // Bind flow condition token via `iff` to its set of constraints:
 // FC <=> (C1 ^ C2 ^ ...), where Ci are constraints
-Constraints.insert((Token, *ConstraintsIT->second));
+Constraints.insert((Token, *ConstraintsIt->second));
   }
 
-  auto DepsIT = FlowConditionDeps.find();
-  if (DepsIT != FlowConditionDeps.end()) {
-for (AtomicBoolValue *DepToken : DepsIT->second) {
+  auto DepsIt = FlowConditionDeps.find();
+  if (DepsIt != FlowConditionDeps.end()) {
+for (AtomicBoolValue *DepToken : DepsIt->second) {
   addTransitiveFlowConditionConstraints(*DepToken, Constraints,
 VisitedTokens);
 }
@@ -220,10 +220,10 @@
 BoolValue ::substituteBoolValue(
 BoolValue ,
 llvm::DenseMap ) {
-  auto IT = SubstitutionsCache.find();
-  if (IT != SubstitutionsCache.end()) {
+  auto It = SubstitutionsCache.find();
+  if (It != SubstitutionsCache.end()) {
 // Return memoized result of substituting this boolean value.
-return *IT->second;
+return *It->second;
   }
 
   // Handle substitution on the boolean value (and its subvalues), saving the
@@ -280,19 +280,19 @@
 BoolValue ::buildAndSubstituteFlowConditionWithCache(
 AtomicBoolValue ,
 llvm::DenseMap ) {
-  auto ConstraintsIT = 

[PATCH] D130423: [clang][dataflow] Rename iterators from IT to It

2022-07-23 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added subscribers: martong, tschuett, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The latter way to abbreviate is a lot more common in the LLVM codebase.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130423

Files:
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -47,9 +47,9 @@
   : CFCtx(CFCtx), BlockToState(BlockToState) {}
 
   const Environment *getEnvironment(const Stmt ) const override {
-auto BlockIT = CFCtx.getStmtToBlock().find((S));
-assert(BlockIT != CFCtx.getStmtToBlock().end());
-const auto  = BlockToState[BlockIT->getSecond()->getBlockID()];
+auto BlockIt = CFCtx.getStmtToBlock().find((S));
+assert(BlockIt != CFCtx.getStmtToBlock().end());
+const auto  = BlockToState[BlockIt->getSecond()->getBlockID()];
 assert(State);
 return ().Env;
   }
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -564,11 +564,11 @@
 Env.setValue(Loc, *Val);
 
 if (Type->isStructureOrClassType()) {
-  for (auto IT : llvm::zip(Type->getAsRecordDecl()->fields(), S->inits())) {
-const FieldDecl *Field = std::get<0>(IT);
+  for (auto It : llvm::zip(Type->getAsRecordDecl()->fields(), S->inits())) {
+const FieldDecl *Field = std::get<0>(It);
 assert(Field != nullptr);
 
-const Expr *Init = std::get<1>(IT);
+const Expr *Init = std::get<1>(It);
 assert(Init != nullptr);
 
 if (Value *InitVal = Env.getValue(*Init, SkipPast::None))
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -2,7 +2,7 @@
 //
 // 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
+// SPDX-License-Identifier: Apache-2.0 WiTH LLVM-exception
 //
 //===--===//
 //
@@ -352,16 +352,16 @@
 }
   }
 
-  auto IT = MemberLocToStruct.find();
-  if (IT != MemberLocToStruct.end()) {
+  auto It = MemberLocToStruct.find();
+  if (It != MemberLocToStruct.end()) {
 // `Loc` is the location of a struct member so we need to also update the
 // value of the member in the corresponding `StructValue`.
 
-assert(IT->second.first != nullptr);
-StructValue  = *IT->second.first;
+assert(It->second.first != nullptr);
+StructValue  = *It->second.first;
 
-assert(IT->second.second != nullptr);
-const ValueDecl  = *IT->second.second;
+assert(It->second.second != nullptr);
+const ValueDecl  = *It->second.second;
 
 StructVal.setChild(Member, Val);
   }
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -199,18 +199,18 @@
   if (!Res.second)
 return;
 
-  auto ConstraintsIT = FlowConditionConstraints.find();
-  if (ConstraintsIT == FlowConditionConstraints.end()) {
+  auto ConstraintsIt = FlowConditionConstraints.find();
+  if (ConstraintsIt == FlowConditionConstraints.end()) {
 Constraints.insert();
   } else {
 // Bind flow condition token via `iff` to its set of constraints:
 // FC <=> (C1 ^ C2 ^ ...), where Ci are constraints
-Constraints.insert((Token, *ConstraintsIT->second));
+Constraints.insert((Token, *ConstraintsIt->second));
   }
 
-  auto DepsIT = FlowConditionDeps.find();
-  if (DepsIT != FlowConditionDeps.end()) {
-for (AtomicBoolValue *DepToken : DepsIT->second) {
+  auto DepsIt = FlowConditionDeps.find();
+  if (DepsIt != FlowConditionDeps.end()) {
+for (AtomicBoolValue *DepToken : DepsIt->second) {
   addTransitiveFlowConditionConstraints(*DepToken, Constraints,
 VisitedTokens);
 }
@@ -220,10 +220,10 @@
 BoolValue ::substituteBoolValue(
 BoolValue ,
 llvm::DenseMap ) {
- 

[PATCH] D130422: [clang-repl] Fix incorrect return code

2022-07-23 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
junaire added a reviewer: v.g.vassilev.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without this patch, clang-repl incorrectly pass some tests when there's
error occured.

Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130422

Files:
  clang/test/Interpreter/fail.cpp
  clang/tools/clang-repl/ClangRepl.cpp


Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -50,7 +50,7 @@
 
 // If we are running with -verify a reported has to be returned as unsuccess.
 // This is relevant especially for the test suite.
-static int checkDiagErrors(const clang::CompilerInstance *CI) {
+static int checkDiagErrors(const clang::CompilerInstance *CI, bool HasError) {
   unsigned Errs = CI->getDiagnostics().getClient()->getNumErrors();
   if (CI->getDiagnosticOpts().VerifyDiagnostics) {
 // If there was an error that came from the verifier we must return 1 as
@@ -62,7 +62,7 @@
 // The interpreter expects BeginSourceFile/EndSourceFiles to be balanced.
 Client->BeginSourceFile(CI->getLangOpts(), >getPreprocessor());
   }
-  return Errs ? EXIT_FAILURE : EXIT_SUCCESS;
+  return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 llvm::ExitOnError ExitOnErr;
@@ -105,6 +105,8 @@
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   }
 
+  bool HasError = false;
+
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
@@ -112,13 +114,17 @@
   if (*Line == R"(%quit)")
 break;
   if (*Line == R"(%undo)") {
-if (auto Err = Interp->Undo())
+if (auto Err = Interp->Undo()) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
 continue;
   }
 
-  if (auto Err = Interp->ParseAndExecute(*Line))
+  if (auto Err = Interp->ParseAndExecute(*Line)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+HasError = true;
+  }
 }
   }
 
@@ -129,5 +135,5 @@
 
   llvm::llvm_shutdown();
 
-  return checkDiagErrors(Interp->getCompilerInstance());
+  return checkDiagErrors(Interp->getCompilerInstance(), HasError);
 }
Index: clang/test/Interpreter/fail.cpp
===
--- /dev/null
+++ clang/test/Interpreter/fail.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// XFAIL: *
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+BOOM!
+extern "C" int printf(const char *, ...);
+int i = 42;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 42
+%quit


Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -50,7 +50,7 @@
 
 // If we are running with -verify a reported has to be returned as unsuccess.
 // This is relevant especially for the test suite.
-static int checkDiagErrors(const clang::CompilerInstance *CI) {
+static int checkDiagErrors(const clang::CompilerInstance *CI, bool HasError) {
   unsigned Errs = CI->getDiagnostics().getClient()->getNumErrors();
   if (CI->getDiagnosticOpts().VerifyDiagnostics) {
 // If there was an error that came from the verifier we must return 1 as
@@ -62,7 +62,7 @@
 // The interpreter expects BeginSourceFile/EndSourceFiles to be balanced.
 Client->BeginSourceFile(CI->getLangOpts(), >getPreprocessor());
   }
-  return Errs ? EXIT_FAILURE : EXIT_SUCCESS;
+  return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 llvm::ExitOnError ExitOnErr;
@@ -105,6 +105,8 @@
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   }
 
+  bool HasError = false;
+
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
@@ -112,13 +114,17 @@
   if (*Line == R"(%quit)")
 break;
   if (*Line == R"(%undo)") {
-if (auto Err = Interp->Undo())
+if (auto Err = Interp->Undo()) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
 continue;
   }
 
-  if (auto Err = Interp->ParseAndExecute(*Line))
+  if (auto Err = Interp->ParseAndExecute(*Line)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+HasError = true;
+  }
 }
   }
 
@@ -129,5 +135,5 @@
 
   

[PATCH] D130406: Use llvm::sort instead of std::sort where possible

2022-07-23 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaba43035bdf8: Use llvm::sort instead of std::sort where 
possible (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130406

Files:
  clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
  clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/unittests/Tooling/TransformerTest.cpp
  lld/COFF/Chunks.cpp
  lld/COFF/DLL.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/SyntheticSections.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
  llvm/lib/MC/MCPseudoProbe.cpp
  llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
  llvm/lib/Target/DirectX/DXILWriter/DXILValueEnumerator.cpp
  llvm/lib/Target/XCore/XCoreFrameLowering.cpp
  llvm/unittests/ADT/SmallSetTest.cpp
  llvm/unittests/MIR/MachineMetadata.cpp
  llvm/unittests/Support/AlignmentTest.cpp
  llvm/utils/TableGen/DXILEmitter.cpp
  llvm/utils/TableGen/DirectiveEmitter.cpp
  llvm/utils/TableGen/SearchableTableEmitter.cpp
  llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
  mlir/lib/Analysis/Liveness.cpp
  mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
  mlir/lib/Dialect/SCF/Utils/Utils.cpp
  mlir/lib/IR/AffineExpr.cpp

Index: mlir/lib/IR/AffineExpr.cpp
===
--- mlir/lib/IR/AffineExpr.cpp
+++ mlir/lib/IR/AffineExpr.cpp
@@ -1073,7 +1073,7 @@
   // Constructing the simplified semi-affine sum of product/division/mod
   // expression from the flattened form in the desired sorted order of indices
   // of the various individual product/division/mod expressions.
-  std::sort(indices.begin(), indices.end());
+  llvm::sort(indices);
   for (const std::pair index : indices) {
 assert(indexToExprMap.lookup(index) &&
"cannot find key in `indexToExprMap` map");
Index: mlir/lib/Dialect/SCF/Utils/Utils.cpp
===
--- mlir/lib/Dialect/SCF/Utils/Utils.cpp
+++ mlir/lib/Dialect/SCF/Utils/Utils.cpp
@@ -673,7 +673,7 @@
   // Presort combined dimensions.
   auto sortedDimensions = llvm::to_vector<3>(combinedDimensions);
   for (auto  : sortedDimensions)
-std::sort(dims.begin(), dims.end());
+llvm::sort(dims);
 
   // Normalize ParallelOp's iteration pattern.
   SmallVector normalizedLowerBounds, normalizedSteps,
Index: mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
===
--- mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
+++ mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
@@ -26,6 +26,7 @@
 #include "mlir/Transforms/Passes.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
@@ -683,7 +684,7 @@
   srcIdCandidates.push_back(srcNode->id);
   }
 
-  std::sort(srcIdCandidates.begin(), srcIdCandidates.end());
+  llvm::sort(srcIdCandidates);
   srcIdCandidates.erase(
   std::unique(srcIdCandidates.begin(), srcIdCandidates.end()),
   srcIdCandidates.end());
Index: mlir/lib/Analysis/Liveness.cpp
===
--- mlir/lib/Analysis/Liveness.cpp
+++ mlir/lib/Analysis/Liveness.cpp
@@ -15,6 +15,7 @@
 #include "mlir/IR/Operation.h"
 #include "mlir/IR/Region.h"
 #include "mlir/IR/Value.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetOperations.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/Support/raw_ostream.h"
@@ -288,10 +289,9 @@
 
   auto printValueRefs = [&](const ValueSetT ) {
 std::vector orderedValues(values.begin(), values.end());
-std::sort(orderedValues.begin(), orderedValues.end(),
-  [&](Value left, Value right) {
-return valueIds[left] < valueIds[right];
-  });
+llvm::sort(orderedValues, [&](Value left, Value right) {
+  return valueIds[left] < valueIds[right];
+});
 for (Value value : orderedValues)
   printValueRef(value);
   };
@@ -317,10 +317,9 @@
 printValueRef(result);
 os << ":";
 auto liveOperations = resolveLiveness(result);
-std::sort(liveOperations.begin(), liveOperations.end(),
-  [&](Operation *left, Operation *right) {
-return 

[clang] e82880e - [Clang] Update the status of N2393 in c_status.html

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

Author: Corentin Jabot
Date: 2022-07-23T15:15:12+02:00
New Revision: e82880e6b8cd2f01ee18e99c4c7b6ec71b764e13

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

LOG: [Clang] Update the status of N2393 in c_status.html

Added: 


Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index f3076d345237..4bb8d3408d00 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -746,7 +746,7 @@ C2x implementation status
 
   _Bool definitions for true and false
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2393.pdf;>N2393
-  No
+  Subsumed by N2935
 
 
 



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


[clang] cd9a5cf - Use the range-based overload of llvm::sort where possible

2022-07-23 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2022-07-23T15:13:25+02:00
New Revision: cd9a5cfd2e4e4d583c9bf5ef1100acaf5e96f29e

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

LOG: Use the range-based overload of llvm::sort where possible

Reviewed By: MaskRay

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

Added: 


Modified: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang-tools-extra/clangd/index/StdLib.cpp
clang/include/clang/Basic/Attr.td
clang/lib/Driver/Multilib.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
lldb/source/Interpreter/OptionValueArray.cpp
lldb/source/Interpreter/OptionValueFileSpecList.cpp
lldb/source/Interpreter/OptionValuePathMappings.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Symbol/ArmUnwindInfo.cpp
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/Symtab.cpp
lldb/source/Target/DynamicRegisterInfo.cpp
lldb/source/Target/Target.cpp
lldb/source/Utility/ReproducerProvider.cpp
lldb/source/Utility/Timer.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/unittests/ADT/SmallPtrSetTest.cpp
llvm/unittests/TextAPI/TextStubV1Tests.cpp
llvm/unittests/TextAPI/TextStubV2Tests.cpp
llvm/unittests/TextAPI/TextStubV3Tests.cpp
llvm/unittests/TextAPI/TextStubV4Tests.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index e25c8e2449dc8..cb5caf1ca92a1 100644
--- 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -193,8 +193,7 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
   // Sort replacements per file to keep consistent behavior when
   // clang-apply-replacements run on 
diff erents machine.
   for (auto  : GroupedReplacements) {
-llvm::sort(FileAndReplacements.second.begin(),
-   FileAndReplacements.second.end());
+llvm::sort(FileAndReplacements.second);
   }
 
   return GroupedReplacements;

diff  --git a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp 
b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
index ebb4a70c1f8db..95b5ed0a8b1aa 100644
--- a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
+++ b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
@@ -59,7 +59,7 @@ static void rank(std::vector ,
   }
   // Sort by the gathered scores. Use file name as a tie breaker so we can
   // deduplicate.
-  llvm::sort(Symbols.begin(), Symbols.end(),
+  llvm::sort(Symbols,
  [&](const SymbolAndSignals , const SymbolAndSignals ) {
auto AS = Score[A.Symbol.getFilePath()];
auto BS = Score[B.Symbol.getFilePath()];

diff  --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
index 0209071af87f4..1d15ae19ead4d 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -104,10 +104,8 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, 
ClangTidyContext *Context)
   consumeError(StatusOrErr.takeError());
   IgnoredDoublePointValues.push_back(DoubleValue.convertToDouble());
 }
-llvm::sort(IgnoredFloatingPointValues.begin(),
-   IgnoredFloatingPointValues.end());
-llvm::sort(IgnoredDoublePointValues.begin(),
-   IgnoredDoublePointValues.end());
+llvm::sort(IgnoredFloatingPointValues);
+llvm::sort(IgnoredDoublePointValues);
   }
 }
 

diff  --git a/clang-tools-extra/clangd/index/StdLib.cpp 
b/clang-tools-extra/clangd/index/StdLib.cpp
index f00067229a860..f2edc514bae30 100644
--- a/clang-tools-extra/clangd/index/StdLib.cpp
+++ b/clang-tools-extra/clangd/index/StdLib.cpp
@@ -80,7 +80,7 @@ std::string buildUmbrella(llvm::StringLiteral Mandatory,
   "#endif\n",
   Mandatory);
 
-  llvm::sort(Headers.begin(), Headers.end());
+  llvm::sort(Headers);
   auto Last = std::unique(Headers.begin(), Headers.end());
   for (auto Header = Headers.begin(); Header != Last; ++Header) {
 OS << llvm::formatv("#if __has_include({0})\n"

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 78e0fce917a0f..d61f3583281d1 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2703,7 +2703,7 @@ def 

[PATCH] D130403: Use the range-based overload of llvm::sort where possible

2022-07-23 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd9a5cfd2e4e: Use the range-based overload of llvm::sort 
where possible (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130403

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/clangd/index/StdLib.cpp
  clang/include/clang/Basic/Attr.td
  clang/lib/Driver/Multilib.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  lldb/source/Interpreter/OptionValueArray.cpp
  lldb/source/Interpreter/OptionValueFileSpecList.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Symbol/ArmUnwindInfo.cpp
  lldb/source/Symbol/CompileUnit.cpp
  lldb/source/Symbol/Symtab.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/source/Utility/Timer.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/unittests/ADT/SmallPtrSetTest.cpp
  llvm/unittests/TextAPI/TextStubV1Tests.cpp
  llvm/unittests/TextAPI/TextStubV2Tests.cpp
  llvm/unittests/TextAPI/TextStubV3Tests.cpp
  llvm/unittests/TextAPI/TextStubV4Tests.cpp

Index: llvm/unittests/TextAPI/TextStubV4Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV4Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV4Tests.cpp
@@ -125,9 +125,9 @@
   Sym->isReexported() ? Reexports.emplace_back(std::move(temp))
   : Exports.emplace_back(std::move(temp));
   }
-  llvm::sort(Exports.begin(), Exports.end());
-  llvm::sort(Reexports.begin(), Reexports.end());
-  llvm::sort(Undefineds.begin(), Undefineds.end());
+  llvm::sort(Exports);
+  llvm::sort(Reexports);
+  llvm::sort(Undefineds);
 
   static ExportedSymbol ExpectedExportedSymbols[] = {
   {SymbolKind::GlobalSymbol, "_symA", false, false},
@@ -296,9 +296,9 @@
   Sym->isReexported() ? Reexports.emplace_back(std::move(Temp))
   : Exports.emplace_back(std::move(Temp));
   }
-  llvm::sort(Exports.begin(), Exports.end());
-  llvm::sort(Reexports.begin(), Reexports.end());
-  llvm::sort(Undefineds.begin(), Undefineds.end());
+  llvm::sort(Exports);
+  llvm::sort(Reexports);
+  llvm::sort(Undefineds);
 
   static ExportedSymbol ExpectedExportedSymbols[] = {
   {SymbolKind::GlobalSymbol, "_symA", false, false},
Index: llvm/unittests/TextAPI/TextStubV3Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV3Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV3Tests.cpp
@@ -111,7 +111,7 @@
 ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined(), Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   EXPECT_EQ(sizeof(TBDv3Symbols) / sizeof(ExportedSymbol), Exports.size());
   EXPECT_TRUE(
@@ -203,7 +203,7 @@
 Sym->isWeakDefined(),
 Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   EXPECT_EQ(sizeof(TBDv3Symbols) / sizeof(ExportedSymbol), Exports.size());
   EXPECT_TRUE(
@@ -228,7 +228,7 @@
 Sym->isWeakDefined(),
 Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   ExportedSymbolSeq DocumentSymbols{
   {SymbolKind::GlobalSymbol, "_sym5", false, false},
Index: llvm/unittests/TextAPI/TextStubV2Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV2Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV2Tests.cpp
@@ -103,7 +103,7 @@
 ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined(), Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   EXPECT_EQ(sizeof(TBDv2Symbols) / sizeof(ExportedSymbol), Exports.size());
   EXPECT_TRUE(
Index: llvm/unittests/TextAPI/TextStubV1Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV1Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV1Tests.cpp
@@ -102,7 +102,7 @@
 ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined(), Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   

[clang-tools-extra] cd9a5cf - Use the range-based overload of llvm::sort where possible

2022-07-23 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2022-07-23T15:13:25+02:00
New Revision: cd9a5cfd2e4e4d583c9bf5ef1100acaf5e96f29e

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

LOG: Use the range-based overload of llvm::sort where possible

Reviewed By: MaskRay

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

Added: 


Modified: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang-tools-extra/clangd/index/StdLib.cpp
clang/include/clang/Basic/Attr.td
clang/lib/Driver/Multilib.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
lldb/source/Interpreter/OptionValueArray.cpp
lldb/source/Interpreter/OptionValueFileSpecList.cpp
lldb/source/Interpreter/OptionValuePathMappings.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Symbol/ArmUnwindInfo.cpp
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/Symtab.cpp
lldb/source/Target/DynamicRegisterInfo.cpp
lldb/source/Target/Target.cpp
lldb/source/Utility/ReproducerProvider.cpp
lldb/source/Utility/Timer.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/unittests/ADT/SmallPtrSetTest.cpp
llvm/unittests/TextAPI/TextStubV1Tests.cpp
llvm/unittests/TextAPI/TextStubV2Tests.cpp
llvm/unittests/TextAPI/TextStubV3Tests.cpp
llvm/unittests/TextAPI/TextStubV4Tests.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index e25c8e2449dc8..cb5caf1ca92a1 100644
--- 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -193,8 +193,7 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
   // Sort replacements per file to keep consistent behavior when
   // clang-apply-replacements run on 
diff erents machine.
   for (auto  : GroupedReplacements) {
-llvm::sort(FileAndReplacements.second.begin(),
-   FileAndReplacements.second.end());
+llvm::sort(FileAndReplacements.second);
   }
 
   return GroupedReplacements;

diff  --git a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp 
b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
index ebb4a70c1f8db..95b5ed0a8b1aa 100644
--- a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
+++ b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
@@ -59,7 +59,7 @@ static void rank(std::vector ,
   }
   // Sort by the gathered scores. Use file name as a tie breaker so we can
   // deduplicate.
-  llvm::sort(Symbols.begin(), Symbols.end(),
+  llvm::sort(Symbols,
  [&](const SymbolAndSignals , const SymbolAndSignals ) {
auto AS = Score[A.Symbol.getFilePath()];
auto BS = Score[B.Symbol.getFilePath()];

diff  --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
index 0209071af87f4..1d15ae19ead4d 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -104,10 +104,8 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, 
ClangTidyContext *Context)
   consumeError(StatusOrErr.takeError());
   IgnoredDoublePointValues.push_back(DoubleValue.convertToDouble());
 }
-llvm::sort(IgnoredFloatingPointValues.begin(),
-   IgnoredFloatingPointValues.end());
-llvm::sort(IgnoredDoublePointValues.begin(),
-   IgnoredDoublePointValues.end());
+llvm::sort(IgnoredFloatingPointValues);
+llvm::sort(IgnoredDoublePointValues);
   }
 }
 

diff  --git a/clang-tools-extra/clangd/index/StdLib.cpp 
b/clang-tools-extra/clangd/index/StdLib.cpp
index f00067229a860..f2edc514bae30 100644
--- a/clang-tools-extra/clangd/index/StdLib.cpp
+++ b/clang-tools-extra/clangd/index/StdLib.cpp
@@ -80,7 +80,7 @@ std::string buildUmbrella(llvm::StringLiteral Mandatory,
   "#endif\n",
   Mandatory);
 
-  llvm::sort(Headers.begin(), Headers.end());
+  llvm::sort(Headers);
   auto Last = std::unique(Headers.begin(), Headers.end());
   for (auto Header = Headers.begin(); Header != Last; ++Header) {
 OS << llvm::formatv("#if __has_include({0})\n"

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 78e0fce917a0f..d61f3583281d1 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2703,7 +2703,7 @@ def 

[PATCH] D128328: [C++20][Modules] Improve handing of Private Module Fragment diagnostics.

2022-07-23 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 447062.
iains added a comment.

rebased, retested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128328

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/Reachability-Private.cpp
  clang/test/Modules/cxx20-10-5-ex1.cpp

Index: clang/test/Modules/cxx20-10-5-ex1.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-5-ex1.cpp
@@ -0,0 +1,53 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-5-ex1-interface.cpp \
+// RUN: -DBAD_FWD_DECL  -fsyntax-only -verify
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-5-ex1-interface.cpp \
+// RUN: -o A.pcm
+
+// RUN: %clang_cc1 -std=c++20 std-10-5-ex1-use.cpp  -fmodule-file=A.pcm \
+// RUN:-fsyntax-only -verify
+
+//--- std-10-5-ex1-interface.cpp
+
+export module A;
+#ifdef BAD_FWD_DECL
+export inline void fn_e(); // expected-error {{exported inline function not defined before the private module fragment}}
+   // expected-n...@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}
+#endif
+export inline void ok_fn() {}
+export inline void ok_fn2();
+#ifdef BAD_FWD_DECL
+inline void fn_m(); // expected-error {{un-exported inline function not defined before the private module fragment}}
+// expected-n...@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}
+#endif
+static void fn_s();
+export struct X;
+export void g(X *x) {
+  fn_s();
+}
+export X *factory();
+void ok_fn2() {}
+
+module :private;
+struct X {};
+X *factory() {
+  return new X();
+}
+
+void fn_e() {}
+void fn_m() {}
+void fn_s() {}
+
+//--- std-10-5-ex1-use.cpp
+
+import A;
+
+void foo() {
+  X x; // expected-error 1+{{missing '#include'; 'X' must be defined before it is used}}
+   // expected-n...@std-10-5-ex1-interface.cpp:22 1+{{definition here is not reachable}}
+  X *p = factory();
+}
Index: clang/test/Modules/Reachability-Private.cpp
===
--- clang/test/Modules/Reachability-Private.cpp
+++ clang/test/Modules/Reachability-Private.cpp
@@ -4,18 +4,25 @@
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
 //
-// RUN: %clang_cc1 -std=c++20 %t/Private.cppm -emit-module-interface -o %t/Private.pcm
-// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++20 %t/Private.cppm -emit-module-interface \
+// RUN: -o %t/Private.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \
+// RUN: -DTEST_BADINLINE -verify -fsyntax-only
 
 //--- Private.cppm
 export module Private;
-inline void fn_m(); // OK, module-linkage inline function
+#ifdef TEST_BADINLINE
+inline void fn_m(); // expected-error {{un-exported inline function not defined before the private module fragment}}
+// expected-n...@private.cppm:13 {{private module fragment begins here}}
+#endif
 static void fn_s();
 export struct X;
 
 export void g(X *x) {
   fn_s(); // OK, call to static function in same translation unit
-  fn_m(); // OK, call to module-linkage inline function
+#ifdef TEST_BADINLINE
+  fn_m(); // fn_m is not OK.
+#endif
 }
 export X *factory(); // OK
 
@@ -30,10 +37,8 @@
 //--- Use.cpp
 import Private;
 void foo() {
-  X x; // expected-error {{definition of 'X' must be imported from module 'Private.' before it is required}}
-   // expected-error@-1 {{definition of 'X' must be imported from module 'Private.' before it is required}}
-   // expected-note@* {{definition here is not reachable}}
-   // expected-note@* {{definition here is not reachable}}
+  X x; // expected-error 1+{{missing '#include'; 'X' must be defined before it is used}}
+   // expected-n...@private.cppm:18 1+{{definition here is not reachable}}
   auto _ = factory();
   auto *__ = factory();
   X *___ = factory();
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -911,6 +911,17 @@
 diagExportedUnnamedDecl(*this, UnnamedDeclKind::Context, Child,
 BlockStart);
   }
+  if (auto *FD = dyn_cast(Child)) {
+// [dcl.inline]/7
+// If an inline function or variable that is attached to a named module
+// is declared in a definition domain, it shall be defined in that
+// domain.
+// So, if the current declaration does not have a definition, we must
+// check at the end of the TU (or when the PMF starts) to see that we
+// have a definition at that point.

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

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

@aaron.ballman I think getting that in 15 would avoid some churn, WDYT?


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] D130421: [Clang] De-deprecate volatile compound operations

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

As per P2327R1,

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


Repository:
  rG LLVM Github Monorepo

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 ,
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;
+  //   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, );
 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, );
 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);
+  ResultTy =
+  CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy, Opc);
 break;
   case BO_AndAssign:
   case BO_OrAssign: // fallthrough
@@ -15011,7 +15025,8 @@
 

[PATCH] D130420: [CodeGen] Consider MangleCtx when move lazy emission States

2022-07-23 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
junaire added a reviewer: v.g.vassilev.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Also move MangleCtx when moving some lazy emission states in
CodeGenModule. Without this patch clang-repl hits an invalid address
access when passing `-Xcc -O2` flag.

Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130420

Files:
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/Interpreter/execute.cpp


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -5,6 +5,7 @@
 // UNSUPPORTED: system-aix
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
 extern "C" int printf(const char *, ...);
 int i = 42;
 auto r1 = printf("i = %d\n", i);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -7000,4 +7000,6 @@
  "Still have (unmerged) EmittedDeferredDecls deferred decls");
 
   NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
+
+  NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
 }
Index: clang/lib/CodeGen/CGCXXABI.h
===
--- clang/lib/CodeGen/CGCXXABI.h
+++ clang/lib/CodeGen/CGCXXABI.h
@@ -41,6 +41,8 @@
 
 /// Implements C++ ABI-specific code generation functions.
 class CGCXXABI {
+  friend class CodeGenModule;
+
 protected:
   CodeGenModule 
   std::unique_ptr MangleCtx;


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -5,6 +5,7 @@
 // UNSUPPORTED: system-aix
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
 extern "C" int printf(const char *, ...);
 int i = 42;
 auto r1 = printf("i = %d\n", i);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -7000,4 +7000,6 @@
  "Still have (unmerged) EmittedDeferredDecls deferred decls");
 
   NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
+
+  NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
 }
Index: clang/lib/CodeGen/CGCXXABI.h
===
--- clang/lib/CodeGen/CGCXXABI.h
+++ clang/lib/CodeGen/CGCXXABI.h
@@ -41,6 +41,8 @@
 
 /// Implements C++ ABI-specific code generation functions.
 class CGCXXABI {
+  friend class CodeGenModule;
+
 protected:
   CodeGenModule 
   std::unique_ptr MangleCtx;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130406: Use llvm::sort instead of std::sort where possible

2022-07-23 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle accepted this revision.
nhaehnle 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/D130406/new/

https://reviews.llvm.org/D130406

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


[PATCH] D130415: [Clang] Adjust extension warnings for #warning

2022-07-23 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 rG559f07b87211: [Clang] Adjust extension warnings for #warning 
(authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130415

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/ext-pp-directive.c


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b 
extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is 
incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards 
before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards 
before C++2b}}
+// pre-cpp2b-compat-warning@-11 {{foo}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,16 @@
   return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
 
 case tok::pp_warning:
-  Diag(Result, diag::ext_pp_warning_directive);
+  if (LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+<< /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive
+  : diag::ext_pp_warning_directive)
+<< /*C2x*/ 0;
+
   return HandleUserDiagnosticDirective(Result, true);
 case tok::pp_ident:
   return HandleIdentSCCSDirective(Result);
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -387,7 +387,15 @@
 def ext_pp_ident_directive : Extension<"#ident is a language extension">;
 def ext_pp_include_next_directive : Extension<
   "#include_next is a language extension">, InGroup;
-def ext_pp_warning_directive : Extension<"#warning is a language extension">;
+
+def ext_pp_warning_directive : Extension<
+  "#warning is a %select{C2x|C++2b}0 extension">;
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<
   "extra tokens at end of #%0 directive">, InGroup;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -262,7 +262,7 @@
 - Added the ``-Wgnu-line-marker`` diagnostic flag (grouped under the ``-Wgnu``
   flag) which is a portability warning about use of GNU linemarker preprocessor
   directives. Fixes `Issue 55067 
`_.
-- Using ``#elifdef`` and ``#elifndef`` that are incompatible with C/C++
+- Using ``#warning``, ``#elifdef`` and ``#elifndef`` that are incompatible 
with C/C++
   standards before C2x/C++2b are now warned via ``-pedantic``. Additionally,
   on such language mode, ``-Wpre-c2x-compat`` and ``-Wpre-c++2b-compat``
   diagnostic flags report a compatibility issue.


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// 

[clang] 559f07b - [Clang] Adjust extension warnings for #warning

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

Author: Corentin Jabot
Date: 2022-07-23T14:10:11+02:00
New Revision: 559f07b872116fb85ea7d493768a6eb450329fa0

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

LOG: [Clang] Adjust extension warnings for #warning

The #warning directive is standard in C++2b and C2x,
this adjusts the pedantic and extensions warning accordingly.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/PPDirectives.cpp
clang/test/Preprocessor/ext-pp-directive.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7fb21dbadea0..6d6faa32e458 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -262,7 +262,7 @@ Improvements to Clang's diagnostics
 - Added the ``-Wgnu-line-marker`` diagnostic flag (grouped under the ``-Wgnu``
   flag) which is a portability warning about use of GNU linemarker preprocessor
   directives. Fixes `Issue 55067 
`_.
-- Using ``#elifdef`` and ``#elifndef`` that are incompatible with C/C++
+- Using ``#warning``, ``#elifdef`` and ``#elifndef`` that are incompatible 
with C/C++
   standards before C2x/C++2b are now warned via ``-pedantic``. Additionally,
   on such language mode, ``-Wpre-c2x-compat`` and ``-Wpre-c++2b-compat``
   diagnostic flags report a compatibility issue.

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 5d3abb1f9b70..6032fbd18d56 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -387,7 +387,15 @@ def ext_pp_include_search_ms : ExtWarn<
 def ext_pp_ident_directive : Extension<"#ident is a language extension">;
 def ext_pp_include_next_directive : Extension<
   "#include_next is a language extension">, InGroup;
-def ext_pp_warning_directive : Extension<"#warning is a language extension">;
+
+def ext_pp_warning_directive : Extension<
+  "#warning is a %select{C2x|C++2b}0 extension">;
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<
   "extra tokens at end of #%0 directive">, InGroup;

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 4679cb4e7a34..9a8fd4391b41 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,16 @@ void Preprocessor::HandleDirective(Token ) {
   return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
 
 case tok::pp_warning:
-  Diag(Result, diag::ext_pp_warning_directive);
+  if (LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+<< /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive
+  : diag::ext_pp_warning_directive)
+<< /*C2x*/ 0;
+
   return HandleUserDiagnosticDirective(Result, true);
 case tok::pp_ident:
   return HandleIdentSCCSDirective(Result);

diff  --git a/clang/test/Preprocessor/ext-pp-directive.c 
b/clang/test/Preprocessor/ext-pp-directive.c
index 45f7ecba3022..97454b4d9002 100644
--- a/clang/test/Preprocessor/ext-pp-directive.c
+++ b/clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@ int x;
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b 
extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is 
incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards 
before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards 
before C++2b}}
+// pre-cpp2b-compat-warning@-11 {{foo}}



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


[PATCH] D130416: [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

2022-07-23 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 rGaee76cb59ca2: [Clang] Add support for Unicode identifiers 
(UAX31) in C2x mode. (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130416

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/unicode.c
  clang/www/c_status.html


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx -x c++ -std=c++11 %s
 // RUN: %clang_cc1 -std=c99 -E -DPP_ONLY=1 %s | FileCheck %s 
--strict-whitespace
 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
 
@@ -31,7 +32,7 @@
 extern int X\U; // expected-error {{not allowed in an identifier}}
 int Y = '\U'; // expected-error {{invalid universal character}}
 
-#ifdef __cplusplus
+#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 
202000L)
 
 extern int ༀ;
 extern int ᩐ;
@@ -46,7 +47,8 @@
 
 
 // This character doesn't have the XID_Start property
-extern int  \U00016AC0; // TANGSA DIGIT ZERO  // expected-error {{expected 
unqualified-id}}
+extern int  \U00016AC0; // TANGSA DIGIT ZERO  // cxx-error {{expected 
unqualified-id}} \
+  // c2x-error {{expected 
identifier or '('}}
 
 extern int ; // expected-error {{unexpected character }} \
   expected-warning {{declaration does not declare anything}}
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1462,11 +1462,11 @@
 return false;
   } else if (LangOpts.DollarIdents && '$' == C) {
 return true;
-  } else if (LangOpts.CPlusPlus) {
+  } else if (LangOpts.CPlusPlus || LangOpts.C2x) {
 // A non-leading codepoint must have the XID_Continue property.
 // XIDContinueRanges doesn't contains characters also in XIDStartRanges,
 // so we need to check both tables.
-// '_' doesn't have the XID_Continue property but is allowed in C++.
+// '_' doesn't have the XID_Continue property but is allowed in C and C++.
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 static const llvm::sys::UnicodeCharSet XIDContinueChars(XIDContinueRanges);
 return C == '_' || XIDStartChars.contains(C) ||
@@ -1486,7 +1486,7 @@
   if (LangOpts.AsmPreprocessor) {
 return false;
   }
-  if (LangOpts.CPlusPlus) {
+  if (LangOpts.CPlusPlus || LangOpts.C2x) {
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 // '_' doesn't have the XID_Start property but is allowed in C++.
 return C == '_' || XIDStartChars.contains(C);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,6 +469,7 @@
   support for functions without prototypes, which no longer exist in C2x.
 - Implemented `WG14 N2841 No function declarators without prototypes 
`_
   and `WG14 N2432 Remove support for function definitions with identifier 
lists `_.
+- Implemented `WG14 N2836 Identifier Syntax using Unicode Standard Annex 31 
`_.
 
 C++ Language Changes in Clang
 -


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 

[clang] aee76cb - [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

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

Author: Corentin Jabot
Date: 2022-07-23T14:08:08+02:00
New Revision: aee76cb59ca273d46db20cd7d23a252a2683ed6a

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

LOG: [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

This implements
N2836 Identifier Syntax using Unicode Standard Annex 31.

The feature was already implemented for C++,
and the semantics are the same.

Unlike C++ there was, afaict, no decision to
backport the feature in older languages mode,
so C17 and earlier are not modified and the
code point tables for these language modes are conserved.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Lex/Lexer.cpp
clang/test/Lexer/unicode.c
clang/www/c_status.html

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9bedbf7a1e76..7fb21dbadea0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -469,6 +469,7 @@ C2x Feature Support
   support for functions without prototypes, which no longer exist in C2x.
 - Implemented `WG14 N2841 No function declarators without prototypes 
`_
   and `WG14 N2432 Remove support for function definitions with identifier 
lists `_.
+- Implemented `WG14 N2836 Identifier Syntax using Unicode Standard Annex 31 
`_.
 
 C++ Language Changes in Clang
 -

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index b3aac9df6546..a4cff403e739 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -1462,11 +1462,11 @@ static bool isAllowedIDChar(uint32_t C, const 
LangOptions ) {
 return false;
   } else if (LangOpts.DollarIdents && '$' == C) {
 return true;
-  } else if (LangOpts.CPlusPlus) {
+  } else if (LangOpts.CPlusPlus || LangOpts.C2x) {
 // A non-leading codepoint must have the XID_Continue property.
 // XIDContinueRanges doesn't contains characters also in XIDStartRanges,
 // so we need to check both tables.
-// '_' doesn't have the XID_Continue property but is allowed in C++.
+// '_' doesn't have the XID_Continue property but is allowed in C and C++.
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 static const llvm::sys::UnicodeCharSet XIDContinueChars(XIDContinueRanges);
 return C == '_' || XIDStartChars.contains(C) ||
@@ -1486,7 +1486,7 @@ static bool isAllowedInitiallyIDChar(uint32_t C, const 
LangOptions ) {
   if (LangOpts.AsmPreprocessor) {
 return false;
   }
-  if (LangOpts.CPlusPlus) {
+  if (LangOpts.CPlusPlus || LangOpts.C2x) {
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 // '_' doesn't have the XID_Start property but is allowed in C++.
 return C == '_' || XIDStartChars.contains(C);

diff  --git a/clang/test/Lexer/unicode.c b/clang/test/Lexer/unicode.c
index efbd63fb0063..8d5295ef338b 100644
--- a/clang/test/Lexer/unicode.c
+++ b/clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx -x c++ -std=c++11 %s
 // RUN: %clang_cc1 -std=c99 -E -DPP_ONLY=1 %s | FileCheck %s 
--strict-whitespace
 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
 
@@ -31,7 +32,7 @@ CHECK : The preprocessor should not complain about Unicode 
characters like ©.
 extern int X\U; // expected-error {{not allowed in an identifier}}
 int Y = '\U'; // expected-error {{invalid universal character}}
 
-#ifdef __cplusplus
+#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 
202000L)
 
 extern int ༀ;
 extern int ᩐ;
@@ -46,7 +47,8 @@ extern int _\N{TANGSALETTERGA}; // expected-error 
{{'TANGSALETTERGA' is not a va
 
 
 // This character doesn't have the XID_Start property
-extern int  \U00016AC0; // TANGSA DIGIT ZERO  // expected-error {{expected 
unqualified-id}}
+extern int  \U00016AC0; // TANGSA DIGIT ZERO  // cxx-error {{expected 
unqualified-id}} \
+  // c2x-error {{expected 
identifier or '('}}
 
 extern int ; // expected-error {{unexpected character }} \
   expected-warning {{declaration does not declare anything}}

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 17d18d8724f8..f3076d345237 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -1024,7 

[PATCH] D130415: [Clang] Adjust extension warnings for #warning

2022-07-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:393-398
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;

aaron.ballman wrote:
> Someday, it would be nice if we made the tablegen for 
> diagnostics a wee bit smarter so that we don't need to use two separate 
> warning declarations for this situation. In fact, it'd be nice if tablegen 
> could just automate this pattern given how often we use it and will be using 
> it in the future.
That would be great indeed!



Comment at: clang/lib/Lex/PPDirectives.cpp:1264-1273
+  if (LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+<< /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive

aaron.ballman wrote:
> Similarly (and also not your problem), it'd be nice to have a helper function 
> so that we don't need this complicated of a dance to diagnose the situation.
Agreed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130415

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


[PATCH] D130416: [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

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

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130416

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/unicode.c
  clang/www/c_status.html


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx -x c++ -std=c++11 %s
 // RUN: %clang_cc1 -std=c99 -E -DPP_ONLY=1 %s | FileCheck %s 
--strict-whitespace
 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
 
@@ -31,7 +32,7 @@
 extern int X\U; // expected-error {{not allowed in an identifier}}
 int Y = '\U'; // expected-error {{invalid universal character}}
 
-#ifdef __cplusplus
+#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 
202000L)
 
 extern int ༀ;
 extern int ᩐ;
@@ -46,7 +47,8 @@
 
 
 // This character doesn't have the XID_Start property
-extern int  \U00016AC0; // TANGSA DIGIT ZERO  // expected-error {{expected 
unqualified-id}}
+extern int  \U00016AC0; // TANGSA DIGIT ZERO  // cxx-error {{expected 
unqualified-id}} \
+  // c2x-error {{expected 
identifier or '('}}
 
 extern int ; // expected-error {{unexpected character }} \
   expected-warning {{declaration does not declare anything}}
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1462,11 +1462,11 @@
 return false;
   } else if (LangOpts.DollarIdents && '$' == C) {
 return true;
-  } else if (LangOpts.CPlusPlus) {
+  } else if (LangOpts.CPlusPlus || LangOpts.C2x) {
 // A non-leading codepoint must have the XID_Continue property.
 // XIDContinueRanges doesn't contains characters also in XIDStartRanges,
 // so we need to check both tables.
-// '_' doesn't have the XID_Continue property but is allowed in C++.
+// '_' doesn't have the XID_Continue property but is allowed in C and C++.
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 static const llvm::sys::UnicodeCharSet XIDContinueChars(XIDContinueRanges);
 return C == '_' || XIDStartChars.contains(C) ||
@@ -1486,7 +1486,7 @@
   if (LangOpts.AsmPreprocessor) {
 return false;
   }
-  if (LangOpts.CPlusPlus) {
+  if (LangOpts.CPlusPlus || LangOpts.C2x) {
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 // '_' doesn't have the XID_Start property but is allowed in C++.
 return C == '_' || XIDStartChars.contains(C);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,6 +469,7 @@
   support for functions without prototypes, which no longer exist in C2x.
 - Implemented `WG14 N2841 No function declarators without prototypes 
`_
   and `WG14 N2432 Remove support for function definitions with identifier 
lists `_.
+- Implemented `WG14 N2836 Identifier Syntax using Unicode Standard Annex 31 
`_.
 
 C++ Language Changes in Clang
 -


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx 

[PATCH] D130415: [Clang] Adjust extension warnings for #warning

2022-07-23 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/include/clang/Basic/DiagnosticLexKinds.td:393-398
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;

Someday, it would be nice if we made the tablegen for 
diagnostics a wee bit smarter so that we don't need to use two separate warning 
declarations for this situation. In fact, it'd be nice if tablegen could just 
automate this pattern given how often we use it and will be using it in the 
future.



Comment at: clang/lib/Lex/PPDirectives.cpp:1264-1273
+  if (LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+<< /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive

Similarly (and also not your problem), it'd be nice to have a helper function 
so that we don't need this complicated of a dance to diagnose the situation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130415

___
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-23 Thread Igor Zhukov via Phabricator via cfe-commits
fsb4000 added a comment.

F23880823: изображение.png 


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


[PATCH] D130416: [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

2022-07-23 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 aside from a typo fix in a comment. One thing worth thinking about is 
whether it would be worth it to have a diagnostic for valid C code in older 
modes that will change behavior in C2x due to this feature, but that can be 
done as follow-up work.




Comment at: clang/lib/Lex/Lexer.cpp:1469
 // so we need to check both tables.
-// '_' doesn't have the XID_Continue property but is allowed in C++.
+// '_' doesn't have the XID_Continue property but is allowed in C an C++.
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130416

___
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-23 Thread Igor Zhukov via Phabricator via cfe-commits
fsb4000 created this revision.
fsb4000 added a project: clang.
Herald added a project: All.
fsb4000 requested review of this revision.
Herald added a subscriber: cfe-commits.

and use fallback only for C.

It fixes the isssue with clang-cl:

  #include 
  #include 
  #ifdef __cplusplus
  #include 
  using namespace std;
  #endif
  
  int main() {
  atomic_bool b = true;
  }



  $ clang-cl /TC main.cpp
  # works

  $ clang-cl /TP /std:c++20 main.cpp
  
  stdatomic.h(70,6): error: conflicting types for 'atomic_thread_fence'
  void atomic_thread_fence(memory_order);
   ^
  atomic(166,24): note: previous definition is here
  extern "C" inline void atomic_thread_fence(const memory_order _Order) 
noexcept {
  
  ...
  
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.

Many errors but 
`` has many macros to built-in functions.

  #define atomic_thread_fence(order) __c11_atomic_thread_fence(order)

and MSVC `` has real functions.
and the built-in functions are redefined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130419

Files:
  clang/lib/Headers/stdatomic.h


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] D130417: [clang-format] Missing space between trailing return type 'auto' and left brace

2022-07-23 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin created this revision.
denis-fatkulin added reviewers: HazardyKnusperkeks, curdeius.
denis-fatkulin added a project: clang-format.
Herald added a project: All.
denis-fatkulin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There's no a space symbol between  trailing return type `auto` and left brace 
`{`.

The simpliest examles of code to reproduce the issue:

  []() -> auto {}

and

  auto foo() -> auto {}


Repository:
  rG LLVM Github Monorepo

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,12 @@
   verifyFormat("auto lambda = [ = a]() { a = 2; };", AlignStyle);
 }
 
+TEST_F(FormatTest, TrailingReturnTypeAuto) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("[]() -> 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,12 @@
   verifyFormat("auto lambda = [ = a]() { a = 2; };", AlignStyle);
 }
 
+TEST_F(FormatTest, TrailingReturnTypeAuto) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("[]() -> 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] D130299: [clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas

2022-07-23 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin updated this revision to Diff 447052.
denis-fatkulin retitled this revision from "[clang-format] FIX: Misformatting 
lambdas with trailing return type 'auto' in braced lists" to "[clang-format] 
FIX: Misannotation 'auto' as trailing return type in lambdas".
denis-fatkulin edited the summary of this revision.
denis-fatkulin added a comment.

Patch is splitted, as suggested by @HazardyKnusperkeks

This piece of changes is related to misannotation KW 'auto' as trailing return 
type in lambdas. Also, appropriate test is 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
@@ -749,6 +749,13 @@
   EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsTrailingReturnTypeAutoInLabmdas) {
+  auto 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);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
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
@@ -749,6 +749,13 @@
   EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsTrailingReturnTypeAutoInLabmdas) {
+  auto 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);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
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] D130416: [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

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

Update a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130416

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/unicode.c
  clang/www/c_status.html


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx -x c++ -std=c++11 %s
 // RUN: %clang_cc1 -std=c99 -E -DPP_ONLY=1 %s | FileCheck %s 
--strict-whitespace
 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
 
@@ -31,7 +32,7 @@
 extern int X\U; // expected-error {{not allowed in an identifier}}
 int Y = '\U'; // expected-error {{invalid universal character}}
 
-#ifdef __cplusplus
+#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 
202000L)
 
 extern int ༀ;
 extern int ᩐ;
@@ -46,7 +47,8 @@
 
 
 // This character doesn't have the XID_Start property
-extern int  \U00016AC0; // TANGSA DIGIT ZERO  // expected-error {{expected 
unqualified-id}}
+extern int  \U00016AC0; // TANGSA DIGIT ZERO  // cxx-error {{expected 
unqualified-id}} \
+  // c2x-error {{expected 
identifier or '('}}
 
 extern int ; // expected-error {{unexpected character }} \
   expected-warning {{declaration does not declare anything}}
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1462,11 +1462,11 @@
 return false;
   } else if (LangOpts.DollarIdents && '$' == C) {
 return true;
-  } else if (LangOpts.CPlusPlus) {
+  } else if (LangOpts.CPlusPlus || LangOpts.C2x) {
 // A non-leading codepoint must have the XID_Continue property.
 // XIDContinueRanges doesn't contains characters also in XIDStartRanges,
 // so we need to check both tables.
-// '_' doesn't have the XID_Continue property but is allowed in C++.
+// '_' doesn't have the XID_Continue property but is allowed in C an C++.
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 static const llvm::sys::UnicodeCharSet XIDContinueChars(XIDContinueRanges);
 return C == '_' || XIDStartChars.contains(C) ||
@@ -1486,7 +1486,7 @@
   if (LangOpts.AsmPreprocessor) {
 return false;
   }
-  if (LangOpts.CPlusPlus) {
+  if (LangOpts.CPlusPlus || LangOpts.C2x) {
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 // '_' doesn't have the XID_Start property but is allowed in C++.
 return C == '_' || XIDStartChars.contains(C);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,6 +469,7 @@
   support for functions without prototypes, which no longer exist in C2x.
 - Implemented `WG14 N2841 No function declarators without prototypes 
`_
   and `WG14 N2432 Remove support for function definitions with identifier 
lists `_.
+- Implemented `WG14 N2836 Identifier Syntax using Unicode Standard Annex 31 
`_.
 
 C++ Language Changes in Clang
 -


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only 

[PATCH] D130416: [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

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

This implements
N2836 Identifier Syntax using Unicode Standard Annex 31.

The feature was already implemented for C++,
and the semantics are the same.

Unlike C++ there was, afaict, no decision to
backport the feature in older languages mode,
so C17 and earlier are not modified and the
code point tables for these language modes are conserved.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130416

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/unicode.c
  clang/www/c_status.html


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx -x c++ -std=c++11 %s
 // RUN: %clang_cc1 -std=c99 -E -DPP_ONLY=1 %s | FileCheck %s 
--strict-whitespace
 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
 
@@ -31,7 +32,7 @@
 extern int X\U; // expected-error {{not allowed in an identifier}}
 int Y = '\U'; // expected-error {{invalid universal character}}
 
-#ifdef __cplusplus
+#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 
202000L)
 
 extern int ༀ;
 extern int ᩐ;
@@ -46,7 +47,8 @@
 
 
 // This character doesn't have the XID_Start property
-extern int  \U00016AC0; // TANGSA DIGIT ZERO  // expected-error {{expected 
unqualified-id}}
+extern int  \U00016AC0; // TANGSA DIGIT ZERO  // cxx-error {{expected 
unqualified-id}} \
+  // c2x-error {{expected 
identifier or '('}}
 
 extern int ; // expected-error {{unexpected character }} \
   expected-warning {{declaration does not declare anything}}
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1462,7 +1462,7 @@
 return false;
   } else if (LangOpts.DollarIdents && '$' == C) {
 return true;
-  } else if (LangOpts.CPlusPlus) {
+  } else if (LangOpts.CPlusPlus || LangOpts.C2x) {
 // A non-leading codepoint must have the XID_Continue property.
 // XIDContinueRanges doesn't contains characters also in XIDStartRanges,
 // so we need to check both tables.
@@ -1486,7 +1486,7 @@
   if (LangOpts.AsmPreprocessor) {
 return false;
   }
-  if (LangOpts.CPlusPlus) {
+  if (LangOpts.CPlusPlus || LangOpts.C2x) {
 static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
 // '_' doesn't have the XID_Start property but is allowed in C++.
 return C == '_' || XIDStartChars.contains(C);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,6 +469,7 @@
   support for functions without prototypes, which no longer exist in C2x.
 - Implemented `WG14 N2841 No function declarators without prototypes 
`_
   and `WG14 N2432 Remove support for function definitions with identifier 
lists `_.
+- Implemented `WG14 N2836 Identifier Syntax using Unicode Standard Annex 31 
`_.
 
 C++ Language Changes in Clang
 -


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1024,7 +1024,7 @@
 
   Identifier Syntax using Unicode Standard Annex 31
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf;>N2836
-  No
+  Clang 15
 
 
   No function declarators without prototypes
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -x c -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only 

[PATCH] D130415: [Clang] Adjust extension warnings for #warning

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

Update release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130415

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/ext-pp-directive.c


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b 
extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is 
incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards 
before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards 
before C++2b}}
+// pre-cpp2b-compat-warning@-11 {{foo}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,16 @@
   return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
 
 case tok::pp_warning:
-  Diag(Result, diag::ext_pp_warning_directive);
+  if (LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+<< /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive
+  : diag::ext_pp_warning_directive)
+<< /*C2x*/ 0;
+
   return HandleUserDiagnosticDirective(Result, true);
 case tok::pp_ident:
   return HandleIdentSCCSDirective(Result);
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -387,7 +387,15 @@
 def ext_pp_ident_directive : Extension<"#ident is a language extension">;
 def ext_pp_include_next_directive : Extension<
   "#include_next is a language extension">, InGroup;
-def ext_pp_warning_directive : Extension<"#warning is a language extension">;
+
+def ext_pp_warning_directive : Extension<
+  "#warning is a %select{C2x|C++2b}0 extension">;
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<
   "extra tokens at end of #%0 directive">, InGroup;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -262,7 +262,7 @@
 - Added the ``-Wgnu-line-marker`` diagnostic flag (grouped under the ``-Wgnu``
   flag) which is a portability warning about use of GNU linemarker preprocessor
   directives. Fixes `Issue 55067 
`_.
-- Using ``#elifdef`` and ``#elifndef`` that are incompatible with C/C++
+- Using ``#warning``, ``#elifdef`` and ``#elifndef`` that are incompatible 
with C/C++
   standards before C2x/C++2b are now warned via ``-pedantic``. Additionally,
   on such language mode, ``-Wpre-c2x-compat`` and ``-Wpre-c++2b-compat``
   diagnostic flags report a compatibility issue.


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards before C++2b}}
+// 

[PATCH] D130415: [Clang] Adjust extension warnings for #warning

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

Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130415

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/ext-pp-directive.c


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b 
extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is 
incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards 
before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards 
before C++2b}}
+// pre-cpp2b-compat-warning@-11 {{foo}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,16 @@
   return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
 
 case tok::pp_warning:
-  Diag(Result, diag::ext_pp_warning_directive);
+  if (LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+<< /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive
+  : diag::ext_pp_warning_directive)
+<< /*C2x*/ 0;
+
   return HandleUserDiagnosticDirective(Result, true);
 case tok::pp_ident:
   return HandleIdentSCCSDirective(Result);
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -387,7 +387,15 @@
 def ext_pp_ident_directive : Extension<"#ident is a language extension">;
 def ext_pp_include_next_directive : Extension<
   "#include_next is a language extension">, InGroup;
-def ext_pp_warning_directive : Extension<"#warning is a language extension">;
+
+def ext_pp_warning_directive : Extension<
+  "#warning is a %select{C2x|C++2b}0 extension">;
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<
   "extra tokens at end of #%0 directive">, InGroup;


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards before C++2b}}
+// pre-cpp2b-compat-warning@-11 {{foo}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,16 @@
   return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
 
 case tok::pp_warning:
-  Diag(Result, diag::ext_pp_warning_directive);
+  if (LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+<< /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive
+  : diag::ext_pp_warning_directive)
+<< /*C2x*/ 0;
+
   return 

[PATCH] D130415: [Clang] Adjust extension warnings for #warning

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

The #warning directive is standard in C++2b and C2x,
this adjusts the pedantic and extensions warning accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130415

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/ext-pp-directive.c


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b 
extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is 
incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards 
before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards 
before C++2b}}
+// pre-cpp2b-compat-warning@-11 {{foo}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,13 @@
   return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
 
 case tok::pp_warning:
-  Diag(Result, diag::ext_pp_warning_directive);
+  if(LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b ?
+ diag::warn_cxx2b_compat_warning_directive : 
diag::ext_pp_warning_directive) << /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ?
+ diag::warn_c2x_compat_warning_directive : 
diag::ext_pp_warning_directive) << /*C2x*/ 0;
+
   return HandleUserDiagnosticDirective(Result, true);
 case tok::pp_ident:
   return HandleIdentSCCSDirective(Result);
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -387,7 +387,15 @@
 def ext_pp_ident_directive : Extension<"#ident is a language extension">;
 def ext_pp_include_next_directive : Extension<
   "#include_next is a language extension">, InGroup;
-def ext_pp_warning_directive : Extension<"#warning is a language extension">;
+
+def ext_pp_warning_directive : Extension<
+  "#warning is a %select{C2x|C++2b}0 extension">;
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<
   "extra tokens at end of #%0 directive">, InGroup;


Index: clang/test/Preprocessor/ext-pp-directive.c
===
--- clang/test/Preprocessor/ext-pp-directive.c
+++ clang/test/Preprocessor/ext-pp-directive.c
@@ -57,3 +57,16 @@
 // For C++
 // pre-cpp2b-pedantic-warning@-7 {{use of a '#elifndef' directive is a C++2b extension}}
 // pre-cpp2b-compat-warning@-8 {{use of a '#elifndef' directive is incompatible with C++ standards before C++2b}}
+
+#warning foo
+// For C
+// pre-c2x-pedantic-warning@-2 {{#warning is a C2x extension}}
+// pre-c2x-pedantic-warning@-3 {{foo}}
+// pre-c2x-compat-warning@-4 {{#warning is incompatible with C standards before C2x}}
+// pre-c2x-compat-warning@-5 {{foo}}
+
+// For C++
+// pre-cpp2b-pedantic-warning@-8 {{#warning is a C++2b extension}}
+// pre-cpp2b-pedantic-warning@-9 {{foo}}
+// pre-cpp2b-compat-warning@-10 {{#warning is incompatible with C++ standards before C++2b}}
+// pre-cpp2b-compat-warning@-11 {{foo}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,13 @@
   return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
 
 case tok::pp_warning:
-  Diag(Result, diag::ext_pp_warning_directive);
+  if(LangOpts.CPlusPlus)
+Diag(Result, LangOpts.CPlusPlus2b ?
+ diag::warn_cxx2b_compat_warning_directive : diag::ext_pp_warning_directive) << /*C++2b*/ 1;
+  else
+Diag(Result, LangOpts.C2x ?
+ diag::warn_c2x_compat_warning_directive : diag::ext_pp_warning_directive) << /*C2x*/ 0;
+
   return 

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

2022-07-23 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked 2 inline comments as done.
iains added a comment.

it would be good to get this landed before llvm-15 branches..




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.

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


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] D129174: [C++20][Modules] Update ADL to handle basic.lookup.argdep p4 [P1815R2 part 1]

2022-07-23 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 447046.
iains added a comment.

rebased, addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129174

Files:
  clang/include/clang/Sema/Overload.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/basic/basic.link/p10-ex2.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p5-ex2.cpp

Index: clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p5-ex2.cpp
===
--- /dev/null
+++ clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p5-ex2.cpp
@@ -0,0 +1,68 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 M.cpp -emit-module-interface -o M.pcm
+// RUN: %clang_cc1 -std=c++20 N.cpp -emit-module-interface -o N.pcm \
+// RUN:   -fmodule-file=M.pcm
+// RUN: %clang_cc1 -std=c++20 Q.cpp -emit-module-interface -o Q.pcm
+// RUN: %clang_cc1 -std=c++20 Q-impl.cpp -fsyntax-only -fmodule-file=Q.pcm \
+// RUN:   -fmodule-file=N.pcm -verify
+
+//--- M.cpp
+export module M;
+namespace R {
+export struct X {};
+export void f(X);
+} // namespace R
+namespace S {
+export void f(R::X, R::X);
+}
+
+//--- N.cpp
+export module N;
+import M;
+export R::X make();
+namespace R {
+static int g(X);
+}
+export template 
+void apply(T t, U u) {
+  f(t, u);
+  g(t);
+}
+
+//--- Q.cpp
+export module Q;
+
+//--- Q-impl.cpp
+module Q;
+import N;
+
+namespace S {
+struct Z {
+  template  operator T();
+};
+} // namespace S
+void test() {
+  // OK, decltype(x) is R::X in module M
+  auto x = make();
+
+  // error: R and R::f are not visible here
+  R::f(x); // expected-error {{declaration of 'R' must be imported from module 'N' before it is required}}
+  // expected-n...@n.cpp:4 {{declaration here is not visible}}
+  // expected-error@-2 {{no type named 'f' in namespace 'R'}}
+
+  f(x); // Found by [basic.lookup.argdep] / p4.3
+
+  // error: S::f in module M not considered even though S is an associated
+  // namespace, since the entity Z is in a different module from f.
+  f(x, S::Z()); // expected-error {{no matching function for call to 'f'}}
+  // expected-n...@m.cpp:4 {{candidate function not viable: requires 1 argument, but 2 were provided}}
+
+  // error: S::f is visible in instantiation context, but  R::g has internal
+  // linkage and cannot be used outside N.cpp
+  apply(x, S::Z()); // expected-er...@n.cpp:10 {{no matching function for call to 'g'}}
+// expected-note@-1 {{in instantiation of function template specialization 'apply' requested here}}
+}
Index: clang/test/CXX/basic/basic.link/p10-ex2.cpp
===
--- /dev/null
+++ clang/test/CXX/basic/basic.link/p10-ex2.cpp
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 M.cpp -fsyntax-only -DTEST_INTERFACE -verify
+// RUN: %clang_cc1 -std=c++20 M.cpp -emit-module-interface -o M.pcm
+// RUN: %clang_cc1 -std=c++20 useM.cpp -fsyntax-only -fmodule-file=M.pcm -verify
+
+//--- decls.h
+int f(); // #1, attached to the global module
+int g(); // #2, attached to the global module
+
+//--- M.cpp
+module;
+#include "decls.h"
+export module M;
+export using ::f; // OK, does not declare an entity, exports #1
+#if TEST_INTERFACE
+// error: matches #2, but attached to M
+int g(); // expected-error {{declaration of 'g' in module M follows declaration in the global module}}
+// expected-note@decls.h:2 {{previous declaration is here}}
+#endif
+export int h(); // #3
+export int k(); // #4
+
+//--- useM.cpp
+import M;
+// error: matches #3
+static int h(); // expected-error {{static declaration of 'h' follows non-static declaration}}
+// expected-n...@m.cpp:10 {{previous declaration is here}}
+
+// error: matches #4
+int k(); // expected-error {{declaration of 'k' in the global module follows declaration in module M}}
+// expected-n...@m.cpp:11 {{previous declaration is here}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -6400,6 +6400,17 @@
 return;
   }
 
+  // Functions with internal linkage are only viable in the same module unit.
+  if (auto *MF = Function->getOwningModule()) {
+if (getLangOpts().CPlusPlusModules && !MF->isModuleMapModule() &&
+Function->getFormalLinkage() <= Linkage::InternalLinkage &&
+!isModuleUnitOfCurrentTU(MF)) {
+  Candidate.Viable = false;
+  Candidate.FailureKind = ovl_fail_module_mismatched;
+  return;
+}
+  }
+
   if (Function->isMultiVersion() && Function->hasAttr() &&
   !Function->getAttr()->isDefaultVersion()) {
 Candidate.Viable = false;
Index: clang/lib/Sema/SemaLookup.cpp

[PATCH] D129448: [CodeGen][Asan] Emit lifetime intrinsic for bypassed label

2022-07-23 Thread luxufan via Phabricator via cfe-commits
StephenFan added a comment.

In D129448#3669296 , @vitalybuka 
wrote:

> I am not sure what to do with this patch. I really prefer to avoid it to 
> minimize the risk of regressions.
>
> We probably considered/prototyped to insert starts like in this solution then 
> in 2016. But at the time of the solution was a comment by @rsmith 
> https://reviews.llvm.org/D24693#559609
> Even if it works for asan, I still don't know how this patch will affect 
> miss-compiles in other places. Dropping intrinsics completely as is must not 
> miscompile.
>
> If the goal to fix asan, then it's extremely rare case, I measured it on llvm 
> codebase and entire Google code. This is not worth of effort to me.
> Also HWAsan and MTE, which can be considered asan successors, does not even 
> bother to handle allocas with multiple lifetime start.

Ok. I'm just fixing this out of interest, and it doesn't look like it's a rigid 
demand to fix it. If this patch may cause potential regression, I respect your 
decision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129448

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


[PATCH] D130337: [pseudo] Eliminate multiple-specified-types ambiguities using guards

2022-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D130337#3671614 , @hokein wrote:

> If we look at the existing guard implementations, we have a few of these 
> usages:
>
> - in `isFunctionDeclarator`, we enumerate all rules of `noptr_declarator`, 
> `ptr_declarator`, `declarator` ;
> - in `hasExclusiveType`, we enumerate all rules of `decl_specifier`, 
> `simple_type_specifier`, `type_specifier`, `type_specifier_seq` etc;

In both cases, we're enumerating all the rules of *multiple* nonterminals.
To get the compiler to verify exhaustiveness, we'd have to first switch over 
target symbol, then switch over rule ID. I expect this to be both a readability 
and performance hit, so I'm not sure we'll actually do it.
Still, `rule::simple_declaration::decl_specifier_seq__declarator-seq__SEMI` is 
a step up in readability and code-completion IMO. Sent 
https://reviews.llvm.org/D130414


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130337

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


[PATCH] D130414: [pseudo] Reorganize CXX.h enums

2022-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, usaxena95.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.

- Place rules under rule::lhs::rhs__rhs__rhs
- Change mangling of keywords to ALL_CAPS (needed to turn keywords that appear 
alone on RHS into valid identifiers)
- Make enums implicitly convertible to underlying type (though still scoped, 
using alias tricks)

In principle this lets us exhaustively write a switch over all rules of a NT:

  switch ((rule::declarator)N->rule()) {
case rule::declarator::noptr_declarator:
  ...
  }

In practice we don't do this anywhere yet as we're often switching over multiple
nonterminal kinds at once.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130414

Files:
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp

Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -113,15 +113,16 @@
   build(R"bnf(
 _ := declaration
 
-declaration := ptr-declarator ;
+declaration := cv-qualifier ptr-declarator ;
 ptr-declarator := * IDENTIFIER
+cv-qualifier := CONST
 
   )bnf");
   ASSERT_TRUE(Diags.empty());
   EXPECT_EQ(G.mangleRule(ruleFor("declaration")),
-"declaration_0ptr_declarator_1semi");
-  EXPECT_EQ(G.mangleRule(ruleFor("ptr-declarator")),
-"ptr_declarator_0star_1identifier");
+"cv_qualifier__ptr_declarator__semi");
+  EXPECT_EQ(G.mangleRule(ruleFor("ptr-declarator")), "star__identifier");
+  EXPECT_EQ(G.mangleRule(ruleFor("cv-qualifier")), "CONST");
 }
 
 TEST_F(GrammarTest, Diagnostics) {
Index: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
===
--- clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -46,11 +46,11 @@
 }
 
 std::string Grammar::mangleSymbol(SymbolID SID) const {
-  static const char *const TokNames[] = {
+  static std::string *TokNames = new std::string[]{
 #define TOK(X) #X,
-#define KEYWORD(X, Y) #X,
+#define KEYWORD(Keyword, Condition) llvm::StringRef(#Keyword).upper(),
 #include "clang/Basic/TokenKinds.def"
-  nullptr};
+  };
   if (clang::pseudo::isToken(SID))
 return TokNames[clang::pseudo::symbolToToken(SID)];
   std::string Name = symbolName(SID).str();
@@ -61,9 +61,13 @@
 
 std::string Grammar::mangleRule(RuleID RID) const {
   const auto  = lookupRule(RID);
-  std::string MangleName = mangleSymbol(R.Target);
-  for (size_t I = 0; I < R.seq().size(); ++I)
-MangleName += llvm::formatv("_{0}{1}", I, mangleSymbol(R.seq()[I]));
+  std::string MangleName;
+  for (size_t I = 0; I < R.seq().size(); ++I) {
+MangleName += mangleSymbol(R.seq()[I]);
+MangleName.append("__");
+  }
+  MangleName.pop_back();
+  MangleName.pop_back();
   return MangleName;
 }
 
Index: clang-tools-extra/pseudo/lib/cxx/CXX.cpp
===
--- clang-tools-extra/pseudo/lib/cxx/CXX.cpp
+++ clang-tools-extra/pseudo/lib/cxx/CXX.cpp
@@ -111,40 +111,39 @@
 bool isFunctionDeclarator(const ForestNode *Declarator) {
   assert(Declarator->symbol() == (SymbolID)(cxx::Symbol::declarator));
   bool IsFunction = false;
-  using cxx::Rule;
   while (true) {
 // not well-formed code, return the best guess.
 if (Declarator->kind() != ForestNode::Sequence)
   return IsFunction;
 
-switch ((cxx::Rule)Declarator->rule()) {
-case Rule::noptr_declarator_0declarator_id: // reached the bottom
+switch (Declarator->rule()) {
+case rule::noptr_declarator::declarator_id: // reached the bottom
   return IsFunction;
 // *X is a nonfunction (unless X is a function).
-case Rule::ptr_declarator_0ptr_operator_1ptr_declarator:
+case rule::ptr_declarator::ptr_operator__ptr_declarator:
   Declarator = Declarator->elements()[1];
   IsFunction = false;
   continue;
 // X() is a function (unless X is a pointer or similar).
-case Rule::
-declarator_0noptr_declarator_1parameters_and_qualifiers_2trailing_return_type:
-case Rule::noptr_declarator_0noptr_declarator_1parameters_and_qualifiers:
+case rule::declarator::
+noptr_declarator__parameters_and_qualifiers__trailing_return_type:
+case rule::noptr_declarator::noptr_declarator__parameters_and_qualifiers:
   Declarator = Declarator->elements()[0];
   IsFunction = true;
   continue;
 // X[] is an array (unless X is a pointer or function).
-case Rule::
-

[PATCH] D130411: [clang-format] Fix a hang when formatting C# $@ string literals

2022-07-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130411

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -574,6 +574,7 @@
   verifyFormat(R"(string str = @;)", Style);
   verifyFormat(R"(string str = @"""Hello world""";)", Style);
   verifyFormat(R"(string str = $@"""Hello {friend}""";)", Style);
+  verifyFormat(R"(return $@"Foo ""/foo?f={Request.Query["f"]}""";)", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpQuotesInInterpolatedStrings) {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -239,55 +239,6 @@
   if (Tokens.size() < 2)
 return false;
 
-  // Interpolated strings could contain { } with " characters inside.
-  // $"{x ?? "null"}"
-  // should not be split into $"{x ?? ", null, "}" but should treated as a
-  // single string-literal.
-  //
-  // We opt not to try and format expressions inside {} within a C#
-  // interpolated string. Formatting expressions within an interpolated string
-  // would require similar work as that done for JavaScript template strings
-  // in `handleTemplateStrings()`.
-  auto  = *(Tokens.end() - 2);
-  if (CSharpInterpolatedString->getType() == TT_CSharpStringLiteral &&
-  (CSharpInterpolatedString->TokenText.startswith(R"($")") ||
-   CSharpInterpolatedString->TokenText.startswith(R"($@")"))) {
-int UnmatchedOpeningBraceCount = 0;
-
-auto TokenTextSize = CSharpInterpolatedString->TokenText.size();
-for (size_t Index = 0; Index < TokenTextSize; ++Index) {
-  char C = CSharpInterpolatedString->TokenText[Index];
-  if (C == '{') {
-// "{{"  inside an interpolated string is an escaped '{' so skip it.
-if (Index + 1 < TokenTextSize &&
-CSharpInterpolatedString->TokenText[Index + 1] == '{') {
-  ++Index;
-  continue;
-}
-++UnmatchedOpeningBraceCount;
-  } else if (C == '}') {
-// "}}"  inside an interpolated string is an escaped '}' so skip it.
-if (Index + 1 < TokenTextSize &&
-CSharpInterpolatedString->TokenText[Index + 1] == '}') {
-  ++Index;
-  continue;
-}
---UnmatchedOpeningBraceCount;
-  }
-}
-
-if (UnmatchedOpeningBraceCount > 0) {
-  auto  = *(Tokens.end() - 1);
-  CSharpInterpolatedString->TokenText =
-  StringRef(CSharpInterpolatedString->TokenText.begin(),
-NextToken->TokenText.end() -
-CSharpInterpolatedString->TokenText.begin());
-  CSharpInterpolatedString->ColumnWidth += NextToken->ColumnWidth;
-  Tokens.erase(Tokens.end() - 1);
-  return true;
-}
-  }
-
   // Look for @"aa" or $"aa".
   auto  = *(Tokens.end() - 1);
   if (!String->is(tok::string_literal))
@@ -571,45 +522,105 @@
   resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset)));
 }
 
+static auto lexCSharpString(const char *Begin, const char *End, bool Verbatim,
+bool Interpolated) {
+  auto Repeated = [, End]() {
+return Begin + 1 < End && Begin[1] == Begin[0];
+  };
+
+  // Look for a terminating '"' in the current file buffer.
+  // Make no effort to format code within an interpolated or verbatim string.
+  //
+  // Interpolated strings could contain { } with " characters inside.
+  // $"{x ?? "null"}"
+  // should not be split into $"{x ?? ", null, "}" but should treated as a
+  // single string-literal.
+  //
+  // We opt not to try and format expressions inside {} within a C#
+  // interpolated string. Formatting expressions within an interpolated string
+  // would require similar work as that done for JavaScript template strings
+  // in `handleTemplateStrings()`.
+  for (int UnmatchedOpeningBraceCount = 0; Begin < End; ++Begin) {
+switch (*Begin) {
+case '\\':
+  if (!Verbatim)
+++Begin;
+  break;
+case '{':
+  if (Interpolated) {
+// {{ inside an interpolated string is escaped, so skip it.
+if (Repeated())
+  ++Begin;
+else
+  ++UnmatchedOpeningBraceCount;
+  }
+  break;
+case '}':
+  if (Interpolated) {
+// }} inside an interpolated string is escaped, so skip it.
+if (Repeated())
+  ++Begin;
+else if 

[PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D129377#3673237 , @mib wrote:

> In D129377#3673204 , @mstorsjo 
> wrote:
>
>> This broke building of Clang, when it's set up by symlinking 
>> `llvm-project/clang` into `llvm-project/llvm/tools`. In that case, cmake 
>> configure errors out like this:
>>
>>   -- Configuring done 
>>   CMake Error in tools/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt:
>> Target "clangHandleCXX" INTERFACE_INCLUDE_DIRECTORIES property contains
>> path:
>>
>>   
>> "/home/martin/code/llvm-project/llvm/tools/clang/tools/clang-fuzzer/handle-cxx/."
>>  
>>   
>> which is prefixed in the source directory.
>>
>> See e.g. 
>> https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
>>  for some discussion on the issue.
>>
>> Can we revert this commit until this has been sorted out?
>
> @mstorsjo I reverted Chelsea's patch in b797834748f1 
> , since 
> she's offline now. Do you have a link to a bot failure that would help us 
> investigate the issue ?
>
> Thanks!

Thanks!

It’s not on a public buildbot but only in my local continuous builds 
unfortunately - but I’ll have look at the issue myself today - I was running 
out of time yesterday.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

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