From 9a7a7be0da05d7b748c703515f028148992cff31 Mon Sep 17 00:00:00 2001 From: Konstantin Romanov Date: Fri, 30 Sep 2022 16:22:26 -0400 Subject: [PATCH] Run clang-format-14 on src/ folder. Signed-off-by: Konstantin Romanov --- .../include_graph/include_graph_util.cpp | 7 +++---- src/include_graph_dependencies.cpp | 19 ++++++++----------- src/propagation/propagation_visitor.h | 10 +++++----- src/tool_application_support.cpp | 2 +- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/collectors/include_graph/include_graph_util.cpp b/src/collectors/include_graph/include_graph_util.cpp index fba3451..7bd08c2 100644 --- a/src/collectors/include_graph/include_graph_util.cpp +++ b/src/collectors/include_graph/include_graph_util.cpp @@ -36,8 +36,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -219,8 +219,7 @@ static clang::Decl *extract_decl_for_type(const clang::Type *t) { } } -bool check_for_first_end(clang::CompilerInstance *ci, - IncludeGraphData *data, +bool check_for_first_end(clang::CompilerInstance *ci, IncludeGraphData *data, const clang::TypeLoc *n) { std::pair tuid = get_fileuid(ci, data, n->getEndLoc()); @@ -256,7 +255,7 @@ void add_type_reference(clang::CompilerInstance *ci, IncludeGraphData *data, decl = extract_decl_for_type(t); if (!decl || !check_for_first_end(ci, data, n)) { - return; + return; } add_usage(ci, data, n->getBeginLoc(), decl->getLocation(), n, diff --git a/src/include_graph_dependencies.cpp b/src/include_graph_dependencies.cpp index 36fa87f..cc29c93 100644 --- a/src/include_graph_dependencies.cpp +++ b/src/include_graph_dependencies.cpp @@ -89,12 +89,10 @@ bool IncludeGraphDependencies::decrementUsageRefCount( return false; } - std::set IncludeGraphDependencies::collectAllIncludes( - const clangmetatool::collectors::IncludeGraphData* data, - const types::FileUID &fileUID) -{ + const clangmetatool::collectors::IncludeGraphData *data, + const types::FileUID &fileUID) { types::FileGraph::const_iterator rangeBegin, rangeEnd; std::tie(rangeBegin, rangeEnd) = edgeRangeStartsWith(data, fileUID); @@ -117,7 +115,6 @@ IncludeGraphDependencies::collectAllIncludes( return visitedNodes; } - std::set IncludeGraphDependencies::liveDependencies( const collectors::IncludeGraphData *data, const clangmetatool::types::FileUID &fileUID) { @@ -143,7 +140,8 @@ std::set IncludeGraphDependencies::liveDependencies( * Traverse the include graph for `forNode` start from `rootNode` to all * accessible node using BFS and update given DirectDependenciesMap. * - * For any node that `usage_reference_count[{rootNode, toNode}] > 0`, add a record + * For any node that `usage_reference_count[{rootNode, toNode}] > 0`, add a + * record * `{toNode: [rootNode]}` to depsMap, means that `forNode` needs to access * resource defined in `toNode` through `rootNode` * @@ -153,7 +151,7 @@ std::set IncludeGraphDependencies::liveDependencies( void traverseFor(const types::FileUID &forNode, const types::FileUID &rootNode, const clangmetatool::collectors::IncludeGraphData *data, std::set &knownNodes, - IncludeGraphDependencies::DirectDependenciesMap& depsMap){ + IncludeGraphDependencies::DirectDependenciesMap &depsMap) { std::queue filesToProcess; filesToProcess.push(rootNode); @@ -165,7 +163,7 @@ void traverseFor(const types::FileUID &forNode, const types::FileUID &rootNode, types::FileGraphEdge currentEdge{forNode, toNode}; auto refCountIt = data->usage_reference_count.find(currentEdge); // the include graph looks like - // forNode -> rootNode -> ... -> toNode + // forNode -> rootNode -> ... -> toNode if (refCountIt != data->usage_reference_count.end() && refCountIt->second > 0) { depsMap[toNode].emplace(rootNode); @@ -185,13 +183,12 @@ void traverseFor(const types::FileUID &forNode, const types::FileUID &rootNode, } } } - } IncludeGraphDependencies::DirectDependenciesMap IncludeGraphDependencies::liveWeakDependencies( const clangmetatool::collectors::IncludeGraphData *data, - const clangmetatool::types::FileUID &fileUID){ + const clangmetatool::types::FileUID &fileUID) { IncludeGraphDependencies::DirectDependenciesMap depsMap; types::FileGraph::const_iterator rangeBegin, rangeEnd; @@ -200,7 +197,7 @@ IncludeGraphDependencies::liveWeakDependencies( for (auto it = rangeBegin; it != rangeEnd; ++it) { assert(it->first == fileUID); std::set knownNodes; - traverseFor(fileUID, it->second, data, knownNodes, depsMap); + traverseFor(fileUID, it->second, data, knownNodes, depsMap); } return depsMap; diff --git a/src/propagation/propagation_visitor.h b/src/propagation/propagation_visitor.h index 46a1265..79a369b 100644 --- a/src/propagation/propagation_visitor.h +++ b/src/propagation/propagation_visitor.h @@ -87,13 +87,13 @@ class PropagationVisitor : public clang::ConstStmtVisitor { // Find the first statement in the block, note that the statements are not // necessarily in order as stored in the block. const clang::Stmt *startStmt = nullptr; - const clang::SourceManager& SM = AC.getSourceManager(); + const clang::SourceManager &SM = AC.getSourceManager(); for (auto elem : *block) { const clang::Stmt *elemStmt = nullptr; - if (util::getStmtFromCFGElement(elemStmt, elem) - && (!startStmt - || SM.isBeforeInTranslationUnit(elemStmt->getBeginLoc(), - startStmt->getBeginLoc()))) { + if (util::getStmtFromCFGElement(elemStmt, elem) && + (!startStmt || + SM.isBeforeInTranslationUnit(elemStmt->getBeginLoc(), + startStmt->getBeginLoc()))) { startStmt = elemStmt; } } diff --git a/src/tool_application_support.cpp b/src/tool_application_support.cpp index d3d13cb..7a92ab0 100644 --- a/src/tool_application_support.cpp +++ b/src/tool_application_support.cpp @@ -46,7 +46,7 @@ std::string getExecutablePathFromArgv(const std::string &argv0) { exePath = argv0; if (!llvm::sys::path::has_parent_path(exePath)) { llvm::Optional maybeExePath = - llvm::sys::Process::FindInEnvPath("PATH", argv0); + llvm::sys::Process::FindInEnvPath("PATH", argv0); exePath = maybeExePath.getValueOr(""); } }