Skip to content

Commit

Permalink
Formatting changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Nov 1, 2023
1 parent bbd7280 commit ca20dbe
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 272 deletions.
30 changes: 15 additions & 15 deletions include/clad/Differentiator/TBRAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ class TBRAnalyzer : public clang::ConstStmtVisitor<TBRAnalyzer> {
struct VarData {
enum VarDataType { UNDEFINED, FUND_TYPE, OBJ_TYPE, ARR_TYPE, REF_TYPE };
union VarDataValue {
bool fundData;
/// objData, arrData are stored as pointers for VarDataValue to take
bool m_FundData;
/// m_ObjData, m_ArrData are stored as pointers for VarDataValue to take
/// less space.
ObjMap* objData;
ArrMap* arrData;
Expr* refData;
VarDataValue() : fundData(false) {}
ObjMap* m_ObjData;
ArrMap* m_ArrData;
Expr* m_RefData;
VarDataValue() : m_FundData(false) {}
};
VarDataType type = UNDEFINED;
VarDataValue val;
Expand All @@ -130,13 +130,13 @@ class TBRAnalyzer : public clang::ConstStmtVisitor<TBRAnalyzer> {
/// Erases all children VarData's of this VarData.
void erase() {
if (type == OBJ_TYPE) {
for (auto& pair : *val.objData)
for (auto& pair : *val.m_ObjData)
pair.second.erase();
delete val.objData;
delete val.m_ObjData;
} else if (type == ARR_TYPE) {
for (auto& pair : *val.arrData)
for (auto& pair : *val.m_ArrData)
pair.second.erase();
delete val.arrData;
delete val.m_ArrData;
}
}
};
Expand Down Expand Up @@ -234,11 +234,11 @@ class TBRAnalyzer : public clang::ConstStmtVisitor<TBRAnalyzer> {
/// Note: the returned VarsData contains original data from
/// the predecessors (NOT copies). It should not be modified.
std::unordered_map<const clang::VarDecl*, VarData*>
collectDataFromPredecessors(VarsData* varsData, VarsData* limit = nullptr);
static collectDataFromPredecessors(VarsData* varsData, VarsData* limit = nullptr);

/// Finds the lowest common ancestor of two VarsData
/// (based on the prev field in VarsData).
VarsData* findLowestCommonAncestor(VarsData* varsData1, VarsData* varsData2);
static VarsData* findLowestCommonAncestor(VarsData* varsData1, VarsData* varsData2);

/// Merges mergeData into targetData. Should be called
/// after mergeData is passed and the corresponding CFG
Expand All @@ -262,7 +262,7 @@ class TBRAnalyzer : public clang::ConstStmtVisitor<TBRAnalyzer> {
/// a new one).
std::vector<short> modeStack;

ASTContext* m_Context;
ASTContext& m_Context;

/// clang::CFG of the function being analysed.
std::unique_ptr<clang::CFG> m_CFG;
Expand Down Expand Up @@ -315,7 +315,7 @@ class TBRAnalyzer : public clang::ConstStmtVisitor<TBRAnalyzer> {

public:
/// Constructor
TBRAnalyzer(ASTContext* m_Context) : m_Context(m_Context) {
TBRAnalyzer(ASTContext& m_Context) : m_Context(m_Context) {
modeStack.push_back(0);
}

Expand All @@ -340,7 +340,7 @@ class TBRAnalyzer : public clang::ConstStmtVisitor<TBRAnalyzer> {
/// Visitors
void Analyze(const clang::FunctionDecl* FD);

void VisitCFGBlock(clang::CFGBlock* block);
void VisitCFGBlock(const clang::CFGBlock* block);

void Visit(const clang::Stmt* stmt) {
clang::ConstStmtVisitor<TBRAnalyzer, void>::Visit(stmt);
Expand Down
Loading

0 comments on commit ca20dbe

Please sign in to comment.