mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 12:35:56 +01:00
Note namespace and static recommendations in C++ style guide (#1041)
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#include "executable_semantics/ast/statement.h"
|
||||
#include "executable_semantics/common/arena.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Carbon::Testing {
|
||||
namespace {
|
||||
|
||||
using ::testing::_;
|
||||
@@ -159,4 +159,4 @@ TEST(ASTDeclarationsTest, BasicUsage) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "executable_semantics/common/arena.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Carbon::Testing {
|
||||
namespace {
|
||||
|
||||
using llvm::cast;
|
||||
@@ -135,4 +135,4 @@ TEST_F(ExpressionTest, BinaryAsTuple) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "executable_semantics/common/arena.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Carbon::Testing {
|
||||
namespace {
|
||||
|
||||
using llvm::cast;
|
||||
@@ -129,4 +129,4 @@ TEST_F(PatternTest, BinaryAsTuplePattern) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace Carbon {
|
||||
namespace Carbon::Testing {
|
||||
namespace {
|
||||
|
||||
TEST(ErrorTest, FatalProgramError) {
|
||||
@@ -30,4 +30,4 @@ TEST(ErrorTest, FatalProgramErrorLine) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
@@ -27,10 +27,8 @@ auto StructValue::FindField(const std::string& name) const
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
auto GetMember(Nonnull<Arena*> arena, Nonnull<const Value*> v,
|
||||
const std::string& f, SourceLocation source_loc)
|
||||
static auto GetMember(Nonnull<Arena*> arena, Nonnull<const Value*> v,
|
||||
const std::string& f, SourceLocation source_loc)
|
||||
-> Nonnull<const Value*> {
|
||||
switch (v->kind()) {
|
||||
case Value::Kind::StructValue: {
|
||||
@@ -62,8 +60,6 @@ auto GetMember(Nonnull<Arena*> arena, Nonnull<const Value*> v,
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
auto Value::GetField(Nonnull<Arena*> arena, const FieldPath& path,
|
||||
SourceLocation source_loc) const -> Nonnull<const Value*> {
|
||||
Nonnull<const Value*> value(this);
|
||||
@@ -73,13 +69,11 @@ auto Value::GetField(Nonnull<Arena*> arena, const FieldPath& path,
|
||||
return value;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
auto SetFieldImpl(Nonnull<Arena*> arena, Nonnull<const Value*> value,
|
||||
std::vector<std::string>::const_iterator path_begin,
|
||||
std::vector<std::string>::const_iterator path_end,
|
||||
Nonnull<const Value*> field_value, SourceLocation source_loc)
|
||||
-> Nonnull<const Value*> {
|
||||
static auto SetFieldImpl(Nonnull<Arena*> arena, Nonnull<const Value*> value,
|
||||
std::vector<std::string>::const_iterator path_begin,
|
||||
std::vector<std::string>::const_iterator path_end,
|
||||
Nonnull<const Value*> field_value,
|
||||
SourceLocation source_loc) -> Nonnull<const Value*> {
|
||||
if (path_begin == path_end) {
|
||||
return field_value;
|
||||
}
|
||||
@@ -120,8 +114,6 @@ auto SetFieldImpl(Nonnull<Arena*> arena, Nonnull<const Value*> value,
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
auto Value::SetField(Nonnull<Arena*> arena, const FieldPath& path,
|
||||
Nonnull<const Value*> field_value,
|
||||
SourceLocation source_loc) const -> Nonnull<const Value*> {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "executable_semantics/common/arena.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Carbon::Testing {
|
||||
namespace {
|
||||
|
||||
static constexpr std::string_view FileContents = R"(
|
||||
@@ -30,4 +30,4 @@ TEST(ParseTest, ParseFromString) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "executable_semantics/syntax/parse.h"
|
||||
#include "executable_semantics/syntax/parse_test_matchers.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Carbon::Testing {
|
||||
namespace {
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
@@ -33,4 +33,4 @@ TEST(UnimplementedExampleTest, VerifyPrecedence) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
Reference in New Issue
Block a user