[clang-format][NFC] Remove redundnat llvm::, clang::, etc.
This commit is contained in:
parent
560c2fd3d4
commit
1c58208d89
@ -5239,7 +5239,7 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
|
||||
/// Returns the replacements corresponding to applying and formatting
|
||||
/// \p Replaces on success; otheriwse, return an llvm::Error carrying
|
||||
/// llvm::StringError.
|
||||
llvm::Expected<tooling::Replacements>
|
||||
Expected<tooling::Replacements>
|
||||
formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
|
||||
const FormatStyle &Style);
|
||||
|
||||
@ -5256,7 +5256,7 @@ formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
|
||||
/// The include manipulation is done via ``tooling::HeaderInclude``, see its
|
||||
/// documentation for more details on how include insertion points are found and
|
||||
/// what edits are produced.
|
||||
llvm::Expected<tooling::Replacements>
|
||||
Expected<tooling::Replacements>
|
||||
cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
|
||||
const FormatStyle &Style);
|
||||
|
||||
@ -5381,11 +5381,10 @@ extern const char *DefaultFallbackStyle;
|
||||
/// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
|
||||
/// "file" and no file is found, returns ``FallbackStyle``. If no style could be
|
||||
/// determined, returns an Error.
|
||||
llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
|
||||
StringRef FallbackStyle,
|
||||
StringRef Code = "",
|
||||
llvm::vfs::FileSystem *FS = nullptr,
|
||||
bool AllowUnknownOptions = false);
|
||||
Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
|
||||
StringRef FallbackStyle, StringRef Code = "",
|
||||
llvm::vfs::FileSystem *FS = nullptr,
|
||||
bool AllowUnknownOptions = false);
|
||||
|
||||
// Guesses the language from the ``FileName`` and ``Code`` to be formatted.
|
||||
// Defaults to FormatStyle::LK_Cpp.
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
using clang::format::FormatStyle;
|
||||
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::RawStringFormat)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(FormatStyle::RawStringFormat)
|
||||
|
||||
namespace llvm {
|
||||
namespace yaml {
|
||||
@ -1235,7 +1235,7 @@ std::error_code make_error_code(ParseError e) {
|
||||
return std::error_code(static_cast<int>(e), getParseCategory());
|
||||
}
|
||||
|
||||
inline llvm::Error make_string_error(const llvm::Twine &Message) {
|
||||
inline llvm::Error make_string_error(const Twine &Message) {
|
||||
return llvm::make_error<llvm::StringError>(Message,
|
||||
llvm::inconvertibleErrorCode());
|
||||
}
|
||||
@ -2361,7 +2361,7 @@ private:
|
||||
// FIXME: handle error. For now, print error message and skip the
|
||||
// replacement for release version.
|
||||
if (Err) {
|
||||
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
|
||||
llvm::errs() << toString(std::move(Err)) << "\n";
|
||||
assert(false);
|
||||
}
|
||||
};
|
||||
@ -2802,7 +2802,7 @@ private:
|
||||
// FIXME: better error handling. for now just print error message and skip
|
||||
// for the release version.
|
||||
if (Err) {
|
||||
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
|
||||
llvm::errs() << toString(std::move(Err)) << "\n";
|
||||
assert(false && "Fixes must not conflict!");
|
||||
}
|
||||
Idx = End + 1;
|
||||
@ -3074,7 +3074,7 @@ static void sortCppIncludes(const FormatStyle &Style,
|
||||
llvm::to_vector<16>(llvm::seq<unsigned>(0, Includes.size()));
|
||||
|
||||
if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive) {
|
||||
llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
|
||||
stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
|
||||
const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
|
||||
const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
|
||||
return std::tie(Includes[LHSI].Priority, LHSFilenameLower,
|
||||
@ -3083,7 +3083,7 @@ static void sortCppIncludes(const FormatStyle &Style,
|
||||
Includes[RHSI].Filename);
|
||||
});
|
||||
} else {
|
||||
llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
|
||||
stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
|
||||
return std::tie(Includes[LHSI].Priority, Includes[LHSI].Filename) <
|
||||
std::tie(Includes[RHSI].Priority, Includes[RHSI].Filename);
|
||||
});
|
||||
@ -3115,7 +3115,7 @@ static void sortCppIncludes(const FormatStyle &Style,
|
||||
// enough as additional newlines might be added or removed across #include
|
||||
// blocks. This we handle below by generating the updated #include blocks and
|
||||
// comparing it to the original.
|
||||
if (Indices.size() == Includes.size() && llvm::is_sorted(Indices) &&
|
||||
if (Indices.size() == Includes.size() && is_sorted(Indices) &&
|
||||
Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve) {
|
||||
return;
|
||||
}
|
||||
@ -3154,7 +3154,7 @@ static void sortCppIncludes(const FormatStyle &Style,
|
||||
// FIXME: better error handling. For now, just skip the replacement for the
|
||||
// release version.
|
||||
if (Err) {
|
||||
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
|
||||
llvm::errs() << toString(std::move(Err)) << "\n";
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
@ -3307,7 +3307,7 @@ static void sortJavaImports(const FormatStyle &Style,
|
||||
|
||||
bool StaticImportAfterNormalImport =
|
||||
Style.SortJavaStaticImport == FormatStyle::SJSIO_After;
|
||||
llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
|
||||
sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
|
||||
// Negating IsStatic to push static imports above non-static imports.
|
||||
return std::make_tuple(!Imports[LHSI].IsStatic ^
|
||||
StaticImportAfterNormalImport,
|
||||
@ -3357,7 +3357,7 @@ static void sortJavaImports(const FormatStyle &Style,
|
||||
// FIXME: better error handling. For now, just skip the replacement for the
|
||||
// release version.
|
||||
if (Err) {
|
||||
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
|
||||
llvm::errs() << toString(std::move(Err)) << "\n";
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
@ -3451,7 +3451,7 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static llvm::Expected<tooling::Replacements>
|
||||
static Expected<tooling::Replacements>
|
||||
processReplacements(T ProcessFunc, StringRef Code,
|
||||
const tooling::Replacements &Replaces,
|
||||
const FormatStyle &Style) {
|
||||
@ -3470,7 +3470,7 @@ processReplacements(T ProcessFunc, StringRef Code,
|
||||
return Replaces.merge(FormatReplaces);
|
||||
}
|
||||
|
||||
llvm::Expected<tooling::Replacements>
|
||||
Expected<tooling::Replacements>
|
||||
formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
|
||||
const FormatStyle &Style) {
|
||||
// We need to use lambda function here since there are two versions of
|
||||
@ -3515,13 +3515,13 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
|
||||
return Replaces;
|
||||
|
||||
tooling::Replacements HeaderInsertions;
|
||||
std::set<llvm::StringRef> HeadersToDelete;
|
||||
std::set<StringRef> HeadersToDelete;
|
||||
tooling::Replacements Result;
|
||||
for (const auto &R : Replaces) {
|
||||
if (isHeaderInsertion(R)) {
|
||||
// Replacements from \p Replaces must be conflict-free already, so we can
|
||||
// simply consume the error.
|
||||
llvm::consumeError(HeaderInsertions.add(R));
|
||||
consumeError(HeaderInsertions.add(R));
|
||||
} else if (isHeaderDeletion(R)) {
|
||||
HeadersToDelete.insert(R.getReplacementText());
|
||||
} else if (R.getOffset() == UINT_MAX) {
|
||||
@ -3529,7 +3529,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
|
||||
"not supported! "
|
||||
<< R.getReplacementText() << "\n";
|
||||
} else {
|
||||
llvm::consumeError(Result.add(R));
|
||||
consumeError(Result.add(R));
|
||||
}
|
||||
}
|
||||
if (HeaderInsertions.empty() && HeadersToDelete.empty())
|
||||
@ -3546,13 +3546,12 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
|
||||
if (Err) {
|
||||
// Ignore the deletion on conflict.
|
||||
llvm::errs() << "Failed to add header deletion replacement for "
|
||||
<< Header << ": " << llvm::toString(std::move(Err))
|
||||
<< "\n";
|
||||
<< Header << ": " << toString(std::move(Err)) << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
llvm::SmallVector<StringRef, 4> Matches;
|
||||
SmallVector<StringRef, 4> Matches;
|
||||
for (const auto &R : HeaderInsertions) {
|
||||
auto IncludeDirective = R.getReplacementText();
|
||||
bool Matched =
|
||||
@ -3567,7 +3566,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
|
||||
if (Replace) {
|
||||
auto Err = Result.add(*Replace);
|
||||
if (Err) {
|
||||
llvm::consumeError(std::move(Err));
|
||||
consumeError(std::move(Err));
|
||||
unsigned NewOffset =
|
||||
Result.getShiftedCodePosition(Replace->getOffset());
|
||||
auto Shifted = tooling::Replacement(FileName, NewOffset, 0,
|
||||
@ -3581,7 +3580,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
llvm::Expected<tooling::Replacements>
|
||||
Expected<tooling::Replacements>
|
||||
cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
|
||||
const FormatStyle &Style) {
|
||||
// We need to use lambda function here since there are two versions of
|
||||
@ -3774,7 +3773,7 @@ reformat(const FormatStyle &Style, StringRef Code,
|
||||
auto Err = NonNoOpFixes.add(Fix);
|
||||
if (Err) {
|
||||
llvm::errs() << "Error adding replacements : "
|
||||
<< llvm::toString(std::move(Err)) << "\n";
|
||||
<< toString(std::move(Err)) << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3956,17 +3955,16 @@ loadAndParseConfigFile(StringRef ConfigFile, llvm::vfs::FileSystem *FS,
|
||||
return Text;
|
||||
}
|
||||
|
||||
llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
|
||||
StringRef FallbackStyleName,
|
||||
StringRef Code, llvm::vfs::FileSystem *FS,
|
||||
bool AllowUnknownOptions) {
|
||||
Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
|
||||
StringRef FallbackStyleName, StringRef Code,
|
||||
llvm::vfs::FileSystem *FS,
|
||||
bool AllowUnknownOptions) {
|
||||
FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code));
|
||||
FormatStyle FallbackStyle = getNoStyle();
|
||||
if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle))
|
||||
return make_string_error("Invalid fallback style: " + FallbackStyleName);
|
||||
|
||||
llvm::SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 1>
|
||||
ChildFormatTextToApply;
|
||||
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 1> ChildFormatTextToApply;
|
||||
|
||||
if (StyleName.starts_with("{")) {
|
||||
// Parse YAML/JSON style from the command line.
|
||||
@ -4041,7 +4039,7 @@ llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
|
||||
};
|
||||
|
||||
// Look for .clang-format/_clang-format file in the file's parent directories.
|
||||
llvm::SmallVector<std::string, 2> FilesToLookFor;
|
||||
SmallVector<std::string, 2> FilesToLookFor;
|
||||
FilesToLookFor.push_back(".clang-format");
|
||||
FilesToLookFor.push_back("_clang-format");
|
||||
|
||||
|
@ -173,7 +173,7 @@ private:
|
||||
return Next;
|
||||
}
|
||||
|
||||
void dbgToken(int Position, llvm::StringRef Indent = "") {
|
||||
void dbgToken(int Position, StringRef Indent = "") {
|
||||
FormatToken *Tok = Tokens[Position];
|
||||
llvm::dbgs() << Indent << "[" << Position
|
||||
<< "] Token: " << Tok->Tok.getName() << " / " << Tok->TokenText
|
||||
|
@ -119,7 +119,7 @@ private:
|
||||
};
|
||||
|
||||
MacroExpander::MacroExpander(
|
||||
const std::vector<std::string> &Macros, clang::SourceManager &SourceMgr,
|
||||
const std::vector<std::string> &Macros, SourceManager &SourceMgr,
|
||||
const FormatStyle &Style,
|
||||
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
|
||||
IdentifierTable &IdentTable)
|
||||
@ -134,7 +134,7 @@ MacroExpander::~MacroExpander() = default;
|
||||
void MacroExpander::parseDefinition(const std::string &Macro) {
|
||||
Buffers.push_back(
|
||||
llvm::MemoryBuffer::getMemBufferCopy(Macro, "<scratch space>"));
|
||||
clang::FileID FID = SourceMgr.createFileID(Buffers.back()->getMemBufferRef());
|
||||
FileID FID = SourceMgr.createFileID(Buffers.back()->getMemBufferRef());
|
||||
FormatTokenLexer Lex(SourceMgr, FID, 0, Style, encoding::Encoding_UTF8,
|
||||
Allocator, IdentTable);
|
||||
const auto Tokens = Lex.lex();
|
||||
@ -150,20 +150,20 @@ void MacroExpander::parseDefinition(const std::string &Macro) {
|
||||
}
|
||||
}
|
||||
|
||||
bool MacroExpander::defined(llvm::StringRef Name) const {
|
||||
bool MacroExpander::defined(StringRef Name) const {
|
||||
return FunctionLike.contains(Name) || ObjectLike.contains(Name);
|
||||
}
|
||||
|
||||
bool MacroExpander::objectLike(llvm::StringRef Name) const {
|
||||
bool MacroExpander::objectLike(StringRef Name) const {
|
||||
return ObjectLike.contains(Name);
|
||||
}
|
||||
|
||||
bool MacroExpander::hasArity(llvm::StringRef Name, unsigned Arity) const {
|
||||
bool MacroExpander::hasArity(StringRef Name, unsigned Arity) const {
|
||||
auto it = FunctionLike.find(Name);
|
||||
return it != FunctionLike.end() && it->second.contains(Arity);
|
||||
}
|
||||
|
||||
llvm::SmallVector<FormatToken *, 8>
|
||||
SmallVector<FormatToken *, 8>
|
||||
MacroExpander::expand(FormatToken *ID,
|
||||
std::optional<ArgsList> OptionalArgs) const {
|
||||
if (OptionalArgs)
|
||||
|
@ -79,7 +79,7 @@ struct UnwrappedLineNode;
|
||||
///
|
||||
class MacroExpander {
|
||||
public:
|
||||
using ArgsList = llvm::ArrayRef<llvm::SmallVector<FormatToken *, 8>>;
|
||||
using ArgsList = ArrayRef<SmallVector<FormatToken *, 8>>;
|
||||
|
||||
/// Construct a macro expander from a set of macro definitions.
|
||||
/// Macro definitions must be encoded as UTF-8.
|
||||
@ -95,27 +95,27 @@ public:
|
||||
/// Macros that cannot be parsed will be silently discarded.
|
||||
///
|
||||
MacroExpander(const std::vector<std::string> &Macros,
|
||||
clang::SourceManager &SourceMgr, const FormatStyle &Style,
|
||||
SourceManager &SourceMgr, const FormatStyle &Style,
|
||||
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
|
||||
IdentifierTable &IdentTable);
|
||||
~MacroExpander();
|
||||
|
||||
/// Returns whether any macro \p Name is defined, regardless of overloads.
|
||||
bool defined(llvm::StringRef Name) const;
|
||||
bool defined(StringRef Name) const;
|
||||
|
||||
/// Returns whetherh there is an object-like overload, i.e. where the macro
|
||||
/// has no arguments and should not consume subsequent parentheses.
|
||||
bool objectLike(llvm::StringRef Name) const;
|
||||
bool objectLike(StringRef Name) const;
|
||||
|
||||
/// Returns whether macro \p Name provides an overload with the given arity.
|
||||
bool hasArity(llvm::StringRef Name, unsigned Arity) const;
|
||||
bool hasArity(StringRef Name, unsigned Arity) const;
|
||||
|
||||
/// Returns the expanded stream of format tokens for \p ID, where
|
||||
/// each element in \p Args is a positional argument to the macro call.
|
||||
/// If \p Args is not set, the object-like overload is used.
|
||||
/// If \p Args is set, the overload with the arity equal to \c Args.size() is
|
||||
/// used.
|
||||
llvm::SmallVector<FormatToken *, 8>
|
||||
SmallVector<FormatToken *, 8>
|
||||
expand(FormatToken *ID, std::optional<ArgsList> OptionalArgs) const;
|
||||
|
||||
private:
|
||||
@ -124,7 +124,7 @@ private:
|
||||
|
||||
void parseDefinition(const std::string &Macro);
|
||||
|
||||
clang::SourceManager &SourceMgr;
|
||||
SourceManager &SourceMgr;
|
||||
const FormatStyle &Style;
|
||||
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator;
|
||||
IdentifierTable &IdentTable;
|
||||
@ -260,7 +260,7 @@ private:
|
||||
LineNode() = default;
|
||||
LineNode(FormatToken *Tok) : Tok(Tok) {}
|
||||
FormatToken *Tok = nullptr;
|
||||
llvm::SmallVector<std::unique_ptr<ReconstructedLine>> Children;
|
||||
SmallVector<std::unique_ptr<ReconstructedLine>> Children;
|
||||
};
|
||||
|
||||
// Line in which we build up the resulting unwrapped line.
|
||||
@ -269,7 +269,7 @@ private:
|
||||
struct ReconstructedLine {
|
||||
explicit ReconstructedLine(unsigned Level) : Level(Level) {}
|
||||
unsigned Level;
|
||||
llvm::SmallVector<std::unique_ptr<LineNode>> Tokens;
|
||||
SmallVector<std::unique_ptr<LineNode>> Tokens;
|
||||
};
|
||||
|
||||
// The line in which we collect the resulting reconstructed output.
|
||||
@ -285,7 +285,7 @@ private:
|
||||
|
||||
// Stack of currently "open" lines, where each line's predecessor's last
|
||||
// token is the parent token for that line.
|
||||
llvm::SmallVector<ReconstructedLine *> ActiveReconstructedLines;
|
||||
SmallVector<ReconstructedLine *> ActiveReconstructedLines;
|
||||
|
||||
// Maps from the expanded token to the token that takes its place in the
|
||||
// reconstructed token stream in terms of parent-child relationships.
|
||||
@ -325,7 +325,7 @@ private:
|
||||
};
|
||||
|
||||
// Stack of macro calls for which we're in the middle of an expansion.
|
||||
llvm::SmallVector<Expansion> ActiveExpansions;
|
||||
SmallVector<Expansion> ActiveExpansions;
|
||||
|
||||
struct MacroCallState {
|
||||
MacroCallState(ReconstructedLine *Line, FormatToken *ParentLastToken,
|
||||
@ -368,7 +368,7 @@ private:
|
||||
// |- ,
|
||||
// | \- <argument>
|
||||
// \- )
|
||||
llvm::SmallVector<MacroCallState> MacroCallStructure;
|
||||
SmallVector<MacroCallState> MacroCallStructure;
|
||||
|
||||
// Maps from identifier of the macro call to an unwrapped line containing
|
||||
// all tokens of the macro call.
|
||||
|
@ -34,8 +34,6 @@ namespace format {
|
||||
|
||||
class FormatTokenLexer;
|
||||
|
||||
using clang::format::FormatStyle;
|
||||
|
||||
// An imported symbol in a JavaScript ES6 import/export, possibly aliased.
|
||||
struct JsImportedSymbol {
|
||||
StringRef Symbol;
|
||||
@ -178,7 +176,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
llvm::StringRef PreviousText = getSourceText(InsertionPoint);
|
||||
StringRef PreviousText = getSourceText(InsertionPoint);
|
||||
if (ReferencesText == PreviousText)
|
||||
return {Result, 0};
|
||||
|
||||
@ -209,7 +207,7 @@ public:
|
||||
// FIXME: better error handling. For now, just print error message and skip
|
||||
// the replacement for the release version.
|
||||
if (Err) {
|
||||
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
|
||||
llvm::errs() << toString(std::move(Err)) << "\n";
|
||||
assert(false);
|
||||
}
|
||||
|
||||
@ -276,7 +274,7 @@ private:
|
||||
SortChunk.push_back(*Start);
|
||||
++Start;
|
||||
}
|
||||
llvm::stable_sort(SortChunk);
|
||||
stable_sort(SortChunk);
|
||||
mergeModuleReferences(SortChunk);
|
||||
ReferencesSorted.insert(ReferencesSorted.end(), SortChunk.begin(),
|
||||
SortChunk.end());
|
||||
@ -334,10 +332,10 @@ private:
|
||||
// Sort the individual symbols within the import.
|
||||
// E.g. `import {b, a} from 'x';` -> `import {a, b} from 'x';`
|
||||
SmallVector<JsImportedSymbol, 1> Symbols = Reference.Symbols;
|
||||
llvm::stable_sort(
|
||||
Symbols, [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
|
||||
return LHS.Symbol.compare_insensitive(RHS.Symbol) < 0;
|
||||
});
|
||||
stable_sort(Symbols,
|
||||
[&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
|
||||
return LHS.Symbol.compare_insensitive(RHS.Symbol) < 0;
|
||||
});
|
||||
if (!Reference.SymbolsMerged && Symbols == Reference.Symbols) {
|
||||
// Symbols didn't change, just emit the entire module reference.
|
||||
StringRef ReferenceStmt = getSourceText(Reference.Range);
|
||||
@ -349,7 +347,7 @@ private:
|
||||
// ... then the references in order ...
|
||||
if (!Symbols.empty()) {
|
||||
Buffer += getSourceText(Symbols.front().Range);
|
||||
for (const JsImportedSymbol &Symbol : llvm::drop_begin(Symbols)) {
|
||||
for (const JsImportedSymbol &Symbol : drop_begin(Symbols)) {
|
||||
Buffer += ",";
|
||||
Buffer += getSourceText(Symbol.Range);
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ emitReplacementWarnings(const Replacements &Replaces, StringRef AssumedFileName,
|
||||
|
||||
unsigned Errors = 0;
|
||||
if (WarnFormat && !NoWarnFormat) {
|
||||
llvm::SourceMgr Mgr;
|
||||
SourceMgr Mgr;
|
||||
const char *StartBuf = Code->getBufferStart();
|
||||
|
||||
Mgr.AddNewSourceBuffer(
|
||||
@ -447,11 +447,11 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
llvm::Expected<FormatStyle> FormatStyle =
|
||||
Expected<FormatStyle> FormatStyle =
|
||||
getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
|
||||
nullptr, WNoErrorList.isSet(WNoError::Unknown));
|
||||
if (!FormatStyle) {
|
||||
llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
|
||||
llvm::errs() << toString(FormatStyle.takeError()) << "\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
|
||||
|
||||
auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces);
|
||||
if (!ChangedCode) {
|
||||
llvm::errs() << llvm::toString(ChangedCode.takeError()) << "\n";
|
||||
llvm::errs() << toString(ChangedCode.takeError()) << "\n";
|
||||
return true;
|
||||
}
|
||||
// Get new affected ranges after sorting `#includes`.
|
||||
@ -567,14 +567,12 @@ static int dumpConfig() {
|
||||
}
|
||||
Code = std::move(CodeOrErr.get());
|
||||
}
|
||||
llvm::Expected<clang::format::FormatStyle> FormatStyle =
|
||||
clang::format::getStyle(Style,
|
||||
FileNames.empty() || FileNames[0] == "-"
|
||||
? AssumeFileName
|
||||
: FileNames[0],
|
||||
FallbackStyle, Code ? Code->getBuffer() : "");
|
||||
Expected<clang::format::FormatStyle> FormatStyle = clang::format::getStyle(
|
||||
Style,
|
||||
FileNames.empty() || FileNames[0] == "-" ? AssumeFileName : FileNames[0],
|
||||
FallbackStyle, Code ? Code->getBuffer() : "");
|
||||
if (!FormatStyle) {
|
||||
llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
|
||||
llvm::errs() << toString(FormatStyle.takeError()) << "\n";
|
||||
return 1;
|
||||
}
|
||||
std::string Config = clang::format::configurationAsText(*FormatStyle);
|
||||
@ -671,7 +669,7 @@ static bool isIgnored(StringRef FilePath) {
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
llvm::InitLLVM X(argc, argv);
|
||||
InitLLVM X(argc, argv);
|
||||
|
||||
cl::HideUnrelatedOptions(ClangFormatCategory);
|
||||
|
||||
|
@ -20,10 +20,9 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class CleanupTest : public ::testing::Test {
|
||||
class CleanupTest : public testing::Test {
|
||||
protected:
|
||||
std::string cleanup(llvm::StringRef Code,
|
||||
const std::vector<tooling::Range> &Ranges,
|
||||
std::string cleanup(StringRef Code, const std::vector<tooling::Range> &Ranges,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
|
||||
|
||||
@ -33,8 +32,7 @@ protected:
|
||||
}
|
||||
|
||||
// Returns code after cleanup around \p Offsets.
|
||||
std::string cleanupAroundOffsets(llvm::ArrayRef<unsigned> Offsets,
|
||||
llvm::StringRef Code,
|
||||
std::string cleanupAroundOffsets(ArrayRef<unsigned> Offsets, StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
std::vector<tooling::Range> Ranges;
|
||||
for (auto Offset : Offsets)
|
||||
@ -332,7 +330,7 @@ protected:
|
||||
const tooling::Replacements &Replaces) {
|
||||
auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
|
||||
EXPECT_TRUE(static_cast<bool>(CleanReplaces))
|
||||
<< llvm::toString(CleanReplaces.takeError()) << "\n";
|
||||
<< toString(CleanReplaces.takeError()) << "\n";
|
||||
auto Result = applyAllReplacements(Code, *CleanReplaces);
|
||||
EXPECT_TRUE(static_cast<bool>(Result));
|
||||
return *Result;
|
||||
@ -342,10 +340,10 @@ protected:
|
||||
const tooling::Replacements &Replaces) {
|
||||
auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
|
||||
EXPECT_TRUE(static_cast<bool>(CleanReplaces))
|
||||
<< llvm::toString(CleanReplaces.takeError()) << "\n";
|
||||
<< toString(CleanReplaces.takeError()) << "\n";
|
||||
auto FormattedReplaces = formatReplacements(Code, *CleanReplaces, Style);
|
||||
EXPECT_TRUE(static_cast<bool>(FormattedReplaces))
|
||||
<< llvm::toString(FormattedReplaces.takeError()) << "\n";
|
||||
<< toString(FormattedReplaces.takeError()) << "\n";
|
||||
auto Result = applyAllReplacements(Code, *FormattedReplaces);
|
||||
EXPECT_TRUE(static_cast<bool>(Result));
|
||||
return *Result;
|
||||
|
@ -18,10 +18,10 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class DefinitionBlockSeparatorTest : public ::testing::Test {
|
||||
class DefinitionBlockSeparatorTest : public testing::Test {
|
||||
protected:
|
||||
static std::string
|
||||
separateDefinitionBlocks(llvm::StringRef Code,
|
||||
separateDefinitionBlocks(StringRef Code,
|
||||
const std::vector<tooling::Range> &Ranges,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
@ -34,18 +34,17 @@ protected:
|
||||
}
|
||||
|
||||
static std::string
|
||||
separateDefinitionBlocks(llvm::StringRef Code,
|
||||
separateDefinitionBlocks(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
return separateDefinitionBlocks(
|
||||
Code,
|
||||
/*Ranges=*/{1, tooling::Range(0, Code.size())}, Style);
|
||||
}
|
||||
|
||||
static void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
|
||||
static void _verifyFormat(const char *File, int Line, StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle(),
|
||||
llvm::StringRef ExpectedCode = "",
|
||||
bool Inverse = true) {
|
||||
::testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
|
||||
StringRef ExpectedCode = "", bool Inverse = true) {
|
||||
testing::ScopedTrace t(File, Line, testing::Message() << Code.str());
|
||||
bool HasOriginalCode = true;
|
||||
if (ExpectedCode == "") {
|
||||
ExpectedCode = Code;
|
||||
@ -70,7 +69,7 @@ protected:
|
||||
EXPECT_EQ(ExpectedCode, Result) << "Test failed. Formatted:\n" << Result;
|
||||
}
|
||||
|
||||
static std::string removeEmptyLines(llvm::StringRef Code) {
|
||||
static std::string removeEmptyLines(StringRef Code) {
|
||||
std::string Result = "";
|
||||
for (auto Char : Code.str()) {
|
||||
if (Result.size()) {
|
||||
@ -165,13 +164,13 @@ TEST_F(DefinitionBlockSeparatorTest, Basic) {
|
||||
TEST_F(DefinitionBlockSeparatorTest, FormatConflict) {
|
||||
FormatStyle Style = getLLVMStyle();
|
||||
Style.SeparateDefinitionBlocks = FormatStyle::SDS_Always;
|
||||
llvm::StringRef Code = "class Test {\n"
|
||||
"public:\n"
|
||||
" static void foo() {\n"
|
||||
" int t;\n"
|
||||
" return 1;\n"
|
||||
" }\n"
|
||||
"};";
|
||||
StringRef Code = "class Test {\n"
|
||||
"public:\n"
|
||||
" static void foo() {\n"
|
||||
" int t;\n"
|
||||
" return 1;\n"
|
||||
" }\n"
|
||||
"};";
|
||||
std::vector<tooling::Range> Ranges = {1, tooling::Range(0, Code.size())};
|
||||
EXPECT_EQ(reformat(Style, Code, Ranges, "<stdin>").size(), 0u);
|
||||
}
|
||||
|
@ -25,17 +25,17 @@ namespace test {
|
||||
|
||||
#define DEBUG_TYPE "format-test-base"
|
||||
|
||||
class FormatTestBase : public ::testing::Test {
|
||||
class FormatTestBase : public testing::Test {
|
||||
protected:
|
||||
enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
|
||||
|
||||
virtual FormatStyle getDefaultStyle() const { return getLLVMStyle(); }
|
||||
|
||||
virtual std::string messUp(llvm::StringRef Code) const {
|
||||
virtual std::string messUp(StringRef Code) const {
|
||||
return test::messUp(Code);
|
||||
}
|
||||
|
||||
std::string format(llvm::StringRef Code,
|
||||
std::string format(StringRef Code,
|
||||
const std::optional<FormatStyle> &Style = {},
|
||||
StatusCheck CheckComplete = SC_ExpectComplete,
|
||||
const std::vector<tooling::Range> &Ranges = {}) {
|
||||
@ -80,11 +80,11 @@ protected:
|
||||
return Style;
|
||||
}
|
||||
|
||||
bool _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
|
||||
llvm::StringRef Code,
|
||||
bool _verifyFormat(const char *File, int Line, StringRef Expected,
|
||||
StringRef Code,
|
||||
const std::optional<FormatStyle> &Style = {},
|
||||
const std::vector<tooling::Range> &Ranges = {}) {
|
||||
testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
|
||||
testing::ScopedTrace t(File, Line, testing::Message() << Code.str());
|
||||
const auto ExpectedCode{Expected.str()};
|
||||
auto FormattedCode{format(Code, Style, SC_ExpectComplete, Ranges)};
|
||||
EXPECT_EQ(ExpectedCode, FormattedCode);
|
||||
@ -111,7 +111,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
|
||||
void _verifyFormat(const char *File, int Line, StringRef Code,
|
||||
const std::optional<FormatStyle> &Style = {}) {
|
||||
if (!_verifyFormat(File, Line, Code, Code, Style))
|
||||
return;
|
||||
@ -119,27 +119,26 @@ protected:
|
||||
_verifyFormat(File, Line, Code, MessedUpCode, Style);
|
||||
}
|
||||
|
||||
void _verifyIncompleteFormat(const char *File, int Line, llvm::StringRef Code,
|
||||
void _verifyIncompleteFormat(const char *File, int Line, StringRef Code,
|
||||
const std::optional<FormatStyle> &Style = {}) {
|
||||
testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
|
||||
testing::ScopedTrace t(File, Line, testing::Message() << Code.str());
|
||||
EXPECT_EQ(Code.str(), format(messUp(Code), Style, SC_ExpectIncomplete));
|
||||
}
|
||||
|
||||
void
|
||||
_verifyIndependentOfContext(const char *File, int Line, llvm::StringRef Text,
|
||||
_verifyIndependentOfContext(const char *File, int Line, StringRef Text,
|
||||
const std::optional<FormatStyle> &Style = {}) {
|
||||
_verifyFormat(File, Line, Text, Style);
|
||||
_verifyFormat(File, Line, llvm::Twine("void f() { " + Text + " }").str(),
|
||||
Style);
|
||||
_verifyFormat(File, Line, Twine("void f() { " + Text + " }").str(), Style);
|
||||
}
|
||||
|
||||
void _verifyNoChange(const char *File, int Line, llvm::StringRef Code,
|
||||
void _verifyNoChange(const char *File, int Line, StringRef Code,
|
||||
const std::optional<FormatStyle> &Style = {}) {
|
||||
_verifyFormat(File, Line, Code, Code, Style);
|
||||
}
|
||||
|
||||
/// \brief Verify that clang-format does not crash on the given input.
|
||||
void verifyNoCrash(llvm::StringRef Code,
|
||||
void verifyNoCrash(StringRef Code,
|
||||
const std::optional<FormatStyle> &Style = {}) {
|
||||
format(Code, Style, SC_DoNotCheck);
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ protected:
|
||||
return getMicrosoftStyle(FormatStyle::LK_CSharp);
|
||||
}
|
||||
|
||||
static std::string format(llvm::StringRef Code, unsigned Offset,
|
||||
unsigned Length, const FormatStyle &Style) {
|
||||
static std::string format(StringRef Code, unsigned Offset, unsigned Length,
|
||||
const FormatStyle &Style) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
|
||||
@ -34,7 +34,7 @@ protected:
|
||||
}
|
||||
|
||||
static std::string
|
||||
format(llvm::StringRef Code,
|
||||
format(StringRef Code,
|
||||
const FormatStyle &Style = getMicrosoftStyle(FormatStyle::LK_CSharp)) {
|
||||
return format(Code, 0, Code.size(), Style);
|
||||
}
|
||||
|
@ -16,10 +16,10 @@
|
||||
namespace clang {
|
||||
namespace format {
|
||||
|
||||
class FormatTestJS : public ::testing::Test {
|
||||
class FormatTestJS : public testing::Test {
|
||||
protected:
|
||||
static std::string format(llvm::StringRef Code, unsigned Offset,
|
||||
unsigned Length, const FormatStyle &Style) {
|
||||
static std::string format(StringRef Code, unsigned Offset, unsigned Length,
|
||||
const FormatStyle &Style) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
|
||||
@ -34,7 +34,7 @@ protected:
|
||||
}
|
||||
|
||||
static std::string format(
|
||||
llvm::StringRef Code,
|
||||
StringRef Code,
|
||||
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
|
||||
return format(Code, 0, Code.size(), Style);
|
||||
}
|
||||
@ -46,7 +46,7 @@ protected:
|
||||
}
|
||||
|
||||
static void verifyFormat(
|
||||
llvm::StringRef Code,
|
||||
StringRef Code,
|
||||
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
|
||||
EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
|
||||
std::string Result = format(test::messUp(Code), Style);
|
||||
@ -54,7 +54,7 @@ protected:
|
||||
}
|
||||
|
||||
static void verifyFormat(
|
||||
llvm::StringRef Expected, llvm::StringRef Code,
|
||||
StringRef Expected, StringRef Code,
|
||||
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
|
||||
EXPECT_EQ(Expected.str(), format(Expected, Style))
|
||||
<< "Expected code is not stable";
|
||||
|
@ -16,10 +16,10 @@
|
||||
namespace clang {
|
||||
namespace format {
|
||||
|
||||
class FormatTestJson : public ::testing::Test {
|
||||
class FormatTestJson : public testing::Test {
|
||||
protected:
|
||||
static std::string format(llvm::StringRef Code, unsigned Offset,
|
||||
unsigned Length, const FormatStyle &Style) {
|
||||
static std::string format(StringRef Code, unsigned Offset, unsigned Length,
|
||||
const FormatStyle &Style) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
|
||||
@ -47,7 +47,7 @@ protected:
|
||||
}
|
||||
|
||||
static std::string
|
||||
format(llvm::StringRef Code,
|
||||
format(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle(FormatStyle::LK_Json)) {
|
||||
return format(Code, 0, Code.size(), Style);
|
||||
}
|
||||
@ -58,13 +58,12 @@ protected:
|
||||
return Style;
|
||||
}
|
||||
|
||||
static void verifyFormatStable(llvm::StringRef Code,
|
||||
const FormatStyle &Style) {
|
||||
static void verifyFormatStable(StringRef Code, const FormatStyle &Style) {
|
||||
EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
|
||||
}
|
||||
|
||||
static void
|
||||
verifyFormat(llvm::StringRef Code,
|
||||
verifyFormat(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle(FormatStyle::LK_Json)) {
|
||||
verifyFormatStable(Code, Style);
|
||||
EXPECT_EQ(Code.str(), format(test::messUp(Code), Style));
|
||||
|
@ -16,10 +16,10 @@
|
||||
namespace clang {
|
||||
namespace format {
|
||||
|
||||
class FormatTestProto : public ::testing::Test {
|
||||
class FormatTestProto : public testing::Test {
|
||||
protected:
|
||||
static std::string format(llvm::StringRef Code, unsigned Offset,
|
||||
unsigned Length, const FormatStyle &Style) {
|
||||
static std::string format(StringRef Code, unsigned Offset, unsigned Length,
|
||||
const FormatStyle &Style) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
|
||||
@ -30,13 +30,13 @@ protected:
|
||||
return *Result;
|
||||
}
|
||||
|
||||
static std::string format(llvm::StringRef Code) {
|
||||
static std::string format(StringRef Code) {
|
||||
FormatStyle Style = getGoogleStyle(FormatStyle::LK_Proto);
|
||||
Style.ColumnLimit = 60; // To make writing tests easier.
|
||||
return format(Code, 0, Code.size(), Style);
|
||||
}
|
||||
|
||||
static void verifyFormat(llvm::StringRef Code) {
|
||||
static void verifyFormat(StringRef Code) {
|
||||
EXPECT_EQ(Code.str(), format(Code)) << "Expected code is not stable";
|
||||
EXPECT_EQ(Code.str(), format(test::messUp(Code)));
|
||||
}
|
||||
|
@ -21,12 +21,11 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class FormatTestRawStrings : public ::testing::Test {
|
||||
class FormatTestRawStrings : public testing::Test {
|
||||
protected:
|
||||
enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
|
||||
|
||||
std::string format(llvm::StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle(),
|
||||
std::string format(StringRef Code, const FormatStyle &Style = getLLVMStyle(),
|
||||
StatusCheck CheckComplete = SC_ExpectComplete) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
|
@ -17,9 +17,9 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class FormatTestSelective : public ::testing::Test {
|
||||
class FormatTestSelective : public testing::Test {
|
||||
protected:
|
||||
std::string format(llvm::StringRef Code, unsigned Offset, unsigned Length) {
|
||||
std::string format(StringRef Code, unsigned Offset, unsigned Length) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
|
||||
|
@ -16,10 +16,10 @@
|
||||
namespace clang {
|
||||
namespace format {
|
||||
|
||||
class FormatTestTableGen : public ::testing::Test {
|
||||
class FormatTestTableGen : public testing::Test {
|
||||
protected:
|
||||
static std::string format(llvm::StringRef Code, unsigned Offset,
|
||||
unsigned Length, const FormatStyle &Style) {
|
||||
static std::string format(StringRef Code, unsigned Offset, unsigned Length,
|
||||
const FormatStyle &Style) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
|
||||
@ -30,22 +30,22 @@ protected:
|
||||
return *Result;
|
||||
}
|
||||
|
||||
static std::string format(llvm::StringRef Code) {
|
||||
static std::string format(StringRef Code) {
|
||||
FormatStyle Style = getGoogleStyle(FormatStyle::LK_TableGen);
|
||||
Style.ColumnLimit = 60; // To make writing tests easier.
|
||||
return format(Code, 0, Code.size(), Style);
|
||||
}
|
||||
|
||||
static void verifyFormat(llvm::StringRef Code) {
|
||||
static void verifyFormat(StringRef Code) {
|
||||
EXPECT_EQ(Code.str(), format(Code)) << "Expected code is not stable";
|
||||
EXPECT_EQ(Code.str(), format(test::messUp(Code)));
|
||||
}
|
||||
|
||||
static void verifyFormat(llvm::StringRef Result, llvm::StringRef MessedUp) {
|
||||
static void verifyFormat(StringRef Result, StringRef MessedUp) {
|
||||
EXPECT_EQ(Result, format(MessedUp));
|
||||
}
|
||||
|
||||
static void verifyFormat(llvm::StringRef Code, const FormatStyle &Style) {
|
||||
static void verifyFormat(StringRef Code, const FormatStyle &Style) {
|
||||
EXPECT_EQ(Code.str(), format(Code, 0, Code.size(), Style))
|
||||
<< "Expected code is not stable";
|
||||
auto MessUp = test::messUp(Code);
|
||||
|
@ -27,7 +27,7 @@ inline FormatStyle getGoogleStyle() {
|
||||
// When HandleHash is false, preprocessor directives starting with hash will not
|
||||
// be on separate lines. This is needed because Verilog uses hash for other
|
||||
// purposes.
|
||||
inline std::string messUp(llvm::StringRef Code, bool HandleHash = true) {
|
||||
inline std::string messUp(StringRef Code, bool HandleHash = true) {
|
||||
std::string MessedUp(Code.str());
|
||||
bool InComment = false;
|
||||
bool InPreprocessorDirective = false;
|
||||
|
@ -19,7 +19,7 @@ protected:
|
||||
FormatStyle getDefaultStyle() const override {
|
||||
return getLLVMStyle(FormatStyle::LK_Verilog);
|
||||
}
|
||||
std::string messUp(llvm::StringRef Code) const override {
|
||||
std::string messUp(StringRef Code) const override {
|
||||
return test::messUp(Code, /*HandleHash=*/false);
|
||||
}
|
||||
};
|
||||
|
@ -15,10 +15,9 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class IndexedTokenSourceTest : public ::testing::Test {
|
||||
class IndexedTokenSourceTest : public testing::Test {
|
||||
protected:
|
||||
TokenList lex(llvm::StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
TokenList lex(StringRef Code, const FormatStyle &Style = getLLVMStyle()) {
|
||||
return TestLexer(Allocator, Buffers, Style).lex(Code);
|
||||
}
|
||||
llvm::SpecificBumpPtrAllocator<FormatToken> Allocator;
|
||||
|
@ -30,15 +30,14 @@ public:
|
||||
// Appends the token stream obtained from expanding the macro Name given
|
||||
// the provided arguments, to be later retrieved with getTokens().
|
||||
// Returns the list of tokens making up the unexpanded macro call.
|
||||
TokenList
|
||||
expand(llvm::StringRef Name,
|
||||
const SmallVector<llvm::SmallVector<FormatToken *, 8>, 1> &Args) {
|
||||
TokenList expand(StringRef Name,
|
||||
const SmallVector<SmallVector<FormatToken *, 8>, 1> &Args) {
|
||||
return expandInternal(Name, Args);
|
||||
}
|
||||
|
||||
TokenList expand(llvm::StringRef Name) { return expandInternal(Name, {}); }
|
||||
TokenList expand(StringRef Name) { return expandInternal(Name, {}); }
|
||||
|
||||
TokenList expand(llvm::StringRef Name, const std::vector<std::string> &Args) {
|
||||
TokenList expand(StringRef Name, const std::vector<std::string> &Args) {
|
||||
return expandInternal(Name, lexArgs(Args));
|
||||
}
|
||||
|
||||
@ -48,8 +47,8 @@ public:
|
||||
|
||||
private:
|
||||
TokenList expandInternal(
|
||||
llvm::StringRef Name,
|
||||
const std::optional<SmallVector<llvm::SmallVector<FormatToken *, 8>, 1>>
|
||||
StringRef Name,
|
||||
const std::optional<SmallVector<SmallVector<FormatToken *, 8>, 1>>
|
||||
&Args) {
|
||||
auto *ID = Lex.id(Name);
|
||||
auto UnexpandedLine = std::make_unique<UnwrappedLine>();
|
||||
@ -75,26 +74,25 @@ private:
|
||||
return UnexpandedTokens;
|
||||
}
|
||||
|
||||
llvm::SmallVector<TokenList, 1>
|
||||
lexArgs(const std::vector<std::string> &Args) {
|
||||
llvm::SmallVector<TokenList, 1> Result;
|
||||
SmallVector<TokenList, 1> lexArgs(const std::vector<std::string> &Args) {
|
||||
SmallVector<TokenList, 1> Result;
|
||||
for (const auto &Arg : Args)
|
||||
Result.push_back(uneof(Lex.lex(Arg)));
|
||||
return Result;
|
||||
}
|
||||
llvm::DenseMap<FormatToken *, std::unique_ptr<UnwrappedLine>> Unexpanded;
|
||||
llvm::SmallVector<FormatToken *, 8> Tokens;
|
||||
SmallVector<FormatToken *, 8> Tokens;
|
||||
TestLexer &Lex;
|
||||
MacroExpander &Macros;
|
||||
};
|
||||
|
||||
struct Chunk {
|
||||
Chunk(llvm::ArrayRef<FormatToken *> Tokens)
|
||||
Chunk(ArrayRef<FormatToken *> Tokens)
|
||||
: Tokens(Tokens.begin(), Tokens.end()) {}
|
||||
Chunk(llvm::ArrayRef<UnwrappedLine> Children)
|
||||
Chunk(ArrayRef<UnwrappedLine> Children)
|
||||
: Children(Children.begin(), Children.end()) {}
|
||||
llvm::SmallVector<UnwrappedLineNode, 1> Tokens;
|
||||
llvm::SmallVector<UnwrappedLine, 0> Children;
|
||||
SmallVector<UnwrappedLineNode, 1> Tokens;
|
||||
SmallVector<UnwrappedLine, 0> Children;
|
||||
};
|
||||
|
||||
// Allows to produce chunks of a token list by typing the code of equal tokens.
|
||||
@ -140,7 +138,7 @@ UnexpandedMap mergeUnexpanded(const UnexpandedMap &M1,
|
||||
return Result;
|
||||
}
|
||||
|
||||
class MacroCallReconstructorTest : public ::testing::Test {
|
||||
class MacroCallReconstructorTest : public testing::Test {
|
||||
public:
|
||||
MacroCallReconstructorTest() : Lex(Allocator, Buffers) {}
|
||||
|
||||
@ -151,7 +149,7 @@ public:
|
||||
Lex.Allocator, Lex.IdentTable);
|
||||
}
|
||||
|
||||
UnwrappedLine line(llvm::ArrayRef<FormatToken *> Tokens, unsigned Level = 0) {
|
||||
UnwrappedLine line(ArrayRef<FormatToken *> Tokens, unsigned Level = 0) {
|
||||
UnwrappedLine Result;
|
||||
Result.Level = Level;
|
||||
for (FormatToken *Tok : Tokens)
|
||||
@ -159,11 +157,11 @@ public:
|
||||
return Result;
|
||||
}
|
||||
|
||||
UnwrappedLine line(llvm::StringRef Text, unsigned Level = 0) {
|
||||
UnwrappedLine line(StringRef Text, unsigned Level = 0) {
|
||||
return line({lex(Text)}, Level);
|
||||
}
|
||||
|
||||
UnwrappedLine line(llvm::ArrayRef<Chunk> Chunks, unsigned Level = 0) {
|
||||
UnwrappedLine line(ArrayRef<Chunk> Chunks, unsigned Level = 0) {
|
||||
UnwrappedLine Result;
|
||||
Result.Level = Level;
|
||||
for (const Chunk &Chunk : Chunks) {
|
||||
@ -176,13 +174,11 @@ public:
|
||||
return Result;
|
||||
}
|
||||
|
||||
TokenList lex(llvm::StringRef Text) { return uneof(Lex.lex(Text)); }
|
||||
TokenList lex(StringRef Text) { return uneof(Lex.lex(Text)); }
|
||||
|
||||
Chunk tokens(llvm::StringRef Text) { return Chunk(lex(Text)); }
|
||||
Chunk tokens(StringRef Text) { return Chunk(lex(Text)); }
|
||||
|
||||
Chunk children(llvm::ArrayRef<UnwrappedLine> Children) {
|
||||
return Chunk(Children);
|
||||
}
|
||||
Chunk children(ArrayRef<UnwrappedLine> Children) { return Chunk(Children); }
|
||||
|
||||
llvm::SpecificBumpPtrAllocator<FormatToken> Allocator;
|
||||
std::vector<std::unique_ptr<llvm::MemoryBuffer>> Buffers;
|
||||
|
@ -9,7 +9,7 @@ namespace format {
|
||||
|
||||
namespace {
|
||||
|
||||
class MacroExpanderTest : public ::testing::Test {
|
||||
class MacroExpanderTest : public testing::Test {
|
||||
public:
|
||||
MacroExpanderTest() : Lex(Allocator, Buffers) {}
|
||||
std::unique_ptr<MacroExpander>
|
||||
@ -19,33 +19,32 @@ public:
|
||||
Lex.Allocator, Lex.IdentTable);
|
||||
}
|
||||
|
||||
std::string expand(MacroExpander &Macros, llvm::StringRef Name) {
|
||||
std::string expand(MacroExpander &Macros, StringRef Name) {
|
||||
EXPECT_TRUE(Macros.defined(Name))
|
||||
<< "Macro not defined: \"" << Name << "\"";
|
||||
return text(Macros.expand(Lex.id(Name), {}));
|
||||
}
|
||||
|
||||
std::string expand(MacroExpander &Macros, llvm::StringRef Name,
|
||||
std::string expand(MacroExpander &Macros, StringRef Name,
|
||||
const std::vector<std::string> &Args) {
|
||||
EXPECT_TRUE(Macros.defined(Name))
|
||||
<< "Macro not defined: \"" << Name << "\"";
|
||||
return text(Macros.expand(Lex.id(Name), lexArgs(Args)));
|
||||
}
|
||||
|
||||
llvm::SmallVector<TokenList, 1>
|
||||
lexArgs(const std::vector<std::string> &Args) {
|
||||
llvm::SmallVector<TokenList, 1> Result;
|
||||
SmallVector<TokenList, 1> lexArgs(const std::vector<std::string> &Args) {
|
||||
SmallVector<TokenList, 1> Result;
|
||||
for (const auto &Arg : Args)
|
||||
Result.push_back(uneof(Lex.lex(Arg)));
|
||||
return Result;
|
||||
}
|
||||
|
||||
struct MacroAttributes {
|
||||
clang::tok::TokenKind Kind;
|
||||
tok::TokenKind Kind;
|
||||
MacroRole Role;
|
||||
unsigned Start;
|
||||
unsigned End;
|
||||
llvm::SmallVector<FormatToken *, 1> ExpandedFrom;
|
||||
SmallVector<FormatToken *, 1> ExpandedFrom;
|
||||
};
|
||||
|
||||
void expectAttributes(const TokenList &Tokens,
|
||||
@ -56,8 +55,8 @@ public:
|
||||
if (I >= Attributes.size())
|
||||
continue;
|
||||
std::string Context =
|
||||
("for token " + llvm::Twine(I) + ": " + Tokens[I]->Tok.getName() +
|
||||
" / " + Tokens[I]->TokenText)
|
||||
("for token " + Twine(I) + ": " + Tokens[I]->Tok.getName() + " / " +
|
||||
Tokens[I]->TokenText)
|
||||
.str();
|
||||
EXPECT_TRUE(Tokens[I]->is(Attributes[I].Kind))
|
||||
<< Context << " in " << text(Tokens) << " at " << File << ":" << Line;
|
||||
|
@ -13,7 +13,7 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class MatchFilePathTest : public ::testing::Test {
|
||||
class MatchFilePathTest : public testing::Test {
|
||||
protected:
|
||||
bool match(llvm::StringRef FilePath, llvm::StringRef Pattern) {
|
||||
return matchFilePath(Pattern, FilePath);
|
||||
|
@ -17,16 +17,16 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class NamespaceEndCommentsFixerTest : public ::testing::Test {
|
||||
class NamespaceEndCommentsFixerTest : public testing::Test {
|
||||
protected:
|
||||
std::string
|
||||
fixNamespaceEndComments(llvm::StringRef Code,
|
||||
fixNamespaceEndComments(StringRef Code,
|
||||
const std::vector<tooling::Range> &Ranges,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
tooling::Replacements Replaces =
|
||||
clang::format::fixNamespaceEndComments(Style, Code, Ranges, "<stdin>");
|
||||
format::fixNamespaceEndComments(Style, Code, Ranges, "<stdin>");
|
||||
auto Result = applyAllReplacements(Code, Replaces);
|
||||
EXPECT_TRUE(static_cast<bool>(Result));
|
||||
LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
|
||||
@ -34,7 +34,7 @@ protected:
|
||||
}
|
||||
|
||||
std::string
|
||||
fixNamespaceEndComments(llvm::StringRef Code,
|
||||
fixNamespaceEndComments(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
return fixNamespaceEndComments(
|
||||
Code,
|
||||
@ -43,8 +43,7 @@ protected:
|
||||
|
||||
bool isFormatted(StringRef Code, const std::vector<tooling::Range> &Ranges,
|
||||
const FormatStyle &Style = getLLVMStyle()) const {
|
||||
return clang::format::fixNamespaceEndComments(Style, Code, Ranges,
|
||||
"<stdin>")
|
||||
return format::fixNamespaceEndComments(Style, Code, Ranges, "<stdin>")
|
||||
.empty();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace {
|
||||
|
||||
class ObjCPropertyAttributeOrderFixerTest : public FormatTestBase {
|
||||
protected:
|
||||
TokenList annotate(llvm::StringRef Code,
|
||||
TokenList annotate(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
return TestLexer(Allocator, Buffers, Style).annotate(Code);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace {
|
||||
|
||||
class QualifierFixerTest : public FormatTestBase {
|
||||
protected:
|
||||
TokenList annotate(llvm::StringRef Code,
|
||||
TokenList annotate(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
return TestLexer(Allocator, Buffers, Style).annotate(Code);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class SortImportsTestJS : public ::testing::Test {
|
||||
class SortImportsTestJS : public testing::Test {
|
||||
protected:
|
||||
std::string sort(StringRef Code, unsigned Offset = 0, unsigned Length = 0) {
|
||||
StringRef FileName = "input.js";
|
||||
@ -33,10 +33,9 @@ protected:
|
||||
return *Formatted;
|
||||
}
|
||||
|
||||
void _verifySort(const char *File, int Line, llvm::StringRef Expected,
|
||||
llvm::StringRef Code, unsigned Offset = 0,
|
||||
unsigned Length = 0) {
|
||||
::testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
|
||||
void _verifySort(const char *File, int Line, StringRef Expected,
|
||||
StringRef Code, unsigned Offset = 0, unsigned Length = 0) {
|
||||
testing::ScopedTrace t(File, Line, testing::Message() << Code.str());
|
||||
std::string Result = sort(Code, Offset, Length);
|
||||
EXPECT_EQ(Expected.str(), Result) << "Expected:\n"
|
||||
<< Expected << "\nActual:\n"
|
||||
|
@ -7,7 +7,7 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class SortImportsTestJava : public ::testing::Test {
|
||||
class SortImportsTestJava : public testing::Test {
|
||||
protected:
|
||||
std::vector<tooling::Range> GetCodeRange(StringRef Code) {
|
||||
return std::vector<tooling::Range>(1, tooling::Range(0, Code.size()));
|
||||
|
@ -43,7 +43,7 @@ protected:
|
||||
return sort(Code, GetCodeRange(Code), FileName, ExpectedNumRanges);
|
||||
}
|
||||
|
||||
unsigned newCursor(llvm::StringRef Code, unsigned Cursor) {
|
||||
unsigned newCursor(StringRef Code, unsigned Cursor) {
|
||||
sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.cpp", &Cursor);
|
||||
return Cursor;
|
||||
}
|
||||
@ -644,7 +644,7 @@ TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveSorting) {
|
||||
"#include \"A/b.h\"",
|
||||
"a.h"));
|
||||
|
||||
Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
|
||||
Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
|
||||
Style.IncludeCategories = {
|
||||
{"^\"", 1, 0, false}, {"^<.*\\.h>$", 2, 0, false}, {"^<", 3, 0, false}};
|
||||
|
||||
@ -694,7 +694,7 @@ TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
|
||||
}
|
||||
|
||||
TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveMachting) {
|
||||
Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
|
||||
Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
|
||||
Style.IncludeCategories = {{"^\"", 1, 0, false},
|
||||
{"^<.*\\.h>$", 2, 0, false},
|
||||
{"^<Q[A-Z][^\\.]*>", 3, 0, false},
|
||||
|
@ -28,7 +28,7 @@
|
||||
namespace clang {
|
||||
namespace format {
|
||||
|
||||
typedef llvm::SmallVector<FormatToken *, 8> TokenList;
|
||||
typedef SmallVector<FormatToken *, 8> TokenList;
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &Stream, const FormatToken &Tok) {
|
||||
Stream << "(" << Tok.Tok.getName() << ", \"" << Tok.TokenText.str() << "\" , "
|
||||
@ -48,7 +48,7 @@ inline TokenList uneof(const TokenList &Tokens) {
|
||||
return TokenList(Tokens.begin(), std::prev(Tokens.end()));
|
||||
}
|
||||
|
||||
inline std::string text(llvm::ArrayRef<FormatToken *> Tokens) {
|
||||
inline std::string text(ArrayRef<FormatToken *> Tokens) {
|
||||
return std::accumulate(Tokens.begin(), Tokens.end(), std::string(),
|
||||
[](const std::string &R, FormatToken *Tok) {
|
||||
return (R + Tok->TokenText).str();
|
||||
@ -63,13 +63,13 @@ public:
|
||||
: Allocator(Allocator), Buffers(Buffers), Style(Style),
|
||||
SourceMgr("test.cpp", ""), IdentTable(getFormattingLangOpts(Style)) {}
|
||||
|
||||
TokenList lex(llvm::StringRef Code) {
|
||||
TokenList lex(StringRef Code) {
|
||||
FormatTokenLexer Lex = getNewLexer(Code);
|
||||
ArrayRef<FormatToken *> Result = Lex.lex();
|
||||
return TokenList(Result.begin(), Result.end());
|
||||
}
|
||||
|
||||
TokenList annotate(llvm::StringRef Code) {
|
||||
TokenList annotate(StringRef Code) {
|
||||
FormatTokenLexer Lex = getNewLexer(Code);
|
||||
auto Tokens = Lex.lex();
|
||||
UnwrappedLineParser Parser(SourceMgr.get(), Style, Lex.getKeywords(), 0,
|
||||
@ -85,7 +85,7 @@ public:
|
||||
return TokenList(Tokens.begin(), Tokens.end());
|
||||
}
|
||||
|
||||
FormatToken *id(llvm::StringRef Code) {
|
||||
FormatToken *id(StringRef Code) {
|
||||
auto Result = uneof(lex(Code));
|
||||
assert(Result.size() == 1U && "Code must expand to 1 token.");
|
||||
return Result[0];
|
||||
@ -100,7 +100,7 @@ protected:
|
||||
FormatTokenLexer getNewLexer(StringRef Code) {
|
||||
Buffers.push_back(
|
||||
llvm::MemoryBuffer::getMemBufferCopy(Code, "<scratch space>"));
|
||||
clang::FileID FID =
|
||||
FileID FID =
|
||||
SourceMgr.get().createFileID(Buffers.back()->getMemBufferRef());
|
||||
return FormatTokenLexer(SourceMgr.get(), FID, 0, Style, Encoding, Allocator,
|
||||
IdentTable);
|
||||
@ -111,7 +111,7 @@ public:
|
||||
std::vector<std::unique_ptr<llvm::MemoryBuffer>> &Buffers;
|
||||
FormatStyle Style;
|
||||
encoding::Encoding Encoding = encoding::Encoding_UTF8;
|
||||
clang::SourceManagerForFile SourceMgr;
|
||||
SourceManagerForFile SourceMgr;
|
||||
IdentifierTable IdentTable;
|
||||
SmallVector<UnwrappedLine, 16> UnwrappedLines;
|
||||
};
|
||||
|
@ -24,9 +24,9 @@ static bool operator==(const FormatToken &LHS,
|
||||
|
||||
namespace {
|
||||
|
||||
class TokenAnnotatorTest : public ::testing::Test {
|
||||
class TokenAnnotatorTest : public testing::Test {
|
||||
protected:
|
||||
TokenList annotate(llvm::StringRef Code,
|
||||
TokenList annotate(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
return TestLexer(Allocator, Buffers, Style).annotate(Code);
|
||||
}
|
||||
@ -2097,7 +2097,7 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacrosOnObjCProperty) {
|
||||
}
|
||||
|
||||
TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) {
|
||||
auto Annotate = [this](llvm::StringRef Code) {
|
||||
auto Annotate = [this](StringRef Code) {
|
||||
return annotate(Code, getLLVMStyle(FormatStyle::LK_Verilog));
|
||||
};
|
||||
// Test that unary operators get labeled as such and that operators like '++'
|
||||
@ -2279,9 +2279,7 @@ TEST_F(TokenAnnotatorTest, UnderstandTableGenTokens) {
|
||||
|
||||
TestLexer Lexer(Allocator, Buffers, Style);
|
||||
AdditionalKeywords Keywords(Lexer.IdentTable);
|
||||
auto Annotate = [&Lexer](llvm::StringRef Code) {
|
||||
return Lexer.annotate(Code);
|
||||
};
|
||||
auto Annotate = [&Lexer](StringRef Code) { return Lexer.annotate(Code); };
|
||||
|
||||
// Additional keywords representation test.
|
||||
auto Tokens = Annotate("def foo : Bar<1>;");
|
||||
@ -2357,7 +2355,7 @@ TEST_F(TokenAnnotatorTest, UnderstandTableGenTokens) {
|
||||
Tokens = Annotate("!cond");
|
||||
EXPECT_TOKEN(Tokens[0], tok::identifier, TT_TableGenCondOperator);
|
||||
|
||||
auto AnnotateValue = [this, &Style](llvm::StringRef Code) {
|
||||
auto AnnotateValue = [this, &Style](StringRef Code) {
|
||||
// Values are annotated only in specific context.
|
||||
auto Result = annotate(("def X { let V = " + Code + "; }").str(), Style);
|
||||
return decltype(Result){Result.begin() + 6, Result.end() - 3};
|
||||
@ -2649,7 +2647,7 @@ TEST_F(TokenAnnotatorTest, UnderstandDesignatedInitializers) {
|
||||
}
|
||||
|
||||
TEST_F(TokenAnnotatorTest, UnderstandsJavaScript) {
|
||||
auto Annotate = [this](llvm::StringRef Code) {
|
||||
auto Annotate = [this](StringRef Code) {
|
||||
return annotate(Code, getLLVMStyle(FormatStyle::LK_JavaScript));
|
||||
};
|
||||
|
||||
|
@ -17,22 +17,22 @@ namespace clang {
|
||||
namespace format {
|
||||
namespace {
|
||||
|
||||
class UsingDeclarationsSorterTest : public ::testing::Test {
|
||||
class UsingDeclarationsSorterTest : public testing::Test {
|
||||
protected:
|
||||
std::string sortUsingDeclarations(llvm::StringRef Code,
|
||||
std::string sortUsingDeclarations(StringRef Code,
|
||||
const std::vector<tooling::Range> &Ranges,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
LLVM_DEBUG(llvm::errs() << "---\n");
|
||||
LLVM_DEBUG(llvm::errs() << Code << "\n\n");
|
||||
tooling::Replacements Replaces =
|
||||
clang::format::sortUsingDeclarations(Style, Code, Ranges, "<stdin>");
|
||||
format::sortUsingDeclarations(Style, Code, Ranges, "<stdin>");
|
||||
auto Result = applyAllReplacements(Code, Replaces);
|
||||
EXPECT_TRUE(static_cast<bool>(Result));
|
||||
LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
|
||||
return *Result;
|
||||
}
|
||||
|
||||
std::string sortUsingDeclarations(llvm::StringRef Code,
|
||||
std::string sortUsingDeclarations(StringRef Code,
|
||||
const FormatStyle &Style = getLLVMStyle()) {
|
||||
return sortUsingDeclarations(Code,
|
||||
/*Ranges=*/{1, tooling::Range(0, Code.size())},
|
||||
|
Loading…
x
Reference in New Issue
Block a user