]> granicus.if.org Git - clang/commitdiff
Query only the latest version of an identifier in the PCH chain. Make sure this versi...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Mon, 2 Aug 2010 18:30:12 +0000 (18:30 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Mon, 2 Aug 2010 18:30:12 +0000 (18:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110052 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/PCHReader.h
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHWriter.cpp
test/PCH/Inputs/chain-decls1.h
test/PCH/Inputs/chain-decls2.h
test/PCH/chain-decls.c

index 87c7624be09ea5e8782de02aafc4a0ffb59bfe12..dda15670b5e95545ab4a886124ec9d99653cd81f 100644 (file)
@@ -906,12 +906,6 @@ public:
   /// \brief Retrieve the macro definition with the given ID.
   MacroDefinition *getMacroDefinition(pch::IdentID ID);
 
-  /// \brief Erase the macro that's bound to the given IdentifierInfo.
-  void EraseMacro(IdentifierInfo *II);
-
-  /// \brief Check if the given macro identifier is built-in.
-  bool isBuiltinMacro(IdentifierInfo *II);
-      
   /// \brief Retrieve the AST context that this PCH reader
   /// supplements.
   ASTContext *getContext() { return Context; }
index 0502e674a9d9fc1a850a1add3d11b7a80f61079c..d5cf75ce3baaef8a4b60d54537888847797922f7 100644 (file)
@@ -689,9 +689,6 @@ public:
       uint32_t Offset = ReadUnalignedLE32(d);
       Reader.ReadMacroRecord(Stream, Offset);
       DataLen -= 4;
-    } else if (II->hasMacroDefinition() && !Reader.isBuiltinMacro(II)) {
-      // A previous part of the chain added a macro, but this part #undefed it.
-      Reader.EraseMacro(II);
     }
 
     // Read all of the declarations visible at global scope with this
@@ -1389,15 +1386,6 @@ MacroDefinition *PCHReader::getMacroDefinition(pch::IdentID ID) {
   return MacroDefinitionsLoaded[ID];
 }
 
-void PCHReader::EraseMacro(IdentifierInfo *II) {
-  PP->setMacroInfo(II, 0);
-}
-
-bool PCHReader::isBuiltinMacro(IdentifierInfo *II) {
-  assert(II->hasMacroDefinition() && "Identifier is not a macro");
-  return PP->getMacroInfo(II)->isBuiltinMacro();
-}
-
 /// \brief If we are loading a relocatable PCH file, and the filename is
 /// not an absolute path, add the system root to the beginning of the file
 /// name.
@@ -3184,12 +3172,11 @@ void PCHReader::InitializeSema(Sema &S) {
 }
 
 IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) {
-  // Try to find this name within our on-disk hash tables. We need to aggregate
-  // the info from all of them.
-  IdentifierInfo *II = 0;
+  // Try to find this name within our on-disk hash tables. We start with the
+  // most recent one, since that one contains the most up-to-date info.
   for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
     PCHIdentifierLookupTable *IdTable
-      = (PCHIdentifierLookupTable *)Chain[N - I - 1]->IdentifierLookupTable;
+        = (PCHIdentifierLookupTable *)Chain[I]->IdentifierLookupTable;
     if (!IdTable)
       continue;
     std::pair<const char*, unsigned> Key(NameStart, NameEnd - NameStart);
@@ -3200,9 +3187,9 @@ IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) {
     // Dereferencing the iterator has the effect of building the
     // IdentifierInfo node and populating it with the various
     // declarations it needs.
-    II = *Pos;
+    return *Pos;
   }
-  return II;
+  return 0;
 }
 
 std::pair<ObjCMethodList, ObjCMethodList>
index 8bf85efd62b47b1d4585a5b6b0f4f8117f1ea62c..641492ca598e48f520a77e93436b1197a1368f27 100644 (file)
@@ -1819,8 +1819,7 @@ public:
       for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
                                      DEnd = IdentifierResolver::end();
            D != DEnd; ++D)
-        if (!Writer.hasChain() || (*D)->getPCHLevel() == 0)
-          DataLen += sizeof(pch::DeclID);
+        DataLen += sizeof(pch::DeclID);
     }
     clang::io::Emit16(Out, DataLen);
     // We emit the key length after the data length so that every
@@ -1872,8 +1871,7 @@ public:
     for (llvm::SmallVector<Decl *, 16>::reverse_iterator D = Decls.rbegin(),
                                                       DEnd = Decls.rend();
          D != DEnd; ++D)
-      if (!Writer.hasChain() || (*D)->getPCHLevel() == 0)
-        clang::io::Emit32(Out, Writer.getDeclID(*D));
+      clang::io::Emit32(Out, Writer.getDeclID(*D));
   }
 };
 } // end anonymous namespace
index 79586ce42a10ecf9db1d3d0e2b20ec07c8dd9f6b..9de446164d6df0c1a575142d3e2a1641335e8c80 100644 (file)
@@ -2,3 +2,10 @@ void f();
 
 struct one {};
 void two();
+
+void many(int i);
+struct many;
+void many(int j);
+struct many;
+
+void noret();
index 1826da9415e6805faccbc7098152e0c922b2587a..b8b7d0466dc31f87574fc64640751ec988c8e2de 100644 (file)
@@ -3,3 +3,10 @@ void g();
 struct two {};
 void one();
 struct three {}; // for verification
+
+void many(int k);
+struct many;
+void many(int l);
+struct many {};
+
+void noret() __attribute__((noreturn));
index f790a29254d0bd473629422dde7acf0d3c279a22..b3daa4a7b7cd998f84630902c3ccd716855a778c 100644 (file)
@@ -10,7 +10,7 @@
 // CHECK: void f();
 // CHECK: void g();
 
-void h() {
+int h() {
   f();
   g();
 
@@ -19,4 +19,9 @@ void h() {
   struct two y;
   two();
   struct three z;
+
+  many(0);
+  struct many m;
+
+  noret();
 }