]> granicus.if.org Git - clang/commitdiff
Fix a bug in loading macro records. Fixes yet another crash in libclang.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Tue, 28 Sep 2010 02:55:49 +0000 (02:55 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Tue, 28 Sep 2010 02:55:49 +0000 (02:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114940 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReader.cpp

index ee9cd1a4df747e0a709180f85bda0156838de74c..0443edb26afc03306575ff851e22978d2ce2561c 100644 (file)
@@ -1494,6 +1494,7 @@ void ASTReader::ReadDefinedMacros() {
 
     RecordData Record;
     while (true) {
+      uint64_t Offset = Cursor.GetCurrentBitNo();
       unsigned Code = Cursor.ReadCode();
       if (Code == llvm::bitc::END_BLOCK) {
         if (Cursor.ReadBlockEnd()) {
@@ -1538,7 +1539,8 @@ void ASTReader::ReadDefinedMacros() {
       case PP_MACRO_INSTANTIATION:
       case PP_MACRO_DEFINITION:
         // Read the macro record.
-        ReadMacroRecord(Chain[N - I - 1]->Stream, Cursor.GetCurrentBitNo());
+        // FIXME: That's a stupid way to do this. We should reuse this cursor.
+        ReadMacroRecord(Chain[N - I - 1]->Stream, Offset);
         break;
       }
     }
@@ -3190,9 +3192,8 @@ bool ASTReader::FindExternalLexicalDecls(const DeclContext *DC,
       continue;
 
     // Load all of the declaration IDs
-    for (const DeclID *ID = I->LexicalDecls,
-                           *IDE = ID + I->NumLexicalDecls;
-        ID != IDE; ++ID) {
+    for (const DeclID *ID = I->LexicalDecls, *IDE = ID + I->NumLexicalDecls;
+         ID != IDE; ++ID) {
       Decl *D = GetDecl(*ID);
       assert(D && "Null decl in lexical decls");
       Decls.push_back(D);