summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-10-28 16:26:26 +0000
committerJustin Lebar <jlebar@google.com>2016-10-28 16:26:26 +0000
commit2b42ccc78b38e5b11305f7316e108882986f5aa9 (patch)
tree382e96370484393998b18a4bf5eba976e84ced42 /clang/lib/AST/Decl.cpp
parent87a47be039226436fe0562f21f6858a2d244bf17 (diff)
downloadbcm5719-llvm-2b42ccc78b38e5b11305f7316e108882986f5aa9.tar.gz
bcm5719-llvm-2b42ccc78b38e5b11305f7316e108882986f5aa9.zip
[CUDA] [AST] Allow isInlineDefinitionExternallyVisible to be called on functions without bodies.
Summary: In CUDA compilation, we call isInlineDefinitionExternallyVisible (via getGVALinkageForFunction) on functions while parsing their definitions. At the point in time when we call getGVALinkageForFunction, we haven't yet added the body to the function, so we trip this assert. But as far as I can tell, this is harmless. To work around this, we add a new flag to FunctionDecl, "WillHaveBody". There was other code that was working around the existing assert with a really awful hack -- this change lets us get rid of that hack. Reviewers: rsmith, tra Subscribers: aemerson, cfe-commits Differential Revision: https://reviews.llvm.org/D25640 llvm-svn: 285410
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 235f2778e87..7898b075d53 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2933,7 +2933,7 @@ static bool RedeclForcesDefC99(const FunctionDecl *Redecl) {
/// of redeclarations of the given functions causes
/// isInlineDefinitionExternallyVisible to change from false to true.
bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
- assert(!doesThisDeclarationHaveABody() &&
+ assert(!doesThisDeclarationHaveABody() && !willHaveBody() &&
"Must have a declaration without a body.");
ASTContext &Context = getASTContext();
@@ -3048,7 +3048,8 @@ const Attr *FunctionDecl::getUnusedResultAttr() const {
/// 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(doesThisDeclarationHaveABody() ||
+ willHaveBody() && "Must be a function definition");
assert(isInlined() && "Function must be inline");
ASTContext &Context = getASTContext();
OpenPOWER on IntegriCloud