#include #include #include #include #include #include ">

clang: lib/Analysis/CFG.cpp File Reference (original) (raw)

#include "[clang/Analysis/CFG.h](CFG%5F8h%5Fsource.html)"
#include "[clang/AST/ASTContext.h](ASTContext%5F8h%5Fsource.html)"
#include "[clang/AST/Attr.h](AST%5F2Attr%5F8h%5Fsource.html)"
#include "[clang/AST/Decl.h](Decl%5F8h%5Fsource.html)"
#include "[clang/AST/DeclBase.h](DeclBase%5F8h%5Fsource.html)"
#include "[clang/AST/DeclCXX.h](DeclCXX%5F8h%5Fsource.html)"
#include "[clang/AST/DeclGroup.h](DeclGroup%5F8h%5Fsource.html)"
#include "[clang/AST/Expr.h](Expr%5F8h%5Fsource.html)"
#include "[clang/AST/ExprCXX.h](ExprCXX%5F8h%5Fsource.html)"
#include "[clang/AST/OperationKinds.h](OperationKinds%5F8h%5Fsource.html)"
#include "[clang/AST/PrettyPrinter.h](PrettyPrinter%5F8h%5Fsource.html)"
#include "[clang/AST/Stmt.h](Stmt%5F8h%5Fsource.html)"
#include "[clang/AST/StmtCXX.h](StmtCXX%5F8h%5Fsource.html)"
#include "[clang/AST/StmtObjC.h](StmtObjC%5F8h%5Fsource.html)"
#include "[clang/AST/StmtVisitor.h](StmtVisitor%5F8h%5Fsource.html)"
#include "[clang/AST/Type.h](Type%5F8h%5Fsource.html)"
#include "[clang/Analysis/ConstructionContext.h](ConstructionContext%5F8h%5Fsource.html)"
#include "[clang/Analysis/Support/BumpVector.h](BumpVector%5F8h%5Fsource.html)"
#include "[clang/Basic/Builtins.h](Builtins%5F8h%5Fsource.html)"
#include "[clang/Basic/ExceptionSpecificationType.h](ExceptionSpecificationType%5F8h%5Fsource.html)"
#include "[clang/Basic/JsonSupport.h](JsonSupport%5F8h%5Fsource.html)"
#include "[clang/Basic/LLVM.h](LLVM%5F8h%5Fsource.html)"
#include "[clang/Basic/LangOptions.h](LangOptions%5F8h%5Fsource.html)"
#include "[clang/Basic/SourceLocation.h](SourceLocation%5F8h%5Fsource.html)"
#include "[clang/Basic/Specifiers.h](Specifiers%5F8h%5Fsource.html)"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces
namespace llvm
Diagnostic wrappers for TextAPI types for error reporting.
Functions
static SourceLocation GetEndLoc (Decl *D)
static bool IsLiteralConstantExpr (const Expr *E)
Returns true on constant values based around a single IntegerLiteral, CharacterLiteral, or FloatingLiteral.
static const Expr * tryTransformToLiteralConstant (const Expr *E)
Helper for tryNormalizeBinaryOperator.
static std::tuple< const Expr *, BinaryOperatorKind, const Expr * > tryNormalizeBinaryOperator (const BinaryOperator *B)
Tries to interpret a binary operator into Expr Op NumExpr form, if NumExpr is an integer literal or an enum constant.
static bool areExprTypesCompatible (const Expr *E1, const Expr *E2)
For an expression x == Foo && x == Bar, this determines whether the Foo and Bar are either of the same enumeration type, or both integer literals.
static TryResult bothKnownTrue (TryResult R1, TryResult R2)
static const VariableArrayType * FindVA (const Type *t)
static QualType getReferenceInitTemporaryType (const Expr *Init, bool *FoundMTE=nullptr)
Retrieve the type of the temporary object whose lifetime was extended by a local reference with the given initializer.
static bool isFallthroughStatement (const AttributedStmt *A)
static bool isCXXAssumeAttr (const AttributedStmt *A)
static bool CanThrow (Expr *E, ASTContext &Ctx)
static bool isBuiltinAssumeWithSideEffects (const ASTContext &Ctx, const CallExpr *CE)
static bool shouldAddCase (bool &switchExclusivelyCovered, const Expr::EvalResult *switchCond, const CaseStmt *CS, ASTContext &Ctx)
static void print_initializer (raw_ostream &OS, StmtPrinterHelper &Helper, const CXXCtorInitializer *I)
static void print_construction_context (raw_ostream &OS, StmtPrinterHelper &Helper, const ConstructionContext *CC)
static void print_elem (raw_ostream &OS, StmtPrinterHelper &Helper, const CFGElement &E, bool TerminateWithNewLine=true)
static void print_block (raw_ostream &OS, const CFG *cfg, const CFGBlock &B, StmtPrinterHelper &Helper, bool print_edges, bool ShowColors)
static bool isImmediateSinkBlock (const CFGBlock *Blk)
Variables
static StmtPrinterHelper * GraphHelper

areExprTypesCompatible()

bool areExprTypesCompatible ( const Expr * E1, const Expr * E2 ) static

For an expression x == Foo && x == Bar, this determines whether the Foo and Bar are either of the same enumeration type, or both integer literals.

It's an error to pass this arguments that are not either IntegerLiterals or DeclRefExprs (that have decls of type EnumConstantDecl)

Definition at line 147 of file CFG.cpp.

References clang::cast(), and clang::isa().

bothKnownTrue()

TryResult bothKnownTrue ( TryResult R1, TryResult R2 ) static

CanThrow()

Definition at line 2788 of file CFG.cpp.

References clang::Type::getAs(), clang::Type::getPointeeType(), clang::Expr::getType(), clang::Type::isBlockPointerType(), clang::Type::isFunctionPointerType(), and clang::isUnresolvedExceptionSpec().

Referenced by clang::BlockVarCopyInit::BlockVarCopyInit(), clang::CodeGen::CodeGenFunction::BuildBlockRelease(), clang::Sema::BuildCXXNoexceptExpr(), clang::CodeGen::CodeGenFunction::enterByrefCleanup(), pushCaptureCleanup(), clang::ASTContext::setBlockVarCopyInit(), and clang::BlockVarCopyInit::setExprAndFlag().

FindVA()

GetEndLoc()

getReferenceInitTemporaryType()

QualType getReferenceInitTemporaryType ( const Expr * Init, bool * FoundMTE = nullptr ) static

isBuiltinAssumeWithSideEffects()

isCXXAssumeAttr()

isFallthroughStatement()

isImmediateSinkBlock()

IsLiteralConstantExpr()

bool IsLiteralConstantExpr ( const Expr * E) static

print_block()

void print_block ( raw_ostream & OS, const CFG * cfg, const CFGBlock & B, StmtPrinterHelper & Helper, bool print_edges, bool ShowColors ) static

Definition at line 6055 of file CFG.cpp.

References clang::CFGBlock::begin(), clang::C, clang::CFGBlock::end(), clang::CFGBlock::getBlockID(), clang::CFG::getEntry(), clang::CXXCatchStmt::getExceptionDecl(), clang::CFG::getExit(), clang::SEHExceptStmt::getFilterExpr(), clang::CFG::getIndirectGotoBlock(), clang::CFGBlock::getLabel(), clang::LabelStmt::getName(), clang::CFGBlock::getTerminator(), clang::CFGBlock::hasNoReturnElement(), clang::isa(), clang::CFGTerminator::isValid(), clang::CFGBlock::Label, clang::CFGBlock::pred_begin(), clang::CFGBlock::pred_empty(), clang::CFGBlock::pred_end(), clang::CFGBlock::pred_size(), print_elem(), clang::Stmt::printPretty(), clang::CFGBlock::succ_begin(), clang::CFGBlock::succ_empty(), clang::CFGBlock::succ_end(), and clang::CFGBlock::succ_size().

Referenced by llvm::DOTGraphTraits< const CFG * >::getNodeLabel(), clang::CFG::print(), and clang::CFGBlock::print().

print_construction_context()

void print_construction_context ( raw_ostream & OS, StmtPrinterHelper & Helper, const ConstructionContext * CC ) static

Definition at line 5799 of file CFG.cpp.

References clang::ConstructionContext::ArgumentKind, clang::cast(), clang::ConstructionContext::CXX17ElidedCopyConstructorInitializerKind, clang::ConstructionContext::CXX17ElidedCopyReturnedValueKind, clang::ConstructionContext::CXX17ElidedCopyVariableKind, clang::ConstructionContext::ElidedTemporaryObjectKind, clang::ConstructionContext::getKind(), clang::ConstructionContext::LambdaCaptureKind, clang::ConstructionContext::NewAllocatedObjectKind, print_initializer(), clang::ConstructionContext::SimpleConstructorInitializerKind, clang::ConstructionContext::SimpleReturnedValueKind, clang::ConstructionContext::SimpleTemporaryObjectKind, and clang::ConstructionContext::SimpleVariableKind.

Referenced by print_elem().

print_elem()

void print_elem ( raw_ostream & OS, StmtPrinterHelper & Helper, const CFGElement & E, bool TerminateWithNewLine = true ) static

Definition at line 5894 of file CFG.cpp.

References clang::CFGElement::AutomaticObjectDtor, clang::CFGElement::BaseDtor, clang::CompoundStmt::body_rbegin(), clang::cast(), clang::CFGElement::castAs(), Children, clang::CFGElement::CleanupFunction, clang::CFGElement::Constructor, clang::CFGElement::CXXRecordTypedCall, clang::CFGElement::DeleteDtor, clang::CFGNewAllocator::getAllocatorExpr(), clang::CXXDeleteExpr::getArgument(), clang::CFGElement::getAs(), clang::Type::getAsCXXRecordDecl(), clang::Type::getBaseElementTypeUnsafe(), clang::CFGDeleteDtor::getCXXRecordDecl(), clang::CFGDeleteDtor::getDeleteExpr(), clang::CFGInitializer::getInitializer(), clang::CFGElement::getKind(), clang::NamedDecl::getName(), clang::BinaryOperator::getOpcode(), clang::NamedDecl::getQualifiedNameAsString(), getReferenceInitTemporaryType(), clang::BinaryOperator::getRHS(), clang::CFGStmt::getStmt(), clang::Stmt::getStmtClassName(), clang::StmtExpr::getSubStmt(), clang::CXXBaseSpecifier::getType(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::CFGAutomaticObjDtor::getVarDecl(), clang::CFGLifetimeEnds::getVarDecl(), clang::CFGScopeBegin::getVarDecl(), clang::CFGScopeEnd::getVarDecl(), clang::CFGElement::Initializer, clang::isa(), clang::CFGElement::LifetimeEnds, clang::CFGElement::LoopExit, clang::CFGElement::MemberDtor, clang::CFGElement::NewAllocator, clang::QualType::print(), print_construction_context(), print_initializer(), clang::CFGElement::ScopeBegin, clang::CFGElement::ScopeEnd, clang::CFGElement::Statement, clang::T, and clang::CFGElement::TemporaryDtor.

Referenced by clang::CFGElement::dumpToStream(), and print_block().

print_initializer()

void print_initializer ( raw_ostream & OS, StmtPrinterHelper & Helper, const CXXCtorInitializer * I ) static

Definition at line 5778 of file CFG.cpp.

References clang::CXXCtorInitializer::getAnyMember(), clang::Type::getAsCXXRecordDecl(), clang::CXXCtorInitializer::getBaseClass(), clang::CXXCtorInitializer::getInit(), clang::NamedDecl::getName(), clang::TypeSourceInfo::getType(), clang::CXXCtorInitializer::getTypeSourceInfo(), clang::CXXCtorInitializer::isBaseInitializer(), clang::CXXCtorInitializer::isDelegatingInitializer(), and clang::Stmt::printPretty().

Referenced by print_construction_context(), and print_elem().

shouldAddCase()

tryNormalizeBinaryOperator()

tryTransformToLiteralConstant()

const Expr * tryTransformToLiteralConstant ( const Expr * E) static

GraphHelper

StmtPrinterHelper* GraphHelper static