MCPcopy Create free account
hub / github.com/beefytech/Beef / Visit

Method Visit

IDEHelper/Clang/ClangHelper.cpp:267–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265 }
266
267 CXChildVisitResult Visit(CXCursor cursor, CXCursor parent)
268 {
269 String& outString = *gTLStrReturn.Get();
270
271 CXSourceLocation sourceLoc = clang_getCursorLocation(cursor);
272 CXFile file;
273 uint32 line;
274 uint32 column;
275 uint32 offset;
276 clang_getFileLocation(sourceLoc, &file, &line, &column, &offset);
277 if ((mWantFile != NULL) && (file != mWantFile))
278 return CXChildVisit_Continue;
279 //if (!clang_Location_isFromMainFile(sourceLoc))
280 //return CXChildVisit_Recurse;
281
282 auto cursorKind = clang_getCursorKind(cursor);
283 if (cursorKind == CXCursor_MacroExpansion)
284 return CXChildVisit_Continue;
285
286 String defString;
287
288 if ((cursorKind == CXCursor_FunctionDecl) || (cursorKind == CXCursor_CXXMethod) || (cursorKind == CXCursor_Constructor) ||
289 (cursorKind == CXCursor_Destructor) || (cursorKind == CXCursor_ConversionFunction) || (cursorKind == CXCursor_FunctionTemplate))
290 {
291 if (!mAllowEmptyMethods)
292 {
293 bool hasBody = false;
294 clang_visitChildren(cursor, HasBodyVisitProc, &hasBody);
295 if (!hasBody)
296 return CXChildVisit_Continue;
297 }
298
299 String methodDefString;
300 methodDefString += ToString(clang_getCursorSpelling(cursor));
301
302 CXType methodType = clang_getCursorType(cursor);
303
304 methodDefString += "(";
305 int numArgs = clang_Cursor_getNumArguments(cursor);
306 for (int argIdx = 0; argIdx < numArgs; argIdx++)
307 {
308 if (argIdx > 0)
309 methodDefString += ", ";
310 CXCursor argCursor = clang_Cursor_getArgument(cursor, argIdx);
311 CXType paramType = clang_getCursorType(argCursor);
312 methodDefString += ToString(clang_getTypeSpelling(paramType));
313
314 String argName = ToString(clang_getCursorSpelling(argCursor));
315 if (!argName.empty())
316 {
317 char lastC = methodDefString[methodDefString.length() - 1];
318 if ((lastC != '*') && (lastC != ' '))
319 methodDefString += " ";
320 methodDefString += argName;
321 }
322 }
323
324 if (clang_isFunctionTypeVariadic(methodType))

Callers

nothing calls this directly

Calls 5

ToStringFunction · 0.70
GetMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected