@@ -20,22 +20,24 @@ namespace clangd {
2020
2121std::optional<Path> getCorrespondingHeaderOrSource (
2222 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" };
2828
2929 llvm::StringRef PathExt = llvm::sys::path::extension (OriginalFile);
3030
3131 // 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+ });
3536
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+ });
3941
4042 // We can only switch between the known extensions.
4143 if (!IsSource && !IsHeader)
@@ -94,7 +96,7 @@ std::optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
9496 //
9597 // For each symbol in the original file, we get its target location (decl or
9698 // def) from the index, then award that target file.
97- bool IsHeader = isHeaderFile (OriginalFile, AST.getLangOpts ());
99+ const bool IsHeader = isHeaderFile (OriginalFile, AST.getLangOpts ());
98100 Index->lookup (Request, [&](const Symbol &Sym) {
99101 if (IsHeader)
100102 AwardTarget (Sym.Definition .FileURI );
0 commit comments