Author: kadir çetinkaya Date: 2024-07-25T11:21:18+02:00 New Revision: 4ca1a901dc6ca1926a594f57e6c4997ea9d185a4
URL: https://github.com/llvm/llvm-project/commit/4ca1a901dc6ca1926a594f57e6c4997ea9d185a4 DIFF: https://github.com/llvm/llvm-project/commit/4ca1a901dc6ca1926a594f57e6c4997ea9d185a4.diff LOG: [clang][CUDA] Assume unknown emission status for skipped function definitions (#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. Added: Modified: clang/lib/Sema/SemaDecl.cpp clang/unittests/Tooling/ToolingTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index bb25a0b3a45ae..575bd292f27de 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -20148,8 +20148,10 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(const FunctionDecl *FD, // be emitted, because (say) the definition could include "inline". const FunctionDecl *Def = FD->getDefinition(); - return Def && !isDiscardableGVALinkage( - getASTContext().GetGVALinkageForFunction(Def)); + // We can't compute linkage when we skip function bodies. + return Def && !Def->hasSkippedBody() && + !isDiscardableGVALinkage( + getASTContext().GetGVALinkageForFunction(Def)); }; if (LangOpts.OpenMPIsTargetDevice) { diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index 2e3da2cd2a701..f41a44fa0922a 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/unittests/Tooling/ToolingTest.cpp @@ -586,6 +586,11 @@ TEST(runToolOnCode, TestSkipFunctionBody) { EXPECT_FALSE(runToolOnCodeWithArgs( std::make_unique<SkipBodyAction>(), "template<typename T> int skipMeNot() { an_error_here }", Args2)); + + EXPECT_TRUE(runToolOnCodeWithArgs( + std::make_unique<SkipBodyAction>(), + "__inline __attribute__((__gnu_inline__)) void skipMe() {}", + {"--cuda-host-only", "-nocudainc", "-xcuda"})); } TEST(runToolOnCodeWithArgs, TestNoDepFile) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits