Skip to content
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

Extract More Information from Debug Info #742

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#ifndef PHASAR_DATAFLOW_IFDSIDE_IDETABULATIONPROBLEM_H_
#define PHASAR_DATAFLOW_IFDSIDE_IDETABULATIONPROBLEM_H_

#include "phasar/ControlFlow/ICFGBase.h"
#include "phasar/DB/ProjectIRDBBase.h"
#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h"
#include "phasar/DataFlow/IfdsIde/EdgeFunctions.h"
Expand All @@ -22,15 +21,10 @@
#include "phasar/DataFlow/IfdsIde/SolverResults.h"
#include "phasar/Utils/JoinLattice.h"
#include "phasar/Utils/NullAnalysisPrinter.h"
#include "phasar/Utils/Printer.h"
#include "phasar/Utils/SemiRing.h"
#include "phasar/Utils/Soundness.h"

#include "llvm/ADT/StringRef.h"

#include <cassert>
#include <functional>
#include <memory>
#include <optional>
#include <set>
#include <string>
Expand Down
1 change: 0 additions & 1 deletion include/phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h"
#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
#include "phasar/Domain/AnalysisDomain.h"
#include "phasar/Domain/BinaryDomain.h"

#include <set>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Utilities.h"

#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/IntEqClasses.h"
#include "llvm/ADT/SmallVector.h"

namespace llvm {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "phasar/DataFlow/IfdsIde/FlowFunctions.h"
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/PointerIntPair.h"
#include "llvm/IR/Constant.h"
Expand All @@ -30,7 +29,6 @@
#include <set>
#include <type_traits>
#include <utility>
#include <vector>

namespace psr {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
#include "phasar/DataFlow/IfdsIde/FlowFunctions.h"
#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h"
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMFlowFunctions.h"
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h"
#include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h"
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h"
#include "phasar/Utils/ByRef.h"
#include "phasar/Utils/JoinLattice.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Printer.h"
#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Value.h"

#include <memory>
#include <set>
#include <string>
#include <type_traits>
Expand Down
55 changes: 29 additions & 26 deletions include/phasar/PhasarLLVM/Utils/LLVMIRToSrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,37 @@ class Value;
class GlobalVariable;
class Module;
class DIFile;
class DILocation;
} // namespace llvm

namespace psr {
struct DebugLocation {
unsigned Line{};
unsigned Column{};
const llvm::DIFile *File{};
};

struct SourceCodeInfo {
std::string SourceCodeLine;
std::string SourceCodeFilename;
std::string SourceCodeFunctionName;
unsigned Line = 0;
unsigned Column = 0;

[[nodiscard]] bool empty() const noexcept;

[[nodiscard]] bool operator==(const SourceCodeInfo &Other) const noexcept;
[[nodiscard]] inline bool
operator!=(const SourceCodeInfo &Other) const noexcept {
return !(*this == Other);
}

/// Similar to operator==, but takes different SourceCodeFileName locations
/// into account
[[nodiscard]] bool equivalentWith(const SourceCodeInfo &Other) const;
};

[[nodiscard]] llvm::DILocation *getDILocation(const llvm::Value *V);

[[nodiscard]] std::string getVarNameFromIR(const llvm::Value *V);

Expand All @@ -55,29 +83,10 @@ getLineAndColFromIR(const llvm::Value *V);

[[nodiscard]] std::string getSrcCodeFromIR(const llvm::Value *V,
bool Trim = true);
[[nodiscard]] std::string getSrcCodeFromIR(DebugLocation Loc, bool Trim = true);

[[nodiscard]] std::string getModuleIDFromIR(const llvm::Value *V);

struct SourceCodeInfo {
std::string SourceCodeLine;
std::string SourceCodeFilename;
std::string SourceCodeFunctionName;
unsigned Line = 0;
unsigned Column = 0;

[[nodiscard]] bool empty() const noexcept;

[[nodiscard]] bool operator==(const SourceCodeInfo &Other) const noexcept;
[[nodiscard]] inline bool
operator!=(const SourceCodeInfo &Other) const noexcept {
return !(*this == Other);
}

/// Similar to operator==, but takes different SourceCodeFileName locations
/// into account
[[nodiscard]] bool equivalentWith(const SourceCodeInfo &Other) const;
};

/// Used from the JSON library internally to implicitly convert between json and
/// SourceCodeInfo
void from_json(const nlohmann::json &J, SourceCodeInfo &Info);
Expand All @@ -87,12 +96,6 @@ void to_json(nlohmann::json &J, const SourceCodeInfo &Info);

[[nodiscard]] SourceCodeInfo getSrcCodeInfoFromIR(const llvm::Value *V);

struct DebugLocation {
unsigned Line{};
unsigned Column{};
const llvm::DIFile *File{};
};

[[nodiscard]] std::optional<DebugLocation>
getDebugLocation(const llvm::Value *V);

Expand Down
1 change: 1 addition & 0 deletions include/phasar/Pointer/AliasInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "phasar/Pointer/AliasResult.h"
#include "phasar/Utils/AnalysisProperties.h"
#include "phasar/Utils/ByRef.h"
#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
Expand Down
5 changes: 2 additions & 3 deletions include/phasar/Pointer/AliasInfoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
#define PHASAR_POINTER_ALIASINFOBASE_H

#include "phasar/Pointer/AliasInfoTraits.h"
#include "phasar/Utils/TypeTraits.h"
#include "phasar/Utils/Macros.h"

#include "llvm/ADT/DenseSet.h"
#include "llvm/Support/raw_ostream.h"

#include "nlohmann/json.hpp"
#include "nlohmann/json_fwd.hpp"

#include <optional>
#include <tuple>
Expand Down
5 changes: 5 additions & 0 deletions include/phasar/Utils/BitVectorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ template <typename T> class BitVectorSet {
}
};

// Overloads with the other intersectWith functions from Utilities.h
template <typename T>
void intersectWith(BitVectorSet<T> &Dest, const BitVectorSet<T> &Src) {
Dest.setIntersectWith(Src);
}
} // namespace psr

namespace std {
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/Utils/ByRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef PHASAR_UTILS_BYREF_H
#define PHASAR_UTILS_BYREF_H

#include "phasar/Utils/TypeTraits.h"
#include "phasar/Utils/Macros.h"

#include <type_traits>

Expand Down
2 changes: 0 additions & 2 deletions include/phasar/Utils/DebugOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#define PHASAR_UTILS_DEBUGOUTPUT_H

#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/SmallBitVector.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
6 changes: 2 additions & 4 deletions include/phasar/Utils/GraphTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
#ifndef PHASAR_UTILS_GRAPHTRAITS_H
#define PHASAR_UTILS_GRAPHTRAITS_H

#include "phasar/Utils/TypeTraits.h"
#include "phasar/Utils/Utilities.h"

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/identity.h"
#include "llvm/Support/raw_ostream.h"

#if __cplusplus >= 202002L
#include <concepts>
#endif
#include <functional>
#include <string>
#include <type_traits>
Expand Down
1 change: 0 additions & 1 deletion include/phasar/Utils/IotaIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <cstddef>
#include <iterator>
#include <optional>
#include <type_traits>

namespace psr {
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/Utils/JoinLattice.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef PHASAR_UTILS_JOINLATTICE_H
#define PHASAR_UTILS_JOINLATTICE_H

#include "phasar/Utils/TypeTraits.h"
#include "phasar/Utils/Macros.h"

#include <type_traits>
#include <utility>
Expand Down
19 changes: 19 additions & 0 deletions include/phasar/Utils/Macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/******************************************************************************
* Copyright (c) 2024 Fabian Schiebel.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of LICENSE.txt.
*
* Contributors:
* Fabian Schiebel and others
*****************************************************************************/

#ifndef PHASAR_UTILS_MACROS_H
#define PHASAR_UTILS_MACROS_H

#if __cplusplus < 202002L
#define PSR_CONCEPT static constexpr bool
#else
#define PSR_CONCEPT concept
#endif

#endif // PHASAR_UTILS_MACROS_H
2 changes: 0 additions & 2 deletions include/phasar/Utils/PAMM.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#ifndef PHASAR_UTILS_PAMM_H_
#define PHASAR_UTILS_PAMM_H_

#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
Expand Down
4 changes: 2 additions & 2 deletions include/phasar/Utils/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef PHASAR_UTILS_TYPETRAITS_H
#define PHASAR_UTILS_TYPETRAITS_H

#include "phasar/Utils/Macros.h"

#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"

Expand All @@ -25,10 +27,8 @@
namespace psr {

#if __cplusplus < 202002L
#define PSR_CONCEPT static constexpr bool
template <typename T> struct type_identity { using type = T; };
#else
#define PSR_CONCEPT concept
template <typename T> using type_identity = std::type_identity<T>;
#endif

Expand Down
8 changes: 0 additions & 8 deletions include/phasar/Utils/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
#ifndef PHASAR_UTILS_UTILITIES_H_
#define PHASAR_UTILS_UTILITIES_H_

#include "phasar/Utils/BitVectorSet.h"
#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
Expand Down Expand Up @@ -153,11 +150,6 @@ intersectWith(ContainerTy &Dest, const OtherContainerTy &Src) {
}
}

template <typename T>
void intersectWith(BitVectorSet<T> &Dest, const BitVectorSet<T> &Src) {
Dest.setIntersectWith(Src);
}

llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const std::vector<bool> &Bits);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/TypeTraits.h"
#include "phasar/Utils/Utilities.h"

#include "llvm/ADT/Hashing.h"
Expand Down
Loading