[PATCH] D25139: [CUDA] Add Sema::CUDADiagBuilder and Sema::CUDADiagIfDeviceCode().

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 12 18:03:58 PDT 2016


rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



================
Comment at: clang/include/clang/Sema/Sema.h:9238
+    ///
+    ///   if (CUDADiagBuilder(...) << foo << bar)
+    ///     return ExprError();
----------------
jlebar wrote:
> rnk wrote:
> > I'm concerned that this usage pattern isn't going to be efficient because you build the complete diagnostic before calling the bool conversion operator to determine that it doesn't need to be emitted. I think you want to construct something more like:
> >   if (isCUDADeviceCode())
> >     CUDADiag(...) << ...;
> > 
> > Otherwise you are going to construct and destruct a large number of diagnostics about language features that are forbidden in device code, but are legal in host code, and 99% of the TU is going to be host code that uses these illegal features.
> I think the comment is misleading -- I tried to update it to resolve this misunderstanding.  Does it make more sense now?
Actually, I just had to think about the problem more to realize why it has to be this way. This is for deferred diagnostics where you don't know if the code is device code yet. :)


https://reviews.llvm.org/D25139





More information about the cfe-commits mailing list