Skip to content

Commit 2292b3a

Browse files
committed
[WIP] Relax libcall-export-from-compartment warnings when the export is weak.
This is needed to unblock updating to a newer libc++ in CheriotRTOS.
1 parent b515057 commit 2292b3a

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15901,17 +15901,21 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
1590115901
getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
1590215902
Diag(FD->getLocation(), diag::warn_function_def_in_objc_container);
1590315903

15904-
if (FD->getType()->getAs<FunctionType>()->getCallConv() == CC_CHERILibCall &&
15905-
!Context.getLangOpts().CheriCompartmentName.empty())
15906-
Diag(FD->getLocation(),
15907-
diag::err_cheri_libcall_implemented_wrong_compartment)
15908-
<< Context.getLangOpts().CheriCompartmentName;
15909-
else if (FD->hasAttr<CHERICompartmentNameAttr>() &&
15910-
(FD->getAttr<CHERICompartmentNameAttr>()->getCompartmentName() !=
15911-
Context.getLangOpts().CheriCompartmentName))
15912-
Diag(FD->getLocation(), diag::err_cheri_implemented_wrong_compartment)
15913-
<< FD->getAttr<CHERICompartmentNameAttr>()->getCompartmentName()
15914-
<< Context.getLangOpts().CheriCompartmentName;
15904+
15905+
auto GVA = Context.GetGVALinkageForFunction(FD);
15906+
if (GVA != GVA_AvailableExternally && GVA != GVA_DiscardableODR) {
15907+
if (FD->getType()->getAs<FunctionType>()->getCallConv() == CC_CHERILibCall &&
15908+
!Context.getLangOpts().CheriCompartmentName.empty())
15909+
Diag(FD->getLocation(),
15910+
diag::err_cheri_libcall_implemented_wrong_compartment)
15911+
<< Context.getLangOpts().CheriCompartmentName;
15912+
else if (FD->hasAttr<CHERICompartmentNameAttr>() &&
15913+
(FD->getAttr<CHERICompartmentNameAttr>()->getCompartmentName() !=
15914+
Context.getLangOpts().CheriCompartmentName))
15915+
Diag(FD->getLocation(), diag::err_cheri_implemented_wrong_compartment)
15916+
<< FD->getAttr<CHERICompartmentNameAttr>()->getCompartmentName()
15917+
<< Context.getLangOpts().CheriCompartmentName;
15918+
}
1591515919

1591615920
maybeAddDeclWithEffects(FD);
1591715921

0 commit comments

Comments
 (0)