Skip to content

Commit 61a1071

Browse files
committed
💥 Rename FunctionName -> functionName, VarName -> var_name
1 parent 62fbde7 commit 61a1071

Some content is hidden

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

62 files changed

+2999
-2984
lines changed

src/clang_tu.cc

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -14,99 +14,99 @@
1414
using namespace clang;
1515

1616
namespace ccls {
17-
std::string PathFromFileEntry(const FileEntry &file) {
18-
StringRef Name = file.tryGetRealPathName();
19-
if (Name.empty())
20-
Name = file.getName();
21-
std::string ret = NormalizePath(Name);
17+
std::string pathFromFileEntry(const FileEntry &file) {
18+
StringRef name = file.tryGetRealPathName();
19+
if (name.empty())
20+
name = file.getName();
21+
std::string ret = normalizePath(name);
2222
// Resolve symlinks outside of workspace folders, e.g. /usr/include/c++/7.3.0
23-
return NormalizeFolder(ret) ? ret : RealPath(ret);
23+
return normalizeFolder(ret) ? ret : realPath(ret);
2424
}
2525

26-
static Pos Decomposed2LineAndCol(const SourceManager &SM,
27-
std::pair<FileID, unsigned> I) {
28-
int l = (int)SM.getLineNumber(I.first, I.second) - 1,
29-
c = (int)SM.getColumnNumber(I.first, I.second) - 1;
30-
bool Invalid = false;
31-
StringRef Buf = SM.getBufferData(I.first, &Invalid);
32-
if (!Invalid) {
33-
StringRef P = Buf.substr(I.second - c, c);
26+
static Pos decomposed2LineAndCol(const SourceManager &sm,
27+
std::pair<FileID, unsigned> i) {
28+
int l = (int)sm.getLineNumber(i.first, i.second) - 1,
29+
c = (int)sm.getColumnNumber(i.first, i.second) - 1;
30+
bool invalid = false;
31+
StringRef buf = sm.getBufferData(i.first, &invalid);
32+
if (!invalid) {
33+
StringRef p = buf.substr(i.second - c, c);
3434
c = 0;
35-
for (size_t i = 0; i < P.size(); )
36-
if (c++, (uint8_t)P[i++] >= 128)
37-
while (i < P.size() && (uint8_t)P[i] >= 128 && (uint8_t)P[i] < 192)
35+
for (size_t i = 0; i < p.size();)
36+
if (c++, (uint8_t)p[i++] >= 128)
37+
while (i < p.size() && (uint8_t)p[i] >= 128 && (uint8_t)p[i] < 192)
3838
i++;
3939
}
4040
return {(uint16_t)std::min<int>(l, UINT16_MAX),
4141
(int16_t)std::min<int>(c, INT16_MAX)};
4242
}
4343

44-
Range FromCharSourceRange(const SourceManager &SM, const LangOptions &LangOpts,
45-
CharSourceRange R,
46-
llvm::sys::fs::UniqueID *UniqueID) {
47-
SourceLocation BLoc = R.getBegin(), ELoc = R.getEnd();
48-
std::pair<FileID, unsigned> BInfo = SM.getDecomposedLoc(BLoc),
49-
EInfo = SM.getDecomposedLoc(ELoc);
50-
if (R.isTokenRange())
51-
EInfo.second += Lexer::MeasureTokenLength(ELoc, SM, LangOpts);
52-
if (UniqueID) {
53-
if (const FileEntry *F = SM.getFileEntryForID(BInfo.first))
54-
*UniqueID = F->getUniqueID();
44+
Range fromCharSourceRange(const SourceManager &sm, const LangOptions &lang,
45+
CharSourceRange csr,
46+
llvm::sys::fs::UniqueID *uniqueID) {
47+
SourceLocation bloc = csr.getBegin(), eloc = csr.getEnd();
48+
std::pair<FileID, unsigned> binfo = sm.getDecomposedLoc(bloc),
49+
einfo = sm.getDecomposedLoc(eloc);
50+
if (csr.isTokenRange())
51+
einfo.second += Lexer::MeasureTokenLength(eloc, sm, lang);
52+
if (uniqueID) {
53+
if (const FileEntry *F = sm.getFileEntryForID(binfo.first))
54+
*uniqueID = F->getUniqueID();
5555
else
56-
*UniqueID = llvm::sys::fs::UniqueID(0, 0);
56+
*uniqueID = llvm::sys::fs::UniqueID(0, 0);
5757
}
58-
return {Decomposed2LineAndCol(SM, BInfo), Decomposed2LineAndCol(SM, EInfo)};
58+
return {decomposed2LineAndCol(sm, binfo), decomposed2LineAndCol(sm, einfo)};
5959
}
6060

61-
Range FromCharRange(const SourceManager &SM, const LangOptions &Lang,
62-
SourceRange R, llvm::sys::fs::UniqueID *UniqueID) {
63-
return FromCharSourceRange(SM, Lang, CharSourceRange::getCharRange(R),
64-
UniqueID);
61+
Range fromCharRange(const SourceManager &sm, const LangOptions &lang,
62+
SourceRange sr, llvm::sys::fs::UniqueID *uniqueID) {
63+
return fromCharSourceRange(sm, lang, CharSourceRange::getCharRange(sr),
64+
uniqueID);
6565
}
6666

67-
Range FromTokenRange(const SourceManager &SM, const LangOptions &Lang,
68-
SourceRange R, llvm::sys::fs::UniqueID *UniqueID) {
69-
return FromCharSourceRange(SM, Lang, CharSourceRange::getTokenRange(R),
70-
UniqueID);
67+
Range fromTokenRange(const SourceManager &sm, const LangOptions &lang,
68+
SourceRange sr, llvm::sys::fs::UniqueID *uniqueID) {
69+
return fromCharSourceRange(sm, lang, CharSourceRange::getTokenRange(sr),
70+
uniqueID);
7171
}
7272

73-
Range FromTokenRangeDefaulted(const SourceManager &SM, const LangOptions &Lang,
74-
SourceRange R, const FileEntry *FE, Range range) {
75-
auto I = SM.getDecomposedLoc(SM.getExpansionLoc(R.getBegin()));
76-
if (SM.getFileEntryForID(I.first) == FE)
77-
range.start = Decomposed2LineAndCol(SM, I);
78-
SourceLocation L = SM.getExpansionLoc(R.getEnd());
79-
I = SM.getDecomposedLoc(L);
80-
if (SM.getFileEntryForID(I.first) == FE) {
81-
I.second += Lexer::MeasureTokenLength(L, SM, Lang);
82-
range.end = Decomposed2LineAndCol(SM, I);
73+
Range fromTokenRangeDefaulted(const SourceManager &sm, const LangOptions &lang,
74+
SourceRange sr, const FileEntry *fe, Range range) {
75+
auto decomposed = sm.getDecomposedLoc(sm.getExpansionLoc(sr.getBegin()));
76+
if (sm.getFileEntryForID(decomposed.first) == fe)
77+
range.start = decomposed2LineAndCol(sm, decomposed);
78+
SourceLocation sl = sm.getExpansionLoc(sr.getEnd());
79+
decomposed = sm.getDecomposedLoc(sl);
80+
if (sm.getFileEntryForID(decomposed.first) == fe) {
81+
decomposed.second += Lexer::MeasureTokenLength(sl, sm, lang);
82+
range.end = decomposed2LineAndCol(sm, decomposed);
8383
}
8484
return range;
8585
}
8686

8787
std::unique_ptr<CompilerInvocation>
88-
BuildCompilerInvocation(const std::string &main, std::vector<const char *> args,
89-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
88+
buildCompilerInvocation(const std::string &main, std::vector<const char *> args,
89+
IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs) {
9090
std::string save = "-resource-dir=" + g_config->clang.resourceDir;
9191
args.push_back(save.c_str());
92-
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
92+
IntrusiveRefCntPtr<DiagnosticsEngine> diags(
9393
CompilerInstance::createDiagnostics(new DiagnosticOptions,
9494
new IgnoringDiagConsumer, true));
95-
std::unique_ptr<CompilerInvocation> CI =
96-
createInvocationFromCommandLine(args, Diags, VFS);
97-
if (CI) {
98-
CI->getDiagnosticOpts().IgnoreWarnings = true;
99-
CI->getFrontendOpts().DisableFree = false;
100-
CI->getLangOpts()->SpellChecking = false;
101-
auto &IS = CI->getFrontendOpts().Inputs;
102-
if (IS.size())
103-
IS[0] = FrontendInputFile(main, IS[0].getKind(), IS[0].isSystem());
95+
std::unique_ptr<CompilerInvocation> ci =
96+
createInvocationFromCommandLine(args, diags, vfs);
97+
if (ci) {
98+
ci->getDiagnosticOpts().IgnoreWarnings = true;
99+
ci->getFrontendOpts().DisableFree = false;
100+
ci->getLangOpts()->SpellChecking = false;
101+
auto &isec = ci->getFrontendOpts().Inputs;
102+
if (isec.size())
103+
isec[0] = FrontendInputFile(main, isec[0].getKind(), isec[0].isSystem());
104104
}
105-
return CI;
105+
return ci;
106106
}
107107

108108
// clang::BuiltinType::getName without PrintingPolicy
109-
const char *ClangBuiltinTypeName(int kind) {
109+
const char *clangBuiltinTypeName(int kind) {
110110
switch (BuiltinType::Kind(kind)) {
111111
case BuiltinType::Void:
112112
return "void";

src/clang_tu.hh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
#include "position.hh"
77

8-
#include <clang/Basic/LangOptions.h>
98
#include <clang/Basic/FileManager.h>
9+
#include <clang/Basic/LangOptions.h>
1010
#include <clang/Basic/SourceManager.h>
1111
#include <clang/Frontend/CompilerInstance.h>
1212

@@ -18,30 +18,29 @@ namespace vfs = clang::vfs;
1818
#endif
1919

2020
namespace ccls {
21-
std::string PathFromFileEntry(const clang::FileEntry &file);
21+
std::string pathFromFileEntry(const clang::FileEntry &file);
2222

23-
Range FromCharSourceRange(const clang::SourceManager &SM,
24-
const clang::LangOptions &LangOpts,
25-
clang::CharSourceRange R,
26-
llvm::sys::fs::UniqueID *UniqueID = nullptr);
23+
Range fromCharSourceRange(const clang::SourceManager &sm,
24+
const clang::LangOptions &lang,
25+
clang::CharSourceRange sr,
26+
llvm::sys::fs::UniqueID *uniqueID = nullptr);
2727

28-
Range FromCharRange(const clang::SourceManager &SM,
29-
const clang::LangOptions &LangOpts, clang::SourceRange R,
30-
llvm::sys::fs::UniqueID *UniqueID = nullptr);
28+
Range fromCharRange(const clang::SourceManager &sm,
29+
const clang::LangOptions &lang, clang::SourceRange sr,
30+
llvm::sys::fs::UniqueID *uniqueID = nullptr);
3131

32-
Range FromTokenRange(const clang::SourceManager &SM,
33-
const clang::LangOptions &LangOpts, clang::SourceRange R,
34-
llvm::sys::fs::UniqueID *UniqueID = nullptr);
32+
Range fromTokenRange(const clang::SourceManager &sm,
33+
const clang::LangOptions &lang, clang::SourceRange sr,
34+
llvm::sys::fs::UniqueID *uniqueID = nullptr);
3535

36-
Range FromTokenRangeDefaulted(const clang::SourceManager &SM,
37-
const clang::LangOptions &Lang,
38-
clang::SourceRange R, const clang::FileEntry *FE,
36+
Range fromTokenRangeDefaulted(const clang::SourceManager &sm,
37+
const clang::LangOptions &lang,
38+
clang::SourceRange sr, const clang::FileEntry *fe,
3939
Range range);
4040

4141
std::unique_ptr<clang::CompilerInvocation>
42-
BuildCompilerInvocation(const std::string &main,
43-
std::vector<const char *> args,
42+
buildCompilerInvocation(const std::string &main, std::vector<const char *> args,
4443
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
4544

46-
const char *ClangBuiltinTypeName(int);
45+
const char *clangBuiltinTypeName(int);
4746
} // namespace ccls

src/config.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace ccls {
77
Config *g_config;
88

9-
void DoPathMapping(std::string &arg) {
9+
void doPathMapping(std::string &arg) {
1010
for (const std::string &mapping : g_config->clang.pathMappings) {
1111
auto sep = mapping.find('>');
1212
if (sep != std::string::npos) {
@@ -16,4 +16,4 @@ void DoPathMapping(std::string &arg) {
1616
}
1717
}
1818
}
19-
}
19+
} // namespace ccls

src/config.hh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ struct Config {
256256
// lines, include the initializer in detailed_name.
257257
int maxInitializerLines = 5;
258258

259-
// If not 0, a file will be indexed in each tranlation unit that includes it.
259+
// If not 0, a file will be indexed in each tranlation unit that includes
260+
// it.
260261
int multiVersion = 0;
261262

262263
// If multiVersion != 0, files that match blacklist but not whitelist will
@@ -351,5 +352,5 @@ REFLECT_STRUCT(Config, compilationDatabaseCommand, compilationDatabaseDirectory,
351352

352353
extern Config *g_config;
353354

354-
void DoPathMapping(std::string &arg);
355-
}
355+
void doPathMapping(std::string &arg);
356+
} // namespace ccls

src/filesystem.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ using namespace llvm;
99
#include <set>
1010
#include <vector>
1111

12-
void GetFilesInFolder(std::string folder, bool recursive, bool dir_prefix,
12+
void getFilesInFolder(std::string folder, bool recursive, bool dir_prefix,
1313
const std::function<void(const std::string &)> &handler) {
14-
ccls::EnsureEndsInSlash(folder);
15-
sys::fs::file_status Status;
16-
if (sys::fs::status(folder, Status, true))
14+
ccls::ensureEndsInSlash(folder);
15+
sys::fs::file_status status;
16+
if (sys::fs::status(folder, status, true))
1717
return;
18-
sys::fs::UniqueID ID;
18+
sys::fs::UniqueID id;
1919
std::vector<std::string> curr{folder};
2020
std::vector<std::pair<std::string, sys::fs::file_status>> succ;
21-
std::set<sys::fs::UniqueID> seen{Status.getUniqueID()};
21+
std::set<sys::fs::UniqueID> seen{status.getUniqueID()};
2222
while (curr.size() || succ.size()) {
2323
if (curr.empty()) {
2424
for (auto &it : succ)
@@ -29,29 +29,29 @@ 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)) {
34-
std::string path = I->path(), filename = sys::path::filename(path);
32+
for (sys::fs::directory_iterator i(folder1, ec, false), e; i != e && !ec;
33+
i.increment(ec)) {
34+
std::string path = i->path(), filename = sys::path::filename(path);
3535
if ((filename[0] == '.' && filename != ".ccls") ||
36-
sys::fs::status(path, Status, false))
36+
sys::fs::status(path, status, false))
3737
continue;
38-
if (sys::fs::is_symlink_file(Status)) {
39-
if (sys::fs::status(path, Status, true))
38+
if (sys::fs::is_symlink_file(status)) {
39+
if (sys::fs::status(path, status, true))
4040
continue;
41-
if (sys::fs::is_directory(Status)) {
41+
if (sys::fs::is_directory(status)) {
4242
if (recursive)
43-
succ.emplace_back(path, Status);
43+
succ.emplace_back(path, status);
4444
continue;
4545
}
4646
}
47-
if (sys::fs::is_regular_file(Status)) {
47+
if (sys::fs::is_regular_file(status)) {
4848
if (!dir_prefix)
4949
path = path.substr(folder.size());
5050
handler(sys::path::convert_to_slash(path));
51-
} else if (recursive && sys::fs::is_directory(Status) &&
52-
!seen.count(ID = Status.getUniqueID())) {
51+
} else if (recursive && sys::fs::is_directory(status) &&
52+
!seen.count(id = status.getUniqueID())) {
5353
curr.push_back(path);
54-
seen.insert(ID);
54+
seen.insert(id);
5555
}
5656
}
5757
}

src/filesystem.hh

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

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

0 commit comments

Comments
 (0)