[PATCH] D25640: [CUDA] [AST] Allow isInlineDefinitionExternallyVisible to be called on functions without bodies.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 14 22:31:40 PDT 2016


jlebar created this revision.
jlebar added reviewers: rsmith, tra.
jlebar added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

In CUDA compilation, we call isInlineDefinitionExternallyVisible (via
getGVALinkageForFunction) on functions while parsing their definitions.

At the point in time when we call getGVALinkageForFunction, the function
may not have a body, so we trip this assert.  But as far as I can tell,
this is harmless.

It is not clear to me whether it's possible to replace this assert with
something slightly weaker.


https://reviews.llvm.org/D25640

Files:
  clang/lib/AST/Decl.cpp
  clang/test/SemaCUDA/gnu-inline.cu


Index: clang/test/SemaCUDA/gnu-inline.cu
===================================================================
--- /dev/null
+++ clang/test/SemaCUDA/gnu-inline.cu
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+// expected-no-diagnostics
+
+// Check that we can handle gnu_inline functions when compiling in CUDA mode.
+
+void foo();
+inline __attribute__((gnu_inline)) void bar() { foo(); }
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3048,7 +3048,6 @@
 /// an externally visible symbol, but "extern inline" will not create an 
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert(doesThisDeclarationHaveABody() && "Must have the function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext &Context = getASTContext();
   


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25640.74766.patch
Type: text/x-patch
Size: 963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161015/75e318cd/attachment.bin>


More information about the cfe-commits mailing list