llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang <details> <summary>Changes</summary> We were previously checking that stencil input ranges were writable. It suffices for them to be readable. -- Full diff: https://github.com/llvm/llvm-project/pull/66480.diff 3 Files Affected: - (modified) clang/include/clang/Tooling/Transformer/SourceCode.h (+4) - (modified) clang/lib/Tooling/Transformer/SourceCode.cpp (+3-3) - (modified) clang/lib/Tooling/Transformer/Stencil.cpp (+3-3) <pre> diff --git a/clang/include/clang/Tooling/Transformer/SourceCode.h b/clang/include/clang/Tooling/Transformer/SourceCode.h index 44a4749db74c96c..01d8ef05e5687e5 100644 --- a/clang/include/clang/Tooling/Transformer/SourceCode.h +++ b/clang/include/clang/Tooling/Transformer/SourceCode.h @@ -91,6 +91,10 @@ StringRef getExtendedText(const T &amp;Node, tok::TokenKind Next, llvm::Error validateEditRange(const CharSourceRange &amp;Range, const SourceManager &amp;SM); +/// Determines whether \p Range is one that can be read from. +llvm::Error validateRange(const CharSourceRange &amp;Range, const SourceManager &amp;SM, + bool AllowSystemHeaders); + /// Attempts to resolve the given range to one that can be edited by a rewrite; /// generally, one that starts and ends within a particular file. If a value is /// returned, it satisfies \c validateEditRange. diff --git a/clang/lib/Tooling/Transformer/SourceCode.cpp b/clang/lib/Tooling/Transformer/SourceCode.cpp index 35edc261ef09670..30009537b5923ce 100644 --- a/clang/lib/Tooling/Transformer/SourceCode.cpp +++ b/clang/lib/Tooling/Transformer/SourceCode.cpp @@ -50,9 +50,9 @@ CharSourceRange clang::tooling::maybeExtendRange(CharSourceRange Range, return CharSourceRange::getTokenRange(Range.getBegin(), Tok.getLocation()); } -static llvm::Error validateRange(const CharSourceRange &amp;Range, - const SourceManager &amp;SM, - bool AllowSystemHeaders) { +llvm::Error clang::tooling::validateRange(const CharSourceRange &amp;Range, + const SourceManager &amp;SM, + bool AllowSystemHeaders) { if (Range.isInvalid()) return llvm::make_error&lt;StringError&gt;(errc::invalid_argument, &quot;Invalid range&quot;); diff --git a/clang/lib/Tooling/Transformer/Stencil.cpp b/clang/lib/Tooling/Transformer/Stencil.cpp index f2c1b6f8520a8cb..0c2037a8ae6c013 100644 --- a/clang/lib/Tooling/Transformer/Stencil.cpp +++ b/clang/lib/Tooling/Transformer/Stencil.cpp @@ -230,7 +230,7 @@ class SelectorStencil : public StencilInterface { // message. If it&#x27;s valid, then something else is the cause and we just // return the generic failure message. if (auto Err = - tooling::validateEditRange(*RawRange, *Match.SourceManager)) + tooling::validateRange(*RawRange, *Match.SourceManager, true)) return handleErrors(std::move(Err), [](std::unique_ptr&lt;StringError&gt; E) { assert(E-&gt;convertToErrorCode() == llvm::make_error_code(errc::invalid_argument) &amp;&amp; @@ -245,8 +245,8 @@ class SelectorStencil : public StencilInterface { &quot;selected range could not be resolved to a valid source range&quot;); } // Validate `Range`, because `makeFileCharRange` accepts some ranges that - // `validateEditRange` rejects. - if (auto Err = tooling::validateEditRange(Range, *Match.SourceManager)) + // `validateRange` rejects. + if (auto Err = tooling::validateRange(Range, *Match.SourceManager, true)) return joinErrors( llvm::createStringError(errc::invalid_argument, &quot;selected range is not valid for editing&quot;), </pre> </details> https://github.com/llvm/llvm-project/pull/66480 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits