]> granicus.if.org Git - clang/commitdiff
[CUDA] Rename CheckCUDATarget to IsAllowedCUDACall. NFC
authorJustin Lebar <jlebar@google.com>
Wed, 10 Aug 2016 01:09:11 +0000 (01:09 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 10 Aug 2016 01:09:11 +0000 (01:09 +0000)
Summary:
I want to reuse "CheckCUDAFoo" in a later patch.  Also, I think
IsAllowedCUDACall gets the point across more clearly.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23238

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278193 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaExpr.cpp
lib/Sema/SemaOverload.cpp

index 36d0d00874150bc41a612a529603d0c3bcae1e6e..e92a35f81926cb32881a998599bc55b30c158a24 100644 (file)
@@ -9161,9 +9161,13 @@ public:
                                                 const FunctionDecl *Callee);
 
   /// Determines whether Caller may invoke Callee, based on their CUDA
-  /// host/device attributes.  Returns true if the call is not allowed.
-  bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee) {
-    return IdentifyCUDAPreference(Caller, Callee) == CFP_Never;
+  /// host/device attributes.  Returns false if the call is not allowed.
+  ///
+  /// Note: Will return true for CFP_WrongSide calls.  These may appear in
+  /// semantically correct CUDA programs, but only if they're never codegen'ed.
+  bool IsAllowedCUDACall(const FunctionDecl *Caller,
+                         const FunctionDecl *Callee) {
+    return IdentifyCUDAPreference(Caller, Callee) != CFP_Never;
   }
 
   /// May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD,
index 4d31cd86cc914b86a3660183a40e5cdf5e787154..7ecf84a38d979ffb9c8a5b1b6489c8a1d062d988 100644 (file)
@@ -1741,7 +1741,7 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
   if (getLangOpts().CUDA)
     if (const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
       if (const FunctionDecl *Callee = dyn_cast<FunctionDecl>(D)) {
-        if (CheckCUDATarget(Caller, Callee)) {
+        if (!IsAllowedCUDACall(Caller, Callee)) {
           Diag(NameInfo.getLoc(), diag::err_ref_bad_target)
             << IdentifyCUDATarget(Callee) << D->getIdentifier()
             << IdentifyCUDATarget(Caller);
index ff820251776c49966a7f2c1f03ed5baf2e82c7ad..2baf696a710d70e2f77ffd6073d69b99632ed0bb 100644 (file)
@@ -5816,7 +5816,7 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
       // case we may not yet know what the member's target is; the target is
       // inferred for the member automatically, based on the bases and fields of
       // the class.
-      if (!Caller->isImplicit() && CheckCUDATarget(Caller, Function)) {
+      if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) {
         Candidate.Viable = false;
         Candidate.FailureKind = ovl_fail_bad_target;
         return;
@@ -6193,7 +6193,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
   // (CUDA B.1): Check for invalid calls between targets.
   if (getLangOpts().CUDA)
     if (const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
-      if (CheckCUDATarget(Caller, Method)) {
+      if (!IsAllowedCUDACall(Caller, Method)) {
         Candidate.Viable = false;
         Candidate.FailureKind = ovl_fail_bad_target;
         return;
@@ -10468,7 +10468,7 @@ private:
     if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
       if (S.getLangOpts().CUDA)
         if (FunctionDecl *Caller = dyn_cast<FunctionDecl>(S.CurContext))
-          if (!Caller->isImplicit() && S.CheckCUDATarget(Caller, FunDecl))
+          if (!Caller->isImplicit() && !S.IsAllowedCUDACall(Caller, FunDecl))
             return false;
 
       // If any candidate has a placeholder return type, trigger its deduction
@@ -12330,7 +12330,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
   // (CUDA B.1): Check for invalid calls between targets.
   if (getLangOpts().CUDA) {
     if (const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext)) {
-      if (CheckCUDATarget(Caller, Method)) {
+      if (!IsAllowedCUDACall(Caller, Method)) {
         Diag(MemExpr->getMemberLoc(), diag::err_ref_bad_target)
             << IdentifyCUDATarget(Method) << Method->getIdentifier()
             << IdentifyCUDATarget(Caller);