summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2017-12-23 00:41:01 +0000
committerRichard Trieu <rtrieu@google.com>2017-12-23 00:41:01 +0000
commite6caa26e5d1f277c620976923bf6fd58433b2c86 (patch)
treeb240071434e238f24a4724c4abaa6fa2f8611171 /clang/lib/AST/Decl.cpp
parent50c342bf3f99c653716bd91201cc2a5189d596db (diff)
downloadbcm5719-llvm-e6caa26e5d1f277c620976923bf6fd58433b2c86.tar.gz
bcm5719-llvm-e6caa26e5d1f277c620976923bf6fd58433b2c86.zip
[ODRHash] Support ODR violation detection in functions.
Extend the hashing to functions, which allows detection of function definition mismatches across modules. This is a re-commit of r320230. llvm-svn: 321395
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ee15a4d2b4f..629037b1755 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -26,6 +26,7 @@
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/ODRHash.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/Redeclarable.h"
#include "clang/AST/Stmt.h"
@@ -3604,6 +3605,25 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
return 0;
}
+unsigned FunctionDecl::getODRHash() {
+ if (HasODRHash)
+ return ODRHash;
+
+ if (FunctionDecl *Definition = getDefinition()) {
+ if (Definition != this) {
+ HasODRHash = true;
+ ODRHash = Definition->getODRHash();
+ return ODRHash;
+ }
+ }
+
+ class ODRHash Hash;
+ Hash.AddFunctionDecl(this);
+ HasODRHash = true;
+ ODRHash = Hash.CalculateHash();
+ return ODRHash;
+}
+
//===----------------------------------------------------------------------===//
// FieldDecl Implementation
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud