#include "clang/Sema/AnalysisBasedWarnings.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/OperationKinds.h"
#include "clang/AST/ParentMap.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Type.h"
#include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
#include "clang/Analysis/Analyses/CalledOnceCheck.h"
#include "clang/Analysis/Analyses/Consumed.h"
#include "clang/Analysis/Analyses/ReachableCode.h"
#include "clang/Analysis/Analyses/ThreadSafety.h"
#include "clang/Analysis/Analyses/UninitializedValues.h"
#include "clang/Analysis/Analyses/UnsafeBufferUsage.h"
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/CFGStmtMap.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaInternal.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include <algorithm>
#include <deque>
#include <iterator>
#include <optional>
usingnamespaceclang;
namespace {
class UnreachableCodeHandler : public reachable_code::Callback { … };
}
static void CheckUnreachable(Sema &S, AnalysisDeclContext &AC) { … }
namespace {
class LogicalErrorHandler : public CFGCallback { … };
}
static bool hasRecursiveCallInPath(const FunctionDecl *FD, CFGBlock &Block) { … }
static bool checkForRecursiveFunctionCall(const FunctionDecl *FD, CFG *cfg) { … }
static void checkRecursiveFunction(Sema &S, const FunctionDecl *FD,
const Stmt *Body, AnalysisDeclContext &AC) { … }
static bool throwEscapes(Sema &S, const CXXThrowExpr *E, CFGBlock &ThrowBlock,
CFG *Body) { … }
static void visitReachableThrows(
CFG *BodyCFG,
llvm::function_ref<void(const CXXThrowExpr *, CFGBlock &)> Visit) { … }
static void EmitDiagForCXXThrowInNonThrowingFunc(Sema &S, SourceLocation OpLoc,
const FunctionDecl *FD) { … }
static void checkThrowInNonThrowingFunc(Sema &S, const FunctionDecl *FD,
AnalysisDeclContext &AC) { … }
static bool isNoexcept(const FunctionDecl *FD) { … }
enum ControlFlowKind { … };
static ControlFlowKind CheckFallThrough(AnalysisDeclContext &AC) { … }
namespace {
struct CheckFallThroughDiagnostics { … };
}
static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
QualType BlockType,
const CheckFallThroughDiagnostics &CD,
AnalysisDeclContext &AC,
sema::FunctionScopeInfo *FSI) { … }
namespace {
class ContainsReference : public ConstEvaluatedExprVisitor<ContainsReference> { … };
}
static bool SuggestInitializationFixit(Sema &S, const VarDecl *VD) { … }
static void CreateIfFixit(Sema &S, const Stmt *If, const Stmt *Then,
const Stmt *Else, bool CondVal,
FixItHint &Fixit1, FixItHint &Fixit2) { … }
static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,
bool IsCapturedByBlock) { … }
static bool DiagnoseUninitializedConstRefUse(Sema &S, const VarDecl *VD,
const UninitUse &Use) { … }
static bool DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
const UninitUse &Use,
bool alwaysReportSelfInit = false) { … }
namespace {
class FallthroughMapper : public RecursiveASTVisitor<FallthroughMapper> { … };
}
static StringRef getFallthroughAttrSpelling(Preprocessor &PP,
SourceLocation Loc) { … }
static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC,
bool PerFunction) { … }
static bool isInLoop(const ASTContext &Ctx, const ParentMap &PM,
const Stmt *S) { … }
static void diagnoseRepeatedUseOfWeak(Sema &S,
const sema::FunctionScopeInfo *CurFn,
const Decl *D,
const ParentMap &PM) { … }
namespace clang {
namespace {
OptionalNotes;
DelayedDiag;
DiagList;
struct SortDiagBySourceLocation { … };
}
}
namespace {
class UninitValsDiagReporter : public UninitVariablesHandler { … };
class CalledOnceInterProceduralData { … };
class CalledOnceCheckReporter : public CalledOnceCheckHandler { … };
constexpr unsigned CalledOnceWarnings[] = …;
constexpr unsigned CompletionHandlerWarnings[]{ … };
bool shouldAnalyzeCalledOnceImpl(llvm::ArrayRef<unsigned> DiagIDs,
const DiagnosticsEngine &Diags,
SourceLocation At) { … }
bool shouldAnalyzeCalledOnceConventions(const DiagnosticsEngine &Diags,
SourceLocation At) { … }
bool shouldAnalyzeCalledOnceParameters(const DiagnosticsEngine &Diags,
SourceLocation At) { … }
}
namespace clang {
namespace threadSafety {
namespace {
class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler { … };
}
}
}
namespace clang {
namespace consumed {
namespace {
class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase { … };
}
}
}
namespace {
class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { … };
}
sema::AnalysisBasedWarnings::Policy::Policy() { … }
class sema::AnalysisBasedWarnings::InterProceduralData { … };
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) { … }
sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s)
: … { … }
sema::AnalysisBasedWarnings::~AnalysisBasedWarnings() = default;
static void flushDiagnostics(Sema &S, const sema::FunctionScopeInfo *fscope) { … }
class CallableVisitor : public RecursiveASTVisitor<CallableVisitor> { … };
void clang::sema::AnalysisBasedWarnings::IssueWarnings(
TranslationUnitDecl *TU) { … }
void clang::sema::AnalysisBasedWarnings::IssueWarnings(
sema::AnalysisBasedWarnings::Policy P, sema::FunctionScopeInfo *fscope,
const Decl *D, QualType BlockType) { … }
void clang::sema::AnalysisBasedWarnings::PrintStats() const { … }