Skip to content

[clang][NFC] declare internal linkage function static #108759

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

#include "Move.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this include added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not unrelated. ::clang::ento::move::isMovedFrom has declaration in "Move.h" but since missing this header, It is treated by clang-tidy check as internal linkage.

I think we need to add this include to make the declaration and definition in the same file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see -- thanks for the explanation!

#include "clang/AST/Attr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/Driver/DriverDiagnostic.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,9 @@ class VarBindingsCollector : public StoreManager::BindingsHandler {
};
} // namespace

Bindings getAllVarBindingsForSymbol(ProgramStateManager &Manager,
const ExplodedNode *Node, SymbolRef Sym) {
static Bindings getAllVarBindingsForSymbol(ProgramStateManager &Manager,
const ExplodedNode *Node,
SymbolRef Sym) {
Bindings Result;
VarBindingsCollector Collector{Sym, Result};
while (Result.empty() && Node) {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ bool SmartPtrModeling::isBoolConversionMethod(const CallEvent &Call) const {

constexpr llvm::StringLiteral BASIC_OSTREAM_NAMES[] = {"basic_ostream"};

bool isStdBasicOstream(const Expr *E) {
static bool isStdBasicOstream(const Expr *E) {
const auto *RD = E->getType()->getAsCXXRecordDecl();
return hasStdClassWithName(RD, BASIC_OSTREAM_NAMES);
}
Expand All @@ -250,7 +250,7 @@ static bool isStdFunctionCall(const CallEvent &Call) {
return Call.getDecl() && Call.getDecl()->getDeclContext()->isStdNamespace();
}

bool isStdOstreamOperatorCall(const CallEvent &Call) {
static bool isStdOstreamOperatorCall(const CallEvent &Call) {
if (Call.getNumArgs() != 2 || !isStdFunctionCall(Call))
return false;
const auto *FC = dyn_cast<SimpleFunctionCall>(&Call);
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static const MemSpaceRegion *getStackOrGlobalSpaceRegion(const MemRegion *R) {
return nullptr;
}

const MemRegion *getOriginBaseRegion(const MemRegion *Reg) {
static const MemRegion *getOriginBaseRegion(const MemRegion *Reg) {
Reg = Reg->getBaseRegion();
while (const auto *SymReg = dyn_cast<SymbolicRegion>(Reg)) {
const auto *OriginReg = SymReg->getSymbol()->getOriginRegion();
Expand All @@ -316,7 +316,7 @@ const MemRegion *getOriginBaseRegion(const MemRegion *Reg) {
return Reg;
}

std::optional<std::string> printReferrer(const MemRegion *Referrer) {
static std::optional<std::string> printReferrer(const MemRegion *Referrer) {
assert(Referrer);
const StringRef ReferrerMemorySpace = [](const MemSpaceRegion *Space) {
if (isa<StaticGlobalSpaceRegion>(Space))
Expand Down Expand Up @@ -354,7 +354,7 @@ std::optional<std::string> printReferrer(const MemRegion *Referrer) {

/// Check whether \p Region refers to a freshly minted symbol after an opaque
/// function call.
bool isInvalidatedSymbolRegion(const MemRegion *Region) {
static bool isInvalidatedSymbolRegion(const MemRegion *Region) {
const auto *SymReg = Region->getAs<SymbolicRegion>();
if (!SymReg)
return false;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ REGISTER_MAP_WITH_PROGRAMSTATE(VariantHeldTypeMap, const MemRegion *, QualType)

namespace clang::ento::tagged_union_modeling {

const CXXConstructorDecl *
static const CXXConstructorDecl *
getConstructorDeclarationForCall(const CallEvent &Call) {
const auto *ConstructorCall = dyn_cast<CXXConstructorCall>(&Call);
if (!ConstructorCall)
Expand Down Expand Up @@ -76,7 +76,7 @@ bool isMoveAssignmentCall(const CallEvent &Call) {
return AsMethodDecl->isMoveAssignmentOperator();
}

bool isStdType(const Type *Type, llvm::StringRef TypeName) {
static bool isStdType(const Type *Type, llvm::StringRef TypeName) {
auto *Decl = Type->getAsRecordDecl();
if (!Decl)
return false;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const PointerToMemberData *BasicValueFactory::getPointerToMemberData(
return D;
}

LLVM_ATTRIBUTE_UNUSED bool hasNoRepeatedElements(
LLVM_ATTRIBUTE_UNUSED static bool hasNoRepeatedElements(
llvm::ImmutableList<const CXXBaseSpecifier *> BaseSpecList) {
llvm::SmallPtrSet<QualType, 16> BaseSpecSeen;
for (const CXXBaseSpecifier *BaseSpec : BaseSpecList) {
Expand Down
7 changes: 4 additions & 3 deletions clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,18 +1211,19 @@ const arrowIndices = )<<<";
OS.str());
}

std::string getSpanBeginForControl(const char *ClassName, unsigned Index) {
static std::string getSpanBeginForControl(const char *ClassName,
unsigned Index) {
std::string Result;
llvm::raw_string_ostream OS(Result);
OS << "<span id=\"" << ClassName << Index << "\">";
return Result;
}

std::string getSpanBeginForControlStart(unsigned Index) {
static std::string getSpanBeginForControlStart(unsigned Index) {
return getSpanBeginForControl("start", Index);
}

std::string getSpanBeginForControlEnd(unsigned Index) {
static std::string getSpanBeginForControlEnd(unsigned Index) {
return getSpanBeginForControl("end", Index);
}

Expand Down
6 changes: 3 additions & 3 deletions clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ static bool isPossiblyEscaped(ExplodedNode *N, const DeclRefExpr *DR) {
llvm_unreachable("Reached root without finding the declaration of VD");
}

bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx,
ExplodedNode *Pred, unsigned &maxStep) {
static bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx,
ExplodedNode *Pred, unsigned &maxStep) {

if (!isLoopStmt(LoopStmt))
return false;
Expand Down Expand Up @@ -297,7 +297,7 @@ bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx,
return !isPossiblyEscaped(Pred, CounterVarRef);
}

bool madeNewBranch(ExplodedNode *N, const Stmt *LoopStmt) {
static bool madeNewBranch(ExplodedNode *N, const Stmt *LoopStmt) {
const Stmt *S = nullptr;
while (!N->pred_empty()) {
if (N->succ_size() > 1)
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ RangeSet RangeSet::Factory::unite(RangeSet Original, llvm::APSInt From,
}

template <typename T>
void swapIterators(T &First, T &FirstEnd, T &Second, T &SecondEnd) {
static void swapIterators(T &First, T &FirstEnd, T &Second, T &SecondEnd) {
std::swap(First, Second);
std::swap(FirstEnd, SecondEnd);
}
Expand Down Expand Up @@ -2624,7 +2624,7 @@ EquivalenceClass::removeMember(ProgramStateRef State, const SymbolRef Old) {
}

// Re-evaluate an SVal with top-level `State->assume` logic.
[[nodiscard]] ProgramStateRef
[[nodiscard]] static ProgramStateRef
reAssume(ProgramStateRef State, const RangeSet *Constraint, SVal TheValue) {
if (!Constraint)
return State;
Expand Down
Loading