| 73 | } |
| 74 | |
| 75 | bool DefMapGenerator::isAggregateDeclInitWOAssignOperator( |
| 76 | const ASTDefNode &Node) const { |
| 77 | const auto &Assignee = Node.getAssignee(); |
| 78 | if (!Node.getAssignee().getNode().get<VarDecl>()) |
| 79 | return false; |
| 80 | |
| 81 | auto T = Assignee.getType(); |
| 82 | if (T.isNull() || !T->isAggregateType()) |
| 83 | return false; |
| 84 | |
| 85 | const auto *Assigned = Node.getAssigned(); |
| 86 | if (!Assigned) |
| 87 | return false; |
| 88 | |
| 89 | auto &SrcManager = |
| 90 | const_cast<ASTNode *>(&Assignee)->getASTUnit().getSourceManager(); |
| 91 | auto AssigneeLoc = util::getTopMacroCallerLoc(Assignee.getNode(), SrcManager); |
| 92 | auto AssignedLoc = util::getTopMacroCallerLoc( |
| 93 | Assigned->getNode(), |
| 94 | const_cast<ASTNode *>(Assigned)->getASTUnit().getSourceManager()); |
| 95 | |
| 96 | auto FileID = SrcManager.getFileID(AssigneeLoc); |
| 97 | if (FileID != SrcManager.getFileID(AssignedLoc)) |
| 98 | return false; |
| 99 | |
| 100 | auto SOffset = Assignee.getOffset(); |
| 101 | auto EOffset = Assigned->getOffset(); |
| 102 | if (SOffset >= EOffset) |
| 103 | return false; |
| 104 | |
| 105 | auto Length = EOffset - SOffset; |
| 106 | auto Content = util::getFileContent(FileID, SrcManager); |
| 107 | if (Content.size() < SOffset + Length) |
| 108 | return false; |
| 109 | |
| 110 | auto Code = std::string(Content.substr(SOffset, Length)); |
| 111 | return Code.find("=") == std::string::npos; |
| 112 | } |
| 113 | |
| 114 | bool DefMapGenerator::isAssignOperatorRequired(const ASTDefNode &Node) const { |
| 115 | return !Node.getAssigned() || isAggregateDeclInitWOAssignOperator(Node); |
nothing calls this directly
no test coverage detected