Lines Matching full:range

31 StringRef clang::tooling::getText(CharSourceRange Range,
33 return Lexer::getSourceText(Range, Context.getSourceManager(),
37 CharSourceRange clang::tooling::maybeExtendRange(CharSourceRange Range,
40 CharSourceRange R = Lexer::getAsCharRange(Range, Context.getSourceManager(),
43 return Range;
49 return Range;
50 return CharSourceRange::getTokenRange(Range.getBegin(), Tok.getLocation());
53 llvm::Error clang::tooling::validateRange(const CharSourceRange &Range,
56 if (Range.isInvalid())
58 "Invalid range");
60 if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
62 errc::invalid_argument, "Range starts or ends in a macro expansion");
65 if (SM.isInSystemHeader(Range.getBegin()) ||
66 SM.isInSystemHeader(Range.getEnd()))
68 "Range is in system header");
71 std::pair<FileID, unsigned> BeginInfo = SM.getDecomposedLoc(Range.getBegin());
72 std::pair<FileID, unsigned> EndInfo = SM.getDecomposedLoc(Range.getEnd());
75 errc::invalid_argument, "Range begins and ends in different files");
79 "Range's begin is past its end");
84 llvm::Error clang::tooling::validateEditRange(const CharSourceRange &Range,
86 return validateRange(Range, SM, /*AllowSystemHeaders=*/false);
104 // Returns the expansion char-range of `Loc` if `Loc` is a split token. For
117 // A char-range expansion is only used where a token-range would be
126 // If `Range` covers a split token, returns the expansion range, otherwise
127 // returns `Range`.
128 static CharSourceRange getRangeForSplitTokens(CharSourceRange Range,
131 if (Range.isTokenRange()) {
132 auto BeginToken = getExpansionForSplitToken(Range.getBegin(), SM, LangOpts);
133 auto EndToken = getExpansionForSplitToken(Range.getEnd(), SM, LangOpts);
136 BeginToken ? BeginToken->getBegin() : Range.getBegin();
137 // We can't use the expansion location with a token-range, because that
138 // will incorrectly lex the end token, so use a char-range that ends at
142 // Since the end token is not split, the whole range covers the split, so
146 Range.getEnd());
149 return Range;
156 CharSourceRange Range;
158 Range = Lexer::makeFileCharRange(EditRange, SM, LangOpts);
169 Range = CharSourceRange::getCharRange(B, E);
171 return Range;
177 CharSourceRange Range =
179 bool IsInvalid = llvm::errorToBool(validateEditRange(Range, SM));
182 return Range;
188 CharSourceRange Range =
191 llvm::errorToBool(validateRange(Range, SM, /*AllowSystemHeaders=*/true));
194 return Range;
227 // `ExpansionRange` is a character range.
250 // First, lex to the current token (which is the last token of the range that
283 // Lex the next token we want to possibly expand the range with.
308 // Lex the next token we want to possibly expand the range with.
416 CharSourceRange Range = CharSourceRange::getTokenRange(Decl.getSourceRange());
421 if (SM.isBeforeInTranslationUnit(T->getBeginLoc(), Range.getBegin()))
422 Range.setBegin(T->getBeginLoc());
425 if (SM.isBeforeInTranslationUnit(T->getBeginLoc(), Range.getBegin()))
426 Range.setBegin(T->getBeginLoc());
431 Range.setEnd(
433 Range.setTokenRange(false);
447 Range.getBegin()) &&
451 atOrBeforeSeparation(SM, Range.getEnd(), LangOpts)) {
455 Range.setBegin(Comment->getBeginLoc());
460 !SM.isBeforeInTranslationUnit(Attr->getLocation(), Range.getBegin()))
462 Range.setBegin(Attr->getLocation());
468 SM.getBufferData(SM.getFileID(Range.getBegin()), &Invalid);
472 Source.substr(0, SM.getFileOffset(Range.getBegin()));
481 Range.setBegin(Range.getBegin().getLocWithOffset(static_cast<int>(
491 // Range.getEnd() is already fully un-expanded by getEntityEndLoc. But,
492 // Range.getBegin() may be inside an expansion.
493 return Lexer::makeFileCharRange(Range, SM, LangOpts);