Skip to content

Commit 4ca1a90

Browse files
authored
[clang][CUDA] Assume unknown emission status for skipped function definitions (llvm#100124)
Emission status seems to be only used by cuda/openmp/hip compiles, to figure out when to emit diagnostics. Current logic emits "uknown" when definition is missing, so i extended that to skipped-function-bodies as well.
1 parent 98c73d5 commit 4ca1a90

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20148,8 +20148,10 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(const FunctionDecl *FD,
2014820148
// be emitted, because (say) the definition could include "inline".
2014920149
const FunctionDecl *Def = FD->getDefinition();
2015020150

20151-
return Def && !isDiscardableGVALinkage(
20152-
getASTContext().GetGVALinkageForFunction(Def));
20151+
// We can't compute linkage when we skip function bodies.
20152+
return Def && !Def->hasSkippedBody() &&
20153+
!isDiscardableGVALinkage(
20154+
getASTContext().GetGVALinkageForFunction(Def));
2015320155
};
2015420156

2015520157
if (LangOpts.OpenMPIsTargetDevice) {

clang/unittests/Tooling/ToolingTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,11 @@ TEST(runToolOnCode, TestSkipFunctionBody) {
586586
EXPECT_FALSE(runToolOnCodeWithArgs(
587587
std::make_unique<SkipBodyAction>(),
588588
"template<typename T> int skipMeNot() { an_error_here }", Args2));
589+
590+
EXPECT_TRUE(runToolOnCodeWithArgs(
591+
std::make_unique<SkipBodyAction>(),
592+
"__inline __attribute__((__gnu_inline__)) void skipMe() {}",
593+
{"--cuda-host-only", "-nocudainc", "-xcuda"}));
589594
}
590595

591596
TEST(runToolOnCodeWithArgs, TestNoDepFile) {

0 commit comments

Comments
 (0)