clang  7.0.0
Functions | Variables
UninitializedObjectChecker.cpp File Reference
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include <algorithm>
Include dependency graph for UninitializedObjectChecker.cpp:

Go to the source code of this file.

Functions

static Optional< nonloc::LazyCompoundValgetObjectVal (const CXXConstructorDecl *CtorDecl, CheckerContext &Context)
 Returns the object that was constructed by CtorDecl, or None if that isn't possible. More...
 
static bool isCalledByConstructor (const CheckerContext &Context)
 Checks whether the constructor under checking is called by another constructor. More...
 
static bool isVoidPointer (const FieldDecl *FD)
 Returns whether FD can be (transitively) dereferenced to a void pointer type (void*, void**, ...). More...
 
static bool isPrimitiveType (const QualType &T)
 Returns true if T is a primitive type. More...
 
static void printNoteMessage (llvm::raw_ostream &Out, const FieldChainInfo &Chain)
 Constructs a note message for a given FieldChainInfo object. More...
 
static StringRef getVariableName (const FieldDecl *Field)
 Returns with Field's name. More...
 

Variables

static llvm::ImmutableListFactory< const FieldRegion * > Factory
 

Function Documentation

◆ getObjectVal()

static Optional< nonloc::LazyCompoundVal > getObjectVal ( const CXXConstructorDecl CtorDecl,
CheckerContext Context 
)
static

◆ getVariableName()

static StringRef getVariableName ( const FieldDecl Field)
static

◆ isCalledByConstructor()

static bool isCalledByConstructor ( const CheckerContext Context)
static

Checks whether the constructor under checking is called by another constructor.

Definition at line 642 of file UninitializedObjectChecker.cpp.

References clang::LocationContext::getDecl(), clang::ento::CheckerContext::getLocationContext(), and clang::LocationContext::getParent().

◆ isPrimitiveType()

static bool isPrimitiveType ( const QualType T)
static

Returns true if T is a primitive type.

We defined this type so that for objects that we'd only like analyze as much as checking whether their value is undefined or not, such as ints and doubles, can be analyzed with ease. This also helps ensuring that every special field type is handled correctly.

Definition at line 227 of file UninitializedObjectChecker.cpp.

References getVariableName(), clang::Type::isBuiltinType(), clang::Type::isEnumeralType(), clang::Type::isMemberPointerType(), and printNoteMessage().

◆ isVoidPointer()

static bool isVoidPointer ( const FieldDecl FD)
static

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.

Definition at line 614 of file UninitializedObjectChecker.cpp.

References clang::Type::getPointeeType(), clang::ValueDecl::getType(), clang::QualType::isNull(), and clang::Type::isVoidPointerType().

◆ printNoteMessage()

static void printNoteMessage ( llvm::raw_ostream &  Out,
const FieldChainInfo &  Chain 
)
static

Constructs a note message for a given FieldChainInfo object.

Definition at line 654 of file UninitializedObjectChecker.cpp.

Referenced by isPrimitiveType().

Variable Documentation

◆ Factory

llvm::ImmutableListFactory<const FieldRegion *> Factory
static