From 9fdb46e71c6f91ccbbbd607830da62352dfd14cc Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Sat, 8 Oct 2016 01:07:11 +0000 Subject: [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 --- clang/lib/CodeGen/CodeGenModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 845edcd2a172..281da3fd65b1 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; -- cgit v1.2.3