[cfe-commits] [PATCH] Allow PCHReader to be used without having a pre-initialized Preprocessor

Douglas Gregor dgregor at apple.com
Thu Jun 18 10:14:24 PDT 2009


On Jun 17, 2009, at 6:19 PM, Argyrios Kyrtzidis wrote:

> Currently PCHReader depends on getting a pre-initialized Preprocessor.
> The attached patch modifies PCHReader so that we can use it to load  
> a .pch file, get the information we need and *afterwards* initialize  
> a Preprocessor with that info.

Looks good. I have one question about these two changes:

@@ -1116,7 +1233,8 @@
                          (const unsigned char *)IdentifierTableData +  
Record[0],
                          (const unsigned char *)IdentifierTableData,
                          PCHIdentifierLookupTrait(*this));
-        PP.getIdentifierTable().setExternalIdentifierLookup(this);
+        if (PP)
+          PP->getIdentifierTable().setExternalIdentifierLookup(this);
        }
        break;

@@ -1127,7 +1245,8 @@
        }
        IdentifierOffsets = (const uint32_t *)BlobStart;
        IdentifiersLoaded.resize(Record[0]);
-      PP.getHeaderSearchInfo().SetExternalLookup(this);
+      if (PP)
+        PP->getHeaderSearchInfo().SetExternalLookup(this);
        break;

      case pch::EXTERNAL_DEFINITIONS:

If PP ends up being NULL, then these two external lookup hooks won't  
be added. I suspect that we want to add them int  
PCHReader::InitializeContext.

	- Doug



More information about the cfe-commits mailing list