#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Lex/Lexer.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Unicode.h"
#include <optional>
usingnamespaceclang;
usingnamespaceento;
namespace {
struct LocalizedState { … };
class NonLocalizedStringChecker
: public Checker<check::PreCall, check::PostCall, check::PreObjCMessage,
check::PostObjCMessage,
check::PostStmt<ObjCStringLiteral>> { … };
}
REGISTER_MAP_WITH_PROGRAMSTATE(…) …
namespace {
class NonLocalizedStringBRVisitor final : public BugReporterVisitor { … };
}
#define NEW_RECEIVER(receiver) …
#define ADD_NULLARY_METHOD(receiver, method, argument) …
#define ADD_UNARY_METHOD(receiver, method, argument) …
#define ADD_METHOD(receiver, method_list, count, argument) …
void NonLocalizedStringChecker::initUIMethods(ASTContext &Ctx) const { … }
#define LSF_INSERT(function_name) …
#define LSM_INSERT_NULLARY(receiver, method_name) …
#define LSM_INSERT_UNARY(receiver, method_name) …
#define LSM_INSERT_SELECTOR(receiver, method_list, arguments) …
void NonLocalizedStringChecker::initLocStringsMethods(ASTContext &Ctx) const { … }
bool NonLocalizedStringChecker::isAnnotatedAsReturningLocalized(
const Decl *D) const { … }
bool NonLocalizedStringChecker::isAnnotatedAsTakingLocalized(
const Decl *D) const { … }
bool NonLocalizedStringChecker::hasLocalizedState(SVal S,
CheckerContext &C) const { … }
bool NonLocalizedStringChecker::hasNonLocalizedState(SVal S,
CheckerContext &C) const { … }
void NonLocalizedStringChecker::setLocalizedState(const SVal S,
CheckerContext &C) const { … }
void NonLocalizedStringChecker::setNonLocalizedState(const SVal S,
CheckerContext &C) const { … }
static bool isDebuggingName(std::string name) { … }
static bool isDebuggingContext(CheckerContext &C) { … }
void NonLocalizedStringChecker::reportLocalizationError(
SVal S, const CallEvent &M, CheckerContext &C, int argumentNumber) const { … }
int NonLocalizedStringChecker::getLocalizedArgumentForSelector(
const IdentifierInfo *Receiver, Selector S) const { … }
void NonLocalizedStringChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
CheckerContext &C) const { … }
void NonLocalizedStringChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const { … }
static inline bool isNSStringType(QualType T, ASTContext &Ctx) { … }
void NonLocalizedStringChecker::checkPostCall(const CallEvent &Call,
CheckerContext &C) const { … }
void NonLocalizedStringChecker::checkPostObjCMessage(const ObjCMethodCall &msg,
CheckerContext &C) const { … }
void NonLocalizedStringChecker::checkPostStmt(const ObjCStringLiteral *SL,
CheckerContext &C) const { … }
PathDiagnosticPieceRef
NonLocalizedStringBRVisitor::VisitNode(const ExplodedNode *Succ,
BugReporterContext &BRC,
PathSensitiveBugReport &BR) { … }
namespace {
class EmptyLocalizationContextChecker
: public Checker<check::ASTDecl<ObjCImplementationDecl>> { … };
}
void EmptyLocalizationContextChecker::checkASTDecl(
const ObjCImplementationDecl *D, AnalysisManager &Mgr,
BugReporter &BR) const { … }
void EmptyLocalizationContextChecker::MethodCrawler::VisitObjCMessageExpr(
const ObjCMessageExpr *ME) { … }
void EmptyLocalizationContextChecker::MethodCrawler::reportEmptyContextError(
const ObjCMessageExpr *ME) const { … }
namespace {
class PluralMisuseChecker : public Checker<check::ASTCodeBody> { … };
}
bool PluralMisuseChecker::MethodCrawler::isCheckingPlurality(
const Expr *Condition) const { … }
bool PluralMisuseChecker::MethodCrawler::VisitCallExpr(const CallExpr *CE) { … }
bool PluralMisuseChecker::MethodCrawler::VisitObjCMessageExpr(
const ObjCMessageExpr *ME) { … }
bool PluralMisuseChecker::MethodCrawler::TraverseIfStmt(IfStmt *I) { … }
bool PluralMisuseChecker::MethodCrawler::EndVisitIfStmt(IfStmt *I) { … }
bool PluralMisuseChecker::MethodCrawler::VisitIfStmt(const IfStmt *I) { … }
bool PluralMisuseChecker::MethodCrawler::TraverseConditionalOperator(
ConditionalOperator *C) { … }
bool PluralMisuseChecker::MethodCrawler::VisitConditionalOperator(
const ConditionalOperator *C) { … }
void PluralMisuseChecker::MethodCrawler::reportPluralMisuseError(
const Stmt *S) const { … }
void ento::registerNonLocalizedStringChecker(CheckerManager &mgr) { … }
bool ento::shouldRegisterNonLocalizedStringChecker(const CheckerManager &mgr) { … }
void ento::registerEmptyLocalizationContextChecker(CheckerManager &mgr) { … }
bool ento::shouldRegisterEmptyLocalizationContextChecker(
const CheckerManager &mgr) { … }
void ento::registerPluralMisuseChecker(CheckerManager &mgr) { … }
bool ento::shouldRegisterPluralMisuseChecker(const CheckerManager &mgr) { … }