[clang] 6bbf51f - [Frontend] Move, don't copy the predefines buffer into PP. NFC.
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Sat May 7 16:15:08 PDT 2022
Author: Sam McCall
Date: 2022-05-08T01:04:46+02:00
New Revision: 6bbf51f3ed59ae37f0fec729f25af002111c9e74
URL: https://github.com/llvm/llvm-project/commit/6bbf51f3ed59ae37f0fec729f25af002111c9e74
DIFF: https://github.com/llvm/llvm-project/commit/6bbf51f3ed59ae37f0fec729f25af002111c9e74.diff
LOG: [Frontend] Move, don't copy the predefines buffer into PP. NFC.
It's not trivially small, >10kb.
Added:
Modified:
clang/include/clang/Lex/Preprocessor.h
clang/lib/Frontend/InitPreprocessor.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 3c74b48d19bec..f0070b3ab7c0a 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1280,13 +1280,10 @@ class Preprocessor {
StringRef getLastMacroWithSpelling(SourceLocation Loc,
ArrayRef<TokenValue> Tokens) const;
- const std::string &getPredefines() const { return Predefines; }
-
/// Set the predefines for this Preprocessor.
///
/// These predefines are automatically injected when parsing the main file.
- void setPredefines(const char *P) { Predefines = P; }
- void setPredefines(StringRef P) { Predefines = std::string(P); }
+ void setPredefines(std::string P) { Predefines = std::move(P); }
/// Return information about the specified preprocessor
/// identifier token.
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 847d3667ff37c..3921f7949a0a9 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -1388,5 +1388,5 @@ void clang::InitializePreprocessor(
InitOpts.PrecompiledPreambleBytes.second);
// Copy PredefinedBuffer into the Preprocessor.
- PP.setPredefines(Predefines.str());
+ PP.setPredefines(std::move(PredefineBuffer));
}
More information about the cfe-commits
mailing list