diff options
| author | Justin Lebar <jlebar@google.com> | 2016-10-28 16:26:26 +0000 |
|---|---|---|
| committer | Justin Lebar <jlebar@google.com> | 2016-10-28 16:26:26 +0000 |
| commit | 2b42ccc78b38e5b11305f7316e108882986f5aa9 (patch) | |
| tree | 382e96370484393998b18a4bf5eba976e84ced42 /clang/lib/Sema | |
| parent | 87a47be039226436fe0562f21f6858a2d244bf17 (diff) | |
| download | bcm5719-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/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f91e9dcdd6d..319e63dbb18 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5762,23 +5762,7 @@ static bool isFunctionDefinitionDiscarded(Sema &S, FunctionDecl *FD) { return false; // Okay, go ahead and call the relatively-more-expensive function. - -#ifndef NDEBUG - // AST quite reasonably asserts that it's working on a function - // definition. We don't really have a way to tell it that we're - // currently defining the function, so just lie to it in +Asserts - // builds. This is an awful hack. - FD->setLazyBody(1); -#endif - - bool isC99Inline = - S.Context.GetGVALinkageForFunction(FD) == GVA_AvailableExternally; - -#ifndef NDEBUG - FD->setLazyBody(0); -#endif - - return isC99Inline; + return S.Context.GetGVALinkageForFunction(FD) == GVA_AvailableExternally; } /// Determine whether a variable is extern "C" prior to attaching @@ -11487,6 +11471,11 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D, return D; } + // Mark this function as "will have a body eventually". This lets users to + // call e.g. isInlineDefinitionExternallyVisible while we're still parsing + // this function. + FD->setWillHaveBody(); + // If we are instantiating a generic lambda call operator, push // a LambdaScopeInfo onto the function stack. But use the information // that's already been calculated (ActOnLambdaExpr) to prime the current |

