diff options
author | Justin Lebar <jlebar@google.com> | 2016-10-08 01:07:11 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-10-08 01:07:11 +0000 |
commit | 9fdb46e71c6f91ccbbbd607830da62352dfd14cc (patch) | |
tree | 4fdd7a53fcda028b42c0b1e88e7c4f57b958e6f6 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | a1a944e3cbb3a04f95ffdf1acebf00d60384b5cc (diff) | |
download | bcm5719-llvm-9fdb46e71c6f91ccbbbd607830da62352dfd14cc.tar.gz bcm5719-llvm-9fdb46e71c6f91ccbbbd607830da62352dfd14cc.zip |
[CUDA] Do a better job at detecting wrong-side calls.
Summary:
Move CheckCUDACall from ActOnCallExpr and BuildDeclRefExpr to
DiagnoseUseOfDecl. This lets us catch some edge cases we were missing,
specifically around class operators.
This necessitates a few other changes:
- Avoid emitting duplicate deferred diags in CheckCUDACall.
Previously we'd carefully placed our call to CheckCUDACall such that
it would only ever run once for a particular callsite. But now this
isn't the case.
- Emit deferred diagnostics from a template
specialization/instantiation's primary template, in addition to from
the specialization/instantiation itself. DiagnoseUseOfDecl ends up
putting the deferred diagnostics on the template, rather than the
specialization, so we need to check both.
Reviewers: rsmith
Subscribers: cfe-commits, tra
Differential Revision: https://reviews.llvm.org/D24573
llvm-svn: 283637
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 845edcd2a17..281da3fd65b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2923,6 +2923,10 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, // non-error diags here, because order can be significant, e.g. with notes // that follow errors.) auto Diags = D->takeDeferredDiags(); + if (auto *Templ = D->getPrimaryTemplate()) { + auto TemplDiags = Templ->getAsFunction()->takeDeferredDiags(); + Diags.insert(Diags.end(), TemplDiags.begin(), TemplDiags.end()); + } bool HasError = llvm::any_of(Diags, [this](const PartialDiagnosticAt &PDAt) { return getDiags().getDiagnosticLevel(PDAt.second.getDiagID(), PDAt.first) >= DiagnosticsEngine::Error; |