Skip to content

Commit eca5949

Browse files
authored
[codegen][NFC] add static mark for internal usage variable and function (#109431)
Detect by clang-tidy misc-use-internal-linkage
1 parent eddbd4e commit eca5949

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,10 @@ static Value *emitCallMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
587587
// matching the argument type. It is assumed that only the first argument is
588588
// overloaded.
589589
template <unsigned N>
590-
Value *emitBuiltinWithOneOverloadedType(CodeGenFunction &CGF, const CallExpr *E,
591-
unsigned IntrinsicID,
592-
llvm::StringRef Name = "") {
590+
static Value *emitBuiltinWithOneOverloadedType(CodeGenFunction &CGF,
591+
const CallExpr *E,
592+
unsigned IntrinsicID,
593+
llvm::StringRef Name = "") {
593594
static_assert(N, "expect non-empty argument");
594595
SmallVector<Value *, N> Args;
595596
for (unsigned I = 0; I < N; ++I)
@@ -18569,7 +18570,7 @@ llvm::Value *CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
1856918570
}
1857018571

1857118572
// Return dot product intrinsic that corresponds to the QT scalar type
18572-
Intrinsic::ID getDotProductIntrinsic(CGHLSLRuntime &RT, QualType QT) {
18573+
static Intrinsic::ID getDotProductIntrinsic(CGHLSLRuntime &RT, QualType QT) {
1857318574
if (QT->isFloatingType())
1857418575
return RT.getFDotIntrinsic();
1857518576
if (QT->isSignedIntegerType())

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() {
14901490
return llvm::PointerType::getUnqual(Kmpc_MicroTy);
14911491
}
14921492

1493-
llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind
1493+
static llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind
14941494
convertDeviceClause(const VarDecl *VD) {
14951495
std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
14961496
OMPDeclareTargetDeclAttr::getDeviceType(VD);
@@ -1513,7 +1513,7 @@ convertDeviceClause(const VarDecl *VD) {
15131513
}
15141514
}
15151515

1516-
llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryKind
1516+
static llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryKind
15171517
convertCaptureClause(const VarDecl *VD) {
15181518
std::optional<OMPDeclareTargetDeclAttr::MapTypeTy> MapType =
15191519
OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
@@ -8836,7 +8836,7 @@ static ValueDecl *getDeclFromThisExpr(const Expr *E) {
88368836

88378837
/// Emit a string constant containing the names of the values mapped to the
88388838
/// offloading runtime library.
8839-
llvm::Constant *
8839+
static llvm::Constant *
88408840
emitMappingInformation(CodeGenFunction &CGF, llvm::OpenMPIRBuilder &OMPBuilder,
88418841
MappableExprsHandler::MappingExprInfo &MapExprs) {
88428842

@@ -9450,8 +9450,8 @@ static llvm::Value *emitDeviceID(
94509450
return DeviceID;
94519451
}
94529452

9453-
llvm::Value *emitDynCGGroupMem(const OMPExecutableDirective &D,
9454-
CodeGenFunction &CGF) {
9453+
static llvm::Value *emitDynCGGroupMem(const OMPExecutableDirective &D,
9454+
CodeGenFunction &CGF) {
94559455
llvm::Value *DynCGroupMem = CGF.Builder.getInt32(0);
94569456

94579457
if (auto *DynMemClause = D.getSingleClause<OMPXDynCGroupMemClause>()) {

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,8 +2734,8 @@ GetAlignedMapping(const OMPLoopDirective &S, CodeGenFunction &CGF) {
27342734

27352735
// Pass OMPLoopDirective (instead of OMPSimdDirective) to make this function
27362736
// available for "loop bind(thread)", which maps to "simd".
2737-
void emitOMPSimdDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
2738-
CodeGenModule &CGM) {
2737+
static void emitOMPSimdDirective(const OMPLoopDirective &S,
2738+
CodeGenFunction &CGF, CodeGenModule &CGM) {
27392739
bool UseOMPIRBuilder =
27402740
CGM.getLangOpts().OpenMPIRBuilder && isSimdSupportedByOpenMPIRBuilder(S);
27412741
if (UseOMPIRBuilder) {
@@ -3987,8 +3987,8 @@ convertClauseKindToSchedKind(OpenMPScheduleClauseKind ScheduleClauseKind) {
39873987

39883988
// Pass OMPLoopDirective (instead of OMPForDirective) to make this function
39893989
// available for "loop bind(parallel)", which maps to "for".
3990-
void emitOMPForDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
3991-
CodeGenModule &CGM, bool HasCancel) {
3990+
static void emitOMPForDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
3991+
CodeGenModule &CGM, bool HasCancel) {
39923992
bool HasLastprivates = false;
39933993
bool UseOMPIRBuilder = CGM.getLangOpts().OpenMPIRBuilder &&
39943994
isForSupportedByOpenMPIRBuilder(S, HasCancel);
@@ -5447,7 +5447,7 @@ void CodeGenFunction::EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &S) {
54475447
CGM.getOpenMPRuntime().emitTaskwaitCall(*this, S.getBeginLoc(), Data);
54485448
}
54495449

5450-
bool isSupportedByOpenMPIRBuilder(const OMPTaskgroupDirective &T) {
5450+
static bool isSupportedByOpenMPIRBuilder(const OMPTaskgroupDirective &T) {
54515451
return T.clauses().empty();
54525452
}
54535453

@@ -5968,8 +5968,9 @@ void CodeGenFunction::EmitOMPDistributeLoop(const OMPLoopDirective &S,
59685968

59695969
// Pass OMPLoopDirective (instead of OMPDistributeDirective) to make this
59705970
// function available for "loop bind(teams)", which maps to "distribute".
5971-
void emitOMPDistributeDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
5972-
CodeGenModule &CGM) {
5971+
static void emitOMPDistributeDirective(const OMPLoopDirective &S,
5972+
CodeGenFunction &CGF,
5973+
CodeGenModule &CGM) {
59735974
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
59745975
CGF.EmitOMPDistributeLoop(S, emitOMPLoopBodyWithStopPoint, S.getInc());
59755976
};

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,9 @@ getLLVMVisibility(clang::LangOptions::VisibilityFromDLLStorageClassKinds K) {
784784
llvm_unreachable("unknown option value!");
785785
}
786786

787-
void setLLVMVisibility(llvm::GlobalValue &GV,
788-
std::optional<llvm::GlobalValue::VisibilityTypes> V) {
787+
static void
788+
setLLVMVisibility(llvm::GlobalValue &GV,
789+
std::optional<llvm::GlobalValue::VisibilityTypes> V) {
789790
if (!V)
790791
return;
791792

@@ -4224,8 +4225,8 @@ TargetMVPriority(const TargetInfo &TI,
42244225
// in the cases of CPUDispatch, this causes issues. This also makes sure we
42254226
// work with internal linkage functions, so that the same function name can be
42264227
// used with internal linkage in multiple TUs.
4227-
llvm::GlobalValue::LinkageTypes getMultiversionLinkage(CodeGenModule &CGM,
4228-
GlobalDecl GD) {
4228+
static llvm::GlobalValue::LinkageTypes
4229+
getMultiversionLinkage(CodeGenModule &CGM, GlobalDecl GD) {
42294230
const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
42304231
if (FD->getFormalLinkage() == Linkage::Internal)
42314232
return llvm::GlobalValue::InternalLinkage;

clang/lib/CodeGen/SanitizerMetadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static bool isAsanHwasanOrMemTag(const SanitizerSet &SS) {
2727
SanitizerKind::HWAddress | SanitizerKind::MemTag);
2828
}
2929

30-
SanitizerMask expandKernelSanitizerMasks(SanitizerMask Mask) {
30+
static SanitizerMask expandKernelSanitizerMasks(SanitizerMask Mask) {
3131
if (Mask & (SanitizerKind::Address | SanitizerKind::KernelAddress))
3232
Mask |= SanitizerKind::Address | SanitizerKind::KernelAddress;
3333
// Note: KHWASan doesn't support globals.

0 commit comments

Comments
 (0)