[PATCH] D147615: [clang][Sema][NFC] Save token name instead of the full token
This revision was automatically updated to reflect the committed changes. Closed by commit rG11ad7d2935af: [clang][Sema][NFC] Save token name instead of the full token (authored by tbaeder). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147615/new/ https://reviews.llvm.org/D147615 Files: clang/lib/Parse/ParseDeclCXX.cpp Index: clang/lib/Parse/ParseDeclCXX.cpp === --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -958,8 +958,8 @@ 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 @@ 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(), Index: clang/lib/Parse/ParseDeclCXX.cpp === --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -958,8 +958,8 @@ 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 @@ 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(), ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147615: [clang][Sema][NFC] Save token name instead of the full token
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! There shouldn't be any lifetime issues from this, as @shafik pointed out, the pointer originates in a static array defined in `TokenKinds.cpp`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147615/new/ https://reviews.llvm.org/D147615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147615: [clang][Sema][NFC] Save token name instead of the full token
shafik added inline comments. Comment at: clang/lib/Parse/ParseDeclCXX.cpp:962 + // Save the token name used for static assertion. + const char *TokName = Tok.getName(); It looks like this comes from a static array so it should be fine but let's see what Aaron says. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147615/new/ https://reviews.llvm.org/D147615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147615: [clang][Sema][NFC] Save token name instead of the full token
tbaeder created this revision. tbaeder added a reviewer: aaron.ballman. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. This makes it a bit clearer why we're saving the token (so no need for the later comment). I'm just not 100% sure about the lifetime of the token name. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D147615 Files: clang/lib/Parse/ParseDeclCXX.cpp Index: clang/lib/Parse/ParseDeclCXX.cpp === --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -958,8 +958,8 @@ 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 @@ 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(), Index: clang/lib/Parse/ParseDeclCXX.cpp === --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -958,8 +958,8 @@ 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 @@ 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(), ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits