Skip to content

[clang][analyzer][NFC] Run modernize-use-using check over all the code #149934

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion clang/lib/Analysis/BodyFarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ ValueDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
// Creation functions for faux ASTs.
//===----------------------------------------------------------------------===//

typedef Stmt *(*FunctionFarmer)(ASTContext &C, const FunctionDecl *D);
using FunctionFarmer = Stmt *(*)(ASTContext & C, const FunctionDecl *D);

static CallExpr *create_call_once_funcptr_call(ASTContext &C, ASTMaker M,
const ParmVarDecl *Callback,
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/CFGStmtMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using namespace clang;

typedef llvm::DenseMap<const Stmt*, CFGBlock*> SMap;
using SMap = llvm::DenseMap<const Stmt *, CFGBlock *>;
static SMap *AsMap(void *m) { return (SMap*) m; }

CFGStmtMap::~CFGStmtMap() { delete AsMap(M); }
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Analysis/ReachableCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ namespace {
Preprocessor &PP;
ASTContext &C;

typedef SmallVector<std::pair<const CFGBlock *, const Stmt *>, 12>
DeferredLocsTy;
using DeferredLocsTy =
SmallVector<std::pair<const CFGBlock *, const Stmt *>, 12>;

DeferredLocsTy DeferredLocs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void CheckObjCInstMethSignature(const ObjCImplementationDecl *ID,
ASTContext &Ctx = BR.getContext();

// Build a DenseMap of the methods for quick querying.
typedef llvm::DenseMap<Selector,ObjCMethodDecl*> MapTy;
using MapTy = llvm::DenseMap<Selector, ObjCMethodDecl *>;
MapTy IMeths;
unsigned NumMethods = 0;

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class WalkAST : public StmtVisitor<WalkAST> {
// Helpers.
bool checkCall_strCommon(const CallExpr *CE, const FunctionDecl *FD);

typedef void (WalkAST::*FnCheck)(const CallExpr *, const FunctionDecl *);
typedef void (WalkAST::*MsgCheck)(const ObjCMessageExpr *);
using FnCheck = void (WalkAST::*)(const CallExpr *, const FunctionDecl *);
using MsgCheck = void (WalkAST::*)(const ObjCMessageExpr *);

// Checker-specific methods.
void checkLoopConditionForFloat(const ForStmt *FS);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ bool ento::shouldRegisterCallGraphDumper(const CheckerManager &mgr) {

namespace {
class ConfigDumper : public Checker< check::EndOfTranslationUnit > {
typedef AnalyzerOptions::ConfigTable Table;
using Table = AnalyzerOptions::ConfigTable;

static int compareEntry(const Table::MapEntryTy *const *LHS,
const Table::MapEntryTy *const *RHS) {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class DebugContainerModeling
void analyzerContainerEnd(const CallExpr *CE, CheckerContext &C) const;
ExplodedNode *reportDebugMsg(llvm::StringRef Msg, CheckerContext &C) const;

typedef void (DebugContainerModeling::*FnCheck)(const CallExpr *,
CheckerContext &) const;
using FnCheck = void (DebugContainerModeling::*)(const CallExpr *,
CheckerContext &) const;

CallDescriptionMap<FnCheck> Callbacks = {
{{CDM::SimpleFunc, {"clang_analyzer_container_begin"}, 1},
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class DebugIteratorModeling
void analyzerIteratorValidity(const CallExpr *CE, CheckerContext &C) const;
ExplodedNode *reportDebugMsg(llvm::StringRef Msg, CheckerContext &C) const;

typedef void (DebugIteratorModeling::*FnCheck)(const CallExpr *,
CheckerContext &) const;
using FnCheck = void (DebugIteratorModeling::*)(const CallExpr *,
CheckerContext &) const;

CallDescriptionMap<FnCheck> Callbacks = {
{{CDM::SimpleFunc, {"clang_analyzer_iterator_position"}, 1},
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ static bool DefaultMethodFilter(const ObjCMethodDecl *M) {
class DirectIvarAssignment :
public Checker<check::ASTDecl<ObjCImplementationDecl> > {

typedef llvm::DenseMap<const ObjCIvarDecl*,
const ObjCPropertyDecl*> IvarToPropertyMapTy;
using IvarToPropertyMapTy =
llvm::DenseMap<const ObjCIvarDecl *, const ObjCPropertyDecl *>;

/// A helper class, which walks the AST and locates all assignments to ivars
/// in the given function.
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class ExprInspectionChecker
void analyzerExpress(const CallExpr *CE, CheckerContext &C) const;
void analyzerIsTainted(const CallExpr *CE, CheckerContext &C) const;

typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,
CheckerContext &C) const;
using FnCheck = void (ExprInspectionChecker::*)(const CallExpr *,
CheckerContext &C) const;

// Optional parameter `ExprVal` for expression value to be marked interesting.
ExplodedNode *reportBug(llvm::StringRef Msg, CheckerContext &C,
Expand Down
16 changes: 8 additions & 8 deletions clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ struct ChecksFilter {
};

class IvarInvalidationCheckerImpl {
typedef llvm::SmallSetVector<const ObjCMethodDecl*, 2> MethodSet;
typedef llvm::DenseMap<const ObjCMethodDecl*,
const ObjCIvarDecl*> MethToIvarMapTy;
typedef llvm::DenseMap<const ObjCPropertyDecl*,
const ObjCIvarDecl*> PropToIvarMapTy;
typedef llvm::DenseMap<const ObjCIvarDecl*,
const ObjCPropertyDecl*> IvarToPropMapTy;
using MethodSet = llvm::SmallSetVector<const ObjCMethodDecl *, 2>;
using MethToIvarMapTy =
llvm::DenseMap<const ObjCMethodDecl *, const ObjCIvarDecl *>;
using PropToIvarMapTy =
llvm::DenseMap<const ObjCPropertyDecl *, const ObjCIvarDecl *>;
using IvarToPropMapTy =
llvm::DenseMap<const ObjCIvarDecl *, const ObjCPropertyDecl *>;

struct InvalidationInfo {
/// Has the ivar been invalidated?
Expand Down Expand Up @@ -90,7 +90,7 @@ class IvarInvalidationCheckerImpl {
}
};

typedef llvm::DenseMap<const ObjCIvarDecl*, InvalidationInfo> IvarSet;
using IvarSet = llvm::DenseMap<const ObjCIvarDecl *, InvalidationInfo>;

/// Statement visitor, which walks the method body and flags the ivars
/// referenced in it (either directly or via property).
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ class Request {
// operations. A custom map implementation is used, in order to make it
// available in an arbitrary amount of translation units.
struct RequestMap {};
typedef llvm::ImmutableMap<const clang::ento::MemRegion *,
clang::ento::mpi::Request>
RequestMapImpl;
using RequestMapImpl = llvm::ImmutableMap<const clang::ento::MemRegion *,
clang::ento::mpi::Request>;

} // end of namespace: mpi

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class MacOSKeychainAPIChecker : public Checker<check::PreStmt<CallExpr>,
const char *NL, const char *Sep) const override;

private:
typedef std::pair<SymbolRef, const AllocationState*> AllocationPair;
typedef SmallVector<AllocationPair, 2> AllocationPairVec;
using AllocationPair = std::pair<SymbolRef, const AllocationState *>;
using AllocationPairVec = SmallVector<AllocationPair, 2>;

enum APIKind {
/// Denotes functions tracked by this checker.
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class MacOSXAPIChecker : public Checker< check::PreStmt<CallExpr> > {
void CheckDispatchOnce(CheckerContext &C, const CallExpr *CE,
StringRef FName) const;

typedef void (MacOSXAPIChecker::*SubChecker)(CheckerContext &,
const CallExpr *,
StringRef FName) const;
using SubChecker = void (MacOSXAPIChecker::*)(CheckerContext &,
const CallExpr *,
StringRef FName) const;
};
} //end anonymous namespace

Expand Down
6 changes: 3 additions & 3 deletions clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ using namespace ento;

namespace {

typedef std::pair<const TypeSourceInfo *, const CallExpr *> TypeCallPair;
typedef llvm::PointerUnion<const Stmt *, const VarDecl *> ExprParent;
using TypeCallPair = std::pair<const TypeSourceInfo *, const CallExpr *>;
using ExprParent = llvm::PointerUnion<const Stmt *, const VarDecl *>;

class CastedAllocFinder
: public ConstStmtVisitor<CastedAllocFinder, TypeCallPair> {
Expand All @@ -47,7 +47,7 @@ class CastedAllocFinder
ExplicitCastType(ExplicitCastType), AllocCall(AllocCall) {}
};

typedef std::vector<CallRecord> CallVec;
using CallVec = std::vector<CallRecord>;
CallVec Calls;

CastedAllocFinder(ASTContext *Ctx) :
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class NSOrCFErrorDerefChecker
};
}

typedef llvm::ImmutableMap<SymbolRef, unsigned> ErrorOutFlag;
using ErrorOutFlag = llvm::ImmutableMap<SymbolRef, unsigned>;
REGISTER_TRAIT_WITH_PROGRAMSTATE(NSErrorOut, ErrorOutFlag)
REGISTER_TRAIT_WITH_PROGRAMSTATE(CFErrorOut, ErrorOutFlag)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace clang;
using namespace ento;

enum IVarState { Unused, Used };
typedef llvm::DenseMap<const ObjCIvarDecl*,IVarState> IvarUsageMap;
using IvarUsageMap = llvm::DenseMap<const ObjCIvarDecl *, IVarState>;

static void Scan(IvarUsageMap& M, const Stmt *S) {
if (!S)
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class PthreadLockChecker : public Checker<check::PostCall, check::DeadSymbols,
CheckerNameRef CheckNames[CK_NumCheckKinds];

private:
typedef void (PthreadLockChecker::*FnCheck)(const CallEvent &Call,
CheckerContext &C,
CheckerKind CheckKind) const;
using FnCheck = void (PthreadLockChecker::*)(const CallEvent &Call,
CheckerContext &C,
CheckerKind CheckKind) const;
CallDescriptionMap<FnCheck> PThreadCallbacks = {
// Init.
{{CDM::CLibrary, {"pthread_mutex_init"}, 2},
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace clang;
using namespace ento;

namespace {
typedef SmallVector<SymbolRef, 2> SymbolVector;
using SymbolVector = SmallVector<SymbolRef, 2>;

struct StreamState {
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ class StdLibraryFunctionsChecker

/// The universal integral type to use in value range descriptions.
/// Unsigned to make sure overflows are well-defined.
typedef uint64_t RangeInt;
using RangeInt = uint64_t;

/// Describes a single range constraint. Eg. {{0, 1}, {3, 4}} is
/// a non-negative integer, which less than 5 and not equal to 2.
typedef std::vector<std::pair<RangeInt, RangeInt>> IntRangeVector;
using IntRangeVector = std::vector<std::pair<RangeInt, RangeInt>>;

/// A reference to an argument or return value by its number.
/// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
/// obviously uint32_t should be enough for all practical purposes.
typedef uint32_t ArgNo;
using ArgNo = uint32_t;
/// Special argument number for specifying the return value.
static const ArgNo Ret;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UnreachableCodeChecker : public Checker<check::EndAnalysis> {
void checkEndAnalysis(ExplodedGraph &G, BugReporter &B,
ExprEngine &Eng) const;
private:
typedef llvm::SmallSet<unsigned, 32> CFGBlocksSet;
using CFGBlocksSet = llvm::SmallSet<unsigned, 32>;

static inline const Stmt *getUnreachableStmt(const CFGBlock *CB);
static void FindUnreachableEntryPoints(const CFGBlock *CB,
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace ento;
REGISTER_SET_WITH_PROGRAMSTATE(InitializedVALists, const MemRegion *)

namespace {
typedef SmallVector<const MemRegion *, 2> RegionVector;
using RegionVector = SmallVector<const MemRegion *, 2>;

class ValistChecker : public Checker<check::PreCall, check::PreStmt<VAArgExpr>,
check::DeadSymbols> {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/BlockCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CountKey {

}

typedef llvm::ImmutableMap<CountKey, unsigned> CountMap;
using CountMap = llvm::ImmutableMap<CountKey, unsigned>;

static inline CountMap GetMap(void *D) {
return CountMap(static_cast<CountMap::TreeTy*>(D));
Expand Down
18 changes: 8 additions & 10 deletions clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ class ConstructedObjectKey {
};
} // namespace

typedef llvm::ImmutableMap<ConstructedObjectKey, SVal>
ObjectsUnderConstructionMap;
using ObjectsUnderConstructionMap =
llvm::ImmutableMap<ConstructedObjectKey, SVal>;
REGISTER_TRAIT_WITH_PROGRAMSTATE(ObjectsUnderConstruction,
ObjectsUnderConstructionMap)

Expand All @@ -194,22 +194,20 @@ REGISTER_TRAIT_WITH_PROGRAMSTATE(ObjectsUnderConstruction,
// memory region, which is important for multi-dimensional arrays. E.g:: int
// arr[2][2]; assume arr[1][1] will be the next element under construction, so
// the index is 3.
typedef llvm::ImmutableMap<
std::pair<const CXXConstructExpr *, const LocationContext *>, unsigned>
IndexOfElementToConstructMap;
using IndexOfElementToConstructMap = llvm::ImmutableMap<
std::pair<const CXXConstructExpr *, const LocationContext *>, unsigned>;
REGISTER_TRAIT_WITH_PROGRAMSTATE(IndexOfElementToConstruct,
IndexOfElementToConstructMap)

// This trait is responsible for holding our pending ArrayInitLoopExprs.
// It pairs the LocationContext and the initializer CXXConstructExpr with
// the size of the array that's being copy initialized.
typedef llvm::ImmutableMap<
std::pair<const CXXConstructExpr *, const LocationContext *>, unsigned>
PendingInitLoopMap;
using PendingInitLoopMap = llvm::ImmutableMap<
std::pair<const CXXConstructExpr *, const LocationContext *>, unsigned>;
REGISTER_TRAIT_WITH_PROGRAMSTATE(PendingInitLoop, PendingInitLoopMap)

typedef llvm::ImmutableMap<const LocationContext *, unsigned>
PendingArrayDestructionMap;
using PendingArrayDestructionMap =
llvm::ImmutableMap<const LocationContext *, unsigned>;
REGISTER_TRAIT_WITH_PROGRAMSTATE(PendingArrayDestruction,
PendingArrayDestructionMap)

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Core/ProgramState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ ProgramState::bindDefaultZero(SVal loc, const LocationContext *LCtx) const {
return Mgr.getOwningEngine().processRegionChange(State, R, LCtx);
}

typedef ArrayRef<const MemRegion *> RegionList;
typedef ArrayRef<SVal> ValueList;
using RegionList = ArrayRef<const MemRegion *>;
using ValueList = ArrayRef<SVal>;

ProgramStateRef ProgramState::invalidateRegions(
RegionList Regions, ConstCFGElementRef Elem, unsigned Count,
Expand Down
Loading