Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,49 @@
//===--- APSIntType.cpp - Simple record of the type of APSInts ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
using namespace clang;
using namespace ento;
APSIntType::RangeTestResultKind
APSIntType::testInRange(const llvm::APSInt &Value,
bool AllowSignConversions) const {
// Negative numbers cannot be losslessly converted to unsigned type.
if (IsUnsigned && !AllowSignConversions &&
Value.isSigned() && Value.isNegative())
return RTR_Below;
unsigned MinBits;
if (AllowSignConversions) {
if (Value.isSigned() && !IsUnsigned)
MinBits = Value.getMinSignedBits();
else
MinBits = Value.getActiveBits();
} else {
// Signed integers can be converted to signed integers of the same width
// or (if positive) unsigned integers with one fewer bit.
// Unsigned integers can be converted to unsigned integers of the same width
// or signed integers with one more bit.
if (Value.isSigned())
MinBits = Value.getMinSignedBits() - IsUnsigned;
else
MinBits = Value.getActiveBits() + !IsUnsigned;
}
if (MinBits <= BitWidth)
return RTR_Within;
if (Value.isSigned() && Value.isNegative())
return RTR_Below;
else
return RTR_Above;
}

View File

@@ -0,0 +1,54 @@
//===-- AnalysisManager.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
using namespace clang;
using namespace ento;
void AnalysisManager::anchor() { }
AnalysisManager::AnalysisManager(
ASTContext &ASTCtx, DiagnosticsEngine &diags, const LangOptions &lang,
const PathDiagnosticConsumers &PDC, StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr, CheckerManager *checkerMgr,
AnalyzerOptions &Options, CodeInjector *injector)
: AnaCtxMgr(ASTCtx, Options.UnoptimizedCFG,
Options.includeImplicitDtorsInCFG(),
/*AddInitializers=*/true, Options.includeTemporaryDtorsInCFG(),
Options.includeLifetimeInCFG(),
// Adding LoopExit elements to the CFG is a requirement for loop
// unrolling.
Options.includeLoopExitInCFG() || Options.shouldUnrollLoops(),
Options.shouldSynthesizeBodies(),
Options.shouldConditionalizeStaticInitializers(),
/*addCXXNewAllocator=*/true,
injector),
Ctx(ASTCtx), Diags(diags), LangOpts(lang), PathConsumers(PDC),
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
CheckerMgr(checkerMgr), options(Options) {
AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
}
AnalysisManager::~AnalysisManager() {
FlushDiagnostics();
for (PathDiagnosticConsumers::iterator I = PathConsumers.begin(),
E = PathConsumers.end(); I != E; ++I) {
delete *I;
}
}
void AnalysisManager::FlushDiagnostics() {
PathDiagnosticConsumer::FilesMade filesMade;
for (PathDiagnosticConsumers::iterator I = PathConsumers.begin(),
E = PathConsumers.end();
I != E; ++I) {
(*I)->FlushDiagnostics(&filesMade);
}
}

View File

@@ -0,0 +1,394 @@
//===-- AnalyzerOptions.cpp - Analysis Engine Options -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains special accessors for analyzer configuration options
// with string representations.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
using namespace ento;
using namespace llvm;
std::vector<StringRef>
AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental /* = false */) {
static const StringRef StaticAnalyzerChecks[] = {
#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN) \
FULLNAME,
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
#undef CHECKER
#undef GET_CHECKERS
};
std::vector<StringRef> Result;
for (StringRef CheckName : StaticAnalyzerChecks) {
if (!CheckName.startswith("debug.") &&
(IncludeExperimental || !CheckName.startswith("alpha.")))
Result.push_back(CheckName);
}
return Result;
}
AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
if (UserMode == UMK_NotSet) {
StringRef ModeStr =
Config.insert(std::make_pair("mode", "deep")).first->second;
UserMode = llvm::StringSwitch<UserModeKind>(ModeStr)
.Case("shallow", UMK_Shallow)
.Case("deep", UMK_Deep)
.Default(UMK_NotSet);
assert(UserMode != UMK_NotSet && "User mode is invalid.");
}
return UserMode;
}
IPAKind AnalyzerOptions::getIPAMode() {
if (IPAMode == IPAK_NotSet) {
// Use the User Mode to set the default IPA value.
// Note, we have to add the string to the Config map for the ConfigDumper
// checker to function properly.
const char *DefaultIPA = nullptr;
UserModeKind HighLevelMode = getUserMode();
if (HighLevelMode == UMK_Shallow)
DefaultIPA = "inlining";
else if (HighLevelMode == UMK_Deep)
DefaultIPA = "dynamic-bifurcate";
assert(DefaultIPA);
// Lookup the ipa configuration option, use the default from User Mode.
StringRef ModeStr =
Config.insert(std::make_pair("ipa", DefaultIPA)).first->second;
IPAKind IPAConfig = llvm::StringSwitch<IPAKind>(ModeStr)
.Case("none", IPAK_None)
.Case("basic-inlining", IPAK_BasicInlining)
.Case("inlining", IPAK_Inlining)
.Case("dynamic", IPAK_DynamicDispatch)
.Case("dynamic-bifurcate", IPAK_DynamicDispatchBifurcate)
.Default(IPAK_NotSet);
assert(IPAConfig != IPAK_NotSet && "IPA Mode is invalid.");
// Set the member variable.
IPAMode = IPAConfig;
}
return IPAMode;
}
bool
AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) {
if (getIPAMode() < IPAK_Inlining)
return false;
if (!CXXMemberInliningMode) {
static const char *ModeKey = "c++-inlining";
StringRef ModeStr =
Config.insert(std::make_pair(ModeKey, "destructors")).first->second;
CXXInlineableMemberKind &MutableMode =
const_cast<CXXInlineableMemberKind &>(CXXMemberInliningMode);
MutableMode = llvm::StringSwitch<CXXInlineableMemberKind>(ModeStr)
.Case("constructors", CIMK_Constructors)
.Case("destructors", CIMK_Destructors)
.Case("none", CIMK_None)
.Case("methods", CIMK_MemberFunctions)
.Default(CXXInlineableMemberKind());
if (!MutableMode) {
// FIXME: We should emit a warning here about an unknown inlining kind,
// but the AnalyzerOptions doesn't have access to a diagnostic engine.
MutableMode = CIMK_None;
}
}
return CXXMemberInliningMode >= K;
}
static StringRef toString(bool b) { return b ? "true" : "false"; }
StringRef AnalyzerOptions::getCheckerOption(StringRef CheckerName,
StringRef OptionName,
StringRef Default,
bool SearchInParents) {
// Search for a package option if the option for the checker is not specified
// and search in parents is enabled.
ConfigTable::const_iterator E = Config.end();
do {
ConfigTable::const_iterator I =
Config.find((Twine(CheckerName) + ":" + OptionName).str());
if (I != E)
return StringRef(I->getValue());
size_t Pos = CheckerName.rfind('.');
if (Pos == StringRef::npos)
return Default;
CheckerName = CheckerName.substr(0, Pos);
} while (!CheckerName.empty() && SearchInParents);
return Default;
}
bool AnalyzerOptions::getBooleanOption(StringRef Name, bool DefaultVal,
const CheckerBase *C,
bool SearchInParents) {
// FIXME: We should emit a warning here if the value is something other than
// "true", "false", or the empty string (meaning the default value),
// but the AnalyzerOptions doesn't have access to a diagnostic engine.
StringRef Default = toString(DefaultVal);
StringRef V =
C ? getCheckerOption(C->getTagDescription(), Name, Default,
SearchInParents)
: StringRef(Config.insert(std::make_pair(Name, Default)).first->second);
return llvm::StringSwitch<bool>(V)
.Case("true", true)
.Case("false", false)
.Default(DefaultVal);
}
bool AnalyzerOptions::getBooleanOption(Optional<bool> &V, StringRef Name,
bool DefaultVal, const CheckerBase *C,
bool SearchInParents) {
if (!V.hasValue())
V = getBooleanOption(Name, DefaultVal, C, SearchInParents);
return V.getValue();
}
bool AnalyzerOptions::includeTemporaryDtorsInCFG() {
return getBooleanOption(IncludeTemporaryDtorsInCFG,
"cfg-temporary-dtors",
/* Default = */ false);
}
bool AnalyzerOptions::includeImplicitDtorsInCFG() {
return getBooleanOption(IncludeImplicitDtorsInCFG,
"cfg-implicit-dtors",
/* Default = */ true);
}
bool AnalyzerOptions::includeLifetimeInCFG() {
return getBooleanOption(IncludeLifetimeInCFG, "cfg-lifetime",
/* Default = */ false);
}
bool AnalyzerOptions::includeLoopExitInCFG() {
return getBooleanOption(IncludeLoopExitInCFG, "cfg-loopexit",
/* Default = */ false);
}
bool AnalyzerOptions::mayInlineCXXStandardLibrary() {
return getBooleanOption(InlineCXXStandardLibrary,
"c++-stdlib-inlining",
/*Default=*/true);
}
bool AnalyzerOptions::mayInlineTemplateFunctions() {
return getBooleanOption(InlineTemplateFunctions,
"c++-template-inlining",
/*Default=*/true);
}
bool AnalyzerOptions::mayInlineCXXAllocator() {
return getBooleanOption(InlineCXXAllocator,
"c++-allocator-inlining",
/*Default=*/false);
}
bool AnalyzerOptions::mayInlineCXXContainerMethods() {
return getBooleanOption(InlineCXXContainerMethods,
"c++-container-inlining",
/*Default=*/false);
}
bool AnalyzerOptions::mayInlineCXXSharedPtrDtor() {
return getBooleanOption(InlineCXXSharedPtrDtor,
"c++-shared_ptr-inlining",
/*Default=*/false);
}
bool AnalyzerOptions::mayInlineObjCMethod() {
return getBooleanOption(ObjCInliningMode,
"objc-inlining",
/* Default = */ true);
}
bool AnalyzerOptions::shouldSuppressNullReturnPaths() {
return getBooleanOption(SuppressNullReturnPaths,
"suppress-null-return-paths",
/* Default = */ true);
}
bool AnalyzerOptions::shouldAvoidSuppressingNullArgumentPaths() {
return getBooleanOption(AvoidSuppressingNullArgumentPaths,
"avoid-suppressing-null-argument-paths",
/* Default = */ false);
}
bool AnalyzerOptions::shouldSuppressInlinedDefensiveChecks() {
return getBooleanOption(SuppressInlinedDefensiveChecks,
"suppress-inlined-defensive-checks",
/* Default = */ true);
}
bool AnalyzerOptions::shouldSuppressFromCXXStandardLibrary() {
return getBooleanOption(SuppressFromCXXStandardLibrary,
"suppress-c++-stdlib",
/* Default = */ true);
}
bool AnalyzerOptions::shouldReportIssuesInMainSourceFile() {
return getBooleanOption(ReportIssuesInMainSourceFile,
"report-in-main-source-file",
/* Default = */ false);
}
bool AnalyzerOptions::shouldWriteStableReportFilename() {
return getBooleanOption(StableReportFilename,
"stable-report-filename",
/* Default = */ false);
}
int AnalyzerOptions::getOptionAsInteger(StringRef Name, int DefaultVal,
const CheckerBase *C,
bool SearchInParents) {
SmallString<10> StrBuf;
llvm::raw_svector_ostream OS(StrBuf);
OS << DefaultVal;
StringRef V = C ? getCheckerOption(C->getTagDescription(), Name, OS.str(),
SearchInParents)
: StringRef(Config.insert(std::make_pair(Name, OS.str()))
.first->second);
int Res = DefaultVal;
bool b = V.getAsInteger(10, Res);
assert(!b && "analyzer-config option should be numeric");
(void)b;
return Res;
}
StringRef AnalyzerOptions::getOptionAsString(StringRef Name,
StringRef DefaultVal,
const CheckerBase *C,
bool SearchInParents) {
return C ? getCheckerOption(C->getTagDescription(), Name, DefaultVal,
SearchInParents)
: StringRef(
Config.insert(std::make_pair(Name, DefaultVal)).first->second);
}
unsigned AnalyzerOptions::getAlwaysInlineSize() {
if (!AlwaysInlineSize.hasValue())
AlwaysInlineSize = getOptionAsInteger("ipa-always-inline-size", 3);
return AlwaysInlineSize.getValue();
}
unsigned AnalyzerOptions::getMaxInlinableSize() {
if (!MaxInlinableSize.hasValue()) {
int DefaultValue = 0;
UserModeKind HighLevelMode = getUserMode();
switch (HighLevelMode) {
default:
llvm_unreachable("Invalid mode.");
case UMK_Shallow:
DefaultValue = 4;
break;
case UMK_Deep:
DefaultValue = 100;
break;
}
MaxInlinableSize = getOptionAsInteger("max-inlinable-size", DefaultValue);
}
return MaxInlinableSize.getValue();
}
unsigned AnalyzerOptions::getGraphTrimInterval() {
if (!GraphTrimInterval.hasValue())
GraphTrimInterval = getOptionAsInteger("graph-trim-interval", 1000);
return GraphTrimInterval.getValue();
}
unsigned AnalyzerOptions::getMaxTimesInlineLarge() {
if (!MaxTimesInlineLarge.hasValue())
MaxTimesInlineLarge = getOptionAsInteger("max-times-inline-large", 32);
return MaxTimesInlineLarge.getValue();
}
unsigned AnalyzerOptions::getMinCFGSizeTreatFunctionsAsLarge() {
if (!MinCFGSizeTreatFunctionsAsLarge.hasValue())
MinCFGSizeTreatFunctionsAsLarge = getOptionAsInteger(
"min-cfg-size-treat-functions-as-large", 14);
return MinCFGSizeTreatFunctionsAsLarge.getValue();
}
unsigned AnalyzerOptions::getMaxNodesPerTopLevelFunction() {
if (!MaxNodesPerTopLevelFunction.hasValue()) {
int DefaultValue = 0;
UserModeKind HighLevelMode = getUserMode();
switch (HighLevelMode) {
default:
llvm_unreachable("Invalid mode.");
case UMK_Shallow:
DefaultValue = 75000;
break;
case UMK_Deep:
DefaultValue = 225000;
break;
}
MaxNodesPerTopLevelFunction = getOptionAsInteger("max-nodes", DefaultValue);
}
return MaxNodesPerTopLevelFunction.getValue();
}
bool AnalyzerOptions::shouldSynthesizeBodies() {
return getBooleanOption("faux-bodies", true);
}
bool AnalyzerOptions::shouldPrunePaths() {
return getBooleanOption("prune-paths", true);
}
bool AnalyzerOptions::shouldConditionalizeStaticInitializers() {
return getBooleanOption("cfg-conditional-static-initializers", true);
}
bool AnalyzerOptions::shouldInlineLambdas() {
if (!InlineLambdas.hasValue())
InlineLambdas = getBooleanOption("inline-lambdas", /*Default=*/true);
return InlineLambdas.getValue();
}
bool AnalyzerOptions::shouldWidenLoops() {
if (!WidenLoops.hasValue())
WidenLoops = getBooleanOption("widen-loops", /*Default=*/false);
return WidenLoops.getValue();
}
bool AnalyzerOptions::shouldUnrollLoops() {
if (!UnrollLoops.hasValue())
UnrollLoops = getBooleanOption("unroll-loops", /*Default=*/false);
return UnrollLoops.getValue();
}
bool AnalyzerOptions::shouldDisplayNotesAsEvents() {
if (!DisplayNotesAsEvents.hasValue())
DisplayNotesAsEvents =
getBooleanOption("notes-as-events", /*Default=*/false);
return DisplayNotesAsEvents.getValue();
}

View File

@@ -0,0 +1,344 @@
//=== BasicValueFactory.cpp - Basic values for Path Sens analysis --*- C++ -*-//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines BasicValueFactory, a class that manages the lifetime
// of APSInt objects and symbolic constraints used by ExprEngine
// and related classes.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
using namespace clang;
using namespace ento;
void CompoundValData::Profile(llvm::FoldingSetNodeID& ID, QualType T,
llvm::ImmutableList<SVal> L) {
T.Profile(ID);
ID.AddPointer(L.getInternalPointer());
}
void LazyCompoundValData::Profile(llvm::FoldingSetNodeID& ID,
const StoreRef &store,
const TypedValueRegion *region) {
ID.AddPointer(store.getStore());
ID.AddPointer(region);
}
void PointerToMemberData::Profile(
llvm::FoldingSetNodeID& ID, const DeclaratorDecl *D,
llvm::ImmutableList<const CXXBaseSpecifier *> L) {
ID.AddPointer(D);
ID.AddPointer(L.getInternalPointer());
}
typedef std::pair<SVal, uintptr_t> SValData;
typedef std::pair<SVal, SVal> SValPair;
namespace llvm {
template<> struct FoldingSetTrait<SValData> {
static inline void Profile(const SValData& X, llvm::FoldingSetNodeID& ID) {
X.first.Profile(ID);
ID.AddPointer( (void*) X.second);
}
};
template<> struct FoldingSetTrait<SValPair> {
static inline void Profile(const SValPair& X, llvm::FoldingSetNodeID& ID) {
X.first.Profile(ID);
X.second.Profile(ID);
}
};
}
typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<SValData> >
PersistentSValsTy;
typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<SValPair> >
PersistentSValPairsTy;
BasicValueFactory::~BasicValueFactory() {
// Note that the dstor for the contents of APSIntSet will never be called,
// so we iterate over the set and invoke the dstor for each APSInt. This
// frees an aux. memory allocated to represent very large constants.
for (APSIntSetTy::iterator I=APSIntSet.begin(), E=APSIntSet.end(); I!=E; ++I)
I->getValue().~APSInt();
delete (PersistentSValsTy*) PersistentSVals;
delete (PersistentSValPairsTy*) PersistentSValPairs;
}
const llvm::APSInt& BasicValueFactory::getValue(const llvm::APSInt& X) {
llvm::FoldingSetNodeID ID;
void *InsertPos;
typedef llvm::FoldingSetNodeWrapper<llvm::APSInt> FoldNodeTy;
X.Profile(ID);
FoldNodeTy* P = APSIntSet.FindNodeOrInsertPos(ID, InsertPos);
if (!P) {
P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
new (P) FoldNodeTy(X);
APSIntSet.InsertNode(P, InsertPos);
}
return *P;
}
const llvm::APSInt& BasicValueFactory::getValue(const llvm::APInt& X,
bool isUnsigned) {
llvm::APSInt V(X, isUnsigned);
return getValue(V);
}
const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, unsigned BitWidth,
bool isUnsigned) {
llvm::APSInt V(BitWidth, isUnsigned);
V = X;
return getValue(V);
}
const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, QualType T) {
return getValue(getAPSIntType(T).getValue(X));
}
const CompoundValData*
BasicValueFactory::getCompoundValData(QualType T,
llvm::ImmutableList<SVal> Vals) {
llvm::FoldingSetNodeID ID;
CompoundValData::Profile(ID, T, Vals);
void *InsertPos;
CompoundValData* D = CompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
if (!D) {
D = (CompoundValData*) BPAlloc.Allocate<CompoundValData>();
new (D) CompoundValData(T, Vals);
CompoundValDataSet.InsertNode(D, InsertPos);
}
return D;
}
const LazyCompoundValData*
BasicValueFactory::getLazyCompoundValData(const StoreRef &store,
const TypedValueRegion *region) {
llvm::FoldingSetNodeID ID;
LazyCompoundValData::Profile(ID, store, region);
void *InsertPos;
LazyCompoundValData *D =
LazyCompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
if (!D) {
D = (LazyCompoundValData*) BPAlloc.Allocate<LazyCompoundValData>();
new (D) LazyCompoundValData(store, region);
LazyCompoundValDataSet.InsertNode(D, InsertPos);
}
return D;
}
const PointerToMemberData *BasicValueFactory::getPointerToMemberData(
const DeclaratorDecl *DD, llvm::ImmutableList<const CXXBaseSpecifier*> L) {
llvm::FoldingSetNodeID ID;
PointerToMemberData::Profile(ID, DD, L);
void *InsertPos;
PointerToMemberData *D =
PointerToMemberDataSet.FindNodeOrInsertPos(ID, InsertPos);
if (!D) {
D = (PointerToMemberData*) BPAlloc.Allocate<PointerToMemberData>();
new (D) PointerToMemberData(DD, L);
PointerToMemberDataSet.InsertNode(D, InsertPos);
}
return D;
}
const clang::ento::PointerToMemberData *BasicValueFactory::accumCXXBase(
llvm::iterator_range<CastExpr::path_const_iterator> PathRange,
const nonloc::PointerToMember &PTM) {
nonloc::PointerToMember::PTMDataType PTMDT = PTM.getPTMData();
const DeclaratorDecl *DD = nullptr;
llvm::ImmutableList<const CXXBaseSpecifier *> PathList;
if (PTMDT.isNull() || PTMDT.is<const DeclaratorDecl *>()) {
if (PTMDT.is<const DeclaratorDecl *>())
DD = PTMDT.get<const DeclaratorDecl *>();
PathList = CXXBaseListFactory.getEmptyList();
} else { // const PointerToMemberData *
const PointerToMemberData *PTMD =
PTMDT.get<const PointerToMemberData *>();
DD = PTMD->getDeclaratorDecl();
PathList = PTMD->getCXXBaseList();
}
for (const auto &I : llvm::reverse(PathRange))
PathList = prependCXXBase(I, PathList);
return getPointerToMemberData(DD, PathList);
}
const llvm::APSInt*
BasicValueFactory::evalAPSInt(BinaryOperator::Opcode Op,
const llvm::APSInt& V1, const llvm::APSInt& V2) {
switch (Op) {
default:
assert (false && "Invalid Opcode.");
case BO_Mul:
return &getValue( V1 * V2 );
case BO_Div:
if (V2 == 0) // Avoid division by zero
return nullptr;
return &getValue( V1 / V2 );
case BO_Rem:
if (V2 == 0) // Avoid division by zero
return nullptr;
return &getValue( V1 % V2 );
case BO_Add:
return &getValue( V1 + V2 );
case BO_Sub:
return &getValue( V1 - V2 );
case BO_Shl: {
// FIXME: This logic should probably go higher up, where we can
// test these conditions symbolically.
// FIXME: Expand these checks to include all undefined behavior.
if (V1.isSigned() && V1.isNegative())
return nullptr;
if (V2.isSigned() && V2.isNegative())
return nullptr;
uint64_t Amt = V2.getZExtValue();
if (Amt >= V1.getBitWidth())
return nullptr;
return &getValue( V1.operator<<( (unsigned) Amt ));
}
case BO_Shr: {
// FIXME: This logic should probably go higher up, where we can
// test these conditions symbolically.
// FIXME: Expand these checks to include all undefined behavior.
if (V2.isSigned() && V2.isNegative())
return nullptr;
uint64_t Amt = V2.getZExtValue();
if (Amt >= V1.getBitWidth())
return nullptr;
return &getValue( V1.operator>>( (unsigned) Amt ));
}
case BO_LT:
return &getTruthValue( V1 < V2 );
case BO_GT:
return &getTruthValue( V1 > V2 );
case BO_LE:
return &getTruthValue( V1 <= V2 );
case BO_GE:
return &getTruthValue( V1 >= V2 );
case BO_EQ:
return &getTruthValue( V1 == V2 );
case BO_NE:
return &getTruthValue( V1 != V2 );
// Note: LAnd, LOr, Comma are handled specially by higher-level logic.
case BO_And:
return &getValue( V1 & V2 );
case BO_Or:
return &getValue( V1 | V2 );
case BO_Xor:
return &getValue( V1 ^ V2 );
}
}
const std::pair<SVal, uintptr_t>&
BasicValueFactory::getPersistentSValWithData(const SVal& V, uintptr_t Data) {
// Lazily create the folding set.
if (!PersistentSVals) PersistentSVals = new PersistentSValsTy();
llvm::FoldingSetNodeID ID;
void *InsertPos;
V.Profile(ID);
ID.AddPointer((void*) Data);
PersistentSValsTy& Map = *((PersistentSValsTy*) PersistentSVals);
typedef llvm::FoldingSetNodeWrapper<SValData> FoldNodeTy;
FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
if (!P) {
P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
new (P) FoldNodeTy(std::make_pair(V, Data));
Map.InsertNode(P, InsertPos);
}
return P->getValue();
}
const std::pair<SVal, SVal>&
BasicValueFactory::getPersistentSValPair(const SVal& V1, const SVal& V2) {
// Lazily create the folding set.
if (!PersistentSValPairs) PersistentSValPairs = new PersistentSValPairsTy();
llvm::FoldingSetNodeID ID;
void *InsertPos;
V1.Profile(ID);
V2.Profile(ID);
PersistentSValPairsTy& Map = *((PersistentSValPairsTy*) PersistentSValPairs);
typedef llvm::FoldingSetNodeWrapper<SValPair> FoldNodeTy;
FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
if (!P) {
P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
new (P) FoldNodeTy(std::make_pair(V1, V2));
Map.InsertNode(P, InsertPos);
}
return P->getValue();
}
const SVal* BasicValueFactory::getPersistentSVal(SVal X) {
return &getPersistentSValWithData(X, 0).first;
}

View File

@@ -0,0 +1,85 @@
//==- BlockCounter.h - ADT for counting block visits -------------*- C++ -*-//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines BlockCounter, an abstract data type used to count
// the number of times a given block has been visited along a path
// analyzed by CoreEngine.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h"
#include "llvm/ADT/ImmutableMap.h"
using namespace clang;
using namespace ento;
namespace {
class CountKey {
const StackFrameContext *CallSite;
unsigned BlockID;
public:
CountKey(const StackFrameContext *CS, unsigned ID)
: CallSite(CS), BlockID(ID) {}
bool operator==(const CountKey &RHS) const {
return (CallSite == RHS.CallSite) && (BlockID == RHS.BlockID);
}
bool operator<(const CountKey &RHS) const {
return std::tie(CallSite, BlockID) < std::tie(RHS.CallSite, RHS.BlockID);
}
void Profile(llvm::FoldingSetNodeID &ID) const {
ID.AddPointer(CallSite);
ID.AddInteger(BlockID);
}
};
}
typedef llvm::ImmutableMap<CountKey, unsigned> CountMap;
static inline CountMap GetMap(void *D) {
return CountMap(static_cast<CountMap::TreeTy*>(D));
}
static inline CountMap::Factory& GetFactory(void *F) {
return *static_cast<CountMap::Factory*>(F);
}
unsigned BlockCounter::getNumVisited(const StackFrameContext *CallSite,
unsigned BlockID) const {
CountMap M = GetMap(Data);
CountMap::data_type* T = M.lookup(CountKey(CallSite, BlockID));
return T ? *T : 0;
}
BlockCounter::Factory::Factory(llvm::BumpPtrAllocator& Alloc) {
F = new CountMap::Factory(Alloc);
}
BlockCounter::Factory::~Factory() {
delete static_cast<CountMap::Factory*>(F);
}
BlockCounter
BlockCounter::Factory::IncrementCount(BlockCounter BC,
const StackFrameContext *CallSite,
unsigned BlockID) {
return BlockCounter(GetFactory(F).add(GetMap(BC.Data),
CountKey(CallSite, BlockID),
BC.getNumVisited(CallSite, BlockID)+1).getRoot());
}
BlockCounter
BlockCounter::Factory::GetEmptyCounter() {
return BlockCounter(GetFactory(F).getEmptyMap().getRoot());
}

View File

@@ -0,0 +1 @@
de0e87bb824947480eb4deefde3ede9bac8f6c1e

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
set(LLVM_LINK_COMPONENTS support)
# Link Z3 if the user wants to build it.
if(CLANG_ANALYZER_WITH_Z3)
set(Z3_LINK_FILES ${Z3_LIBRARIES})
else()
set(Z3_LINK_FILES "")
endif()
add_clang_library(clangStaticAnalyzerCore
APSIntType.cpp
AnalysisManager.cpp
AnalyzerOptions.cpp
BasicValueFactory.cpp
BlockCounter.cpp
IssueHash.cpp
BugReporter.cpp
BugReporterVisitors.cpp
CallEvent.cpp
Checker.cpp
CheckerContext.cpp
CheckerHelpers.cpp
CheckerManager.cpp
CheckerRegistry.cpp
CommonBugCategories.cpp
ConstraintManager.cpp
CoreEngine.cpp
DynamicTypeMap.cpp
Environment.cpp
ExplodedGraph.cpp
ExprEngine.cpp
ExprEngineC.cpp
ExprEngineCXX.cpp
ExprEngineCallAndReturn.cpp
ExprEngineObjC.cpp
FunctionSummary.cpp
HTMLDiagnostics.cpp
LoopUnrolling.cpp
LoopWidening.cpp
MemRegion.cpp
PathDiagnostic.cpp
PlistDiagnostics.cpp
ProgramState.cpp
RangeConstraintManager.cpp
RangedConstraintManager.cpp
RegionStore.cpp
SValBuilder.cpp
SVals.cpp
SimpleConstraintManager.cpp
SimpleSValBuilder.cpp
Store.cpp
SubEngine.cpp
SymbolManager.cpp
Z3ConstraintManager.cpp
LINK_LIBS
clangAST
clangASTMatchers
clangAnalysis
clangBasic
clangLex
clangRewrite
${Z3_LINK_FILES}
)
if(CLANG_ANALYZER_WITH_Z3)
target_include_directories(clangStaticAnalyzerCore SYSTEM
PRIVATE
${Z3_INCLUDE_DIR}
)
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
//== Checker.cpp - Registration mechanism for checkers -----------*- C++ -*--=//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines Checker, used to create and register checkers.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
using namespace clang;
using namespace ento;
StringRef CheckerBase::getTagDescription() const {
return getCheckName().getName();
}
CheckName CheckerBase::getCheckName() const { return Name; }
CheckerProgramPointTag::CheckerProgramPointTag(StringRef CheckerName,
StringRef Msg)
: SimpleProgramPointTag(CheckerName, Msg) {}
CheckerProgramPointTag::CheckerProgramPointTag(const CheckerBase *Checker,
StringRef Msg)
: SimpleProgramPointTag(Checker->getCheckName().getName(), Msg) {}
raw_ostream& clang::ento::operator<<(raw_ostream &Out,
const CheckerBase &Checker) {
Out << Checker.getCheckName().getName();
return Out;
}

View File

@@ -0,0 +1,133 @@
//== CheckerContext.cpp - Context info for path-sensitive checkers-----------=//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines CheckerContext that provides contextual info for
// path-sensitive checkers.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/Basic/Builtins.h"
#include "clang/Lex/Lexer.h"
using namespace clang;
using namespace ento;
const FunctionDecl *CheckerContext::getCalleeDecl(const CallExpr *CE) const {
ProgramStateRef State = getState();
const Expr *Callee = CE->getCallee();
SVal L = State->getSVal(Callee, Pred->getLocationContext());
return L.getAsFunctionDecl();
}
StringRef CheckerContext::getCalleeName(const FunctionDecl *FunDecl) const {
if (!FunDecl)
return StringRef();
IdentifierInfo *funI = FunDecl->getIdentifier();
if (!funI)
return StringRef();
return funI->getName();
}
StringRef CheckerContext::getDeclDescription(const Decl *D) {
if (isa<ObjCMethodDecl>(D) || isa<CXXMethodDecl>(D))
return "method";
if (isa<BlockDecl>(D))
return "anonymous block";
return "function";
}
bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
StringRef Name) {
// To avoid false positives (Ex: finding user defined functions with
// similar names), only perform fuzzy name matching when it's a builtin.
// Using a string compare is slow, we might want to switch on BuiltinID here.
unsigned BId = FD->getBuiltinID();
if (BId != 0) {
if (Name.empty())
return true;
StringRef BName = FD->getASTContext().BuiltinInfo.getName(BId);
if (BName.find(Name) != StringRef::npos)
return true;
}
const IdentifierInfo *II = FD->getIdentifier();
// If this is a special C++ name without IdentifierInfo, it can't be a
// C library function.
if (!II)
return false;
// Look through 'extern "C"' and anything similar invented in the future.
// If this function is not in TU directly, it is not a C library function.
if (!FD->getDeclContext()->getRedeclContext()->isTranslationUnit())
return false;
// If this function is not externally visible, it is not a C library function.
// Note that we make an exception for inline functions, which may be
// declared in header files without external linkage.
if (!FD->isInlined() && !FD->isExternallyVisible())
return false;
if (Name.empty())
return true;
StringRef FName = II->getName();
if (FName.equals(Name))
return true;
if (FName.startswith("__inline") && (FName.find(Name) != StringRef::npos))
return true;
if (FName.startswith("__") && FName.endswith("_chk") &&
FName.find(Name) != StringRef::npos)
return true;
return false;
}
StringRef CheckerContext::getMacroNameOrSpelling(SourceLocation &Loc) {
if (Loc.isMacroID())
return Lexer::getImmediateMacroName(Loc, getSourceManager(),
getLangOpts());
SmallVector<char, 16> buf;
return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOpts());
}
/// Evaluate comparison and return true if it's known that condition is true
static bool evalComparison(SVal LHSVal, BinaryOperatorKind ComparisonOp,
SVal RHSVal, ProgramStateRef State) {
if (LHSVal.isUnknownOrUndef())
return false;
ProgramStateManager &Mgr = State->getStateManager();
if (!LHSVal.getAs<NonLoc>()) {
LHSVal = Mgr.getStoreManager().getBinding(State->getStore(),
LHSVal.castAs<Loc>());
if (LHSVal.isUnknownOrUndef() || !LHSVal.getAs<NonLoc>())
return false;
}
SValBuilder &Bldr = Mgr.getSValBuilder();
SVal Eval = Bldr.evalBinOp(State, ComparisonOp, LHSVal, RHSVal,
Bldr.getConditionType());
if (Eval.isUnknownOrUndef())
return false;
ProgramStateRef StTrue, StFalse;
std::tie(StTrue, StFalse) = State->assume(Eval.castAs<DefinedSVal>());
return StTrue && !StFalse;
}
bool CheckerContext::isGreaterOrEqual(const Expr *E, unsigned long long Val) {
DefinedSVal V = getSValBuilder().makeIntVal(Val, getASTContext().LongLongTy);
return evalComparison(getSVal(E), BO_GE, V, getState());
}
bool CheckerContext::isNegative(const Expr *E) {
DefinedSVal V = getSValBuilder().makeIntVal(0, false);
return evalComparison(getSVal(E), BO_LT, V, getState());
}

View File

@@ -0,0 +1,96 @@
//===---- CheckerHelpers.cpp - Helper functions for checkers ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines several static functions for use in checkers.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
// Recursively find any substatements containing macros
bool clang::ento::containsMacro(const Stmt *S) {
if (S->getLocStart().isMacroID())
return true;
if (S->getLocEnd().isMacroID())
return true;
for (const Stmt *Child : S->children())
if (Child && containsMacro(Child))
return true;
return false;
}
// Recursively find any substatements containing enum constants
bool clang::ento::containsEnum(const Stmt *S) {
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S);
if (DR && isa<EnumConstantDecl>(DR->getDecl()))
return true;
for (const Stmt *Child : S->children())
if (Child && containsEnum(Child))
return true;
return false;
}
// Recursively find any substatements containing static vars
bool clang::ento::containsStaticLocal(const Stmt *S) {
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S);
if (DR)
if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl()))
if (VD->isStaticLocal())
return true;
for (const Stmt *Child : S->children())
if (Child && containsStaticLocal(Child))
return true;
return false;
}
// Recursively find any substatements containing __builtin_offsetof
bool clang::ento::containsBuiltinOffsetOf(const Stmt *S) {
if (isa<OffsetOfExpr>(S))
return true;
for (const Stmt *Child : S->children())
if (Child && containsBuiltinOffsetOf(Child))
return true;
return false;
}
// Extract lhs and rhs from assignment statement
std::pair<const clang::VarDecl *, const clang::Expr *>
clang::ento::parseAssignment(const Stmt *S) {
const VarDecl *VD = nullptr;
const Expr *RHS = nullptr;
if (auto Assign = dyn_cast_or_null<BinaryOperator>(S)) {
if (Assign->isAssignmentOp()) {
// Ordinary assignment
RHS = Assign->getRHS();
if (auto DE = dyn_cast_or_null<DeclRefExpr>(Assign->getLHS()))
VD = dyn_cast_or_null<VarDecl>(DE->getDecl());
}
} else if (auto PD = dyn_cast_or_null<DeclStmt>(S)) {
// Initialization
assert(PD->isSingleDecl() && "We process decls one by one");
VD = dyn_cast_or_null<VarDecl>(PD->getSingleDecl());
RHS = VD->getAnyInitializer();
}
return std::make_pair(VD, RHS);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,196 @@
//===--- CheckerRegistry.cpp - Maintains all available checkers -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/CheckerRegistry.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/StaticAnalyzer/Core/CheckerOptInfo.h"
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
using namespace ento;
static const char PackageSeparator = '.';
typedef llvm::SetVector<const CheckerRegistry::CheckerInfo *> CheckerInfoSet;
static bool checkerNameLT(const CheckerRegistry::CheckerInfo &a,
const CheckerRegistry::CheckerInfo &b) {
return a.FullName < b.FullName;
}
static bool isInPackage(const CheckerRegistry::CheckerInfo &checker,
StringRef packageName) {
// Does the checker's full name have the package as a prefix?
if (!checker.FullName.startswith(packageName))
return false;
// Is the package actually just the name of a specific checker?
if (checker.FullName.size() == packageName.size())
return true;
// Is the checker in the package (or a subpackage)?
if (checker.FullName[packageName.size()] == PackageSeparator)
return true;
return false;
}
static void collectCheckers(const CheckerRegistry::CheckerInfoList &checkers,
const llvm::StringMap<size_t> &packageSizes,
CheckerOptInfo &opt, CheckerInfoSet &collected) {
// Use a binary search to find the possible start of the package.
CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.getName(), "");
auto end = checkers.cend();
CheckerRegistry::CheckerInfoList::const_iterator i =
std::lower_bound(checkers.cbegin(), end, packageInfo, checkerNameLT);
// If we didn't even find a possible package, give up.
if (i == end)
return;
// If what we found doesn't actually start the package, give up.
if (!isInPackage(*i, opt.getName()))
return;
// There is at least one checker in the package; claim the option.
opt.claim();
// See how large the package is.
// If the package doesn't exist, assume the option refers to a single checker.
size_t size = 1;
llvm::StringMap<size_t>::const_iterator packageSize =
packageSizes.find(opt.getName());
if (packageSize != packageSizes.end())
size = packageSize->getValue();
// Step through all the checkers in the package.
for (auto checkEnd = i+size; i != checkEnd; ++i) {
if (opt.isEnabled())
collected.insert(&*i);
else
collected.remove(&*i);
}
}
void CheckerRegistry::addChecker(InitializationFunction fn, StringRef name,
StringRef desc) {
Checkers.push_back(CheckerInfo(fn, name, desc));
// Record the presence of the checker in its packages.
StringRef packageName, leafName;
std::tie(packageName, leafName) = name.rsplit(PackageSeparator);
while (!leafName.empty()) {
Packages[packageName] += 1;
std::tie(packageName, leafName) = packageName.rsplit(PackageSeparator);
}
}
void CheckerRegistry::initializeManager(CheckerManager &checkerMgr,
SmallVectorImpl<CheckerOptInfo> &opts) const {
// Sort checkers for efficient collection.
std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
// Collect checkers enabled by the options.
CheckerInfoSet enabledCheckers;
for (SmallVectorImpl<CheckerOptInfo>::iterator
i = opts.begin(), e = opts.end(); i != e; ++i) {
collectCheckers(Checkers, Packages, *i, enabledCheckers);
}
// Initialize the CheckerManager with all enabled checkers.
for (CheckerInfoSet::iterator
i = enabledCheckers.begin(), e = enabledCheckers.end(); i != e; ++i) {
checkerMgr.setCurrentCheckName(CheckName((*i)->FullName));
(*i)->Initialize(checkerMgr);
}
}
void CheckerRegistry::validateCheckerOptions(const AnalyzerOptions &opts,
DiagnosticsEngine &diags) const {
for (auto &config : opts.Config) {
size_t pos = config.getKey().find(':');
if (pos == StringRef::npos)
continue;
bool hasChecker = false;
StringRef checkerName = config.getKey().substr(0, pos);
for (auto &checker : Checkers) {
if (checker.FullName.startswith(checkerName) &&
(checker.FullName.size() == pos || checker.FullName[pos] == '.')) {
hasChecker = true;
break;
}
}
if (!hasChecker) {
diags.Report(diag::err_unknown_analyzer_checker) << checkerName;
}
}
}
void CheckerRegistry::printHelp(raw_ostream &out,
size_t maxNameChars) const {
// FIXME: Alphabetical sort puts 'experimental' in the middle.
// Would it be better to name it '~experimental' or something else
// that's ASCIIbetically last?
std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
// FIXME: Print available packages.
out << "CHECKERS:\n";
// Find the maximum option length.
size_t optionFieldWidth = 0;
for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end();
i != e; ++i) {
// Limit the amount of padding we are willing to give up for alignment.
// Package.Name Description [Hidden]
size_t nameLength = i->FullName.size();
if (nameLength <= maxNameChars)
optionFieldWidth = std::max(optionFieldWidth, nameLength);
}
const size_t initialPad = 2;
for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end();
i != e; ++i) {
out.indent(initialPad) << i->FullName;
int pad = optionFieldWidth - i->FullName.size();
// Break on long option names.
if (pad < 0) {
out << '\n';
pad = optionFieldWidth + initialPad;
}
out.indent(pad + 2) << i->Desc;
out << '\n';
}
}
void CheckerRegistry::printList(
raw_ostream &out, SmallVectorImpl<CheckerOptInfo> &opts) const {
std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
// Collect checkers enabled by the options.
CheckerInfoSet enabledCheckers;
for (SmallVectorImpl<CheckerOptInfo>::iterator i = opts.begin(),
e = opts.end();
i != e; ++i) {
collectCheckers(Checkers, Packages, *i, enabledCheckers);
}
for (CheckerInfoSet::const_iterator i = enabledCheckers.begin(),
e = enabledCheckers.end();
i != e; ++i) {
out << (*i)->FullName << '\n';
}
}

View File

@@ -0,0 +1,21 @@
//=--- CommonBugCategories.cpp - Provides common issue categories -*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
// Common strings used for the "category" of many static analyzer issues.
namespace clang { namespace ento { namespace categories {
const char * const CoreFoundationObjectiveC = "Core Foundation/Objective-C";
const char * const LogicError = "Logic error";
const char * const MemoryCoreFoundationObjectiveC =
"Memory (Core Foundation/Objective-C)";
const char * const MemoryError = "Memory error";
const char * const UnixAPI = "Unix API";
}}}

View File

@@ -0,0 +1,39 @@
//== ConstraintManager.cpp - Constraints on symbolic values -----*- C++ -*--==//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defined the interface to manage constraints on symbolic values.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
using namespace clang;
using namespace ento;
ConstraintManager::~ConstraintManager() {}
static DefinedSVal getLocFromSymbol(const ProgramStateRef &State,
SymbolRef Sym) {
const MemRegion *R =
State->getStateManager().getRegionManager().getSymbolicRegion(Sym);
return loc::MemRegionVal(R);
}
ConditionTruthVal ConstraintManager::checkNull(ProgramStateRef State,
SymbolRef Sym) {
QualType Ty = Sym->getType();
DefinedSVal V = Loc::isLocType(Ty) ? getLocFromSymbol(State, Sym)
: nonloc::SymbolVal(Sym);
const ProgramStatePair &P = assumeDual(State, V);
if (P.first && !P.second)
return ConditionTruthVal(false);
if (!P.first && P.second)
return ConditionTruthVal(true);
return ConditionTruthVal();
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
//==- DynamicTypeMap.cpp - Dynamic Type Info related APIs ----------*- C++ -*-//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines APIs that track and query dynamic type information. This
// information can be used to devirtualize calls during the symbolic execution
// or do type checking.
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
namespace clang {
namespace ento {
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State,
const MemRegion *Reg) {
Reg = Reg->StripCasts();
// Look up the dynamic type in the GDM.
const DynamicTypeInfo *GDMType = State->get<DynamicTypeMap>(Reg);
if (GDMType)
return *GDMType;
// Otherwise, fall back to what we know about the region.
if (const TypedRegion *TR = dyn_cast<TypedRegion>(Reg))
return DynamicTypeInfo(TR->getLocationType(), /*CanBeSubclass=*/false);
if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) {
SymbolRef Sym = SR->getSymbol();
return DynamicTypeInfo(Sym->getType());
}
return DynamicTypeInfo();
}
ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg,
DynamicTypeInfo NewTy) {
Reg = Reg->StripCasts();
ProgramStateRef NewState = State->set<DynamicTypeMap>(Reg, NewTy);
assert(NewState);
return NewState;
}
} // namespace ento
} // namespace clang

View File

@@ -0,0 +1,213 @@
//== Environment.cpp - Map from Stmt* to Locations/Values -------*- C++ -*--==//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defined the Environment and EnvironmentManager classes.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
using namespace ento;
static const Expr *ignoreTransparentExprs(const Expr *E) {
E = E->IgnoreParens();
switch (E->getStmtClass()) {
case Stmt::OpaqueValueExprClass:
E = cast<OpaqueValueExpr>(E)->getSourceExpr();
break;
case Stmt::ExprWithCleanupsClass:
E = cast<ExprWithCleanups>(E)->getSubExpr();
break;
case Stmt::CXXBindTemporaryExprClass:
E = cast<CXXBindTemporaryExpr>(E)->getSubExpr();
break;
case Stmt::SubstNonTypeTemplateParmExprClass:
E = cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement();
break;
default:
// This is the base case: we can't look through more than we already have.
return E;
}
return ignoreTransparentExprs(E);
}
static const Stmt *ignoreTransparentExprs(const Stmt *S) {
if (const Expr *E = dyn_cast<Expr>(S))
return ignoreTransparentExprs(E);
return S;
}
EnvironmentEntry::EnvironmentEntry(const Stmt *S, const LocationContext *L)
: std::pair<const Stmt *,
const StackFrameContext *>(ignoreTransparentExprs(S),
L ? L->getCurrentStackFrame()
: nullptr) {}
SVal Environment::lookupExpr(const EnvironmentEntry &E) const {
const SVal* X = ExprBindings.lookup(E);
if (X) {
SVal V = *X;
return V;
}
return UnknownVal();
}
SVal Environment::getSVal(const EnvironmentEntry &Entry,
SValBuilder& svalBuilder) const {
const Stmt *S = Entry.getStmt();
const LocationContext *LCtx = Entry.getLocationContext();
switch (S->getStmtClass()) {
case Stmt::CXXBindTemporaryExprClass:
case Stmt::ExprWithCleanupsClass:
case Stmt::GenericSelectionExprClass:
case Stmt::OpaqueValueExprClass:
case Stmt::ParenExprClass:
case Stmt::SubstNonTypeTemplateParmExprClass:
llvm_unreachable("Should have been handled by ignoreTransparentExprs");
case Stmt::AddrLabelExprClass:
case Stmt::CharacterLiteralClass:
case Stmt::CXXBoolLiteralExprClass:
case Stmt::CXXScalarValueInitExprClass:
case Stmt::ImplicitValueInitExprClass:
case Stmt::IntegerLiteralClass:
case Stmt::ObjCBoolLiteralExprClass:
case Stmt::CXXNullPtrLiteralExprClass:
case Stmt::ObjCStringLiteralClass:
case Stmt::StringLiteralClass:
case Stmt::TypeTraitExprClass:
// Known constants; defer to SValBuilder.
return svalBuilder.getConstantVal(cast<Expr>(S)).getValue();
case Stmt::ReturnStmtClass: {
const ReturnStmt *RS = cast<ReturnStmt>(S);
if (const Expr *RE = RS->getRetValue())
return getSVal(EnvironmentEntry(RE, LCtx), svalBuilder);
return UndefinedVal();
}
// Handle all other Stmt* using a lookup.
default:
return lookupExpr(EnvironmentEntry(S, LCtx));
}
}
Environment EnvironmentManager::bindExpr(Environment Env,
const EnvironmentEntry &E,
SVal V,
bool Invalidate) {
if (V.isUnknown()) {
if (Invalidate)
return Environment(F.remove(Env.ExprBindings, E));
else
return Env;
}
return Environment(F.add(Env.ExprBindings, E, V));
}
namespace {
class MarkLiveCallback final : public SymbolVisitor {
SymbolReaper &SymReaper;
public:
MarkLiveCallback(SymbolReaper &symreaper) : SymReaper(symreaper) {}
bool VisitSymbol(SymbolRef sym) override {
SymReaper.markLive(sym);
return true;
}
bool VisitMemRegion(const MemRegion *R) override {
SymReaper.markLive(R);
return true;
}
};
} // end anonymous namespace
// removeDeadBindings:
// - Remove subexpression bindings.
// - Remove dead block expression bindings.
// - Keep live block expression bindings:
// - Mark their reachable symbols live in SymbolReaper,
// see ScanReachableSymbols.
// - Mark the region in DRoots if the binding is a loc::MemRegionVal.
Environment
EnvironmentManager::removeDeadBindings(Environment Env,
SymbolReaper &SymReaper,
ProgramStateRef ST) {
// We construct a new Environment object entirely, as this is cheaper than
// individually removing all the subexpression bindings (which will greatly
// outnumber block-level expression bindings).
Environment NewEnv = getInitialEnvironment();
MarkLiveCallback CB(SymReaper);
ScanReachableSymbols RSScaner(ST, CB);
llvm::ImmutableMapRef<EnvironmentEntry,SVal>
EBMapRef(NewEnv.ExprBindings.getRootWithoutRetain(),
F.getTreeFactory());
// Iterate over the block-expr bindings.
for (Environment::iterator I = Env.begin(), E = Env.end();
I != E; ++I) {
const EnvironmentEntry &BlkExpr = I.getKey();
const SVal &X = I.getData();
if (SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext())) {
// Copy the binding to the new map.
EBMapRef = EBMapRef.add(BlkExpr, X);
// Mark all symbols in the block expr's value live.
RSScaner.scan(X);
continue;
} else {
SymExpr::symbol_iterator SI = X.symbol_begin(), SE = X.symbol_end();
for (; SI != SE; ++SI)
SymReaper.maybeDead(*SI);
}
}
NewEnv.ExprBindings = EBMapRef.asImmutableMap();
return NewEnv;
}
void Environment::print(raw_ostream &Out, const char *NL,
const char *Sep) const {
bool isFirst = true;
for (Environment::iterator I = begin(), E = end(); I != E; ++I) {
const EnvironmentEntry &En = I.getKey();
if (isFirst) {
Out << NL << NL
<< "Expressions:"
<< NL;
isFirst = false;
} else {
Out << NL;
}
const Stmt *S = En.getStmt();
assert(S != nullptr && "Expected non-null Stmt");
Out << " (" << (const void*) En.getLocationContext() << ','
<< (const void*) S << ") ";
LangOptions LO; // FIXME.
S->printPretty(Out, nullptr, PrintingPolicy(LO));
Out << " : " << I.getData();
}
}

View File

@@ -0,0 +1,448 @@
//=-- ExplodedGraph.cpp - Local, Path-Sens. "Exploded Graph" -*- C++ -*------=//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the template classes ExplodedNode and ExplodedGraph,
// which represent a path-sensitive, intra-procedural "exploded graph."
//
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
#include "clang/AST/ParentMap.h"
#include "clang/AST/Stmt.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
using namespace clang;
using namespace ento;
//===----------------------------------------------------------------------===//
// Node auditing.
//===----------------------------------------------------------------------===//
// An out of line virtual method to provide a home for the class vtable.
ExplodedNode::Auditor::~Auditor() {}
#ifndef NDEBUG
static ExplodedNode::Auditor* NodeAuditor = nullptr;
#endif
void ExplodedNode::SetAuditor(ExplodedNode::Auditor* A) {
#ifndef NDEBUG
NodeAuditor = A;
#endif
}
//===----------------------------------------------------------------------===//
// Cleanup.
//===----------------------------------------------------------------------===//
ExplodedGraph::ExplodedGraph()
: NumNodes(0), ReclaimNodeInterval(0) {}
ExplodedGraph::~ExplodedGraph() {}
//===----------------------------------------------------------------------===//
// Node reclamation.
//===----------------------------------------------------------------------===//
bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) {
if (!Ex->isLValue())
return false;
return isa<DeclRefExpr>(Ex) ||
isa<MemberExpr>(Ex) ||
isa<ObjCIvarRefExpr>(Ex);
}
bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
// First, we only consider nodes for reclamation of the following
// conditions apply:
//
// (1) 1 predecessor (that has one successor)
// (2) 1 successor (that has one predecessor)
//
// If a node has no successor it is on the "frontier", while a node
// with no predecessor is a root.
//
// After these prerequisites, we discard all "filler" nodes that
// are used only for intermediate processing, and are not essential
// for analyzer history:
//
// (a) PreStmtPurgeDeadSymbols
//
// We then discard all other nodes where *all* of the following conditions
// apply:
//
// (3) The ProgramPoint is for a PostStmt, but not a PostStore.
// (4) There is no 'tag' for the ProgramPoint.
// (5) The 'store' is the same as the predecessor.
// (6) The 'GDM' is the same as the predecessor.
// (7) The LocationContext is the same as the predecessor.
// (8) Expressions that are *not* lvalue expressions.
// (9) The PostStmt isn't for a non-consumed Stmt or Expr.
// (10) The successor is neither a CallExpr StmtPoint nor a CallEnter or
// PreImplicitCall (so that we would be able to find it when retrying a
// call with no inlining).
// FIXME: It may be safe to reclaim PreCall and PostCall nodes as well.
// Conditions 1 and 2.
if (node->pred_size() != 1 || node->succ_size() != 1)
return false;
const ExplodedNode *pred = *(node->pred_begin());
if (pred->succ_size() != 1)
return false;
const ExplodedNode *succ = *(node->succ_begin());
if (succ->pred_size() != 1)
return false;
// Now reclaim any nodes that are (by definition) not essential to
// analysis history and are not consulted by any client code.
ProgramPoint progPoint = node->getLocation();
if (progPoint.getAs<PreStmtPurgeDeadSymbols>())
return !progPoint.getTag();
// Condition 3.
if (!progPoint.getAs<PostStmt>() || progPoint.getAs<PostStore>())
return false;
// Condition 4.
if (progPoint.getTag())
return false;
// Conditions 5, 6, and 7.
ProgramStateRef state = node->getState();
ProgramStateRef pred_state = pred->getState();
if (state->store != pred_state->store || state->GDM != pred_state->GDM ||
progPoint.getLocationContext() != pred->getLocationContext())
return false;
// All further checks require expressions. As per #3, we know that we have
// a PostStmt.
const Expr *Ex = dyn_cast<Expr>(progPoint.castAs<PostStmt>().getStmt());
if (!Ex)
return false;
// Condition 8.
// Do not collect nodes for "interesting" lvalue expressions since they are
// used extensively for generating path diagnostics.
if (isInterestingLValueExpr(Ex))
return false;
// Condition 9.
// Do not collect nodes for non-consumed Stmt or Expr to ensure precise
// diagnostic generation; specifically, so that we could anchor arrows
// pointing to the beginning of statements (as written in code).
ParentMap &PM = progPoint.getLocationContext()->getParentMap();
if (!PM.isConsumedExpr(Ex))
return false;
// Condition 10.
const ProgramPoint SuccLoc = succ->getLocation();
if (Optional<StmtPoint> SP = SuccLoc.getAs<StmtPoint>())
if (CallEvent::isCallStmt(SP->getStmt()))
return false;
// Condition 10, continuation.
if (SuccLoc.getAs<CallEnter>() || SuccLoc.getAs<PreImplicitCall>())
return false;
return true;
}
void ExplodedGraph::collectNode(ExplodedNode *node) {
// Removing a node means:
// (a) changing the predecessors successor to the successor of this node
// (b) changing the successors predecessor to the predecessor of this node
// (c) Putting 'node' onto freeNodes.
assert(node->pred_size() == 1 || node->succ_size() == 1);
ExplodedNode *pred = *(node->pred_begin());
ExplodedNode *succ = *(node->succ_begin());
pred->replaceSuccessor(succ);
succ->replacePredecessor(pred);
FreeNodes.push_back(node);
Nodes.RemoveNode(node);
--NumNodes;
node->~ExplodedNode();
}
void ExplodedGraph::reclaimRecentlyAllocatedNodes() {
if (ChangedNodes.empty())
return;
// Only periodically reclaim nodes so that we can build up a set of
// nodes that meet the reclamation criteria. Freshly created nodes
// by definition have no successor, and thus cannot be reclaimed (see below).
assert(ReclaimCounter > 0);
if (--ReclaimCounter != 0)
return;
ReclaimCounter = ReclaimNodeInterval;
for (NodeVector::iterator it = ChangedNodes.begin(), et = ChangedNodes.end();
it != et; ++it) {
ExplodedNode *node = *it;
if (shouldCollect(node))
collectNode(node);
}
ChangedNodes.clear();
}
//===----------------------------------------------------------------------===//
// ExplodedNode.
//===----------------------------------------------------------------------===//
// An NodeGroup's storage type is actually very much like a TinyPtrVector:
// it can be either a pointer to a single ExplodedNode, or a pointer to a
// BumpVector allocated with the ExplodedGraph's allocator. This allows the
// common case of single-node NodeGroups to be implemented with no extra memory.
//
// Consequently, each of the NodeGroup methods have up to four cases to handle:
// 1. The flag is set and this group does not actually contain any nodes.
// 2. The group is empty, in which case the storage value is null.
// 3. The group contains a single node.
// 4. The group contains more than one node.
typedef BumpVector<ExplodedNode *> ExplodedNodeVector;
typedef llvm::PointerUnion<ExplodedNode *, ExplodedNodeVector *> GroupStorage;
void ExplodedNode::addPredecessor(ExplodedNode *V, ExplodedGraph &G) {
assert (!V->isSink());
Preds.addNode(V, G);
V->Succs.addNode(this, G);
#ifndef NDEBUG
if (NodeAuditor) NodeAuditor->AddEdge(V, this);
#endif
}
void ExplodedNode::NodeGroup::replaceNode(ExplodedNode *node) {
assert(!getFlag());
GroupStorage &Storage = reinterpret_cast<GroupStorage&>(P);
assert(Storage.is<ExplodedNode *>());
Storage = node;
assert(Storage.is<ExplodedNode *>());
}
void ExplodedNode::NodeGroup::addNode(ExplodedNode *N, ExplodedGraph &G) {
assert(!getFlag());
GroupStorage &Storage = reinterpret_cast<GroupStorage&>(P);
if (Storage.isNull()) {
Storage = N;
assert(Storage.is<ExplodedNode *>());
return;
}
ExplodedNodeVector *V = Storage.dyn_cast<ExplodedNodeVector *>();
if (!V) {
// Switch from single-node to multi-node representation.
ExplodedNode *Old = Storage.get<ExplodedNode *>();
BumpVectorContext &Ctx = G.getNodeAllocator();
V = G.getAllocator().Allocate<ExplodedNodeVector>();
new (V) ExplodedNodeVector(Ctx, 4);
V->push_back(Old, Ctx);
Storage = V;
assert(!getFlag());
assert(Storage.is<ExplodedNodeVector *>());
}
V->push_back(N, G.getNodeAllocator());
}
unsigned ExplodedNode::NodeGroup::size() const {
if (getFlag())
return 0;
const GroupStorage &Storage = reinterpret_cast<const GroupStorage &>(P);
if (Storage.isNull())
return 0;
if (ExplodedNodeVector *V = Storage.dyn_cast<ExplodedNodeVector *>())
return V->size();
return 1;
}
ExplodedNode * const *ExplodedNode::NodeGroup::begin() const {
if (getFlag())
return nullptr;
const GroupStorage &Storage = reinterpret_cast<const GroupStorage &>(P);
if (Storage.isNull())
return nullptr;
if (ExplodedNodeVector *V = Storage.dyn_cast<ExplodedNodeVector *>())
return V->begin();
return Storage.getAddrOfPtr1();
}
ExplodedNode * const *ExplodedNode::NodeGroup::end() const {
if (getFlag())
return nullptr;
const GroupStorage &Storage = reinterpret_cast<const GroupStorage &>(P);
if (Storage.isNull())
return nullptr;
if (ExplodedNodeVector *V = Storage.dyn_cast<ExplodedNodeVector *>())
return V->end();
return Storage.getAddrOfPtr1() + 1;
}
ExplodedNode *ExplodedGraph::getNode(const ProgramPoint &L,
ProgramStateRef State,
bool IsSink,
bool* IsNew) {
// Profile 'State' to determine if we already have an existing node.
llvm::FoldingSetNodeID profile;
void *InsertPos = nullptr;
NodeTy::Profile(profile, L, State, IsSink);
NodeTy* V = Nodes.FindNodeOrInsertPos(profile, InsertPos);
if (!V) {
if (!FreeNodes.empty()) {
V = FreeNodes.back();
FreeNodes.pop_back();
}
else {
// Allocate a new node.
V = (NodeTy*) getAllocator().Allocate<NodeTy>();
}
new (V) NodeTy(L, State, IsSink);
if (ReclaimNodeInterval)
ChangedNodes.push_back(V);
// Insert the node into the node set and return it.
Nodes.InsertNode(V, InsertPos);
++NumNodes;
if (IsNew) *IsNew = true;
}
else
if (IsNew) *IsNew = false;
return V;
}
ExplodedNode *ExplodedGraph::createUncachedNode(const ProgramPoint &L,
ProgramStateRef State,
bool IsSink) {
NodeTy *V = (NodeTy *) getAllocator().Allocate<NodeTy>();
new (V) NodeTy(L, State, IsSink);
return V;
}
std::unique_ptr<ExplodedGraph>
ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
InterExplodedGraphMap *ForwardMap,
InterExplodedGraphMap *InverseMap) const {
if (Nodes.empty())
return nullptr;
typedef llvm::DenseSet<const ExplodedNode*> Pass1Ty;
Pass1Ty Pass1;
typedef InterExplodedGraphMap Pass2Ty;
InterExplodedGraphMap Pass2Scratch;
Pass2Ty &Pass2 = ForwardMap ? *ForwardMap : Pass2Scratch;
SmallVector<const ExplodedNode*, 10> WL1, WL2;
// ===- Pass 1 (reverse DFS) -===
for (ArrayRef<const NodeTy *>::iterator I = Sinks.begin(), E = Sinks.end();
I != E; ++I) {
if (*I)
WL1.push_back(*I);
}
// Process the first worklist until it is empty.
while (!WL1.empty()) {
const ExplodedNode *N = WL1.pop_back_val();
// Have we already visited this node? If so, continue to the next one.
if (!Pass1.insert(N).second)
continue;
// If this is a root enqueue it to the second worklist.
if (N->Preds.empty()) {
WL2.push_back(N);
continue;
}
// Visit our predecessors and enqueue them.
WL1.append(N->Preds.begin(), N->Preds.end());
}
// We didn't hit a root? Return with a null pointer for the new graph.
if (WL2.empty())
return nullptr;
// Create an empty graph.
std::unique_ptr<ExplodedGraph> G = MakeEmptyGraph();
// ===- Pass 2 (forward DFS to construct the new graph) -===
while (!WL2.empty()) {
const ExplodedNode *N = WL2.pop_back_val();
// Skip this node if we have already processed it.
if (Pass2.find(N) != Pass2.end())
continue;
// Create the corresponding node in the new graph and record the mapping
// from the old node to the new node.
ExplodedNode *NewN = G->createUncachedNode(N->getLocation(), N->State, N->isSink());
Pass2[N] = NewN;
// Also record the reverse mapping from the new node to the old node.
if (InverseMap) (*InverseMap)[NewN] = N;
// If this node is a root, designate it as such in the graph.
if (N->Preds.empty())
G->addRoot(NewN);
// In the case that some of the intended predecessors of NewN have already
// been created, we should hook them up as predecessors.
// Walk through the predecessors of 'N' and hook up their corresponding
// nodes in the new graph (if any) to the freshly created node.
for (ExplodedNode::pred_iterator I = N->Preds.begin(), E = N->Preds.end();
I != E; ++I) {
Pass2Ty::iterator PI = Pass2.find(*I);
if (PI == Pass2.end())
continue;
NewN->addPredecessor(const_cast<ExplodedNode *>(PI->second), *G);
}
// In the case that some of the intended successors of NewN have already
// been created, we should hook them up as successors. Otherwise, enqueue
// the new nodes from the original graph that should have nodes created
// in the new graph.
for (ExplodedNode::succ_iterator I = N->Succs.begin(), E = N->Succs.end();
I != E; ++I) {
Pass2Ty::iterator PI = Pass2.find(*I);
if (PI != Pass2.end()) {
const_cast<ExplodedNode *>(PI->second)->addPredecessor(NewN, *G);
continue;
}
// Enqueue nodes to the worklist that were marked during pass 1.
if (Pass1.count(*I))
WL2.push_back(*I);
}
}
return G;
}

Some files were not shown because too many files have changed in this diff Show More