-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add struct size into tooltip #12
Conversation
* clang::ASTContext::getTypeInfo() -> getTypeInfoImpl() | ||
*/ | ||
if (cxx->isDependentContext()) { | ||
return (size_t)-1; |
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.
Style issue: avoid C casts: prefer size_t(-1)
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.
On Fri, Jun 13, 2014 at 04:54:26AM -0700, Olivier Goffart wrote:
+{
- const clang::ASTContext &ctx = t->getASTContext();
- const clang::QualType &ty = ctx.getRecordType(t);
- return ctx.getTypeSize(ty);
+}
+size_t getDeclSize(const clang::NamedDecl* decl)
+{
- const clang::CXXRecordDecl *cxx = llvm::dyn_castclang::CXXRecordDecl(decl);
- if (cxx && (cxx = cxx->getDefinition())) {
/**
\* XXX: avoid endless recursion inside
\* clang::ASTContext::getTypeInfo() -> getTypeInfoImpl()
*/
if (cxx->isDependentContext()) {
return (size_t)-1;
Style issue: avoid C casts: prefer
size_t(-1)
I follow the rule, that for POD-types it is okay to use C-style cast.
But no problem, I will fix this.
Thanks.
Reply to this email directly or view it on GitHub:
https://github.com/woboq/woboq_codebrowser/pull/12/files#r13747200
Respectfully
Azat Khuzhin
@@ -531,6 +569,10 @@ void Annotator::registerReference(clang::NamedDecl* decl, clang::SourceRange ran | |||
if (declType == Definition && visibility != Visibility::Local) { | |||
clas += " def"; | |||
} | |||
if (type == Type) { | |||
tags %= " data-size="; |
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.
minor issue: should be on one line:
tags %= " data-size=" % std::to_string(getDeclSize(decl));
Or even better: use llvm::Twine which reduce the number of string allocation.
But the number should be within quotes.
Also please check it is not -1
Thanks for the patch. Maybe it is better to store the size in the |
On Fri, Jun 13, 2014 at 05:07:24AM -0700, Olivier Goffart wrote:
I don't have any objections, I will move it into refs shortly.
Respectfully |
See add-struct-size-v2 branch. |
No description provided.