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/Sema/SemaCUDA.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/Sema/SemaCUDA.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCUDA.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index 822304195d5..cb7019242f1 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -495,7 +495,13 @@ bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee) { Diag(Callee->getLocation(), diag::note_previous_decl) << Callee; return false; } - if (Pref == Sema::CFP_WrongSide) { + + // Insert into LocsWithCUDADeferredDiags to avoid emitting duplicate deferred + // diagnostics for the same location. Duplicate deferred diags are otherwise + // tricky to avoid, because, unlike with regular errors, sema checking + // proceeds unhindered when we omit a deferred diagnostic. + if (Pref == Sema::CFP_WrongSide && + LocsWithCUDACallDeferredDiags.insert(Loc.getRawEncoding()).second) { // We have to do this odd dance to create our PartialDiagnostic because we // want its storage to be allocated with operator new, not in an arena. PartialDiagnostic ErrPD{PartialDiagnostic::NullDiagnostic()}; |