[clang] [Clang][Parse] Fix ambiguity with nested-name-specifiers that may declarative (PR #96364)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 23 04:23:19 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 177ce1900f0de05337f744edd3f4e454f7a93b06 140ee8f42dde356ffe95c0fefd54dcde441be319 --extensions cpp,h -- clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp clang/include/clang/Lex/Preprocessor.h clang/include/clang/Parse/Parser.h clang/lib/Lex/PPCaching.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Parse/ParseCXXInlineMethods.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseExprCXX.cpp clang/test/CXX/temp/temp.res/p3.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Lex/PPCaching.cpp b/clang/lib/Lex/PPCaching.cpp
index cf688a9705..0695f3cf02 100644
--- a/clang/lib/Lex/PPCaching.cpp
+++ b/clang/lib/Lex/PPCaching.cpp
@@ -14,11 +14,11 @@
 #include "clang/Lex/Preprocessor.h"
 using namespace clang;
 
- std::pair<std::size_t, bool> Preprocessor::LastBacktrackPos() {
-   assert(isBacktrackEnabled());
-   auto BacktrackPos = BacktrackPositions.back();
-   return {std::abs(BacktrackPos), BacktrackPos < 0};
- }
+std::pair<std::size_t, bool> Preprocessor::LastBacktrackPos() {
+  assert(isBacktrackEnabled());
+  auto BacktrackPos = BacktrackPositions.back();
+  return {std::abs(BacktrackPos), BacktrackPos < 0};
+}
 
 // EnableBacktrackAtThisPos - From the point that this method is called, and
 // until CommitBacktrackedTokens() or Backtrack() is called, the Preprocessor
@@ -51,8 +51,7 @@ Preprocessor::CachedTokensTy Preprocessor::PopUnannotatedBacktrackTokens() {
 
 // Disable the last EnableBacktrackAtThisPos call.
 void Preprocessor::CommitBacktrackedTokens() {
-  assert(isBacktrackEnabled()
-         && "EnableBacktrackAtThisPos was not called!");
+  assert(isBacktrackEnabled() && "EnableBacktrackAtThisPos was not called!");
   auto [BacktrackPos, Unannotated] = LastBacktrackPos();
   BacktrackPositions.pop_back();
   if (Unannotated)
@@ -62,8 +61,7 @@ void Preprocessor::CommitBacktrackedTokens() {
 // Make Preprocessor re-lex the tokens that were lexed since
 // EnableBacktrackAtThisPos() was previously called.
 void Preprocessor::Backtrack() {
-  assert(isBacktrackEnabled()
-         && "EnableBacktrackAtThisPos was not called!");
+  assert(isBacktrackEnabled() && "EnableBacktrackAtThisPos was not called!");
   auto [BacktrackPos, Unannotated] = LastBacktrackPos();
   BacktrackPositions.pop_back();
   CachedLexPos = BacktrackPos;
@@ -155,8 +153,7 @@ void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
   for (CachedTokensTy::size_type i = CachedLexPos; i != 0; --i) {
     CachedTokensTy::iterator AnnotBegin = CachedTokens.begin() + i-1;
     if (AnnotBegin->getLocation() == Tok.getLocation()) {
-      assert((!isBacktrackEnabled() ||
-              LastBacktrackPos().first <= i) &&
+      assert((!isBacktrackEnabled() || LastBacktrackPos().first <= i) &&
              "The backtrack pos points inside the annotated tokens!");
       // Replace the cached tokens with the single annotation token.
       if (i < CachedLexPos)

``````````

</details>


https://github.com/llvm/llvm-project/pull/96364


More information about the cfe-commits mailing list