summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-10-21 20:08:52 +0000
committerJustin Lebar <jlebar@google.com>2016-10-21 20:08:52 +0000
commit6f72737c3bd66085e5196b7cb78ef4fdfc39e796 (patch)
tree6b5629fe2d85f12b58413688c2cde71e56051030 /clang/include
parentfaa857dba7426af47269fad1e5feba19050c2d58 (diff)
downloadbcm5719-llvm-6f72737c3bd66085e5196b7cb78ef4fdfc39e796.tar.gz
bcm5719-llvm-6f72737c3bd66085e5196b7cb78ef4fdfc39e796.zip
[CUDA] Use FunctionDeclAndLoc for the Sema::LocsWithCUDACallDiags hashtable.
Summary: NFC Reviewers: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25797 llvm-svn: 284869
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Sema/Sema.h41
1 files changed, 34 insertions, 7 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 70db36f2bf3..541451f5e49 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9250,18 +9250,18 @@ public:
std::vector<PartialDiagnosticAt>>
CUDADeferredDiags;
- /// FunctionDecls plus raw encodings of SourceLocations for which
- /// CheckCUDACall has emitted a (maybe deferred) "bad call" diagnostic. We
- /// use this to avoid emitting the same deferred diag twice.
- llvm::DenseSet<std::pair<CanonicalDeclPtr<FunctionDecl>, unsigned>>
- LocsWithCUDACallDiags;
-
- /// A pair of a canonical FunctionDecl and a SourceLocation.
+ /// A pair of a canonical FunctionDecl and a SourceLocation. When used as the
+ /// key in a hashtable, both the FD and location are hashed.
struct FunctionDeclAndLoc {
CanonicalDeclPtr<FunctionDecl> FD;
SourceLocation Loc;
};
+ /// FunctionDecls and SourceLocations for which CheckCUDACall has emitted a
+ /// (maybe deferred) "bad call" diagnostic. We use this to avoid emitting the
+ /// same deferred diag twice.
+ llvm::DenseSet<FunctionDeclAndLoc> LocsWithCUDACallDiags;
+
/// An inverse call graph, mapping known-emitted functions to one of their
/// known-emitted callers (plus the location of the call).
///
@@ -10035,4 +10035,31 @@ struct LateParsedTemplate {
} // end namespace clang
+namespace llvm {
+// Hash a FunctionDeclAndLoc by looking at both its FunctionDecl and its
+// SourceLocation.
+template <> struct DenseMapInfo<clang::Sema::FunctionDeclAndLoc> {
+ using FunctionDeclAndLoc = clang::Sema::FunctionDeclAndLoc;
+ using FDBaseInfo = DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl>>;
+
+ static FunctionDeclAndLoc getEmptyKey() {
+ return {FDBaseInfo::getEmptyKey(), clang::SourceLocation()};
+ }
+
+ static FunctionDeclAndLoc getTombstoneKey() {
+ return {FDBaseInfo::getTombstoneKey(), clang::SourceLocation()};
+ }
+
+ static unsigned getHashValue(const FunctionDeclAndLoc &FDL) {
+ return hash_combine(FDBaseInfo::getHashValue(FDL.FD),
+ FDL.Loc.getRawEncoding());
+ }
+
+ static bool isEqual(const FunctionDeclAndLoc &LHS,
+ const FunctionDeclAndLoc &RHS) {
+ return LHS.FD == RHS.FD && LHS.Loc == RHS.Loc;
+ }
+};
+} // namespace llvm
+
#endif
OpenPOWER on IntegriCloud