25class StringChecker :
public Checker<check::PreCall> {
27 mutable const FunctionDecl *StringConstCharPtrCtor =
nullptr;
30 CDM::CXXMethod, {
"std",
"basic_string",
"basic_string"}, 2, 2};
40 if (!TwoParamStdStringCtor.matches(
Call))
42 const auto *FD = dyn_cast<FunctionDecl>(
Call.getDecl());
46 if (StringConstCharPtrCtor && StringConstCharPtrCtor == FD)
52 const QualType Arg1Ty =
Call.getArgExpr(0)->getType().getCanonicalType();
53 const QualType Arg2Ty =
Call.getArgExpr(1)->getType().getCanonicalType();
63 StringConstCharPtrCtor = FD;
69 if (!isCharToStringCtor(
Call,
C.getASTContext()))
71 const auto Param =
Call.getArgSVal(0).getAs<
Loc>();
77 std::tie(NotNull, Null) =
C.getState()->assume(*Param);
81 return BR.isInteresting(*Param) ?
"Assuming the pointer is not null."
86 C.addTransition(NotNull, Null ?
C.getNoteTag(Callback) :
nullptr);
92 auto R = std::make_unique<PathSensitiveBugReport>(
93 BT_Null,
"The parameter must not be null", N);
95 C.emitReport(std::move(R));
105bool ento::shouldRegisterStringChecker(
const CheckerManager &) {
return true; }
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Represents a function declaration or definition.
A (possibly-)qualified type.
QualType getCanonicalType() const
bool isPointerType() const
A CallDescription is a pattern that can be used to match calls based on the qualified name and the ar...
Represents an abstract call to a function or method along a particular path.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
bool trackExpressionValue(const ExplodedNode *N, const Expr *E, PathSensitiveBugReport &R, TrackingOptions Opts={})
Attempts to add visitors to track expression value back to its point of origin.
const char *const LogicError
bool Null(InterpState &S, CodePtr OpPC, const Descriptor *Desc)
The JSON file list parser is used to communicate input to InstallAPI.