[cfe-commits] r107885 - in /cfe/trunk: include/clang/Frontend/PCHReader.h lib/Frontend/PCHReader.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Jul 8 10:13:03 PDT 2010


Author: akirtzidis
Date: Thu Jul  8 12:13:02 2010
New Revision: 107885

URL: http://llvm.org/viewvc/llvm-project?rev=107885&view=rev
Log:
Introduce PCHReader::GetTranslationUnitDecl() and use it instead of ReadDeclRecord when initializing.

ReadDeclRecord would hit assertion if the translation unit declaration was already loaded during
IdentifierInfo initialization.

Modified:
    cfe/trunk/include/clang/Frontend/PCHReader.h
    cfe/trunk/lib/Frontend/PCHReader.cpp

Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=107885&r1=107884&r2=107885&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Thu Jul  8 12:13:02 2010
@@ -616,6 +616,9 @@
   TypeSourceInfo *GetTypeSourceInfo(const RecordData &Record,
                                     unsigned &Idx);
 
+  /// \brief Resolve and return the translation unit declaration.
+  TranslationUnitDecl *GetTranslationUnitDecl();
+
   /// \brief Resolve a type ID into a type, potentially building a new
   /// type.
   QualType GetType(pch::TypeID ID);

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=107885&r1=107884&r2=107885&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Thu Jul  8 12:13:02 2010
@@ -1702,7 +1702,7 @@
   PP->setExternalSource(this);
 
   // Load the translation unit declaration
-  ReadDeclRecord(DeclOffsets[0], 0);
+  GetTranslationUnitDecl();
 
   // Load the special types.
   Context->setBuiltinVaListType(
@@ -2590,6 +2590,13 @@
   return GetDecl(ID);
 }
 
+TranslationUnitDecl *PCHReader::GetTranslationUnitDecl() {
+  if (!DeclsLoaded[0])
+    ReadDeclRecord(DeclOffsets[0], 0);
+
+  return cast<TranslationUnitDecl>(DeclsLoaded[0]);
+}
+
 Decl *PCHReader::GetDecl(pch::DeclID ID) {
   if (ID == 0)
     return 0;





More information about the cfe-commits mailing list