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

Method setFullLocationFromFunctionDecl

lib/utils/Location.cpp:62–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62void Location::setFullLocationFromFunctionDecl(const clang::FunctionDecl *FD) {
63 auto &Ctx = FD->getASTContext();
64 auto &SM = Ctx.getSourceManager();
65 auto BeginLoc = SM.getExpansionLoc(FD->getBeginLoc());
66 SourceLocation EndLoc;
67 if (!FD->getBody())
68 EndLoc = FD->getEndLoc();
69 else
70 EndLoc = FD->getBody()->getEndLoc();
71 EndLoc = SM.getExpansionLoc(EndLoc);
72 auto BeginOffset = SM.getDecomposedLoc(BeginLoc).second;
73 auto EndOffset = SM.getDecomposedLoc(EndLoc).second;
74 assert(BeginOffset <= EndOffset && "Invalid location for main function");
75
76 m_offset = BeginOffset;
77 m_length = (EndOffset - BeginOffset +
78 Lexer::MeasureTokenLength(EndLoc, SM, LangOptions()));
79 m_line = SM.getPresumedLoc(BeginLoc).getLine();
80 m_filePath = util::getNormalizedPath(SM.getFilename(BeginLoc).str());
81}
82
83// // Ref : lib/Tooling/Core/Replacement.cpp#L122
84unsigned Location::getRangeSize(const clang::SourceManager &Sources,

Callers 1

SourceAnalyzerImplMethod · 0.80

Calls 4

getNormalizedPathFunction · 0.85
getBeginLocMethod · 0.80
getEndLocMethod · 0.80
getLineMethod · 0.45

Tested by

no test coverage detected