forked from apple/swift-clang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] Create generic SMT Expr class
Summary: New base class for all future SMT Exprs. No major changes except moving `areEquivalent` and `getFloatSemantics` outside of `Z3Expr` to keep the class minimal. Reviewers: NoQ, george.karpenkov Reviewed By: george.karpenkov Subscribers: xazax.hun, szepet, a.sidorin Differential Revision: https://reviews.llvm.org/D49551 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337917 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
143e570
commit 9a5865c
Showing
2 changed files
with
101 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//== SMTExpr.h --------------------------------------------------*- 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 a SMT generic Expr API, which will be the base class | ||
// for every SMT solver expr specific class. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTEXPR_H | ||
#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTEXPR_H | ||
|
||
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" | ||
|
||
namespace clang { | ||
namespace ento { | ||
|
||
class SMTExpr { | ||
public: | ||
SMTExpr() = default; | ||
virtual ~SMTExpr() = default; | ||
|
||
bool operator<(const SMTExpr &Other) const { | ||
llvm::FoldingSetNodeID ID1, ID2; | ||
Profile(ID1); | ||
Other.Profile(ID2); | ||
return ID1 < ID2; | ||
} | ||
|
||
virtual void Profile(llvm::FoldingSetNodeID &ID) const { | ||
static int Tag = 0; | ||
ID.AddPointer(&Tag); | ||
} | ||
|
||
friend bool operator==(SMTExpr const &LHS, SMTExpr const &RHS) { | ||
return LHS.equal_to(RHS); | ||
} | ||
|
||
virtual void print(raw_ostream &OS) const = 0; | ||
|
||
LLVM_DUMP_METHOD void dump() const { print(llvm::errs()); } | ||
|
||
protected: | ||
virtual bool equal_to(SMTExpr const &other) const = 0; | ||
}; | ||
|
||
using SMTExprRef = std::shared_ptr<SMTExpr>; | ||
|
||
} // namespace ento | ||
} // namespace clang | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters