Skip to content

Commit 36c81f6

Browse files
committed
Fix docstring and comments
Signed-off-by: Ti Liang <tliang54@bloomberg.net>
1 parent 5030e69 commit 36c81f6

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

include/clangmetatool/include_graph_dependencies.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct IncludeGraphDependencies {
3030
*/
3131
static std::set<clangmetatool::types::FileUID>
3232
collectAllIncludes(const clangmetatool::collectors::IncludeGraphData* data,
33-
const clangmetatool::types::FileUID &fileFUID);
33+
const clangmetatool::types::FileUID &fileUID);
3434

3535

3636
/**
@@ -46,38 +46,41 @@ struct IncludeGraphDependencies {
4646
*/
4747
static std::set<clangmetatool::types::FileUID>
4848
liveDependencies(const clangmetatool::collectors::IncludeGraphData *data,
49-
const clangmetatool::types::FileUID &fileFUID);
49+
const clangmetatool::types::FileUID &fileUID);
5050

5151
/*
5252
* A data structure for include graph weak dependencies analysis
5353
* for a specific source file
5454
*
55-
* Key: all headers the file directly depends on
55+
* Key: all headers the file indirectly depends on
5656
* Value: a set of direct included headers that could allow the file to
5757
* access the key header
5858
*
5959
* Example:
60+
* \code{.unparsed}
6061
* { "def1.h": {"a.h", "b.h"},
6162
* "def2.h": {"a.h", "c.h"} }
63+
* \endcode
6264
*
6365
* So that given the example data above it means current analyzing file:
64-
* - depends on definitions from "def1.h", "def2.h" directly
65-
* - includes "a.h", "b.h", "c.h"
66-
* - can access "def1.h" by "a.h" and "b.h"
67-
* - can access "def2.h" by "a.h" and "c.h"
66+
* - depends on definitions from \c "def1.h", \c "def2.h"
67+
* - includes \c "a.h", \c "b.h", \c "c.h"
68+
* - can access \c "def1.h" by \c "a.h" and \c "b.h"
69+
* - can access \c "def2.h" by \c "a.h" and \c "c.h"
6870
*/
6971
typedef std::map<clangmetatool::types::FileUID,
7072
std::set<clangmetatool::types::FileUID>> DirectDependenciesMap;
7173

7274
/**
73-
* Get the 'live' weak dependencies of a header within the given include graph.
74-
* This will return data structure(called DirectDependenciesMap) shows weak dependencies of headers
75+
* Get the live weak dependencies of a header within the given include graph.
7576
*
76-
* (See docstring of DirectDependenciesMap typedef above for more details of the data structure)
77+
* Unlike \c "liveDependencies" which returns the first header that leads to a header
78+
* with a needed declaration, the output of this function includes all direct includes
79+
* that have a path to a header with a needed declaration.
7780
*/
7881
static DirectDependenciesMap
7982
liveWeakDependencies(const clangmetatool::collectors::IncludeGraphData *data,
80-
const clangmetatool::types::FileUID &fileFUID);
83+
const clangmetatool::types::FileUID &fileUID);
8184

8285
}; // struct IncludeGraphDependencies
8386
} // namespace clangmetatool

src/include_graph_dependencies.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ bool IncludeGraphDependencies::decrementUsageRefCount(
9393
std::set<clangmetatool::types::FileUID>
9494
IncludeGraphDependencies::collectAllIncludes(
9595
const clangmetatool::collectors::IncludeGraphData* data,
96-
const types::FileUID &fileFUID)
96+
const types::FileUID &fileUID)
9797
{
9898
types::FileGraph::const_iterator rangeBegin, rangeEnd;
99-
std::tie(rangeBegin, rangeEnd) = edgeRangeStartsWith(data, fileFUID);
99+
std::tie(rangeBegin, rangeEnd) = edgeRangeStartsWith(data, fileUID);
100100

101101
std::set<clangmetatool::types::FileUID> visitedNodes;
102102
std::queue<clangmetatool::types::FileUID> toVisit;
103-
toVisit.push(fileFUID);
103+
toVisit.push(fileUID);
104104
while (!toVisit.empty()) {
105105
auto currentFUID = toVisit.front();
106106
toVisit.pop();
@@ -120,18 +120,18 @@ IncludeGraphDependencies::collectAllIncludes(
120120

121121
std::set<types::FileUID> IncludeGraphDependencies::liveDependencies(
122122
const collectors::IncludeGraphData *data,
123-
const clangmetatool::types::FileUID &fileFUID) {
123+
const clangmetatool::types::FileUID &fileUID) {
124124
std::set<types::FileUID> dependencies;
125125
std::set<types::FileGraphEdge> visitedEdges;
126126
std::set<types::FileUID> visitedNodes;
127127

128128
types::FileGraph::const_iterator rangeBegin, rangeEnd;
129-
std::tie(rangeBegin, rangeEnd) = edgeRangeStartsWith(data, fileFUID);
129+
std::tie(rangeBegin, rangeEnd) = edgeRangeStartsWith(data, fileUID);
130130

131131
for (auto it = rangeBegin; it != rangeEnd; ++it) {
132-
assert(it->first == fileFUID);
132+
assert(it->first == fileUID);
133133
auto &dependency = it->second;
134-
if (isRequired(data, fileFUID, dependency, visitedEdges, visitedNodes)) {
134+
if (isRequired(data, fileUID, dependency, visitedEdges, visitedNodes)) {
135135
dependencies.insert(dependency);
136136
}
137137
}
@@ -191,16 +191,16 @@ void traverseFor(const types::FileUID &forNode, const types::FileUID &rootNode,
191191
IncludeGraphDependencies::DirectDependenciesMap
192192
IncludeGraphDependencies::liveWeakDependencies(
193193
const clangmetatool::collectors::IncludeGraphData *data,
194-
const clangmetatool::types::FileUID &fileFUID){
194+
const clangmetatool::types::FileUID &fileUID){
195195
IncludeGraphDependencies::DirectDependenciesMap depsMap;
196196

197197
types::FileGraph::const_iterator rangeBegin, rangeEnd;
198-
std::tie(rangeBegin, rangeEnd) = edgeRangeStartsWith(data, fileFUID);
198+
std::tie(rangeBegin, rangeEnd) = edgeRangeStartsWith(data, fileUID);
199199

200200
for (auto it = rangeBegin; it != rangeEnd; ++it) {
201-
assert(it->first == fileFUID);
201+
assert(it->first == fileUID);
202202
std::set<types::FileUID> knownNodes;
203-
traverseFor(fileFUID, it->second, data, knownNodes, depsMap);
203+
traverseFor(fileUID, it->second, data, knownNodes, depsMap);
204204
}
205205

206206
return depsMap;

0 commit comments

Comments
 (0)