MCPcopy Create free account
hub / github.com/Samsung/UTopia / isAggregateDeclInitWOAssignOperator

Method isAggregateDeclInitWOAssignOperator

lib/inputanalysis/DefMapGenerator.cpp:75–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75bool 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
114bool DefMapGenerator::isAssignOperatorRequired(const ASTDefNode &Node) const {
115 return !Node.getAssigned() || isAggregateDeclInitWOAssignOperator(Node);

Callers

nothing calls this directly

Calls 8

getTopMacroCallerLocFunction · 0.85
getFileContentFunction · 0.85
isNullMethod · 0.80
getAssignedMethod · 0.80
sizeMethod · 0.80
getTypeMethod · 0.45
getOffsetMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected