forked from OSchip/llvm-project
[analyzer][UninitializedObjectChecker] Moved non-member functions out of the anonymous namespace
As the code for the checker grew, it became increasinly difficult to see whether a function was global or statically defined. In this patch, anything that isn't a type declaration or definition was moved out of the anonymous namespace and is marked as static. llvm-svn: 336901
This commit is contained in:
parent
8a463897e9
commit
cc85244528
|
@ -50,8 +50,6 @@ public:
|
|||
void checkEndFunction(CheckerContext &C) const;
|
||||
};
|
||||
|
||||
llvm::ImmutableListFactory<const FieldRegion *> Factory;
|
||||
|
||||
/// Represents a field chain. A field chain is a vector of fields where the
|
||||
/// first element of the chain is the object under checking (not stored), and
|
||||
/// every other element is a field, and the element that precedes it is the
|
||||
|
@ -205,32 +203,37 @@ private:
|
|||
// TODO: Add a support for nonloc::LocAsInteger.
|
||||
};
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
// Static variable instantionations.
|
||||
|
||||
static llvm::ImmutableListFactory<const FieldRegion *> Factory;
|
||||
|
||||
// Utility function declarations.
|
||||
|
||||
/// Returns the object that was constructed by CtorDecl, or None if that isn't
|
||||
/// possible.
|
||||
Optional<nonloc::LazyCompoundVal>
|
||||
static Optional<nonloc::LazyCompoundVal>
|
||||
getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context);
|
||||
|
||||
/// Checks whether the constructor under checking is called by another
|
||||
/// constructor.
|
||||
bool isCalledByConstructor(const CheckerContext &Context);
|
||||
static bool isCalledByConstructor(const CheckerContext &Context);
|
||||
|
||||
/// Returns whether FD can be (transitively) dereferenced to a void pointer type
|
||||
/// (void*, void**, ...). The type of the region behind a void pointer isn't
|
||||
/// known, and thus FD can not be analyzed.
|
||||
bool isVoidPointer(const FieldDecl *FD);
|
||||
static bool isVoidPointer(const FieldDecl *FD);
|
||||
|
||||
/// Returns true if T is a primitive type. We'll call a type primitive if it's
|
||||
/// either a BuiltinType or an EnumeralType.
|
||||
bool isPrimitiveType(const QualType &T) {
|
||||
static bool isPrimitiveType(const QualType &T) {
|
||||
return T->isBuiltinType() || T->isEnumeralType();
|
||||
}
|
||||
|
||||
/// Constructs a note message for a given FieldChainInfo object.
|
||||
void printNoteMessage(llvm::raw_ostream &Out, const FieldChainInfo &Chain);
|
||||
|
||||
} // end of anonymous namespace
|
||||
static void printNoteMessage(llvm::raw_ostream &Out,
|
||||
const FieldChainInfo &Chain);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Methods for UninitializedObjectChecker.
|
||||
|
@ -638,9 +641,7 @@ void FieldChainInfo::printTail(
|
|||
// Utility functions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
bool isVoidPointer(const FieldDecl *FD) {
|
||||
static bool isVoidPointer(const FieldDecl *FD) {
|
||||
QualType T = FD->getType();
|
||||
|
||||
while (!T.isNull()) {
|
||||
|
@ -651,7 +652,7 @@ bool isVoidPointer(const FieldDecl *FD) {
|
|||
return false;
|
||||
}
|
||||
|
||||
Optional<nonloc::LazyCompoundVal>
|
||||
static Optional<nonloc::LazyCompoundVal>
|
||||
getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context) {
|
||||
|
||||
Loc ThisLoc = Context.getSValBuilder().getCXXThis(CtorDecl->getParent(),
|
||||
|
@ -668,7 +669,7 @@ getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context) {
|
|||
// TODO: We should also check that if the constructor was called by another
|
||||
// constructor, whether those two are in any relation to one another. In it's
|
||||
// current state, this introduces some false negatives.
|
||||
bool isCalledByConstructor(const CheckerContext &Context) {
|
||||
static bool isCalledByConstructor(const CheckerContext &Context) {
|
||||
const LocationContext *LC = Context.getLocationContext()->getParent();
|
||||
|
||||
while (LC) {
|
||||
|
@ -680,7 +681,8 @@ bool isCalledByConstructor(const CheckerContext &Context) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void printNoteMessage(llvm::raw_ostream &Out, const FieldChainInfo &Chain) {
|
||||
static void printNoteMessage(llvm::raw_ostream &Out,
|
||||
const FieldChainInfo &Chain) {
|
||||
if (Chain.isPointer()) {
|
||||
if (Chain.isDereferenced())
|
||||
Out << "uninitialized pointee 'this->";
|
||||
|
@ -692,8 +694,6 @@ void printNoteMessage(llvm::raw_ostream &Out, const FieldChainInfo &Chain) {
|
|||
Out << "'";
|
||||
}
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
void ento::registerUninitializedObjectChecker(CheckerManager &Mgr) {
|
||||
auto Chk = Mgr.registerChecker<UninitializedObjectChecker>();
|
||||
Chk->IsPedantic = Mgr.getAnalyzerOptions().getBooleanOption(
|
||||
|
|
Loading…
Reference in New Issue