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

Method getFromArgMap

lib/astirmap/DebugInfoMap.cpp:139–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139ASTDefNode *DebugInfoMap::getFromArgMap(const llvm::CallBase &CB,
140 unsigned ArgNo) {
141 if (hasDiffNumArgs(CB))
142 return nullptr;
143
144 auto *ACN = getFromCallMap(CB);
145 if (!ACN)
146 return nullptr;
147
148 const auto *E = ACN->getNode().get<Expr>();
149 if (!E)
150 return nullptr;
151
152 if (util::isImplicitArgument(*const_cast<Expr *>(E), ArgNo) ||
153 util::isDefaultArgument(*const_cast<Expr *>(E), ArgNo))
154 return nullptr;
155
156 ASTDefNode *Result = nullptr;
157 ArgMapKey Key = {const_cast<Expr *>(E), ArgNo};
158 auto ArgMapIter = ArgMap.find(Key);
159 if (ArgMapIter != ArgMap.end())
160 Result = ArgMapIter->second.get();
161 else
162 Result = updateArgMap(*ACN, ArgNo);
163
164 if (!Result)
165 return Result;
166
167 // NOTE: If, argument comes from a macro, (10 in below case)
168 // ex) #define MACRO(a, b, c) call(a, b, c, 10);
169 // The location of 10 same as the MACRO, thus we should ignore this case.
170 // It requires further investigation check this location carefully.
171 auto &Assignee = Result->getAssignee();
172 auto *Assigned = Result->getAssigned();
173 assert(Assigned && "Unexpected Program State");
174
175 auto AssigneeIndex = Assignee.getIndex();
176 auto AssignedIndex = Assigned->getIndex();
177 if (AssigneeIndex.getPath() == AssignedIndex.getPath() &&
178 Assignee.getOffset() == Assigned->getOffset()) {
179 auto &Node = Assignee.getNode();
180 auto *CCE = Node.get<CXXConstructExpr>();
181 if (!CCE)
182 return nullptr;
183 if (CCE->getType().getAsString() != "std::string")
184 return nullptr;
185 }
186 return Result;
187}
188
189ASTDefNode *DebugInfoMap::getFromDefMap(const llvm::Instruction &I) const {
190 try {

Callers

nothing calls this directly

Calls 10

isImplicitArgumentFunction · 0.85
isDefaultArgumentFunction · 0.85
endMethod · 0.80
getAssignedMethod · 0.80
getPathMethod · 0.80
findMethod · 0.45
getMethod · 0.45
getOffsetMethod · 0.45
getAsStringMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected