-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[clangd][NFC] added const and constexpr to HeaderSourceSwitch #143193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clangd Author: Jouni (JohnFinn) ChangesFull diff: https://github.com/llvm/llvm-project/pull/143193.diff 1 Files Affected:
diff --git a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
index d54c3668570eb..ee4bea1401490 100644
--- a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
+++ b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
@@ -20,22 +20,24 @@ namespace clangd {
std::optional<Path> getCorrespondingHeaderOrSource(
PathRef OriginalFile, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
- llvm::StringRef SourceExtensions[] = {".cpp", ".c", ".cc", ".cxx",
- ".c++", ".m", ".mm"};
- llvm::StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx",
- ".inc", ".cppm", ".ccm", ".cxxm",
- ".c++m", ".ixx"};
+ static constexpr llvm::StringRef SourceExtensions[] = {
+ ".cpp", ".c", ".cc", ".cxx", ".c++", ".m", ".mm"};
+ static constexpr llvm::StringRef HeaderExtensions[] = {
+ ".h", ".hh", ".hpp", ".hxx", ".inc",
+ ".cppm", ".ccm", ".cxxm", ".c++m", ".ixx"};
llvm::StringRef PathExt = llvm::sys::path::extension(OriginalFile);
// Lookup in a list of known extensions.
- bool IsSource = llvm::any_of(SourceExtensions, [&PathExt](PathRef SourceExt) {
- return SourceExt.equals_insensitive(PathExt);
- });
+ const bool IsSource =
+ llvm::any_of(SourceExtensions, [&PathExt](PathRef SourceExt) {
+ return SourceExt.equals_insensitive(PathExt);
+ });
- bool IsHeader = llvm::any_of(HeaderExtensions, [&PathExt](PathRef HeaderExt) {
- return HeaderExt.equals_insensitive(PathExt);
- });
+ const bool IsHeader =
+ llvm::any_of(HeaderExtensions, [&PathExt](PathRef HeaderExt) {
+ return HeaderExt.equals_insensitive(PathExt);
+ });
// We can only switch between the known extensions.
if (!IsSource && !IsHeader)
@@ -94,7 +96,7 @@ std::optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
//
// For each symbol in the original file, we get its target location (decl or
// def) from the index, then award that target file.
- bool IsHeader = isHeaderFile(OriginalFile, AST.getLangOpts());
+ const bool IsHeader = isHeaderFile(OriginalFile, AST.getLangOpts());
Index->lookup(Request, [&](const Symbol &Sym) {
if (IsHeader)
AwardTarget(Sym.Definition.FileURI);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch LGTM, but it may have to be approved by one of clangd's maintainers that I added.
You should also add NFC
in the title if you have non-functional changes (I already did it this time).
No description provided.