Skip to content

Commit df18650

Browse files
committed
Make helper functions static or move them into anonymous namespaces. NFC.
1 parent bff33bd commit df18650

File tree

35 files changed

+134
-93
lines changed

35 files changed

+134
-93
lines changed

clang/lib/AST/ASTImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3081,7 +3081,7 @@ Error ASTNodeImporter::ImportFunctionDeclBody(FunctionDecl *FromFD,
30813081

30823082
// Returns true if the given D has a DeclContext up to the TranslationUnitDecl
30833083
// which is equal to the given DC.
3084-
bool isAncestorDeclContextOf(const DeclContext *DC, const Decl *D) {
3084+
static bool isAncestorDeclContextOf(const DeclContext *DC, const Decl *D) {
30853085
const DeclContext *DCi = D->getDeclContext();
30863086
while (DCi != D->getTranslationUnitDecl()) {
30873087
if (DCi == DC)

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14260,6 +14260,7 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
1426014260
}
1426114261
}
1426214262

14263+
namespace {
1426314264
struct BuiltinAlignArgs {
1426414265
llvm::Value *Src = nullptr;
1426514266
llvm::Type *SrcType = nullptr;
@@ -14288,6 +14289,7 @@ struct BuiltinAlignArgs {
1428814289
Mask = CGF.Builder.CreateSub(Alignment, One, "mask");
1428914290
}
1429014291
};
14292+
} // namespace
1429114293

1429214294
/// Generate (x & (y-1)) == 0.
1429314295
RValue CodeGenFunction::EmitBuiltinIsAligned(const CallExpr *E) {

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,7 @@ CGOpenMPRuntime::getUserDefinedReduction(const OMPDeclareReductionDecl *D) {
14381438
return UDRMap.lookup(D);
14391439
}
14401440

1441+
namespace {
14411442
// Temporary RAII solution to perform a push/pop stack event on the OpenMP IR
14421443
// Builder if one is present.
14431444
struct PushAndPopStackRAII {
@@ -1481,6 +1482,7 @@ struct PushAndPopStackRAII {
14811482
}
14821483
llvm::OpenMPIRBuilder *OMPBuilder;
14831484
};
1485+
} // namespace
14841486

14851487
static llvm::Function *emitParallelOrTeamsOutlinedFunction(
14861488
CodeGenModule &CGM, const OMPExecutableDirective &D, const CapturedStmt *CS,
@@ -11122,8 +11124,8 @@ bool checkContext<OMP_CTX_SET_device, OMP_CTX_kind, CodeGenModule &>(
1112211124
return true;
1112311125
}
1112411126

11125-
bool matchesContext(CodeGenModule &CGM,
11126-
const CompleteOMPContextSelectorData &ContextData) {
11127+
static bool matchesContext(CodeGenModule &CGM,
11128+
const CompleteOMPContextSelectorData &ContextData) {
1112711129
for (const OMPContextSelectorData &Data : ContextData) {
1112811130
switch (Data.Ctx) {
1112911131
case OMP_CTX_vendor:

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ static void getARMHWDivFeatures(const Driver &D, const Arg *A,
6363
}
6464

6565
// Handle -mfpu=.
66-
unsigned getARMFPUFeatures(const Driver &D, const Arg *A,
67-
const ArgList &Args, StringRef FPU,
68-
std::vector<StringRef> &Features) {
66+
static unsigned getARMFPUFeatures(const Driver &D, const Arg *A,
67+
const ArgList &Args, StringRef FPU,
68+
std::vector<StringRef> &Features) {
6969
unsigned FPUID = llvm::ARM::parseFPU(FPU);
7070
if (!llvm::ARM::getFPUFeatures(FPUID, Features))
7171
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);

clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using namespace clang;
77
using namespace ento;
88

9+
namespace {
910
class PlacementNewChecker : public Checker<check::PreStmt<CXXNewExpr>> {
1011
public:
1112
void checkPreStmt(const CXXNewExpr *NE, CheckerContext &C) const;
@@ -22,6 +23,7 @@ class PlacementNewChecker : public Checker<check::PreStmt<CXXNewExpr>> {
2223
BugType BT{this, "Insufficient storage for placement new",
2324
categories::MemoryError};
2425
};
26+
} // namespace
2527

2628
SVal PlacementNewChecker::getExtentSizeOfPlace(const Expr *Place,
2729
ProgramStateRef State,

clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ static const ExplodedNode *getAcquireSite(const ExplodedNode *N, SymbolRef Sym,
223223

224224
/// Returns the symbols extracted from the argument or null if it cannot be
225225
/// found.
226-
SymbolRef getFuchsiaHandleSymbol(QualType QT, SVal Arg, ProgramStateRef State) {
226+
static SymbolRef getFuchsiaHandleSymbol(QualType QT, SVal Arg,
227+
ProgramStateRef State) {
227228
int PtrToHandleLevel = 0;
228229
while (QT->isAnyPointerType() || QT->isReferenceType()) {
229230
++PtrToHandleLevel;

llvm/lib/CodeGen/MIRParser/MIParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,8 +1734,8 @@ static bool getHexUint(const MIToken &Token, APInt &Result) {
17341734
return false;
17351735
}
17361736

1737-
bool getUnsigned(const MIToken &Token, unsigned &Result,
1738-
ErrorCallbackType ErrCB) {
1737+
static bool getUnsigned(const MIToken &Token, unsigned &Result,
1738+
ErrorCallbackType ErrCB) {
17391739
if (Token.hasIntegerValue()) {
17401740
const uint64_t Limit = uint64_t(std::numeric_limits<unsigned>::max()) + 1;
17411741
uint64_t Val64 = Token.integerValue().getLimitedValue(Limit);

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ static bool isTargetDarwin(const MachineFunction &MF) {
837837
}
838838

839839
// Convenience function to determine whether I is an SVE callee save.
840-
bool IsSVECalleeSave(MachineBasicBlock::iterator I) {
840+
static bool IsSVECalleeSave(MachineBasicBlock::iterator I) {
841841
switch (I->getOpcode()) {
842842
default:
843843
return false;

llvm/lib/Target/Mips/MipsLegalizerInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ static bool MSA3OpIntrinsicToGeneric(MachineInstr &MI, unsigned Opcode,
341341
return true;
342342
}
343343

344-
bool MSA2OpIntrinsicToGeneric(MachineInstr &MI, unsigned Opcode,
345-
MachineIRBuilder &MIRBuilder,
346-
const MipsSubtarget &ST) {
344+
static bool MSA2OpIntrinsicToGeneric(MachineInstr &MI, unsigned Opcode,
345+
MachineIRBuilder &MIRBuilder,
346+
const MipsSubtarget &ST) {
347347
assert(ST.hasMSA() && "MSA intrinsic not supported on target without MSA.");
348348
MIRBuilder.buildInstr(Opcode)
349349
.add(MI.getOperand(0))

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ Instruction *InstCombiner::narrowMathIfNoOverflow(BinaryOperator &BO) {
16491649
return CastInst::Create(CastOpc, NarrowBO, BO.getType());
16501650
}
16511651

1652-
bool isMergedGEPInBounds(GEPOperator &GEP1, GEPOperator &GEP2) {
1652+
static bool isMergedGEPInBounds(GEPOperator &GEP1, GEPOperator &GEP2) {
16531653
// At least one GEP must be inbounds.
16541654
if (!GEP1.isInBounds() && !GEP2.isInBounds())
16551655
return false;

0 commit comments

Comments
 (0)