[PATCH] D121765: [CUDA][HIP] Fix hostness check with -fopenmp

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 14:01:08 PDT 2022


rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/include/clang/Sema/Sema.h:3325-3330
+  /// getCurFunctionDecl - If parsing a lambda, then return the lambda
+  /// declaration if \p AllowLambda is true, otherwise return the function
+  /// declaration enclosing the lambda. If in 'block' context, return the
+  /// enclosing function or lambda declaration if \p AllowLambda is true,
+  /// otherwise return the enclosing function declaration. For regular
+  /// functions, return the function declarations.
----------------
This comment would be clearer if it started with the common case and then explains any special cases. We also prefer to not include the function name at the start of the comment, so that should be removed when updating a function comment. It's also possible for a (member) function to be nested within a lambda, so I don't think it's correct that we will return the lambda whenever we're parsing one. Also, talking about "parsing" isn't right during template instantiation.

Maybe: "Returns a pointer to the innermost enclosing function, or `nullptr` if the current context is not inside a function. If \p AllowLambda is true, this can return the call operator of an enclosing lambda, otherwise lambdas are skipped when looking for an enclosing function."


================
Comment at: clang/test/CodeGenCUDA/openmp-parallel.cu:10
+// Check foo resolves to the host function.
+// CHECK-LABLE: define {{.*}}@_Z5test1v
+// CHECK: call void @_Z3food(double noundef 1.000000e+00)
----------------



================
Comment at: clang/test/CodeGenCUDA/openmp-parallel.cu:19
+// Check foo resolves to the host function.
+// CHECK-LABLE: define {{.*}}@_Z5test2v
+// CHECK: call void @_Z3food(double noundef 1.000000e+00)
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121765/new/

https://reviews.llvm.org/D121765



More information about the cfe-commits mailing list