- 
                Notifications
    You must be signed in to change notification settings 
- Fork 35
Fix: resolve nested attributes of anonymous records in GetDatamembers #321
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
Conversation
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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 24. Check the log or trigger a new build to see more.
| The test fail with  | 
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 16. Check the log or trigger a new build to see more.
        
          
                lib/Interpreter/CppInterOp.cpp
              
                Outdated
          
        
      | if (D->getKind() == clang::Decl::Field && | ||
| dyn_cast<FieldDecl>(D)->isAnonymousStructOrUnion()) { | 
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.
| if (D->getKind() == clang::Decl::Field && | |
| dyn_cast<FieldDecl>(D)->isAnonymousStructOrUnion()) { | |
| if (isa<FieldDecl>(D) && | |
| cast<FieldDecl>(D)->isAnonymousStructOrUnion()) { | 
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 think we should have a proper dyn_cast and isAnonymousStructOrUnion as a nested if...
| 
 Yes, but only for this test file. | 
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.
clang-tidy made some suggestions
| Hi @vgvassilev, Valgrind fails. Should I add if (llvm::sys::RunningOnValgrind())
    GTEST_SKIP() << "XFAIL due to Valgrind report";? It is  | 
        
          
                lib/Interpreter/CppInterOp.cpp
              
                Outdated
          
        
      | continue; | ||
| } | ||
| Decl* D = *(stack_begin.back()); | ||
| if (D->getKind() == clang::Decl::Field) { | 
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.
| if (D->getKind() == clang::Decl::Field) { | 
        
          
                lib/Interpreter/CppInterOp.cpp
              
                Outdated
          
        
      | const clang::RecordDecl* RD = FD->getParent(); | ||
| intptr_t offset = | ||
| C.toCharUnitsFromBits( | ||
| C.getASTRecordLayout(RD).getFieldOffset(FD->getFieldIndex())) | 
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.
| C.getASTRecordLayout(RD).getFieldOffset(FD->getFieldIndex())) | |
| C.getFieldOffset(FD) | 
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.
clang-tidy made some suggestions
        
          
                lib/Interpreter/CppInterOp.cpp
              
                Outdated
          
        
      | if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) { | ||
| if (FD->isAnonymousStructOrUnion()) { | ||
| if (auto* CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>( | ||
| FD->getType()->getAs<RecordType>()->getDecl())) { | 
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.
warning: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage]
                    FD->getType()->getAs<RecordType>()->getDecl())) {
                    ^Additional context
lib/Interpreter/CppInterOp.cpp:1128: Assuming 'D' is a 'CastReturnType'
    if (auto *CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>(D)) {
                      ^lib/Interpreter/CppInterOp.cpp:1128: 'CXXRD' is non-null
    if (auto *CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>(D)) {
              ^lib/Interpreter/CppInterOp.cpp:1128: Taking true branch
    if (auto *CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>(D)) {
    ^lib/Interpreter/CppInterOp.cpp:1134: Loop condition is true. Entering loop body
      while (!stack_begin.empty()) {
      ^lib/Interpreter/CppInterOp.cpp:1135: Taking false branch
        if (stack_begin.back() == stack_end.back()) {
        ^lib/Interpreter/CppInterOp.cpp:1141: Assuming 'D' is a 'CastReturnType'
        if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) {
                       ^lib/Interpreter/CppInterOp.cpp:1141: 'FD' is non-null
        if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) {
                  ^lib/Interpreter/CppInterOp.cpp:1141: Taking true branch
        if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) {
        ^lib/Interpreter/CppInterOp.cpp:1142: Assuming the condition is true
          if (FD->isAnonymousStructOrUnion()) {
              ^lib/Interpreter/CppInterOp.cpp:1142: Taking true branch
          if (FD->isAnonymousStructOrUnion()) {
          ^lib/Interpreter/CppInterOp.cpp:1144: Assuming the object is not a 'const RecordType *'
                    FD->getType()->getAs<RecordType>()->getDecl())) {
                    ^lib/Interpreter/CppInterOp.cpp:1144: Called C++ object pointer is null
                    FD->getType()->getAs<RecordType>()->getDecl())) {
                    ^| 
 Yes, please do. | 
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.
clang-tidy made some suggestions
| if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) { | ||
| const clang::RecordDecl* RD = FD->getParent(); | ||
| intptr_t offset = | ||
| C.toCharUnitsFromBits(C.getFieldOffset(FD)).getQuantity(); | 
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.
warning: narrowing conversion from 'uint64_t' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [cppcoreguidelines-narrowing-conversions]
          C.toCharUnitsFromBits(C.getFieldOffset(FD)).getQuantity();
                                ^| break; | ||
| } | ||
| } | ||
| offset += C.toCharUnitsFromBits(C.getFieldOffset(FD)).getQuantity(); | 
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.
warning: narrowing conversion from 'uint64_t' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [cppcoreguidelines-narrowing-conversions]
        offset += C.toCharUnitsFromBits(C.getFieldOffset(FD)).getQuantity();
                                        ^| Codecov ReportAll modified and coverable lines are covered by tests ✅ 
 Additional details and impacted files@@            Coverage Diff             @@
##             main     #321      +/-   ##
==========================================
+ Coverage   73.44%   73.69%   +0.25%     
==========================================
  Files           8        8              
  Lines        2990     3019      +29     
==========================================
+ Hits         2196     2225      +29     
  Misses        794      794              
 
 | 
Co-authored-by: Vassil Vassilev <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Lgtm!
No description provided.