| 60 | } |
| 61 | |
| 62 | void 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 |
| 84 | unsigned Location::getRangeSize(const clang::SourceManager &Sources, |
no test coverage detected