@@ -20,22 +20,24 @@ namespace clangd {
20
20
21
21
std::optional<Path> getCorrespondingHeaderOrSource (
22
22
PathRef OriginalFile, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
23
- llvm::StringRef SourceExtensions[] = {" .cpp " , " .c " , " .cc " , " .cxx " ,
24
- " .c++" , " .m" , " .mm" };
25
- llvm::StringRef HeaderExtensions[] = {" .h " , " .hh " , " .hpp " , " .hxx " ,
26
- " .inc " , " .cppm " , " .ccm " , " .cxxm " ,
27
- " .c++m" , " .ixx" };
23
+ static constexpr llvm::StringRef SourceExtensions[] = {
24
+ " .cpp " , " .c " , " .cc " , " .cxx " , " .c++" , " .m" , " .mm" };
25
+ static constexpr llvm::StringRef HeaderExtensions[] = {
26
+ " .h " , " .hh " , " .hpp " , " .hxx " , " .inc " ,
27
+ " .cppm " , " .ccm " , " .cxxm " , " .c++m" , " .ixx" };
28
28
29
29
llvm::StringRef PathExt = llvm::sys::path::extension (OriginalFile);
30
30
31
31
// Lookup in a list of known extensions.
32
- bool IsSource = llvm::any_of (SourceExtensions, [&PathExt](PathRef SourceExt) {
33
- return SourceExt.equals_insensitive (PathExt);
34
- });
32
+ const bool IsSource =
33
+ llvm::any_of (SourceExtensions, [&PathExt](PathRef SourceExt) {
34
+ return SourceExt.equals_insensitive (PathExt);
35
+ });
35
36
36
- bool IsHeader = llvm::any_of (HeaderExtensions, [&PathExt](PathRef HeaderExt) {
37
- return HeaderExt.equals_insensitive (PathExt);
38
- });
37
+ const bool IsHeader =
38
+ llvm::any_of (HeaderExtensions, [&PathExt](PathRef HeaderExt) {
39
+ return HeaderExt.equals_insensitive (PathExt);
40
+ });
39
41
40
42
// We can only switch between the known extensions.
41
43
if (!IsSource && !IsHeader)
@@ -94,7 +96,7 @@ std::optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
94
96
//
95
97
// For each symbol in the original file, we get its target ___location (decl or
96
98
// def) from the index, then award that target file.
97
- bool IsHeader = isHeaderFile (OriginalFile, AST.getLangOpts ());
99
+ const bool IsHeader = isHeaderFile (OriginalFile, AST.getLangOpts ());
98
100
Index->lookup (Request, [&](const Symbol &Sym) {
99
101
if (IsHeader)
100
102
AwardTarget (Sym.Definition .FileURI );
0 commit comments