-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[clang-doc] refactor JSON for better Mustache compatibility #149588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,10 @@ struct Reference { | |
Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName, | ||
StringRef Path = StringRef()) | ||
: USR(USR), Name(Name), QualName(QualName), RefType(IT), Path(Path) {} | ||
Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName, | ||
StringRef Path, SmallString<16> DocumentationFileName) | ||
: USR(USR), Name(Name), QualName(QualName), RefType(IT), Path(Path), | ||
DocumentationFileName(DocumentationFileName) {} | ||
|
||
bool operator==(const Reference &Other) const { | ||
return std::tie(USR, Name, QualName, RefType) == | ||
|
@@ -155,6 +159,7 @@ struct Reference { | |
// Path of directory where the clang-doc generated file will be saved | ||
// (possibly unresolved) | ||
llvm::SmallString<128> Path; | ||
SmallString<16> DocumentationFileName; | ||
}; | ||
|
||
// Holds the children of a record or namespace. | ||
|
@@ -331,6 +336,11 @@ struct Info { | |
llvm::SmallString<128> Path; // Path of directory where the clang-doc | ||
// generated file will be saved | ||
|
||
// The name used for the file that this info is documented in. | ||
// In the JSON generator, infos are documented in files with mangled names. | ||
// Thus, we keep track of the physical filename for linking purposes. | ||
SmallString<16> DocumentationFileName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why 16? I'm guessing no mangled name will be only 16 chars (unless its C and not C++). For now this is fine, but we should try and revisit our string usage and try to make it consistent. Some day, I'd like to start interning strings as well, and then just dropping them w/ an arena, ala |
||
|
||
void mergeBase(Info &&I); | ||
bool mergeable(const Info &Other); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
enumerate()
will make this nicer, but its available if you do. It's not the most widely used pattern, but I'd hate for you not to know its around (like I did for a couple years).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I saw that Peter had used it previously for the same function but I really didn't see the benefit over this if I couldn't use a range-based loop naturally. I think the old enumeration would actually serialize
"End" = false
everywhere else.