[cfe-commits] r39701 - /cfe/cfe/trunk/Driver/clang.cpp

clattner at cs.uiuc.edu clattner at cs.uiuc.edu
Wed Jul 11 09:47:18 PDT 2007


Author: clattner
Date: Wed Jul 11 11:47:18 2007
New Revision: 39701

URL: http://llvm.org/viewvc/llvm-project?rev=39701&view=rev
Log:
Add a hack to fix a really subtle memory lifetime bug Bill introduced with his
recent changes.  carbon.h now preprocesses just fine.

Modified:
    cfe/cfe/trunk/Driver/clang.cpp

Modified: cfe/cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/clang.cpp?rev=39701&r1=39700&r2=39701&view=diff

==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:47:18 2007
@@ -698,11 +698,11 @@
                                        const std::string &InFile,
                                        SourceManager &SourceMgr,
                                        HeaderSearch &HeaderInfo,
-                                       const LangOptions &LangInfo) {
+                                       const LangOptions &LangInfo,
+                                       std::vector<char> &PrologMacros) {
   FileManager &FileMgr = HeaderInfo.getFileMgr();
   
   // Install things like __POWERPC__, __GNUC__, etc into the macro table.
-  std::vector<char> PrologMacros;
   InitializePredefinedMacros(PP, PrologMacros);
   
   // Read any files specified by -imacros or -include.
@@ -731,7 +731,7 @@
 
   // Memory buffer must end with a null byte!
   PrologMacros.push_back(0);
-    
+
   llvm::MemoryBuffer *SB = 
     llvm::MemoryBuffer::getMemBuffer(&PrologMacros.front(),&PrologMacros.back(),
                                      "<predefines>");
@@ -749,7 +749,7 @@
 
   // Once we've read this, we're done.
   return MainFileID;
-}  
+}
 
 /// ProcessInputFile - Process a single input file with the specified state.
 ///
@@ -854,8 +854,10 @@
     Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo);
     OurDiagnosticClient.setPreprocessor(PP);
     const std::string &InFile = InputFilenames[i];
+    std::vector<char> PrologMacros;
     unsigned MainFileID = InitializePreprocessor(PP, InFile, SourceMgr,
-                                                 HeaderInfo, LangInfo);
+                                                 HeaderInfo, LangInfo,
+                                                 PrologMacros);
 
     if (!MainFileID) continue;
 
@@ -910,8 +912,10 @@
     Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo);
     OurDiagnosticClient.setPreprocessor(PP);
     const std::string &InFile = InputFilenames[i];
+    std::vector<char> PrologMacros;
     unsigned MainFileID = InitializePreprocessor(PP, InFile, SourceMgr,
-                                                 HeaderInfo, LangInfo);
+                                                 HeaderInfo, LangInfo,
+                                                 PrologMacros);
 
     if (!MainFileID) continue;
 





More information about the cfe-commits mailing list