Skip to content
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

Closed
wants to merge 12 commits into from
Closed

Conversation

azat
Copy link
Contributor

@azat azat commented Jun 12, 2014

No description provided.

* clang::ASTContext::getTypeInfo() -> getTypeInfoImpl()
*/
if (cxx->isDependentContext()) {
return (size_t)-1;
Copy link
Contributor

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)

Copy link
Contributor Author

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=";
Copy link
Contributor

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

@ogoffart
Copy link
Contributor

Thanks for the patch.

Maybe it is better to store the size in the refs file instead of everywhere in each .html. Don't you think?

@azat
Copy link
Contributor Author

azat commented Jun 13, 2014

On Fri, Jun 13, 2014 at 05:07:24AM -0700, Olivier Goffart wrote:

Thanks for the patch.

Maybe it is better to store the size in the refs file instead of everywhere in each .html. Don't you think?

I don't have any objections, I will move it into refs shortly.
Thanks for comments.


Reply to this email directly or view it on GitHub:
#12 (comment)

Respectfully
Azat Khuzhin

@azat
Copy link
Contributor Author

azat commented Jun 13, 2014

See add-struct-size-v2 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants