Skip to content

Commit 48f1a00

Browse files
authored
Reformat all the files after 192a82b (#979)
Since the introduction of "ColumnLimit: 120" in .clang-format, the column limit has become 120 characters instead of 80 characters. This prevents clang-format from generating too much changes even if just a small portion of a source file or header file is modified.
1 parent 4331c89 commit 48f1a00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+974
-1760
lines changed

src/clang_tu.cc

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ bool isInsideMainFile(const SourceManager &sm, SourceLocation sl) {
5757
return fid == sm.getMainFileID() || fid == sm.getPreambleFileID();
5858
}
5959

60-
static Pos decomposed2LineAndCol(const SourceManager &sm,
61-
std::pair<FileID, unsigned> i) {
62-
int l = (int)sm.getLineNumber(i.first, i.second) - 1,
63-
c = (int)sm.getColumnNumber(i.first, i.second) - 1;
60+
static Pos decomposed2LineAndCol(const SourceManager &sm, std::pair<FileID, unsigned> i) {
61+
int l = (int)sm.getLineNumber(i.first, i.second) - 1, c = (int)sm.getColumnNumber(i.first, i.second) - 1;
6462
bool invalid = false;
6563
StringRef buf = sm.getBufferData(i.first, &invalid);
6664
if (!invalid) {
@@ -71,29 +69,25 @@ static Pos decomposed2LineAndCol(const SourceManager &sm,
7169
while (i < p.size() && (uint8_t)p[i] >= 128 && (uint8_t)p[i] < 192)
7270
i++;
7371
}
74-
return {(uint16_t)std::min<int>(l, UINT16_MAX),
75-
(int16_t)std::min<int>(c, INT16_MAX)};
72+
return {(uint16_t)std::min<int>(l, UINT16_MAX), (int16_t)std::min<int>(c, INT16_MAX)};
7673
}
7774

78-
Range fromCharSourceRange(const SourceManager &sm, const LangOptions &lang,
79-
CharSourceRange csr, FileID *fid) {
75+
Range fromCharSourceRange(const SourceManager &sm, const LangOptions &lang, CharSourceRange csr, FileID *fid) {
8076
SourceLocation bloc = csr.getBegin(), eloc = csr.getEnd();
81-
std::pair<FileID, unsigned> binfo = sm.getDecomposedLoc(bloc),
82-
einfo = sm.getDecomposedLoc(eloc);
77+
std::pair<FileID, unsigned> binfo = sm.getDecomposedLoc(bloc), einfo = sm.getDecomposedLoc(eloc);
8378
if (csr.isTokenRange())
8479
einfo.second += Lexer::MeasureTokenLength(eloc, sm, lang);
8580
if (fid)
8681
*fid = binfo.first;
8782
return {decomposed2LineAndCol(sm, binfo), decomposed2LineAndCol(sm, einfo)};
8883
}
8984

90-
Range fromTokenRange(const SourceManager &sm, const LangOptions &lang,
91-
SourceRange sr, FileID *fid) {
85+
Range fromTokenRange(const SourceManager &sm, const LangOptions &lang, SourceRange sr, FileID *fid) {
9286
return fromCharSourceRange(sm, lang, CharSourceRange::getTokenRange(sr), fid);
9387
}
9488

95-
Range fromTokenRangeDefaulted(const SourceManager &sm, const LangOptions &lang,
96-
SourceRange sr, FileID fid, Range range) {
89+
Range fromTokenRangeDefaulted(const SourceManager &sm, const LangOptions &lang, SourceRange sr, FileID fid,
90+
Range range) {
9791
auto decomposed = sm.getDecomposedLoc(sm.getExpansionLoc(sr.getBegin()));
9892
if (decomposed.first == fid)
9993
range.start = decomposed2LineAndCol(sm, decomposed);
@@ -106,17 +100,15 @@ Range fromTokenRangeDefaulted(const SourceManager &sm, const LangOptions &lang,
106100
return range;
107101
}
108102

109-
std::unique_ptr<CompilerInvocation>
110-
buildCompilerInvocation(const std::string &main, std::vector<const char *> args,
111-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs) {
103+
std::unique_ptr<CompilerInvocation> buildCompilerInvocation(const std::string &main, std::vector<const char *> args,
104+
IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs) {
112105
std::string save = "-resource-dir=" + g_config->clang.resourceDir;
113106
args.push_back(save.c_str());
114107
args.push_back("-fsyntax-only");
115108

116109
// Similar to clang/tools/driver/driver.cpp:insertTargetAndModeArgs but don't
117110
// require llvm::InitializeAllTargetInfos().
118-
auto target_and_mode =
119-
driver::ToolChain::getTargetAndModeFromProgramName(args[0]);
111+
auto target_and_mode = driver::ToolChain::getTargetAndModeFromProgramName(args[0]);
120112
if (target_and_mode.DriverMode)
121113
args.insert(args.begin() + 1, target_and_mode.DriverMode);
122114
if (!target_and_mode.TargetPrefix.empty()) {
@@ -145,7 +137,7 @@ buildCompilerInvocation(const std::string &main, std::vector<const char *> args,
145137
const driver::JobList &jobs = comp->getJobs();
146138
bool offload_compilation = false;
147139
if (jobs.size() > 1) {
148-
for (auto &a : comp->getActions()){
140+
for (auto &a : comp->getActions()) {
149141
// On MacOSX real actions may end up being wrapped in BindArchAction
150142
if (isa<driver::BindArchAction>(a))
151143
a = *a->input_begin();

src/clang_tu.hh

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,18 @@ std::string pathFromFileEntry(clang::FileEntryRef file);
2828

2929
bool isInsideMainFile(const clang::SourceManager &sm, clang::SourceLocation sl);
3030

31-
Range fromCharSourceRange(const clang::SourceManager &sm,
32-
const clang::LangOptions &lang,
33-
clang::CharSourceRange csr,
31+
Range fromCharSourceRange(const clang::SourceManager &sm, const clang::LangOptions &lang, clang::CharSourceRange csr,
3432
clang::FileID *fid = nullptr);
3533

36-
Range fromTokenRange(const clang::SourceManager &sm,
37-
const clang::LangOptions &lang, clang::SourceRange sr,
34+
Range fromTokenRange(const clang::SourceManager &sm, const clang::LangOptions &lang, clang::SourceRange sr,
3835
clang::FileID *fid = nullptr);
3936

40-
Range fromTokenRangeDefaulted(const clang::SourceManager &sm,
41-
const clang::LangOptions &lang,
42-
clang::SourceRange sr, clang::FileID fid,
43-
Range range);
37+
Range fromTokenRangeDefaulted(const clang::SourceManager &sm, const clang::LangOptions &lang, clang::SourceRange sr,
38+
clang::FileID fid, Range range);
4439

45-
std::unique_ptr<clang::CompilerInvocation>
46-
buildCompilerInvocation(const std::string &main, std::vector<const char *> args,
47-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
40+
std::unique_ptr<clang::CompilerInvocation> buildCompilerInvocation(const std::string &main,
41+
std::vector<const char *> args,
42+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
4843

4944
const char *clangBuiltinTypeName(int);
5045
} // namespace ccls

src/config.hh

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -324,42 +324,30 @@ struct Config {
324324
int maxNum = 2000;
325325
} xref;
326326
};
327-
REFLECT_STRUCT(Config::Cache, directory, format, hierarchicalPath,
328-
retainInMemory);
329-
REFLECT_STRUCT(Config::ServerCap::DocumentOnTypeFormattingOptions,
330-
firstTriggerCharacter, moreTriggerCharacter);
331-
REFLECT_STRUCT(Config::ServerCap::Workspace::WorkspaceFolders, supported,
332-
changeNotifications);
327+
REFLECT_STRUCT(Config::Cache, directory, format, hierarchicalPath, retainInMemory);
328+
REFLECT_STRUCT(Config::ServerCap::DocumentOnTypeFormattingOptions, firstTriggerCharacter, moreTriggerCharacter);
329+
REFLECT_STRUCT(Config::ServerCap::Workspace::WorkspaceFolders, supported, changeNotifications);
333330
REFLECT_STRUCT(Config::ServerCap::Workspace, workspaceFolders);
334-
REFLECT_STRUCT(Config::ServerCap, documentOnTypeFormattingProvider,
335-
foldingRangeProvider, workspace);
336-
REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, pathMappings,
337-
resourceDir);
338-
REFLECT_STRUCT(Config::ClientCapability, diagnosticsRelatedInformation,
339-
hierarchicalDocumentSymbolSupport, linkSupport, snippetSupport);
331+
REFLECT_STRUCT(Config::ServerCap, documentOnTypeFormattingProvider, foldingRangeProvider, workspace);
332+
REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, pathMappings, resourceDir);
333+
REFLECT_STRUCT(Config::ClientCapability, diagnosticsRelatedInformation, hierarchicalDocumentSymbolSupport, linkSupport,
334+
snippetSupport);
340335
REFLECT_STRUCT(Config::CodeLens, localVariables);
341-
REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize,
342-
suffixWhitelist, whitelist);
343-
REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
344-
dropOldRequests, duplicateOptional, filterAndSort, include,
345-
maxNum, placeholder);
346-
REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
347-
spellChecking, whitelist)
336+
REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize, suffixWhitelist, whitelist);
337+
REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel, dropOldRequests, duplicateOptional, filterAndSort,
338+
include, maxNum, placeholder);
339+
REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave, spellChecking, whitelist)
348340
REFLECT_STRUCT(Config::Highlight, largeFileSize, rainbow, blacklist, whitelist)
349341
REFLECT_STRUCT(Config::Index::Name, suppressUnwrittenScope);
350-
REFLECT_STRUCT(Config::Index, blacklist, comments, initialNoLinkage,
351-
initialBlacklist, initialWhitelist, maxInitializerLines,
352-
multiVersion, multiVersionBlacklist, multiVersionWhitelist, name,
353-
onChange, parametersInDeclarations, threads, trackDependency,
354-
whitelist);
342+
REFLECT_STRUCT(Config::Index, blacklist, comments, initialNoLinkage, initialBlacklist, initialWhitelist,
343+
maxInitializerLines, multiVersion, multiVersionBlacklist, multiVersionWhitelist, name, onChange,
344+
parametersInDeclarations, threads, trackDependency, whitelist);
355345
REFLECT_STRUCT(Config::Request, timeout);
356346
REFLECT_STRUCT(Config::Session, maxNum);
357347
REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort);
358348
REFLECT_STRUCT(Config::Xref, maxNum);
359-
REFLECT_STRUCT(Config, compilationDatabaseCommand, compilationDatabaseDirectory,
360-
cache, capabilities, clang, client, codeLens, completion,
361-
diagnostics, highlight, index, request, session, workspaceSymbol,
362-
xref);
349+
REFLECT_STRUCT(Config, compilationDatabaseCommand, compilationDatabaseDirectory, cache, capabilities, clang, client,
350+
codeLens, completion, diagnostics, highlight, index, request, session, workspaceSymbol, xref);
363351

364352
extern Config *g_config;
365353

src/filesystem.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ void getFilesInFolder(std::string folder, bool recursive, bool dir_prefix,
2929
std::error_code ec;
3030
std::string folder1 = curr.back();
3131
curr.pop_back();
32-
for (sys::fs::directory_iterator i(folder1, ec, false), e; i != e && !ec;
33-
i.increment(ec)) {
32+
for (sys::fs::directory_iterator i(folder1, ec, false), e; i != e && !ec; i.increment(ec)) {
3433
std::string path = i->path();
3534
std::string filename(sys::path::filename(path));
36-
if ((filename[0] == '.' && filename != ".ccls") ||
37-
sys::fs::status(path, status, false))
35+
if ((filename[0] == '.' && filename != ".ccls") || sys::fs::status(path, status, false))
3836
continue;
3937
if (sys::fs::is_symlink_file(status)) {
4038
if (sys::fs::status(path, status, true))
@@ -49,8 +47,7 @@ void getFilesInFolder(std::string folder, bool recursive, bool dir_prefix,
4947
if (!dir_prefix)
5048
path = path.substr(folder.size());
5149
handler(sys::path::convert_to_slash(path));
52-
} else if (recursive && sys::fs::is_directory(status) &&
53-
!seen.count(id = status.getUniqueID())) {
50+
} else if (recursive && sys::fs::is_directory(status) && !seen.count(id = status.getUniqueID())) {
5451
curr.push_back(path);
5552
seen.insert(id);
5653
}

src/filesystem.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@
99
#include <functional>
1010
#include <string>
1111

12-
void getFilesInFolder(std::string folder, bool recursive,
13-
bool add_folder_to_path,
12+
void getFilesInFolder(std::string folder, bool recursive, bool add_folder_to_path,
1413
const std::function<void(const std::string &)> &handler);

src/fuzzy_match.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ void calculateRoles(std::string_view s, int roles[], int *class_set) {
3232
if (cur == Other)
3333
return None;
3434
// U(U)L is Head while U(U)U is Tail
35-
return pre == Other || (cur == Upper && (pre == Lower || suc == Lower))
36-
? Head
37-
: Tail;
35+
return pre == Other || (cur == Upper && (pre == Lower || suc == Lower)) ? Head : Tail;
3836
};
3937
for (size_t i = 0; i < s.size() - 1; i++) {
4038
suc = getCharClass(s[i + 1]);
@@ -117,16 +115,12 @@ int FuzzyMatcher::match(std::string_view text, bool strict) {
117115
int(*cur)[2] = dp[(i + 1) & 1];
118116
cur[i][0] = cur[i][1] = kMinScore;
119117
for (int j = i; j < n; j++) {
120-
cur[j + 1][0] = std::max(cur[j][0] + missScore(j, false),
121-
cur[j][1] + missScore(j, true));
118+
cur[j + 1][0] = std::max(cur[j][0] + missScore(j, false), cur[j][1] + missScore(j, true));
122119
// For the first char of pattern, apply extra restriction to filter bad
123120
// candidates (e.g. |int| in |PRINT|)
124121
cur[j + 1][1] = (case_sensitivity ? pat[i] == text[j]
125-
: low_pat[i] == low_text[j] &&
126-
(i || text_role[j] != Tail ||
127-
pat[i] == text[j]))
128-
? std::max(pre[j][0] + matchScore(i, j, false),
129-
pre[j][1] + matchScore(i, j, true))
122+
: low_pat[i] == low_text[j] && (i || text_role[j] != Tail || pat[i] == text[j]))
123+
? std::max(pre[j][0] + matchScore(i, j, false), pre[j][1] + matchScore(i, j, true))
130124
: kMinScore * 2;
131125
}
132126
}

src/hierarchy.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#include <queue>
1010

1111
namespace ccls {
12-
template <typename Node>
13-
std::vector<Location> flattenHierarchy(const std::optional<Node> &root) {
12+
template <typename Node> std::vector<Location> flattenHierarchy(const std::optional<Node> &root) {
1413
if (!root)
1514
return {};
1615
std::vector<Location> ret;

0 commit comments

Comments
 (0)