aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization/GeneratePCH.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-22 06:03:18 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-22 06:03:18 +0000
commit4947e25dd9f7ac1f2176d63262563ba3e96538fe (patch)
tree7a5ee5899de2a01a199998d5390b66116a292bea /lib/Serialization/GeneratePCH.cpp
parentd837c0dc361a000b951593eaaa80c46b73d15b1d (diff)
Fix an embarrassing bug in relocatable PCH support, where we were
passing a temporary const char* down as the "isysroot" parameter and then accessing it later. Fixes <rdar://problem/9035180>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135749 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/GeneratePCH.cpp')
-rw-r--r--lib/Serialization/GeneratePCH.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp
index b8833ceacc..9cd694e05c 100644
--- a/lib/Serialization/GeneratePCH.cpp
+++ b/lib/Serialization/GeneratePCH.cpp
@@ -23,6 +23,8 @@
#include "llvm/Bitcode/BitstreamWriter.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
+#include <string.h>
+#include <stdlib.h>
using namespace clang;
@@ -31,7 +33,7 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP,
bool Chaining,
const char *isysroot,
llvm::raw_ostream *OS)
- : PP(PP), OutputFile(OutputFile), isysroot(isysroot), Out(OS), SemaPtr(0),
+ : PP(PP), OutputFile(OutputFile), isysroot(0), Out(OS), SemaPtr(0),
StatCalls(0), Stream(Buffer), Writer(Stream), Chaining(Chaining) {
// Install a stat() listener to keep track of all of the stat()
// calls.
@@ -40,6 +42,13 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP,
// *after* the already installed ASTReader's stat cache.
PP.getFileManager().addStatCache(StatCalls,
/*AtBeginning=*/!Chaining);
+
+ if (isysroot)
+ this->isysroot = strdup(isysroot);
+}
+
+PCHGenerator::~PCHGenerator() {
+ free((void*)isysroot);
}
void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {