summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2017-07-14 01:36:41 +0000
committerRichard Trieu <rtrieu@google.com>2017-07-14 01:36:41 +0000
commit9747a7c5622c42a88d868ee0220cdef8ed387781 (patch)
tree157508d2b9fbd8bffdebadd6d330242969092348 /clang
parent7641d962da225993937b972368e21a1641366ada (diff)
downloadbcm5719-llvm-9747a7c5622c42a88d868ee0220cdef8ed387781.tar.gz
bcm5719-llvm-9747a7c5622c42a88d868ee0220cdef8ed387781.zip
[ODRHash] Avoid taking the types of FunctionDecl's
FunctionDecl already hashes most of the information in the function's type. Add hashing of the return type, and skip hashing the function's type to avoid redundancy and extra work when computing the hash. llvm-svn: 307986
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/ODRHash.cpp6
-rw-r--r--clang/test/Modules/odr_hash.cpp14
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 66b9940b8b0..c16f4f336af 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -246,7 +246,9 @@ public:
}
void VisitValueDecl(const ValueDecl *D) {
- AddQualType(D->getType());
+ if (!isa<FunctionDecl>(D)) {
+ AddQualType(D->getType());
+ }
Inherited::VisitValueDecl(D);
}
@@ -305,6 +307,8 @@ public:
Hash.AddSubDecl(Param);
}
+ AddQualType(D->getReturnType());
+
Inherited::VisitFunctionDecl(D);
}
diff --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp
index ee45ae52996..91230c52c8e 100644
--- a/clang/test/Modules/odr_hash.cpp
+++ b/clang/test/Modules/odr_hash.cpp
@@ -517,6 +517,20 @@ S14 s14;
// expected-error@second.h:* {{'Method::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [3]'}}
// expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [2]'}}
#endif
+
+#if defined(FIRST)
+struct S15 {
+ int A() { return 0; }
+};
+#elif defined(SECOND)
+struct S15 {
+ long A() { return 0; }
+};
+#else
+S15 s15;
+// expected-error@first.h:* {{'Method::S15::A' from module 'FirstModule' is not present in definition of 'Method::S15' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'A' does not match}}
+#endif
} // namespace Method
// Naive parsing of AST can lead to cycles in processing. Ensure
OpenPOWER on IntegriCloud