diff options
author | Justin Lebar <jlebar@google.com> | 2016-08-15 20:38:56 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-08-15 20:38:56 +0000 |
commit | 60dcc1344a27c62ba7b49dc1ff39881b606a97a3 (patch) | |
tree | 17d3403fdafc820f889f2da77c237f18e6820b37 /clang/lib/AST/Decl.cpp | |
parent | 9421ba6c024151a2be99ccb58f657d09189e2464 (diff) | |
download | bcm5719-llvm-60dcc1344a27c62ba7b49dc1ff39881b606a97a3.tar.gz bcm5719-llvm-60dcc1344a27c62ba7b49dc1ff39881b606a97a3.zip |
Add the notion of deferred diagnostics.
Summary:
This patch lets you create diagnostics that are emitted if and only if a
particular FunctionDecl is codegen'ed.
This is necessary for CUDA, where some constructs -- e.g. calls from
host+device functions to host functions when compiling for device -- are
allowed to appear in semantically-correct programs, but only if they're
never codegen'ed.
Reviewers: rnk
Subscribers: cfe-commits, tra
Differential Revision: https://reviews.llvm.org/D23241
llvm-svn: 278735
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 4486cb89404..98711822a51 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3446,6 +3446,20 @@ unsigned FunctionDecl::getMemoryFunctionKind() const { return 0; } +void FunctionDecl::addDeferredDiag(PartialDiagnosticAt PD) { + getASTContext().getDeferredDiags()[this].push_back(std::move(PD)); +} + +std::vector<PartialDiagnosticAt> FunctionDecl::takeDeferredDiags() const { + auto &DD = getASTContext().getDeferredDiags(); + auto It = DD.find(this); + if (It == DD.end()) + return {}; + auto Ret = std::move(It->second); + DD.erase(It); + return Ret; +} + //===----------------------------------------------------------------------===// // FieldDecl Implementation //===----------------------------------------------------------------------===// |