From 6bbf51f3ed59ae37f0fec729f25af002111c9e74 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Sun, 8 May 2022 01:03:35 +0200 Subject: [PATCH] [Frontend] Move, don't copy the predefines buffer into PP. NFC. It's not trivially small, >10kb. --- clang/include/clang/Lex/Preprocessor.h | 5 +---- clang/lib/Frontend/InitPreprocessor.cpp | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 3c74b48d1..f0070b3 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -1280,13 +1280,10 @@ public: StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef 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 847d366..3921f79 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)); } -- 2.7.4