summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ODRHash.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2017-02-22 22:22:42 +0000
committerRichard Trieu <rtrieu@google.com>2017-02-22 22:22:42 +0000
commit639d7b68d656d73bf8ee0b05bc9476502dcdb21d (patch)
treee2d0f16dafa07caf070885503046f9469ce40d90 /clang/lib/AST/ODRHash.cpp
parentfccbda967a37741656e85c235a69e8d86f70396f (diff)
[ODRHash] static_cast and Stmt hashing.
Add support for static_cast in classes. Add pointer-independent profiling for Stmt's, sharing most of the logic with Stmt::Profile. This is the first of the deep sub-Decl diffing for error messages. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295890
Diffstat (limited to 'clang/lib/AST/ODRHash.cpp')
-rw-r--r--clang/lib/AST/ODRHash.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index a74c03802253..9c6f38c2d9da 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -22,7 +22,10 @@
using namespace clang;
-void ODRHash::AddStmt(const Stmt *S) {}
+void ODRHash::AddStmt(const Stmt *S) {
+ assert(S && "Expecting non-null pointer.");
+ S->ProcessODRHash(ID, *this);
+}
void ODRHash::AddIdentifierInfo(const IdentifierInfo *II) {}
void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {}
void ODRHash::AddTemplateName(TemplateName Name) {}
@@ -74,10 +77,18 @@ unsigned ODRHash::CalculateHash() {
class ODRDeclVisitor : public ConstDeclVisitor<ODRDeclVisitor> {
typedef ConstDeclVisitor<ODRDeclVisitor> Inherited;
llvm::FoldingSetNodeID &ID;
+ ODRHash &Hash;
public:
- ODRDeclVisitor(llvm::FoldingSetNodeID &ID)
- : ID(ID) {}
+ ODRDeclVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
+ : ID(ID), Hash(Hash) {}
+
+ void AddStmt(const Stmt *S) {
+ Hash.AddBoolean(S);
+ if (S) {
+ Hash.AddStmt(S);
+ }
+ }
void Visit(const Decl *D) {
ID.AddInteger(D->getKind());
@@ -88,6 +99,13 @@ public:
ID.AddInteger(D->getAccess());
Inherited::VisitAccessSpecDecl(D);
}
+
+ void VisitStaticAssertDecl(const StaticAssertDecl *D) {
+ AddStmt(D->getAssertExpr());
+ AddStmt(D->getMessage());
+
+ Inherited::VisitStaticAssertDecl(D);
+ }
};
// Only allow a small portion of Decl's to be processed. Remove this once
@@ -100,6 +118,7 @@ bool ODRHash::isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Parent) {
default:
return false;
case Decl::AccessSpec:
+ case Decl::StaticAssert:
return true;
}
}
@@ -108,7 +127,7 @@ void ODRHash::AddSubDecl(const Decl *D) {
assert(D && "Expecting non-null pointer.");
AddDecl(D);
- ODRDeclVisitor(ID).Visit(D);
+ ODRDeclVisitor(ID, *this).Visit(D);
}
void ODRHash::AddCXXRecordDecl(const CXXRecordDecl *Record) {