From: Ted Kremenek Date: Fri, 11 Jan 2008 16:36:20 +0000 (+0000) Subject: Added ProgramPoint.cpp, which implements several methods of the subclasses X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33bfb5c9ce8d5909a124f684af698a021100a652;p=clang Added ProgramPoint.cpp, which implements several methods of the subclasses of ProgramPoint. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45866 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/ProgramPoint.cpp b/Analysis/ProgramPoint.cpp new file mode 100644 index 0000000000..c089e48698 --- /dev/null +++ b/Analysis/ProgramPoint.cpp @@ -0,0 +1,65 @@ +//= ProgramPoint.cpp - Program Points for Path-Sensitive 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 implements methods for subclasses of ProgramPoint. +// +//===----------------------------------------------------------------------===// + +#include "clang/AST/CFG.h" +#include "clang/Analysis/ProgramPoint.h" + +using namespace clang; + +BlockEdge::BlockEdge(CFG& cfg, const CFGBlock* B1, const CFGBlock* B2) { + if (B1->succ_size() == 1) { + assert (*(B1->succ_begin()) == B2); + Data = reinterpret_cast(B1) | BlockEdgeSrcKind; + } + else if (B2->pred_size() == 1) { + assert (*(B2->pred_begin()) == B1); + Data = reinterpret_cast(B2) | BlockEdgeDstKind; + } + else + Data = reinterpret_cast(cfg.getBlockEdgeImpl(B1,B2)) + | BlockEdgeAuxKind; +} + +CFGBlock* BlockEdge::getSrc() const { + switch (getKind()) { + default: + assert (false && "Invalid BlockEdgeKind."); + return NULL; + + case BlockEdgeSrcKind: + return reinterpret_cast(getRawPtr()); + + case BlockEdgeDstKind: + return *(reinterpret_cast(getRawPtr())->pred_begin()); + + case BlockEdgeAuxKind: + return reinterpret_cast(getRawPtr())->first; + } +} + +CFGBlock* BlockEdge::getDst() const { + switch (getKind()) { + default: + assert (false && "Invalid BlockEdgeKind."); + return NULL; + + case BlockEdgeSrcKind: + return *(reinterpret_cast(getRawPtr())->succ_begin()); + + case BlockEdgeDstKind: + return reinterpret_cast(getRawPtr()); + + case BlockEdgeAuxKind: + return reinterpret_cast(getRawPtr())->second; + } +}