]> granicus.if.org Git - clang/commitdiff
[ODRHash] Skip inline namespaces when hashing.
authorRichard Trieu <rtrieu@google.com>
Fri, 9 Jun 2017 20:11:51 +0000 (20:11 +0000)
committerRichard Trieu <rtrieu@google.com>
Fri, 9 Jun 2017 20:11:51 +0000 (20:11 +0000)
Speculatively try to fix the underlying issue from r304592, of underlying types
being confused when inline namespaces are used.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305104 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ODRHash.cpp
lib/AST/StmtProfile.cpp

index 0e822ce35b8ce19e88f25a10e94eb2b92f4a09ce..08593da89bbd8236a33785c4e01b16c5cde0f22a 100644 (file)
@@ -82,13 +82,25 @@ void ODRHash::AddDeclarationName(DeclarationName Name) {
 }
 
 void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
-  assert(NNS && "Expecting non-null pointer.");
-  const auto *Prefix = NNS->getPrefix();
-  AddBoolean(Prefix);
-  if (Prefix) {
-    AddNestedNameSpecifier(Prefix);
+  // Unlike the other pointer handling functions, allow null pointers here.
+  if (!NNS) {
+    AddBoolean(false);
+    return;
   }
+
+  // Skip inlined namespaces.
   auto Kind = NNS->getKind();
+  if (Kind == NestedNameSpecifier::Namespace) {
+    if (NNS->getAsNamespace()->isInline()) {
+      return AddNestedNameSpecifier(NNS->getPrefix());
+    }
+  }
+
+  AddBoolean(true);
+
+  // Process prefix
+  AddNestedNameSpecifier(NNS->getPrefix());
+
   ID.AddInteger(Kind);
   switch (Kind) {
   case NestedNameSpecifier::Identifier:
@@ -381,10 +393,7 @@ public:
   }
 
   void AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
-    Hash.AddBoolean(NNS);
-    if (NNS) {
-      Hash.AddNestedNameSpecifier(NNS);
-    }
+    Hash.AddNestedNameSpecifier(NNS);
   }
 
   void AddIdentifierInfo(const IdentifierInfo *II) {
index f1fbe2806b5d09c3ebeda1afc1ffbca0a5cd4f8f..99a25f3425268585ec9e7953b6feee02c2f38e11 100644 (file)
@@ -186,10 +186,7 @@ namespace {
       Hash.AddTemplateName(Name);
     }
     void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
-      ID.AddBoolean(NNS);
-      if (NNS) {
-        Hash.AddNestedNameSpecifier(NNS);
-      }
+      Hash.AddNestedNameSpecifier(NNS);
     }
   };
 }