Skip to content

Commit

Permalink
Avoid adding overloads for the same thing when there's no comment on …
Browse files Browse the repository at this point in the history
…it and its visited repeatedly

This avoids the UDLs in macros from appearing N times.
  • Loading branch information
danakj committed Aug 13, 2023
1 parent 7244011 commit 34b7e46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions subdoc/lib/visit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,14 @@ class Visitor : public clang::RecursiveASTVisitor<Visitor> {
if (it == db_map.end()) {
db_map.emplace(key, std::move(db_element));
add_overload = false;
} else if (!it->second.has_comment()) {
} else if (!it->second.has_comment() && db_element.has_comment()) {
// Steal the comment.
sus::mem::swap(db_map.at(key).comment, db_element.comment);
} else if (!db_element.has_comment()) {
} else if (!db_element.has_comment() & it->second.has_comment()) {
// Leave the existing comment in place.
} else if (db_element.comment.begin_loc == it->second.comment.begin_loc) {
// We already visited this thing, from another translation unit.
add_overload = false;
} else {
auto& ast_cx = decl->getASTContext();
const FunctionElement& old_element = it->second;
Expand Down
2 changes: 1 addition & 1 deletion tools/run_subdoc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ out\subdoc\subdoc -p out --out docs ^
--copy-file sus/index.html ^
--project-md sus/project.md ^
--project-name Subspace ^
subspace/sus/containers/vec_unit
subspace/sus/num/i32 subspace/sus/num/i64

0 comments on commit 34b7e46

Please sign in to comment.