aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2009-12-31 15:33:09 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2009-12-31 15:33:09 +0000
commitffd6e39006a7177c4c537a6ce701bcd852fb3e7c (patch)
tree0cf90eb82e1ba0170bb17f1e808198b88b71e34a /lib/Lex/Preprocessor.cpp
parentb939a4e8b471f6a5e996fa57b2fd9df30b59cb60 (diff)
Avoid an unnecessary copy of Predefines. getMemBufferCopy does the null termination for us.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92358 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index d4e441b2f1..81966cb2b9 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -446,19 +446,10 @@ void Preprocessor::EnterMainSourceFile() {
if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
HeaderInfo.IncrementIncludeCount(FE);
- std::vector<char> PrologFile;
- PrologFile.reserve(4080);
-
- // FIXME: Don't make a copy.
- PrologFile.insert(PrologFile.end(), Predefines.begin(), Predefines.end());
-
- // Memory buffer must end with a null byte!
- PrologFile.push_back(0);
-
- // Now that we have emitted the predefined macros, #includes, etc into
- // PrologFile, preprocess it to populate the initial preprocessor state.
+ // Preprocess Predefines to populate the initial preprocessor state.
llvm::MemoryBuffer *SB =
- llvm::MemoryBuffer::getMemBufferCopy(&PrologFile.front(),&PrologFile.back(),
+ llvm::MemoryBuffer::getMemBufferCopy(Predefines.data(),
+ Predefines.data() + Predefines.size(),
"<built-in>");
assert(SB && "Cannot fail to create predefined source buffer");
FileID FID = SourceMgr.createFileIDForMemBuffer(SB);