[ODRHash] Add IdentiferInfo and FieldDecl support.

IdentifierInfo is hashed based on the stored string.  FieldDecl versus other
Decl is now detected, as well as differently named fields.

Differential Revision: https://reviews.llvm.org/D21675

llvm-svn: 295911
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 9c6f38c..35af0e9 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -26,7 +26,12 @@
   assert(S && "Expecting non-null pointer.");
   S->ProcessODRHash(ID, *this);
 }
-void ODRHash::AddIdentifierInfo(const IdentifierInfo *II) {}
+
+void ODRHash::AddIdentifierInfo(const IdentifierInfo *II) {
+  assert(II && "Expecting non-null pointer.");
+  ID.AddString(II->getName());
+}
+
 void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {}
 void ODRHash::AddTemplateName(TemplateName Name) {}
 void ODRHash::AddDeclarationName(DeclarationName Name) {}
@@ -90,11 +95,23 @@
     }
   }
 
+  void AddIdentifierInfo(const IdentifierInfo *II) {
+    Hash.AddBoolean(II);
+    if (II) {
+      Hash.AddIdentifierInfo(II);
+    }
+  }
+
   void Visit(const Decl *D) {
     ID.AddInteger(D->getKind());
     Inherited::Visit(D);
   }
 
+  void VisitNamedDecl(const NamedDecl *D) {
+    AddIdentifierInfo(D->getIdentifier());
+    Inherited::VisitNamedDecl(D);
+  }
+
   void VisitAccessSpecDecl(const AccessSpecDecl *D) {
     ID.AddInteger(D->getAccess());
     Inherited::VisitAccessSpecDecl(D);
@@ -106,6 +123,10 @@
 
     Inherited::VisitStaticAssertDecl(D);
   }
+
+  void VisitFieldDecl(const FieldDecl *D) {
+    Inherited::VisitFieldDecl(D);
+  }
 };
 
 // Only allow a small portion of Decl's to be processed.  Remove this once
@@ -118,6 +139,7 @@
     default:
       return false;
     case Decl::AccessSpec:
+    case Decl::Field:
     case Decl::StaticAssert:
       return true;
   }