-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang][analysis][NFC]add static for internal linkage function #117481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Detected by misc-use-internal-linkage
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-analysis Author: Congcong Cai (HerrCai0907) ChangesDetected by misc-use-internal-linkage Full diff: https://github.com/llvm/llvm-project/pull/117481.diff 5 Files Affected:
diff --git a/clang/lib/Analysis/FlowSensitive/Arena.cpp b/clang/lib/Analysis/FlowSensitive/Arena.cpp
index 81137e8088e330..7542a137c735e0 100644
--- a/clang/lib/Analysis/FlowSensitive/Arena.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Arena.cpp
@@ -23,8 +23,8 @@ canonicalFormulaPair(const Formula &LHS, const Formula &RHS) {
}
template <class Key, class ComputeFunc>
-const Formula &cached(llvm::DenseMap<Key, const Formula *> &Cache, Key K,
- ComputeFunc &&Compute) {
+static const Formula &cached(llvm::DenseMap<Key, const Formula *> &Cache, Key K,
+ ComputeFunc &&Compute) {
auto [It, Inserted] = Cache.try_emplace(std::forward<Key>(K));
if (Inserted)
It->second = Compute();
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index c5c6e900b79766..693313b322af1b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -64,7 +64,8 @@ static llvm::DenseMap<const ValueDecl *, StorageLocation *> intersectDeclToLoc(
// expression must map to the same location / value. This is the case if we are
// performing a join for control flow within a full-expression (which is the
// only case when this function should be used).
-template <typename MapT> MapT joinExprMaps(const MapT &Map1, const MapT &Map2) {
+template <typename MapT>
+static MapT joinExprMaps(const MapT &Map1, const MapT &Map2) {
MapT Result = Map1;
for (const auto &Entry : Map2) {
@@ -204,10 +205,11 @@ static WidenResult widenDistinctValues(QualType Type, Value &Prev,
// Returns whether the values in `Map1` and `Map2` compare equal for those
// keys that `Map1` and `Map2` have in common.
template <typename Key>
-bool compareKeyToValueMaps(const llvm::MapVector<Key, Value *> &Map1,
- const llvm::MapVector<Key, Value *> &Map2,
- const Environment &Env1, const Environment &Env2,
- Environment::ValueModel &Model) {
+static bool compareKeyToValueMaps(const llvm::MapVector<Key, Value *> &Map1,
+ const llvm::MapVector<Key, Value *> &Map2,
+ const Environment &Env1,
+ const Environment &Env2,
+ Environment::ValueModel &Model) {
for (auto &Entry : Map1) {
Key K = Entry.first;
assert(K != nullptr);
@@ -260,7 +262,7 @@ joinLocToVal(const llvm::MapVector<const StorageLocation *, Value *> &LocToVal,
// Perform widening on either `LocToVal` or `ExprToVal`. `Key` must be either
// `const StorageLocation *` or `const Expr *`.
template <typename Key>
-llvm::MapVector<Key, Value *>
+static llvm::MapVector<Key, Value *>
widenKeyToValueMap(const llvm::MapVector<Key, Value *> &CurMap,
const llvm::MapVector<Key, Value *> &PrevMap,
Environment &CurEnv, const Environment &PrevEnv,
diff --git a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
index 77d817dafe8378..02fd73754f01be 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
@@ -16,8 +16,9 @@ namespace dataflow {
/// Determines whether `D` is one of the methods used to implement Chromium's
/// `CHECK` macros. Populates `CheckDecls`, if empty.
-bool isCheckLikeMethod(llvm::SmallDenseSet<const CXXMethodDecl *> &CheckDecls,
- const CXXMethodDecl &D) {
+static bool
+isCheckLikeMethod(llvm::SmallDenseSet<const CXXMethodDecl *> &CheckDecls,
+ const CXXMethodDecl &D) {
// All of the methods of interest are static, so avoid any lookup for
// non-static methods (the common case).
if (!D.isStatic())
diff --git a/clang/lib/Analysis/IntervalPartition.cpp b/clang/lib/Analysis/IntervalPartition.cpp
index 5f06606ec132e9..41199f358c5b97 100644
--- a/clang/lib/Analysis/IntervalPartition.cpp
+++ b/clang/lib/Analysis/IntervalPartition.cpp
@@ -36,8 +36,8 @@ static unsigned getID(const CFGIntervalNode &I) { return I.ID; }
// `Node` must be one of `CFGBlock` or `CFGIntervalNode`.
template <typename Node>
-BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
- const Node *Header) {
+static BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
+ const Node *Header) {
assert(Header != nullptr);
BuildResult<Node> Interval;
Interval.Nodes.push_back(Header);
@@ -102,10 +102,10 @@ BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
}
template <typename Node>
-void fillIntervalNode(CFGIntervalGraph &Graph,
- std::vector<CFGIntervalNode *> &Index,
- std::queue<const Node *> &Successors,
- llvm::BitVector &Partitioned, const Node *Header) {
+static void fillIntervalNode(CFGIntervalGraph &Graph,
+ std::vector<CFGIntervalNode *> &Index,
+ std::queue<const Node *> &Successors,
+ llvm::BitVector &Partitioned, const Node *Header) {
BuildResult<Node> Result = buildInterval(Partitioned, Header);
for (const auto *S : Result.Successors)
Successors.push(S);
@@ -138,8 +138,8 @@ void fillIntervalNode(CFGIntervalGraph &Graph,
}
template <typename Node>
-CFGIntervalGraph partitionIntoIntervalsImpl(unsigned NumBlockIDs,
- const Node *EntryBlock) {
+static CFGIntervalGraph partitionIntoIntervalsImpl(unsigned NumBlockIDs,
+ const Node *EntryBlock) {
assert(EntryBlock != nullptr);
CFGIntervalGraph Graph;
// `Index` maps all of the nodes of the input graph to the interval to which
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 5f36ffa926b269..321097e16a45f7 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2326,7 +2326,8 @@ static StringRef getEndOfLine() {
}
// Returns the text indicating that the user needs to provide input there:
-std::string getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
+static std::string
+getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
std::string s = std::string("<# ");
s += HintTextToUser;
s += " #>";
|
NagyDonat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with these files, but the change seems to be harmless enough...
Let's hope that it doesn't cause any weird bugs.
Detected by misc-use-internal-linkage