================ @@ -979,3 +979,50 @@ Preprocessor::EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro, return EvaluateDirectiveExpression(IfNDefMacro, Tok, EvaluatedDefined, CheckForEoD); } + +static std::optional<CXXStandardLibraryVersionInfo> +getCXXStandardLibraryVersion(Preprocessor &PP, StringRef MacroName, + CXXStandardLibraryVersionInfo::Library Lib) { + MacroInfo *Macro = PP.getMacroInfo(PP.getIdentifierInfo(MacroName)); + + if (!Macro || Macro->getNumTokens() != 1) + return std::nullopt; + + const Token &RevisionDateTok = Macro->getReplacementToken(0); + + bool Invalid = false; + llvm::SmallVector<char, 10> Buffer; + llvm::StringRef RevisionDate = + PP.getSpelling(RevisionDateTok, Buffer, &Invalid); + if (!Invalid) { + unsigned Value; + // We don't use NumericParser to avoid diagnostics + if (!RevisionDate.consumeInteger(10, Value)) + return CXXStandardLibraryVersionInfo{ + CXXStandardLibraryVersionInfo::LibStdCXX, Value}; ---------------- erichkeane wrote:
So it seems weird to me that the `macro name` is sent to this function, and thus could be basically anything, but we set this always to `LibStdCXX`. It seems to me that the 1st part of this should be `Lib`, right? https://github.com/llvm/llvm-project/pull/141977 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits