[clang-tools-extra] [clang-doc] Display enum type along with enum name in HTML view (PR #181347)
Samrudh Nelli via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 20 03:11:48 PST 2026
================
@@ -1207,8 +1207,8 @@ emitInfo(const EnumDecl *D, const FullComment *FC, Location Loc,
return {};
Enum.Scoped = D->isScoped();
- if (D->isFixed()) {
- auto Name = D->getIntegerType().getAsString();
+ if (const TypeSourceInfo *Info = D->getIntegerTypeSourceInfo()) {
+ auto Name = Info->getType().getAsString();
Enum.BaseType = TypeInfo(Name, Name);
----------------
SamrudhNelli wrote:
I had a look inside `AST/TypePrinter.cpp` and the following function is called eventually by `getAsString()`.
```
void QualType::getAsStringInternal(const Type *ty, Qualifiers qs,
std::string &buffer,
const PrintingPolicy &policy) {
SmallString<256> Buf;
llvm::raw_svector_ostream StrOS(Buf);
TypePrinter(policy).print(ty, qs, StrOS, buffer);
std::string str = std::string(StrOS.str());
buffer.swap(str);
}
```
Since, this uses `TypePrinter`, I think we do need a string, we can't pass a StringRef, as the temporary string could be out of scope just like you mentioned.
I would love to hear your ideas on implementing the StringRef function, do we need a custom TypePrinter() for that?
https://github.com/llvm/llvm-project/pull/181347
More information about the cfe-commits
mailing list