[PATCH] D106416: [analyzer] Fix build dependency issues for SATest

2021-09-25 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 375017.
manas added a comment.

Upgrade cmake to 3.21.3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106416

Files:
  clang/utils/analyzer/Dockerfile


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -17,8 +17,9 @@
 gettext=0.19.8.1* \
 python3=3.6.7-1~18.04 \
 python3-pip=9.0.1-2.3* \
-cmake=3.20.5* \
-ninja-build=1.8.2-1
+cmake=3.21.3* \
+ninja-build=1.8.2-1 \
+ccache=3.4*
 
 # box2d dependencies
 RUN apt-get install -y \


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -17,8 +17,9 @@
 gettext=0.19.8.1* \
 python3=3.6.7-1~18.04 \
 python3-pip=9.0.1-2.3* \
-cmake=3.20.5* \
-ninja-build=1.8.2-1
+cmake=3.21.3* \
+ninja-build=1.8.2-1 \
+ccache=3.4*
 
 # box2d dependencies
 RUN apt-get install -y \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106416: [analyzer] Fix build dependency issues for SATest

2021-09-25 Thread Manas Gupta via Phabricator via cfe-commits
manas added a comment.

@vsavchenko should we land this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106416

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


[PATCH] D110392: [clang-format] Left/Right alignment fixer can cause false positive replacements when they don't actually change anything

2021-09-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 375023.
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.

Address review comment


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

https://reviews.llvm.org/D110392

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -806,5 +806,17 @@
"Foo(unsigned const char *bytes)", Style);
 }
 
+TEST_F(QualifierFixerTest, NoOpQualifierReplacements) {
+
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"static", "const", "type"};
+
+  ReplacementCount = 0;
+  EXPECT_EQ(ReplacementCount, 0);
+  verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  EXPECT_EQ(ReplacementCount, 0);
+}
+
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -67,14 +67,12 @@
 NextStartColumn, LastStartColumn);
   llvm::Optional CurrentCode = None;
   tooling::Replacements Fixes;
-  unsigned Penalty = 0;
   for (size_t I = 0, E = Passes.size(); I < E; ++I) {
 std::pair PassFixes = Passes[I](*Env);
 auto NewCode = applyAllReplacements(
 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first);
 if (NewCode) {
   Fixes = Fixes.merge(PassFixes.first);
-  Penalty += PassFixes.second;
   if (I + 1 < E) {
 CurrentCode = std::move(*NewCode);
 Env = std::make_unique(
@@ -84,7 +82,21 @@
   }
 }
   }
-  return {Fixes, Penalty};
+
+  // Don't make replacements that replace nothing.
+  tooling::Replacements NonNoOpFixes;
+
+  for (auto I = Fixes.begin(), E = Fixes.end(); I != E; ++I) {
+StringRef OriginalCode = Code.substr(I->getOffset(), I->getLength());
+
+if (!OriginalCode.equals(I->getReplacementText())) {
+  auto Err = NonNoOpFixes.add(*I);
+  if (Err)
+llvm::errs() << "Error adding replacements : "
+ << llvm::toString(std::move(Err)) << "\n";
+}
+  }
+  return {NonNoOpFixes, 0};
 }
 
 static void replaceToken(const SourceManager &SourceMgr,


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -806,5 +806,17 @@
"Foo(unsigned const char *bytes)", Style);
 }
 
+TEST_F(QualifierFixerTest, NoOpQualifierReplacements) {
+
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"static", "const", "type"};
+
+  ReplacementCount = 0;
+  EXPECT_EQ(ReplacementCount, 0);
+  verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  EXPECT_EQ(ReplacementCount, 0);
+}
+
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -67,14 +67,12 @@
 NextStartColumn, LastStartColumn);
   llvm::Optional CurrentCode = None;
   tooling::Replacements Fixes;
-  unsigned Penalty = 0;
   for (size_t I = 0, E = Passes.size(); I < E; ++I) {
 std::pair PassFixes = Passes[I](*Env);
 auto NewCode = applyAllReplacements(
 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first);
 if (NewCode) {
   Fixes = Fixes.merge(PassFixes.first);
-  Penalty += PassFixes.second;
   if (I + 1 < E) {
 CurrentCode = std::move(*NewCode);
 Env = std::make_unique(
@@ -84,7 +82,21 @@
   }
 }
   }
-  return {Fixes, Penalty};
+
+  // Don't make replacements that replace nothing.
+  tooling::Replacements NonNoOpFixes;
+
+  for (auto I = Fixes.begin(), E = Fixes.end(); I != E; ++I) {
+StringRef OriginalCode = Code.substr(I->getOffset(), I->getLength());
+
+if (!OriginalCode.equals(I->getReplacementText())) {
+  auto Err = NonNoOpFixes.add(*I);
+  if (Err)
+llvm::errs() << "Error adding replacements : "
+ << llvm::toString(std::move(Err)) << "\n";
+}
+  }
+  return {NonNoOpFixes, 0};
 }
 
 static void replaceToken(const SourceManager &SourceMgr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-25 Thread Markus Böck via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b61f43b6096: [CMake] Consistently use the LibXml2::LibXml2 
target instead of… (authored by zero9178).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

Files:
  clang/tools/c-index-test/CMakeLists.txt
  lldb/source/Host/CMakeLists.txt


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0b61f43 - [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-25 Thread Markus Böck via cfe-commits

Author: Markus Böck
Date: 2021-09-25T13:13:11+02:00
New Revision: 0b61f43b6096a9e98652991cba34e8ad44d35101

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

LOG: [CMake] Consistently use the LibXml2::LibXml2 target instead of 
LIBXML2_LIBRARIES

Linking against the LibXml2::LibXml2 target has the advantage of not only 
importing the library, but also adding the include path as well as any 
definitions the library requires. In case of a static build of libxml2, eg. a 
define is set on Windows to remove any DLL imports and export.

LLVM already makes use of the target, but c-index-test and lldb were still 
linking against the library only.

The workaround for Mac OS-X that I removed seems to have also been made 
redundant since https://reviews.llvm.org/D84563 I believe

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

Added: 


Modified: 
clang/tools/c-index-test/CMakeLists.txt
lldb/source/Host/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/c-index-test/CMakeLists.txt 
b/clang/tools/c-index-test/CMakeLists.txt
index ceef4b08637cc..99c6081db2d63 100644
--- a/clang/tools/c-index-test/CMakeLists.txt
+++ b/clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@ set_target_properties(c-index-test
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)

diff  --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index a018fd6c183dc..c18e8ce004b08 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})



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


[PATCH] D110252: Added note about Whatstyle and Unformat

2021-09-25 Thread Volker Weißmann via Phabricator via cfe-commits
Volker-Weissmann added a comment.

In D110252#3018375 , @MyDeveloperDay 
wrote:

> Whatstyle has not been updated since Dec 2020, is it going to cover the 
> latest style configuration options?

No it doesn't. 
As I wrote, both work on a best-effort basis. I tried them myself, they are far 
from guaranteed to give you the correct .clang-format file. But it's better 
than nothing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110252

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


[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-25 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added inline comments.



Comment at: clang/lib/AST/DeclPrinter.cpp:161-163
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
+else if (const FunctionType *FTy = BaseType->getAs())

dexonsmith wrote:
> Seems unrelated to this commit?
Did it to quiet clang-tidy because I modified this function


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

https://reviews.llvm.org/D110068

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


[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-25 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 375035.
gAlfonso-bit marked an inline comment as done.

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

https://reviews.llvm.org/D110068

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-25 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

In D110068#3013636 , @dexonsmith 
wrote:

> I'm a bit hesitant to trust lack of tests as proof that old FIXMEs can be 
> resolved safely. Can you add some background information about why this was 
> originally a specifier, and why it's safe to fix it now? (If you don't know, 
> I suggest looking through git-blame to figure it out (unless @ahatanak 
> already knows?).)

I did and it was originally put there when the function was made. Not because 
of a bug.


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

https://reviews.llvm.org/D110068

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


[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-25 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

In D110068#3013636 , @dexonsmith 
wrote:

> I'm a bit hesitant to trust lack of tests as proof that old FIXMEs can be 
> resolved safely. Can you add some background information about why this was 
> originally a specifier, and why it's safe to fix it now? (If you don't know, 
> I suggest looking through git-blame to figure it out (unless @ahatanak 
> already knows?).)

This was introduced in 2010, with multiple changes following. The 
ObjCObjectPointer type was at a time before ObjCObject was defined.


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

https://reviews.llvm.org/D110068

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


[PATCH] D110481: fixes bug #51926 where dangling comma caused overrun

2021-09-25 Thread Fred Grim via Phabricator via cfe-commits
feg208 created this revision.
feg208 added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius, klimek, 
djasper, tinloaf.
feg208 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

bug 51926 identified an issue where a dangling comma caused the cell count to 
be to off by one


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110481

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17800,6 +17800,12 @@
 TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) {
   auto Style = getLLVMStyle();
   Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
+  verifyFormat("auto foo = Items{\n"
+   "Section{\n"
+   "0, bar(),\n"
+   "}\n"
+   "};\n",
+   Style);
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"},\n"
"{-1, 93463, \"world\"},\n"
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1146,14 +1146,15 @@
   } else if (C.Tok->is(tok::comma)) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
-Cell++;
+if (C.Tok->Next->isNot(tok::r_brace))
+  Cell++;
   }
 } else if (Depth == 1) {
   if (C.Tok == MatchingParen) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
 Cells.push_back(CellDescription{i, ++Cell, i + 1, false, nullptr});
-CellCount = Cell + 1;
+CellCount = C.Tok->Previous->isNot(tok::comma) ? Cell + 1 : Cell;
 // Go to the next non-comment and ensure there is a break in front
 const auto *NextNonComment = C.Tok->getNextNonComment();
 while (NextNonComment->is(tok::comma))


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17800,6 +17800,12 @@
 TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) {
   auto Style = getLLVMStyle();
   Style.AlignArrayOfStructures = FormatStyle::AIAS_Left;
+  verifyFormat("auto foo = Items{\n"
+   "Section{\n"
+   "0, bar(),\n"
+   "}\n"
+   "};\n",
+   Style);
   verifyFormat("struct test demo[] = {\n"
"{56, 23,\"hello\"},\n"
"{-1, 93463, \"world\"},\n"
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1146,14 +1146,15 @@
   } else if (C.Tok->is(tok::comma)) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
-Cell++;
+if (C.Tok->Next->isNot(tok::r_brace))
+  Cell++;
   }
 } else if (Depth == 1) {
   if (C.Tok == MatchingParen) {
 if (!Cells.empty())
   Cells.back().EndIndex = i;
 Cells.push_back(CellDescription{i, ++Cell, i + 1, false, nullptr});
-CellCount = Cell + 1;
+CellCount = C.Tok->Previous->isNot(tok::comma) ? Cell + 1 : Cell;
 // Go to the next non-comment and ensure there is a break in front
 const auto *NextNonComment = C.Tok->getNextNonComment();
 while (NextNonComment->is(tok::comma))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added subscribers: wenlei, martong.
Herald added a reviewer: shafik.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Modify the IfStmt node to tuppoort constant evaluated expressions.

Add a new ExpressionEvaluationContext::ImmediateFunctionContext to
keep track of immediate function contexts.

This proved easier/better/probably more efficient than
walking the AST backward.
It allows diagnosing nested if consteval statements.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110482

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp

Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++2b %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used
+
+void should_be_used_1();
+void should_be_used_2();
+void should_be_used_3();
+constexpr void should_not_be_used() {}
+
+constexpr void f() {
+  if consteval {
+should_not_be_used();
+  } else {
+should_be_used_1();
+  }
+
+  if !consteval {
+should_be_used_2();
+  }
+
+  if !consteval {
+should_be_used_3();
+  } else {
+should_not_be_used();
+  }
+}
+
+void g() {
+  f();
+}
+
+// CHECK: should_be_used_1
+// CHECK: should_be_used_2
+// CHECK: should_be_used_3
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+void test_consteval() {
+  if consteval (void)
+0; // expected-error {{expected { after consteval}}
+  if consteval {
+(void)0;
+  } else
+(void)0; // expected-error {{expected { after else}}
+
+  static_assert([] {
+if consteval {
+  return 0;
+}
+return 1;
+  }() == 0);
+
+  static_assert([] {
+if consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 0);
+
+  static_assert([] {
+if !consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 1);
+
+  static_assert([] {
+if not consteval {
+  return 0;
+}
+return 1;
+  }() == 1);
+}
+
+void test_consteval_jumps() {
+  if consteval { // expected-note 4{{jump enters controlled statement of if consteval}}
+goto a;
+goto b; // expected-error {{cannot jump from this goto statement to its label}}
+  a:;
+  } else {
+goto b;
+goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  b:;
+  }
+  goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  goto b; // expected-error {{cannot jump from this goto statement to its label}}
+}
+
+void test_consteval_switch() {
+  int x = 42;
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+case 1:;   // expected-error {{cannot jump from switch statement to this case label}}
+default:;  // expected-error {{cannot jump from switch statement to this case label}}
+} else {
+}
+  }
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+} else {
+case 2:;  // expected-error {{cannot jump from switch statement to this case label}}
+default:; // expected-error {{cannot jump from switch statement to this case label}}
+}
+  }
+}
+
+consteval int f(int i) { return i; }
+constexpr int g(int i) {
+  if consteval {
+return f(i);
+  } else {
+return 42;
+  }
+}
+static_assert(g(10) == 10);
+
+constexpr int h(int i) { // expected-note {{declared here}}
+  if !consteval {
+return f(i); // expected-error {{c

[clang] c2ec5dd - [clang-format] Left/Right alignment fixer can cause false positive replacements when they don't actually change anything

2021-09-25 Thread via cfe-commits

Author: mydeveloperday
Date: 2021-09-25T17:35:41+01:00
New Revision: c2ec5dd209532b1d618958ade6a7d550a0c31ea5

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

LOG: [clang-format] Left/Right alignment fixer can cause false positive 
replacements when they don't actually change anything

Earlier during the development of {D69764} I felt it was no longer necessary to
ensure we were not trying to change code which didn't need to change
and we felt this could be removed, however I'd like to bring this back for now
as I am seeing some false positives in terms of the "replacements"

What I see is the generation of a replacement which is a "No Op" on the original
code, I think this comes about because of the merging of replacements:

```
static const a;
->
const static a;
->
static const a;
```

The replacements don't really merge, in such a way as to identify when we have 
gone
back to the original

Also remove the Penalty as I'm not using it (and it became marked as set and no 
used,
I'd rather get rid of it if it means nothing)

I think we need to do this step for now, as many people use the 
--output-replacements-xml
to identify that the file "needs a clang-format"

The same can be seen with the -n or --dry-run option as this uses the 
replacements
to drive the error/warning output.

Reviewed By: HazardyKnusperkeks

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

Added: 


Modified: 
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/QualifierAlignmentFixer.cpp 
b/clang/lib/Format/QualifierAlignmentFixer.cpp
index 4a42442ca24bc..30b199952edbd 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -67,14 +67,12 @@ std::pair 
QualifierAlignmentFixer::analyze(
 NextStartColumn, LastStartColumn);
   llvm::Optional CurrentCode = None;
   tooling::Replacements Fixes;
-  unsigned Penalty = 0;
   for (size_t I = 0, E = Passes.size(); I < E; ++I) {
 std::pair PassFixes = Passes[I](*Env);
 auto NewCode = applyAllReplacements(
 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first);
 if (NewCode) {
   Fixes = Fixes.merge(PassFixes.first);
-  Penalty += PassFixes.second;
   if (I + 1 < E) {
 CurrentCode = std::move(*NewCode);
 Env = std::make_unique(
@@ -84,7 +82,21 @@ std::pair 
QualifierAlignmentFixer::analyze(
   }
 }
   }
-  return {Fixes, Penalty};
+
+  // Don't make replacements that replace nothing.
+  tooling::Replacements NonNoOpFixes;
+
+  for (auto I = Fixes.begin(), E = Fixes.end(); I != E; ++I) {
+StringRef OriginalCode = Code.substr(I->getOffset(), I->getLength());
+
+if (!OriginalCode.equals(I->getReplacementText())) {
+  auto Err = NonNoOpFixes.add(*I);
+  if (Err)
+llvm::errs() << "Error adding replacements : "
+ << llvm::toString(std::move(Err)) << "\n";
+}
+  }
+  return {NonNoOpFixes, 0};
 }
 
 static void replaceToken(const SourceManager &SourceMgr,

diff  --git a/clang/unittests/Format/QualifierFixerTest.cpp 
b/clang/unittests/Format/QualifierFixerTest.cpp
index 0592cef1eaae5..e3d0a9a0e2607 100755
--- a/clang/unittests/Format/QualifierFixerTest.cpp
+++ b/clang/unittests/Format/QualifierFixerTest.cpp
@@ -806,5 +806,17 @@ TEST_F(QualifierFixerTest, UnsignedQualifier) {
"Foo(unsigned const char *bytes)", Style);
 }
 
+TEST_F(QualifierFixerTest, NoOpQualifierReplacements) {
+
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"static", "const", "type"};
+
+  ReplacementCount = 0;
+  EXPECT_EQ(ReplacementCount, 0);
+  verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  EXPECT_EQ(ReplacementCount, 0);
+}
+
 } // namespace format
 } // namespace clang



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


[PATCH] D110392: [clang-format] Left/Right alignment fixer can cause false positive replacements when they don't actually change anything

2021-09-25 Thread MyDeveloperDay 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 rGc2ec5dd20953: [clang-format] Left/Right alignment fixer can 
cause false positive replacements… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110392

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -806,5 +806,17 @@
"Foo(unsigned const char *bytes)", Style);
 }
 
+TEST_F(QualifierFixerTest, NoOpQualifierReplacements) {
+
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"static", "const", "type"};
+
+  ReplacementCount = 0;
+  EXPECT_EQ(ReplacementCount, 0);
+  verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  EXPECT_EQ(ReplacementCount, 0);
+}
+
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -67,14 +67,12 @@
 NextStartColumn, LastStartColumn);
   llvm::Optional CurrentCode = None;
   tooling::Replacements Fixes;
-  unsigned Penalty = 0;
   for (size_t I = 0, E = Passes.size(); I < E; ++I) {
 std::pair PassFixes = Passes[I](*Env);
 auto NewCode = applyAllReplacements(
 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first);
 if (NewCode) {
   Fixes = Fixes.merge(PassFixes.first);
-  Penalty += PassFixes.second;
   if (I + 1 < E) {
 CurrentCode = std::move(*NewCode);
 Env = std::make_unique(
@@ -84,7 +82,21 @@
   }
 }
   }
-  return {Fixes, Penalty};
+
+  // Don't make replacements that replace nothing.
+  tooling::Replacements NonNoOpFixes;
+
+  for (auto I = Fixes.begin(), E = Fixes.end(); I != E; ++I) {
+StringRef OriginalCode = Code.substr(I->getOffset(), I->getLength());
+
+if (!OriginalCode.equals(I->getReplacementText())) {
+  auto Err = NonNoOpFixes.add(*I);
+  if (Err)
+llvm::errs() << "Error adding replacements : "
+ << llvm::toString(std::move(Err)) << "\n";
+}
+  }
+  return {NonNoOpFixes, 0};
 }
 
 static void replaceToken(const SourceManager &SourceMgr,


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -806,5 +806,17 @@
"Foo(unsigned const char *bytes)", Style);
 }
 
+TEST_F(QualifierFixerTest, NoOpQualifierReplacements) {
+
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"static", "const", "type"};
+
+  ReplacementCount = 0;
+  EXPECT_EQ(ReplacementCount, 0);
+  verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  EXPECT_EQ(ReplacementCount, 0);
+}
+
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -67,14 +67,12 @@
 NextStartColumn, LastStartColumn);
   llvm::Optional CurrentCode = None;
   tooling::Replacements Fixes;
-  unsigned Penalty = 0;
   for (size_t I = 0, E = Passes.size(); I < E; ++I) {
 std::pair PassFixes = Passes[I](*Env);
 auto NewCode = applyAllReplacements(
 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first);
 if (NewCode) {
   Fixes = Fixes.merge(PassFixes.first);
-  Penalty += PassFixes.second;
   if (I + 1 < E) {
 CurrentCode = std::move(*NewCode);
 Env = std::make_unique(
@@ -84,7 +82,21 @@
   }
 }
   }
-  return {Fixes, Penalty};
+
+  // Don't make replacements that replace nothing.
+  tooling::Replacements NonNoOpFixes;
+
+  for (auto I = Fixes.begin(), E = Fixes.end(); I != E; ++I) {
+StringRef OriginalCode = Code.substr(I->getOffset(), I->getLength());
+
+if (!OriginalCode.equals(I->getReplacementText())) {
+  auto Err = NonNoOpFixes.add(*I);
+  if (Err)
+llvm::errs() << "Error adding replacements : "
+ << llvm::toString(std::move(Err)) << "\n";
+}
+  }
+  return {NonNoOpFixes, 0};
 }
 
 static void replaceToken(const SourceManager &SourceMgr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375045.
cor3ntin added a comment.

Remove untested clang-format changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp

Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++2b %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used
+
+void should_be_used_1();
+void should_be_used_2();
+void should_be_used_3();
+constexpr void should_not_be_used() {}
+
+constexpr void f() {
+  if consteval {
+should_not_be_used();
+  } else {
+should_be_used_1();
+  }
+
+  if !consteval {
+should_be_used_2();
+  }
+
+  if !consteval {
+should_be_used_3();
+  } else {
+should_not_be_used();
+  }
+}
+
+void g() {
+  f();
+}
+
+// CHECK: should_be_used_1
+// CHECK: should_be_used_2
+// CHECK: should_be_used_3
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+void test_consteval() {
+  if consteval (void)
+0; // expected-error {{expected { after consteval}}
+  if consteval {
+(void)0;
+  } else
+(void)0; // expected-error {{expected { after else}}
+
+  static_assert([] {
+if consteval {
+  return 0;
+}
+return 1;
+  }() == 0);
+
+  static_assert([] {
+if consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 0);
+
+  static_assert([] {
+if !consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 1);
+
+  static_assert([] {
+if not consteval {
+  return 0;
+}
+return 1;
+  }() == 1);
+}
+
+void test_consteval_jumps() {
+  if consteval { // expected-note 4{{jump enters controlled statement of if consteval}}
+goto a;
+goto b; // expected-error {{cannot jump from this goto statement to its label}}
+  a:;
+  } else {
+goto b;
+goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  b:;
+  }
+  goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  goto b; // expected-error {{cannot jump from this goto statement to its label}}
+}
+
+void test_consteval_switch() {
+  int x = 42;
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+case 1:;   // expected-error {{cannot jump from switch statement to this case label}}
+default:;  // expected-error {{cannot jump from switch statement to this case label}}
+} else {
+}
+  }
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+} else {
+case 2:;  // expected-error {{cannot jump from switch statement to this case label}}
+default:; // expected-error {{cannot jump from switch statement to this case label}}
+}
+  }
+}
+
+consteval int f(int i) { return i; }
+constexpr int g(int i) {
+  if consteval {
+return f(i);
+  } else {
+return 42;
+  }
+}
+static_assert(g(10) == 10);
+
+constexpr int h(int i) { // expected-note {{declared here}}
+  if !consteval {
+return f(i); // expected-error {{call to consteval function 'f' is not a constant expression}}\
+ // expected-note  {{cannot be used in a constant expression}}
+  }
+  return 0;
+}
+
+consteval void warn_in_consteval() {
+  if consteval { // expected-warning {{if consteval is always true in an immediate context}}
+if consteval {
+} // expected-warning {{if consteval is always true in an immediate context}}
+  }
+}
+
+constexpr void warn_in_consteval2() {
+  if consteval {
+ 

[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375046.
cor3ntin added a comment.

Fix tests formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp

Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++2b %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used
+
+void should_be_used_1();
+void should_be_used_2();
+void should_be_used_3();
+constexpr void should_not_be_used() {}
+
+constexpr void f() {
+  if consteval {
+should_not_be_used();
+  } else {
+should_be_used_1();
+  }
+
+  if !consteval {
+should_be_used_2();
+  }
+
+  if !consteval {
+should_be_used_3();
+  } else {
+should_not_be_used();
+  }
+}
+
+void g() {
+  f();
+}
+
+// CHECK: should_be_used_1
+// CHECK: should_be_used_2
+// CHECK: should_be_used_3
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+void test_consteval() {
+  if consteval // expected-error {{expected { after consteval}}
+(void) 0;
+  if consteval {
+(void)0;
+  } else (void)0; // expected-error {{expected { after else}}
+
+  static_assert([] {
+if consteval {
+  return 0;
+}
+return 1;
+  }() == 0);
+
+  static_assert([] {
+if consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 0);
+
+  static_assert([] {
+if !consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 1);
+
+  static_assert([] {
+if not consteval {
+  return 0;
+}
+return 1;
+  }() == 1);
+}
+
+void test_consteval_jumps() {
+  if consteval { // expected-note 4{{jump enters controlled statement of if consteval}}
+goto a;
+goto b; // expected-error {{cannot jump from this goto statement to its label}}
+  a:;
+  } else {
+goto b;
+goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  b:;
+  }
+  goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  goto b; // expected-error {{cannot jump from this goto statement to its label}}
+}
+
+void test_consteval_switch() {
+  int x = 42;
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+case 1:;   // expected-error {{cannot jump from switch statement to this case label}}
+default:;  // expected-error {{cannot jump from switch statement to this case label}}
+} else {
+}
+  }
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+} else {
+case 2:;  // expected-error {{cannot jump from switch statement to this case label}}
+default:; // expected-error {{cannot jump from switch statement to this case label}}
+}
+  }
+}
+
+consteval int f(int i) { return i; }
+constexpr int g(int i) {
+  if consteval {
+return f(i);
+  } else {
+return 42;
+  }
+}
+static_assert(g(10) == 10);
+
+constexpr int h(int i) { // expected-note {{declared here}}
+  if !consteval {
+return f(i); // expected-error {{call to consteval function 'f' is not a constant expression}}\
+ // expected-note  {{cannot be used in a constant expression}}
+  }
+  return 0;
+}
+
+consteval void warn_in_consteval() {
+  if consteval { // expected-warning {{if consteval is always true in an immediate context}}
+if consteval {} // expected-warning {{if consteval is always true in an immediate context}}
+  }
+}
+
+constexpr void warn_in_consteval2() {
+  if consteval {
+if consteval {} // expec

[PATCH] D110484: [clang-repl] Allow loading of plugins in clang-repl.

2021-09-25 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: rsmith, teemperor, sgraenitz, john.brawn, klimek, 
bkramer.
Herald added a subscriber: mgorny.
v.g.vassilev requested review of this revision.

https://reviews.llvm.org/D110484

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/tools/clang-repl/CMakeLists.txt
  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
@@ -80,6 +80,9 @@
   llvm::install_fatal_error_handler(LLVMErrorHandler,
 static_cast(&CI->getDiagnostics()));
 
+  // Load any requested plugins.
+  CI->LoadRequestedPlugins();
+
   auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
   for (const std::string &input : OptInputs) {
 if (auto Err = Interp->ParseAndExecute(input))
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -16,3 +16,8 @@
   clangInterpreter
   clangTooling
   )
+
+# Support plugins.
+if(CLANG_PLUGIN_SUPPORT)
+  export_executable_symbols_for_plugins(clang-repl)
+endif()
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -65,6 +65,8 @@
   case frontend::ParseSyntaxOnly:
 Act = CreateFrontendAction(CI);
 break;
+  case frontend::PluginAction:
+LLVM_FALLTHROUGH;
   case frontend::EmitAssembly:
 LLVM_FALLTHROUGH;
   case frontend::EmitObj:
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -203,24 +203,7 @@
 return true;
   }
 
-  // Load any requested plugins.
-  for (const std::string &Path : Clang->getFrontendOpts().Plugins) {
-std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
-  Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
-<< Path << Error;
-  }
-
-  // Check if any of the loaded plugins replaces the main AST action
-  for (const FrontendPluginRegistry::entry &Plugin :
-   FrontendPluginRegistry::entries()) {
-std::unique_ptr P(Plugin.instantiate());
-if (P->getActionType() == PluginASTAction::ReplaceAction) {
-  Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
-  Clang->getFrontendOpts().ActionName = Plugin.getName().str();
-  break;
-}
-  }
+  Clang->LoadRequestedPlugins();
 
   // Honor -mllvm.
   //
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -23,6 +23,7 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Frontend/LogDiagnosticPrinter.h"
 #include "clang/Frontend/SerializedDiagnosticPrinter.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -1029,6 +1030,27 @@
   return !getDiagnostics().getClient()->getNumErrors();
 }
 
+void CompilerInstance::LoadRequestedPlugins() {
+  // Load any requested plugins.
+  for (const std::string &Path : getFrontendOpts().Plugins) {
+std::string Error;
+if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
+  getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
+  << Path << Error;
+  }
+
+  // Check if any of the loaded plugins replaces the main AST action
+  for (const FrontendPluginRegistry::entry &Plugin :
+   FrontendPluginRegistry::entries()) {
+std::unique_ptr P(Plugin.instantiate());
+if (P->getActionType() == PluginASTAction::ReplaceAction) {
+  getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
+  getFrontendOpts().ActionName = Plugin.getName().str();
+  break;
+}
+  }
+}
+
 /// Determine the appropriate source input kind based on language
 /// options.
 static Language getLanguageFromOptions(const LangOptions &LangOpts) {
Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -219,6 +219,8 @@
   // of the context or else not Com

[PATCH] D110484: [clang-repl] Allow loading of plugins in clang-repl.

2021-09-25 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 375050.
v.g.vassilev added a comment.

add forgotten test file


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

https://reviews.llvm.org/D110484

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/test/Interpreter/plugins.cpp
  clang/tools/clang-repl/CMakeLists.txt
  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
@@ -80,6 +80,9 @@
   llvm::install_fatal_error_handler(LLVMErrorHandler,
 static_cast(&CI->getDiagnostics()));
 
+  // Load any requested plugins.
+  CI->LoadRequestedPlugins();
+
   auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
   for (const std::string &input : OptInputs) {
 if (auto Err = Interp->ParseAndExecute(input))
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -16,3 +16,8 @@
   clangInterpreter
   clangTooling
   )
+
+# Support plugins.
+if(CLANG_PLUGIN_SUPPORT)
+  export_executable_symbols_for_plugins(clang-repl)
+endif()
Index: clang/test/Interpreter/plugins.cpp
===
--- /dev/null
+++ clang/test/Interpreter/plugins.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-repl -Xcc -Xclang -Xcc -load -Xcc -Xclang \
+// RUN:-Xcc %llvmshlibdir/PrintFunctionNames%pluginext -Xcc -Xclang\
+// RUN:-Xcc -add-plugin -Xcc -Xclang -Xcc print-fns 'int i = 10;' \
+// RUN:'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' 2>&1 | FileCheck %s
+// REQUIRES: host-supports-jit, plugins, examples
+// CHECK: top-level-decl: "i"
+// CHECK-NEXT: top-level-decl: "r1"
+// CHECK-NEXT: i = 10
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -65,6 +65,8 @@
   case frontend::ParseSyntaxOnly:
 Act = CreateFrontendAction(CI);
 break;
+  case frontend::PluginAction:
+LLVM_FALLTHROUGH;
   case frontend::EmitAssembly:
 LLVM_FALLTHROUGH;
   case frontend::EmitObj:
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -203,24 +203,7 @@
 return true;
   }
 
-  // Load any requested plugins.
-  for (const std::string &Path : Clang->getFrontendOpts().Plugins) {
-std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
-  Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
-<< Path << Error;
-  }
-
-  // Check if any of the loaded plugins replaces the main AST action
-  for (const FrontendPluginRegistry::entry &Plugin :
-   FrontendPluginRegistry::entries()) {
-std::unique_ptr P(Plugin.instantiate());
-if (P->getActionType() == PluginASTAction::ReplaceAction) {
-  Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
-  Clang->getFrontendOpts().ActionName = Plugin.getName().str();
-  break;
-}
-  }
+  Clang->LoadRequestedPlugins();
 
   // Honor -mllvm.
   //
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -23,6 +23,7 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Frontend/LogDiagnosticPrinter.h"
 #include "clang/Frontend/SerializedDiagnosticPrinter.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -1029,6 +1030,27 @@
   return !getDiagnostics().getClient()->getNumErrors();
 }
 
+void CompilerInstance::LoadRequestedPlugins() {
+  // Load any requested plugins.
+  for (const std::string &Path : getFrontendOpts().Plugins) {
+std::string Error;
+if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
+  getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
+  << Path << Error;
+  }
+
+  // Check if any of the loaded plugins replaces the main AST action
+  for (const FrontendPluginRegistry::entry &Plugin :
+   FrontendPluginRegistry::entries()) {
+std::unique_ptr P(Plug

[PATCH] D110481: fixes bug #51926 where dangling comma caused overrun

2021-09-25 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:17805
+   "Section{\n"
+   "0, bar(),\n"
+   "}\n"

Here is no alignment, maybe add another case with another line?

What happens if one line has the trailing comma and the next doesn't?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110481

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


[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375064.
cor3ntin added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp

Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++2b %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used
+
+void should_be_used_1();
+void should_be_used_2();
+void should_be_used_3();
+constexpr void should_not_be_used() {}
+
+constexpr void f() {
+  if consteval {
+should_not_be_used();
+  } else {
+should_be_used_1();
+  }
+
+  if !consteval {
+should_be_used_2();
+  }
+
+  if !consteval {
+should_be_used_3();
+  } else {
+should_not_be_used();
+  }
+}
+
+void g() {
+  f();
+}
+
+// CHECK: should_be_used_1
+// CHECK: should_be_used_2
+// CHECK: should_be_used_3
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+void test_consteval() {
+  if consteval // expected-error {{expected { after consteval}}
+(void) 0;
+  if consteval {
+(void)0;
+  } else (void)0; // expected-error {{expected { after else}}
+
+  static_assert([] {
+if consteval {
+  return 0;
+}
+return 1;
+  }() == 0);
+
+  static_assert([] {
+if consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 0);
+
+  static_assert([] {
+if !consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 1);
+
+  static_assert([] {
+if not consteval {
+  return 0;
+}
+return 1;
+  }() == 1);
+}
+
+void test_consteval_jumps() {
+  if consteval { // expected-note 4{{jump enters controlled statement of if consteval}}
+goto a;
+goto b; // expected-error {{cannot jump from this goto statement to its label}}
+  a:;
+  } else {
+goto b;
+goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  b:;
+  }
+  goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  goto b; // expected-error {{cannot jump from this goto statement to its label}}
+}
+
+void test_consteval_switch() {
+  int x = 42;
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+case 1:;   // expected-error {{cannot jump from switch statement to this case label}}
+default:;  // expected-error {{cannot jump from switch statement to this case label}}
+} else {
+}
+  }
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+} else {
+case 2:;  // expected-error {{cannot jump from switch statement to this case label}}
+default:; // expected-error {{cannot jump from switch statement to this case label}}
+}
+  }
+}
+
+consteval int f(int i) { return i; }
+constexpr int g(int i) {
+  if consteval {
+return f(i);
+  } else {
+return 42;
+  }
+}
+static_assert(g(10) == 10);
+
+constexpr int h(int i) { // expected-note {{declared here}}
+  if !consteval {
+return f(i); // expected-error {{call to consteval function 'f' is not a constant expression}}\
+ // expected-note  {{cannot be used in a constant expression}}
+  }
+  return 0;
+}
+
+consteval void warn_in_consteval() {
+  if consteval { // expected-warning {{if consteval is always true in an immediate context}}
+if consteval {} // expected-warning {{if consteval is always true in an immediate context}}
+  }
+}
+
+constexpr void warn_in_consteval2() {
+  if consteval {
+if consteval {} // expected-warning {{

[PATCH] D110482: [clang] Implement if consteval (P1938)

2021-09-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 375065.
cor3ntin added a comment.

Update cxx_status.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110482

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
  clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1289,7 +1289,7 @@
 
   if consteval
   https://wg21.link/P1938R3";>P1938R3
-  No
+  Clang 14
 
 
   Allow duplicate attributes
Index: clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2b-consteval-if.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++2b %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used
+
+void should_be_used_1();
+void should_be_used_2();
+void should_be_used_3();
+constexpr void should_not_be_used() {}
+
+constexpr void f() {
+  if consteval {
+should_not_be_used();
+  } else {
+should_be_used_1();
+  }
+
+  if !consteval {
+should_be_used_2();
+  }
+
+  if !consteval {
+should_be_used_3();
+  } else {
+should_not_be_used();
+  }
+}
+
+void g() {
+  f();
+}
+
+// CHECK: should_be_used_1
+// CHECK: should_be_used_2
+// CHECK: should_be_used_3
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+void test_consteval() {
+  if consteval // expected-error {{expected { after consteval}}
+(void) 0;
+  if consteval {
+(void)0;
+  } else (void)0; // expected-error {{expected { after else}}
+
+  static_assert([] {
+if consteval {
+  return 0;
+}
+return 1;
+  }() == 0);
+
+  static_assert([] {
+if consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 0);
+
+  static_assert([] {
+if !consteval {
+  return 0;
+} else {
+  return 1;
+}
+  }() == 1);
+
+  static_assert([] {
+if not consteval {
+  return 0;
+}
+return 1;
+  }() == 1);
+}
+
+void test_consteval_jumps() {
+  if consteval { // expected-note 4{{jump enters controlled statement of if consteval}}
+goto a;
+goto b; // expected-error {{cannot jump from this goto statement to its label}}
+  a:;
+  } else {
+goto b;
+goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  b:;
+  }
+  goto a; // expected-error {{cannot jump from this goto statement to its label}}
+  goto b; // expected-error {{cannot jump from this goto statement to its label}}
+}
+
+void test_consteval_switch() {
+  int x = 42;
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+case 1:;   // expected-error {{cannot jump from switch statement to this case label}}
+default:;  // expected-error {{cannot jump from switch statement to this case label}}
+} else {
+}
+  }
+  switch (x) {
+if consteval { // expected-note 2{{jump enters controlled statement of if consteval}}
+} else {
+case 2:;  // expected-error {{cannot jump from switch statement to this case label}}
+default:; // expected-error {{cannot jump from switch statement to this case label}}
+}
+  }
+}
+
+consteval int f(int i) { return i; }
+constexpr int g(int i) {
+  if consteval {
+return f(i);
+  } else {
+return 42;
+  }
+}
+static_assert(g(10) == 10);
+
+constexpr int h(int i) { // expected-note {{declared here}}
+  if !consteval {
+return f(i); // expected-error {{call to consteval function 'f' is not a constant expression}}\
+ // expected-note  {{cannot be used in a constant express

[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-09-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Repeating my question from an earlier comment: would a header glob list 
(similar to how the format of the `-checks=` flag) be enough for the use cases 
folks have? On the one hand glob list doesn't support all the features of 
regular expressions, but are they all useful for matching paths? Glob list in 
clang-tidy currently supports set union (similar to regex `|`) and  - `*` (regex `.*`). If needed, the support can be expanded with 
`?`, character classes, character ranges and/or other features of POSIX globs 
(https://man7.org/linux/man-pages/man7/glob.7.html). On the flipside, glob list 
has a cleaner syntax (no need to quote characters common in paths - like `.`), 
and allows to easily express exclusion of subsets. It should be a convenient 
tool to represent a set of files / directories. In comparison to the proposed 
header-filter + exclude-header-filter glob list makes it possible to naturally 
express restrictions similar to "everything under a/ (except for everything 
under a/b/ (except for everything under a/b/c/))" - `a/,-a/b/,a/b/c/`.

What do folks think?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[PATCH] D110481: fixes bug #51926 where dangling comma caused overrun

2021-09-25 Thread Fred Grim via Phabricator via cfe-commits
feg208 added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:17805
+   "Section{\n"
+   "0, bar(),\n"
+   "}\n"

HazardyKnusperkeks wrote:
> Here is no alignment, maybe add another case with another line?
> 
> What happens if one line has the trailing comma and the next doesn't?
yesh this is pretty ugly. In the second case it crashes. This isn't going to be 
fixed for a bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110481

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


[PATCH] D93817: [InstCombine] Update transformations to use poison for insertelement/shufflevector's placeholder value (2/2)

2021-09-25 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune abandoned this revision.
aqjune added a comment.

I abandon this patch because (1) shufflevector parts are covered in D110226 
, D110227 , 
D110230 , and (2) insertelement parts will be 
covered in upcoming new patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93817

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


[PATCH] D94380: [InstCombine] Update transformations to use poison for insertelement/shufflevector's placeholder value (1/2)

2021-09-25 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune abandoned this revision.
aqjune added a comment.

I abandon this patch because (1) shufflevector parts are covered in D110226 
, D110227 , 
D110230 , and (2) insertelement parts will be 
covered in upcoming new patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94380

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


Maintenance works in LLVM Lab today at 11:00 PM PDT

2021-09-25 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM Lab and the build bot will be unavailable today, September 25th, for
about 30 minutes starting from 11:00 PM PDT due to some maintenance work.

Thank you for your understanding and patience.

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