Skip to content
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

modern-concat-nested-namespaces does not warn on header files #41015

Closed
llvmbot opened this issue Apr 30, 2019 · 2 comments
Closed

modern-concat-nested-namespaces does not warn on header files #41015

llvmbot opened this issue Apr 30, 2019 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang-tidy worksforme Resolved as "works for me"

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 30, 2019

Bugzilla Link 41670
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

For header files that pass the -header-filter, the modernize-concat-nested-namespaces check does not generate the expected warning and fix for un-concatenated namespaces.

E.g.,
====a.h===
#pragma once
namespace foo {
namespace bar {
namespace baz {
struct S {};
}
}
}

====a.cpp====
#include "a.h"

namespace foo {
namespace bar {
namespace baz {
void foo(const S&) {}
}
}
}

int main () {
return 0;
}

Running the following command only generates fixes for a.cpp, not the instance in a.h:
clang-tidy -checks="modernize-concat-nested-namespaces" -p path/to/compilation_database.json -header-filter="a.h" -fix-errors a.cpp

If instead, I pass a.h as the last argument, clang-tidy does generate fixes for the header.

I suspect this is due to the early return here:
https://github.com/llvm-mirror/clang-tools-extra/blob/e5a800d6f7b093471c7bb509dfcc3713ef01caf8/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp#L88

Perhaps we should only return if the location is not in the main file and if it's not a header.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 16, 2019

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@carlosgalvezp
Copy link
Contributor

Fixed on latest trunk

@carlosgalvezp carlosgalvezp closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2023
@EugeneZelenko EugeneZelenko added the worksforme Resolved as "works for me" label Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-tidy worksforme Resolved as "works for me"
Projects
None yet
Development

No branches or pull requests

3 participants