mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 09:35:02 +01:00
Enable misc-non-private-member-variables-in-classes and adjust style to match (#4702)
Pursuant to discussion regarding #4699, turn on `misc-non-private-member-variables-in-classes` using the `IgnoreClassesWithAllMemberVariablesBeingPublic` flag (the check treats structs as classes, so we need this for structs with all-public members). Updates the style guide notes to match, which should be pretty minor due to the scoping of test fixtures. Also fixes some underscore uses in test files on the way. Basically this is keeping the style for [class data member naming](https://google.github.io/styleguide/cppguide.html#Variable_Names) even while making them public.
This commit is contained in:
@@ -19,25 +19,25 @@ namespace Carbon::Testing {
|
||||
template <typename MatcherFactoryType>
|
||||
class MatcherTestBase : public ::testing::Test {
|
||||
protected:
|
||||
MatcherTestBase() : matchers(&replacements) {
|
||||
matchers.Register(std::make_unique<MatcherFactoryType>());
|
||||
MatcherTestBase() : matchers_(&replacements_) {
|
||||
matchers_.Register(std::make_unique<MatcherFactoryType>());
|
||||
}
|
||||
|
||||
// Expects that the replacements produced by running the finder result in
|
||||
// the specified code transformation.
|
||||
void ExpectReplacement(llvm::StringRef before, llvm::StringRef after) {
|
||||
auto factory =
|
||||
clang::tooling::newFrontendActionFactory(matchers.GetFinder());
|
||||
clang::tooling::newFrontendActionFactory(matchers_.GetFinder());
|
||||
constexpr char Filename[] = "test.cc";
|
||||
replacements.clear();
|
||||
replacements.insert({Filename, {}});
|
||||
replacements_.clear();
|
||||
replacements_.insert({Filename, {}});
|
||||
ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
|
||||
factory->create(), before, {}, Filename, "clang-tool",
|
||||
std::make_shared<clang::PCHContainerOperations>(),
|
||||
clang::tooling::FileContentMappings()));
|
||||
EXPECT_THAT(replacements, testing::ElementsAre(testing::Key(Filename)));
|
||||
EXPECT_THAT(replacements_, testing::ElementsAre(testing::Key(Filename)));
|
||||
llvm::Expected<std::string> actual =
|
||||
clang::tooling::applyAllReplacements(before, replacements[Filename]);
|
||||
clang::tooling::applyAllReplacements(before, replacements_[Filename]);
|
||||
|
||||
// Make a specific note if the matcher didn't make any changes.
|
||||
std::string unchanged;
|
||||
@@ -57,8 +57,9 @@ class MatcherTestBase : public ::testing::Test {
|
||||
}
|
||||
}
|
||||
|
||||
Matcher::ReplacementMap replacements;
|
||||
MatcherManager matchers;
|
||||
private:
|
||||
Matcher::ReplacementMap replacements_;
|
||||
MatcherManager matchers_;
|
||||
};
|
||||
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
Reference in New Issue
Block a user