diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Format/TokenAnalyzer.h')
-rw-r--r-- | contrib/llvm-project/clang/lib/Format/TokenAnalyzer.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/contrib/llvm-project/clang/lib/Format/TokenAnalyzer.h b/contrib/llvm-project/clang/lib/Format/TokenAnalyzer.h index 5ce44a0f3ea7..4086dab1c94c 100644 --- a/contrib/llvm-project/clang/lib/Format/TokenAnalyzer.h +++ b/contrib/llvm-project/clang/lib/Format/TokenAnalyzer.h @@ -29,6 +29,7 @@ #include "clang/Format/Format.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Debug.h" +#include <memory> namespace clang { namespace format { @@ -40,13 +41,12 @@ public: // that the next lines of \p Code should start at \p NextStartColumn, and // that \p Code should end at \p LastStartColumn if it ends in newline. // See also the documentation of clang::format::internal::reformat. - Environment(StringRef Code, StringRef FileName, - ArrayRef<tooling::Range> Ranges, unsigned FirstStartColumn = 0, + Environment(StringRef Code, StringRef FileName, unsigned FirstStartColumn = 0, unsigned NextStartColumn = 0, unsigned LastStartColumn = 0); FileID getFileID() const { return ID; } - const SourceManager &getSourceManager() const { return SM; } + SourceManager &getSourceManager() const { return SM; } ArrayRef<CharSourceRange> getCharRanges() const { return CharRanges; } @@ -62,6 +62,14 @@ public: // environment should end if it ends in a newline. unsigned getLastStartColumn() const { return LastStartColumn; } + // Returns nullptr and prints a diagnostic to stderr if the environment + // can't be created. + static std::unique_ptr<Environment> make(StringRef Code, StringRef FileName, + ArrayRef<tooling::Range> Ranges, + unsigned FirstStartColumn = 0, + unsigned NextStartColumn = 0, + unsigned LastStartColumn = 0); + private: // This is only set if constructed from string. std::unique_ptr<SourceManagerForFile> VirtualSM; @@ -81,7 +89,8 @@ class TokenAnalyzer : public UnwrappedLineConsumer { public: TokenAnalyzer(const Environment &Env, const FormatStyle &Style); - std::pair<tooling::Replacements, unsigned> process(); + std::pair<tooling::Replacements, unsigned> + process(bool SkipAnnotation = false); protected: virtual std::pair<tooling::Replacements, unsigned> |