Skip to content

Commit

Permalink
Merge pull request #73 from ksromanov/clang-format-14
Browse files Browse the repository at this point in the history
Run clang-format-14 on src/ folder
  • Loading branch information
dbeer1 authored Oct 3, 2022
2 parents 5a7f5c2 + 9a7a7be commit cb17e41
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
7 changes: 3 additions & 4 deletions src/collectors/include_graph/include_graph_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#include <llvm/ADT/StringRef.h>
#include <llvm/Support/CommandLine.h>
#include <map>
#include <sstream>
#include <ostream>
#include <sstream>
#include <string>
#include <unistd.h>
#include <utility>
Expand Down Expand Up @@ -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<FileUID, bool> tuid = get_fileuid(ci, data, n->getEndLoc());

Expand Down Expand Up @@ -256,7 +255,7 @@ void add_type_reference(clang::CompilerInstance *ci, IncludeGraphData *data,
decl = extract_decl_for_type<clang::UnresolvedUsingType>(t);

if (!decl || !check_for_first_end(ci, data, n)) {
return;
return;
}

add_usage(ci, data, n->getBeginLoc(), decl->getLocation(), n,
Expand Down
19 changes: 8 additions & 11 deletions src/include_graph_dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,10 @@ bool IncludeGraphDependencies::decrementUsageRefCount(
return false;
}


std::set<clangmetatool::types::FileUID>
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);

Expand All @@ -117,7 +115,6 @@ IncludeGraphDependencies::collectAllIncludes(
return visitedNodes;
}


std::set<types::FileUID> IncludeGraphDependencies::liveDependencies(
const collectors::IncludeGraphData *data,
const clangmetatool::types::FileUID &fileUID) {
Expand All @@ -143,7 +140,8 @@ std::set<types::FileUID> 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`
*
Expand All @@ -153,7 +151,7 @@ std::set<types::FileUID> IncludeGraphDependencies::liveDependencies(
void traverseFor(const types::FileUID &forNode, const types::FileUID &rootNode,
const clangmetatool::collectors::IncludeGraphData *data,
std::set<types::FileUID> &knownNodes,
IncludeGraphDependencies::DirectDependenciesMap& depsMap){
IncludeGraphDependencies::DirectDependenciesMap &depsMap) {
std::queue<types::FileUID> filesToProcess;

filesToProcess.push(rootNode);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -200,7 +197,7 @@ IncludeGraphDependencies::liveWeakDependencies(
for (auto it = rangeBegin; it != rangeEnd; ++it) {
assert(it->first == fileUID);
std::set<types::FileUID> knownNodes;
traverseFor(fileUID, it->second, data, knownNodes, depsMap);
traverseFor(fileUID, it->second, data, knownNodes, depsMap);
}

return depsMap;
Expand Down
10 changes: 5 additions & 5 deletions src/propagation/propagation_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ class PropagationVisitor : public clang::ConstStmtVisitor<S> {
// 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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tool_application_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ std::string getExecutablePathFromArgv(const std::string &argv0) {
exePath = argv0;
if (!llvm::sys::path::has_parent_path(exePath)) {
llvm::Optional<std::string> maybeExePath =
llvm::sys::Process::FindInEnvPath("PATH", argv0);
llvm::sys::Process::FindInEnvPath("PATH", argv0);
exePath = maybeExePath.getValueOr("");
}
}
Expand Down

0 comments on commit cb17e41

Please sign in to comment.