================
@@ -129,11 +129,19 @@ std::optional<int> tryExpandAsInteger(StringRef Macro,
const Preprocessor &PP) {
// Parse an integer at the end of the macro definition.
const Token &T = FilteredTokens.back();
- // FIXME: EOF macro token coming from a PCH file on macOS while marked as
- // literal, doesn't contain any literal data
- if (!T.isLiteral() || !T.getLiteralData())
+
+ if (!T.isLiteral())
return std::nullopt;
- StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
+
+ bool InvalidSpelling = false;
+ // `Preprocessor::getSpelling` can get the spelling of the token regardless
of
+ // whether the macro is defined in a PCH or not:
+ std::string Spelling = PP.getSpelling(T, &InvalidSpelling);
----------------
steakhal wrote:
`getSpelling` appears to return StringRef. We could bind this directly to
`ValueStr` and avoid a possible allocation I think.
https://github.com/llvm/llvm-project/pull/142722
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits