-
Notifications
You must be signed in to change notification settings - Fork 155
clang-tidy: Fix IDE generalized LCA #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2640f29
clang-tidy fixes for IDEGeneralizedLCA
84b29c2
Fixes formatting and lineendings
vulder 855e176
Remove windows lineendings
vulder da0ed46
Fixes next file
vulder f12f491
Merge branch 'development' into f-ClangTidyFixIDEGeneralizedLCA
pdschubert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
247 changes: 125 additions & 122 deletions
247
include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEGeneralizedLCA/EdgeValue.h
This file contains hidden or 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 |
|---|---|---|
| @@ -1,122 +1,125 @@ | ||
| /****************************************************************************** | ||
| * Copyright (c) 2020 Fabian Schiebel. | ||
| * All rights reserved. This program and the accompanying materials are made | ||
| * available under the terms of LICENSE.txt. | ||
| * | ||
| * Contributors: | ||
| * Fabian Schiebel, Alexander Meinhold and others | ||
| *****************************************************************************/ | ||
|
|
||
| #ifndef PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H | ||
| #define PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H | ||
|
|
||
| #include <iostream> | ||
| #include <memory> | ||
| #include <unordered_set> | ||
| #include <variant> | ||
|
|
||
| #include "llvm/ADT/APSInt.h" | ||
| #include "llvm/ADT/Twine.h" | ||
| #include "llvm/IR/Constant.h" | ||
| #include "llvm/IR/Instructions.h" | ||
|
|
||
| namespace psr { | ||
|
|
||
| enum class Ordering { Less, Greater, Equal, Incomparable }; | ||
|
|
||
| class EdgeValue { | ||
| public: | ||
| enum Type { Top, Integer, String, FloatingPoint }; | ||
|
|
||
| private: | ||
| std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t> value = | ||
| nullptr; | ||
| Type type; | ||
|
|
||
| public: | ||
| EdgeValue(const llvm::Value *val); | ||
| EdgeValue(const EdgeValue &ev); | ||
| EdgeValue(llvm::APInt &&vi); | ||
| EdgeValue(const llvm::APInt &vi); | ||
| EdgeValue(llvm::APFloat &&vf); | ||
| EdgeValue(long long vi); | ||
| EdgeValue(int vi); | ||
| EdgeValue(double d); | ||
| EdgeValue(float d); | ||
| EdgeValue(std::string &&vs); | ||
| EdgeValue(std::nullptr_t); | ||
| ~EdgeValue(); | ||
| const static EdgeValue top; | ||
| [[nodiscard]] bool tryGetInt(uint64_t &Res) const; | ||
| [[nodiscard]] bool tryGetFP(double &Res) const; | ||
| [[nodiscard]] bool tryGetString(std::string &Res) const; | ||
| [[nodiscard]] bool isTop() const; | ||
| [[nodiscard]] bool isNumeric() const; | ||
| [[nodiscard]] bool isString() const; | ||
| [[nodiscard]] Type getKind() const; | ||
| // std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const; | ||
| bool sqSubsetEq(const EdgeValue &other) const; | ||
| EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps op, | ||
| const EdgeValue &other) const; | ||
| EdgeValue typecast(Type dest, unsigned bits) const; | ||
| EdgeValue &operator=(const EdgeValue &ev); | ||
|
|
||
| operator bool(); | ||
| friend bool operator==(const EdgeValue &v1, const EdgeValue &v2); | ||
|
|
||
| // binary operators | ||
| friend EdgeValue operator+(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator-(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator*(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator/(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator%(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator&(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator|(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator^(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator<<(const EdgeValue &v1, const EdgeValue &v2); | ||
| friend EdgeValue operator>>(const EdgeValue &v1, const EdgeValue &v2); | ||
| static int compare(const EdgeValue &v1, const EdgeValue &v2); | ||
|
|
||
| // unary operators | ||
| EdgeValue operator-() const; | ||
| EdgeValue operator~() const; | ||
| friend std::ostream &operator<<(std::ostream &os, const EdgeValue &ev); | ||
| static std::string typeToString(Type ty); | ||
| }; | ||
| class EdgeValueSet; | ||
| using ev_t = EdgeValueSet; | ||
|
|
||
| ev_t performBinOp(llvm::BinaryOperator::BinaryOps op, const ev_t &v1, | ||
| const ev_t &v2, size_t maxSize); | ||
| ev_t performTypecast(const ev_t &ev, EdgeValue::Type dest, unsigned bits); | ||
| Ordering compare(const ev_t &v1, const ev_t &v2); | ||
| ev_t join(const ev_t &v1, const ev_t &v2, size_t maxSize); | ||
| /// \brief implements square subset equal | ||
| bool operator<(const ev_t &v1, const ev_t &v2); | ||
| bool isTopValue(const ev_t &v); | ||
| std::ostream &operator<<(std::ostream &os, const ev_t &v); | ||
|
|
||
| } // namespace psr | ||
|
|
||
| namespace std { | ||
|
|
||
| template <> struct hash<psr::EdgeValue> { | ||
| hash() {} | ||
| size_t operator()(const psr::EdgeValue &val) const { | ||
| auto hc = hash<int>()(val.getKind()); | ||
| uint64_t asInt; | ||
| double asFloat; | ||
| string asString; | ||
| if (val.tryGetInt(asInt)) | ||
| return hash<uint64_t>()(asInt) * 31 + hc; | ||
| else if (val.tryGetFP(asFloat)) | ||
| return hash<double>()(round(asFloat)) * 31 + hc; | ||
| else if (val.tryGetString(asString)) | ||
| return hash<string>()(asString) * 31 + hc; | ||
| return hc; | ||
| } | ||
| }; | ||
|
|
||
| } // namespace std | ||
|
|
||
| #endif | ||
| /****************************************************************************** | ||
| * Copyright (c) 2020 Fabian Schiebel. | ||
| * All rights reserved. This program and the accompanying materials are made | ||
| * available under the terms of LICENSE.txt. | ||
| * | ||
| * Contributors: | ||
| * Fabian Schiebel, Alexander Meinhold and others | ||
| *****************************************************************************/ | ||
|
|
||
| #ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H_ | ||
| #define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H_ | ||
|
|
||
| #include <iostream> | ||
| #include <memory> | ||
| #include <unordered_set> | ||
| #include <variant> | ||
|
|
||
| #include "llvm/ADT/APSInt.h" | ||
| #include "llvm/ADT/Twine.h" | ||
| #include "llvm/IR/Constant.h" | ||
| #include "llvm/IR/Instructions.h" | ||
|
|
||
| namespace psr { | ||
|
|
||
| enum class Ordering { Less, Greater, Equal, Incomparable }; | ||
|
|
||
| class EdgeValue { | ||
| public: | ||
| enum Type { Top, Integer, String, FloatingPoint }; | ||
|
|
||
| private: | ||
| std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t> | ||
| ValVariant = nullptr; | ||
| Type VariantType; | ||
|
|
||
| public: | ||
| EdgeValue(const llvm::Value *Val); | ||
| EdgeValue(const EdgeValue &EV); | ||
| EdgeValue(llvm::APInt &&VI); | ||
| EdgeValue(const llvm::APInt &VI); | ||
| EdgeValue(llvm::APFloat &&VF); | ||
| EdgeValue(long long VI); | ||
| EdgeValue(int VI); | ||
| EdgeValue(double Double); | ||
| EdgeValue(float Float); | ||
| EdgeValue(std::string &&VS); | ||
| EdgeValue(std::nullptr_t); | ||
| ~EdgeValue(); | ||
| const static EdgeValue TopValue; | ||
| [[nodiscard]] bool tryGetInt(uint64_t &Res) const; | ||
| [[nodiscard]] bool tryGetFP(double &Res) const; | ||
| [[nodiscard]] bool tryGetString(std::string &Res) const; | ||
| [[nodiscard]] bool isTop() const; | ||
| [[nodiscard]] bool isNumeric() const; | ||
| [[nodiscard]] bool isString() const; | ||
| [[nodiscard]] Type getKind() const; | ||
| // std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const; | ||
| [[nodiscard]] bool sqSubsetEq(const EdgeValue &Other) const; | ||
| [[nodiscard]] EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps Op, | ||
|
vulder marked this conversation as resolved.
|
||
| const EdgeValue &Other) const; | ||
| [[nodiscard]] EdgeValue typecast(Type Dest, unsigned Bits) const; | ||
| EdgeValue &operator=(const EdgeValue &EV); | ||
|
|
||
| operator bool(); | ||
| friend bool operator==(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
|
|
||
| // binary operators | ||
| friend EdgeValue operator+(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator-(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator*(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator/(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator%(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator&(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator|(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator^(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator<<(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| friend EdgeValue operator>>(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
| static int compare(const EdgeValue &Lhs, const EdgeValue &Rhs); | ||
|
|
||
| // unary operators | ||
| EdgeValue operator-() const; | ||
| EdgeValue operator~() const; | ||
| friend std::ostream &operator<<(std::ostream &Os, const EdgeValue &EV); | ||
| static std::string typeToString(Type Ty); | ||
| }; | ||
| class EdgeValueSet; | ||
| typedef EdgeValueSet ev_t; | ||
|
|
||
| ev_t performBinOp(llvm::BinaryOperator::BinaryOps Op, const ev_t &Lhs, | ||
| const ev_t &Rhs, size_t MaxSize); | ||
| ev_t performTypecast(const ev_t &Ev, EdgeValue::Type Dest, unsigned Bits); | ||
| Ordering compare(const ev_t &Lhs, const ev_t &Rhs); | ||
|
vulder marked this conversation as resolved.
|
||
| ev_t join(const ev_t &Lhs, const ev_t &Rhs, size_t MaxSize); | ||
| /// \brief implements square subset equal | ||
| bool operator<(const ev_t &Lhs, const ev_t &Rhs); | ||
| bool isTopValue(const ev_t &Val); | ||
| std::ostream &operator<<(std::ostream &Os, const ev_t &Val); | ||
|
|
||
| } // namespace psr | ||
|
|
||
| namespace std { | ||
|
|
||
| template <> struct hash<psr::EdgeValue> { | ||
| hash() = default; | ||
| size_t operator()(const psr::EdgeValue &Val) const { | ||
| auto Hash = hash<int>()(Val.getKind()); | ||
| uint64_t AsInt; | ||
| double AsFloat; | ||
| string AsString; | ||
| if (Val.tryGetInt(AsInt)) { | ||
| return hash<uint64_t>()(AsInt) * 31 + Hash; | ||
| } | ||
|
vulder marked this conversation as resolved.
|
||
| if (Val.tryGetFP(AsFloat)) { | ||
| return hash<double>()(round(AsFloat)) * 31 + Hash; | ||
| } | ||
| if (Val.tryGetString(AsString)) { | ||
| return hash<string>()(AsString) * 31 + Hash; | ||
|
vulder marked this conversation as resolved.
|
||
| } | ||
| return Hash; | ||
| } | ||
| }; | ||
|
|
||
| } // namespace std | ||
|
|
||
| #endif | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.