[clang][Sema][NFC] Save token name instead of the full token
authorTimm Bäder <tbaeder@redhat.com>
Wed, 5 Apr 2023 11:46:11 +0000 (13:46 +0200)
committerTimm Bäder <tbaeder@redhat.com>
Sat, 8 Apr 2023 07:02:19 +0000 (09:02 +0200)
Differential Revision: https://reviews.llvm.org/D147615

clang/lib/Parse/ParseDeclCXX.cpp

index 037bc86..1530d82 100644 (file)
@@ -958,8 +958,8 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd) {
   assert(Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
          "Not a static_assert declaration");
 
-  // Save the token used for static assertion.
-  Token SavedTok = Tok;
+  // Save the token name used for static assertion.
+  const char *TokName = Tok.getName();
 
   if (Tok.is(tok::kw__Static_assert) && !getLangOpts().C11)
     Diag(Tok, diag::ext_c11_feature) << Tok.getName();
@@ -1027,9 +1027,7 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd) {
   T.consumeClose();
 
   DeclEnd = Tok.getLocation();
-  // Passing the token used to the error message.
-  ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert,
-                       SavedTok.getName());
+  ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
 
   return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, AssertExpr.get(),
                                               AssertMessage.get(),