Skip to content

Commit 65c3617

Browse files
authored
[clang][analysis][NFC]add static for internal linkage function (#117481)
Detected by misc-use-internal-linkage
1 parent eb5d69c commit 65c3617

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

clang/lib/Analysis/FlowSensitive/Arena.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ canonicalFormulaPair(const Formula &LHS, const Formula &RHS) {
2323
}
2424

2525
template <class Key, class ComputeFunc>
26-
const Formula &cached(llvm::DenseMap<Key, const Formula *> &Cache, Key K,
27-
ComputeFunc &&Compute) {
26+
static const Formula &cached(llvm::DenseMap<Key, const Formula *> &Cache, Key K,
27+
ComputeFunc &&Compute) {
2828
auto [It, Inserted] = Cache.try_emplace(std::forward<Key>(K));
2929
if (Inserted)
3030
It->second = Compute();

clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static llvm::DenseMap<const ValueDecl *, StorageLocation *> intersectDeclToLoc(
6464
// expression must map to the same location / value. This is the case if we are
6565
// performing a join for control flow within a full-expression (which is the
6666
// only case when this function should be used).
67-
template <typename MapT> MapT joinExprMaps(const MapT &Map1, const MapT &Map2) {
67+
template <typename MapT>
68+
static MapT joinExprMaps(const MapT &Map1, const MapT &Map2) {
6869
MapT Result = Map1;
6970

7071
for (const auto &Entry : Map2) {
@@ -204,10 +205,11 @@ static WidenResult widenDistinctValues(QualType Type, Value &Prev,
204205
// Returns whether the values in `Map1` and `Map2` compare equal for those
205206
// keys that `Map1` and `Map2` have in common.
206207
template <typename Key>
207-
bool compareKeyToValueMaps(const llvm::MapVector<Key, Value *> &Map1,
208-
const llvm::MapVector<Key, Value *> &Map2,
209-
const Environment &Env1, const Environment &Env2,
210-
Environment::ValueModel &Model) {
208+
static bool compareKeyToValueMaps(const llvm::MapVector<Key, Value *> &Map1,
209+
const llvm::MapVector<Key, Value *> &Map2,
210+
const Environment &Env1,
211+
const Environment &Env2,
212+
Environment::ValueModel &Model) {
211213
for (auto &Entry : Map1) {
212214
Key K = Entry.first;
213215
assert(K != nullptr);
@@ -260,7 +262,7 @@ joinLocToVal(const llvm::MapVector<const StorageLocation *, Value *> &LocToVal,
260262
// Perform widening on either `LocToVal` or `ExprToVal`. `Key` must be either
261263
// `const StorageLocation *` or `const Expr *`.
262264
template <typename Key>
263-
llvm::MapVector<Key, Value *>
265+
static llvm::MapVector<Key, Value *>
264266
widenKeyToValueMap(const llvm::MapVector<Key, Value *> &CurMap,
265267
const llvm::MapVector<Key, Value *> &PrevMap,
266268
Environment &CurEnv, const Environment &PrevEnv,

clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ namespace dataflow {
1616

1717
/// Determines whether `D` is one of the methods used to implement Chromium's
1818
/// `CHECK` macros. Populates `CheckDecls`, if empty.
19-
bool isCheckLikeMethod(llvm::SmallDenseSet<const CXXMethodDecl *> &CheckDecls,
20-
const CXXMethodDecl &D) {
19+
static bool
20+
isCheckLikeMethod(llvm::SmallDenseSet<const CXXMethodDecl *> &CheckDecls,
21+
const CXXMethodDecl &D) {
2122
// All of the methods of interest are static, so avoid any lookup for
2223
// non-static methods (the common case).
2324
if (!D.isStatic())

clang/lib/Analysis/IntervalPartition.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ static unsigned getID(const CFGIntervalNode &I) { return I.ID; }
3636

3737
// `Node` must be one of `CFGBlock` or `CFGIntervalNode`.
3838
template <typename Node>
39-
BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
40-
const Node *Header) {
39+
static BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
40+
const Node *Header) {
4141
assert(Header != nullptr);
4242
BuildResult<Node> Interval;
4343
Interval.Nodes.push_back(Header);
@@ -102,10 +102,10 @@ BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
102102
}
103103

104104
template <typename Node>
105-
void fillIntervalNode(CFGIntervalGraph &Graph,
106-
std::vector<CFGIntervalNode *> &Index,
107-
std::queue<const Node *> &Successors,
108-
llvm::BitVector &Partitioned, const Node *Header) {
105+
static void fillIntervalNode(CFGIntervalGraph &Graph,
106+
std::vector<CFGIntervalNode *> &Index,
107+
std::queue<const Node *> &Successors,
108+
llvm::BitVector &Partitioned, const Node *Header) {
109109
BuildResult<Node> Result = buildInterval(Partitioned, Header);
110110
for (const auto *S : Result.Successors)
111111
Successors.push(S);
@@ -138,8 +138,8 @@ void fillIntervalNode(CFGIntervalGraph &Graph,
138138
}
139139

140140
template <typename Node>
141-
CFGIntervalGraph partitionIntoIntervalsImpl(unsigned NumBlockIDs,
142-
const Node *EntryBlock) {
141+
static CFGIntervalGraph partitionIntoIntervalsImpl(unsigned NumBlockIDs,
142+
const Node *EntryBlock) {
143143
assert(EntryBlock != nullptr);
144144
CFGIntervalGraph Graph;
145145
// `Index` maps all of the nodes of the input graph to the interval to which

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,8 @@ static StringRef getEndOfLine() {
23262326
}
23272327

23282328
// Returns the text indicating that the user needs to provide input there:
2329-
std::string getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
2329+
static std::string
2330+
getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
23302331
std::string s = std::string("<# ");
23312332
s += HintTextToUser;
23322333
s += " #>";

0 commit comments

Comments
 (0)