From 7f0bc2ee9098cc76fe4afed22a3a2adc63a5dd96 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sun, 16 Feb 2025 08:51:37 -0800 Subject: [PATCH] Be a bit more explicit with internal and external linkage. There are a bunch of functions only really used locally, so make them explicitly static (or put in anonymous namespace). Functiont that are not in header files but are used externally (typically in their corresponding tests): mark explicitly extern. (Hat-tip to new clang-tidy check `[misc-use-internal-linkage]`) --- .../analysis/matcher/inner-match-handlers.cc | 2 ++ verible/common/formatting/align.cc | 15 ++++++++------- verible/common/lsp/dummy-ls.cc | 2 +- verible/common/lsp/jcxxgen.cc | 13 +++++++------ verible/common/lsp/lsp-file-utils_test.cc | 4 ++-- verible/common/strings/diff_test.cc | 16 ++-------------- verible/common/text/text-structure.cc | 2 +- verible/common/text/text-structure_test.cc | 6 +++--- verible/verilog/CST/module.cc | 2 +- verible/verilog/CST/statement.cc | 14 +++++++------- verible/verilog/CST/type.cc | 2 +- .../analysis/verilog-linter-configuration.cc | 2 +- verible/verilog/formatting/align.cc | 13 +++++++------ verible/verilog/formatting/formatter.cc | 7 ++++--- verible/verilog/formatting/formatter_test.cc | 6 +++--- verible/verilog/formatting/token-annotator.cc | 10 +++++----- verible/verilog/formatting/tree-unwrapper.cc | 11 ++++++----- verible/verilog/tools/diff/verilog-diff.cc | 7 ++++--- .../verilog/tools/formatter/verilog-format.cc | 6 +++--- .../tools/kythe/indexing-facts-tree-extractor.cc | 6 +++--- verible/verilog/tools/lint/verilog-lint.cc | 8 ++++---- verible/verilog/tools/ls/symbol-table-handler.cc | 2 +- 22 files changed, 76 insertions(+), 80 deletions(-) diff --git a/verible/common/analysis/matcher/inner-match-handlers.cc b/verible/common/analysis/matcher/inner-match-handlers.cc index 776adadcd..f07b6b2be 100644 --- a/verible/common/analysis/matcher/inner-match-handlers.cc +++ b/verible/common/analysis/matcher/inner-match-handlers.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "verible/common/analysis/matcher/inner-match-handlers.h" + #include #include "verible/common/analysis/matcher/bound-symbol-manager.h" diff --git a/verible/common/formatting/align.cc b/verible/common/formatting/align.cc index 6f69ef39f..7f9ceb089 100644 --- a/verible/common/formatting/align.cc +++ b/verible/common/formatting/align.cc @@ -132,7 +132,8 @@ struct AlignmentCell { using AlignmentRow = VectorTree; using AlignmentMatrix = std::vector; -std::ostream &operator<<(std::ostream &stream, const AlignmentCell &cell) { +static std::ostream &operator<<(std::ostream &stream, + const AlignmentCell &cell) { if (!cell.tokens.empty()) { // See UnwrappedLine::AsCode for similar printing. stream << absl::StrJoin(cell.tokens, " ", @@ -480,8 +481,8 @@ static std::pair GetColumnDataCellLabel( return {label.str(), node.Value().properties.flush_left ? '<' : '>'}; } -std::ostream &operator<<(std::ostream &stream, - const VectorTree &tree) { +static std::ostream &operator<<(std::ostream &stream, + const VectorTree &tree) { ColumnsTreeFormatter( stream, tree, GetColumnDataCellLabel); return stream; @@ -493,8 +494,8 @@ std::ostream &operator<<(std::ostream &stream, const ColumnPositionTree &tree) { return stream; } -std::ostream &operator<<(std::ostream &stream, - const VectorTree &tree) { +static std::ostream &operator<<(std::ostream &stream, + const VectorTree &tree) { ColumnsTreeFormatter( stream, tree, [](const VectorTree &node) @@ -515,8 +516,8 @@ std::ostream &operator<<(std::ostream &stream, return stream; } -std::ostream &operator<<(std::ostream &stream, - const VectorTree &tree) { +static std::ostream &operator<<( + std::ostream &stream, const VectorTree &tree) { ColumnsTreeFormatter( stream, tree, [](const VectorTree &node) { const auto &cell = node.Value(); diff --git a/verible/common/lsp/dummy-ls.cc b/verible/common/lsp/dummy-ls.cc index 95d8c76a4..1f9b42470 100644 --- a/verible/common/lsp/dummy-ls.cc +++ b/verible/common/lsp/dummy-ls.cc @@ -44,7 +44,7 @@ using verible::lsp::JsonRpcDispatcher; using verible::lsp::MessageStreamSplitter; // The "initialize" method requests server capabilities. -InitializeResult InitializeServer(const nlohmann::json ¶ms) { +static InitializeResult InitializeServer(const nlohmann::json ¶ms) { // Ignore passed client capabilities from params right now, // just announce what we do. InitializeResult result; diff --git a/verible/common/lsp/jcxxgen.cc b/verible/common/lsp/jcxxgen.cc index fe08e47e5..87bd9ec49 100644 --- a/verible/common/lsp/jcxxgen.cc +++ b/verible/common/lsp/jcxxgen.cc @@ -37,6 +37,7 @@ ABSL_FLAG(std::string, json_header, "\"nlohmann/json.hpp\"", "Include path to json.hpp including brackets <> or quotes \"\" " "around."); +namespace { // Interface. Currently private, but could be moved to a header if needed. struct Location { const char *filename; @@ -89,13 +90,11 @@ struct ObjectType { using ObjectTypeVector = std::vector; -static bool contains(const std::string &s, char c) { - return absl::StrContains(s, c); -} +bool contains(const std::string &s, char c) { return absl::StrContains(s, c); } // Returns if successful. -static bool ParseObjectTypesFromFile(const std::string &filename, - ObjectTypeVector *parsed_out) { +bool ParseObjectTypesFromFile(const std::string &filename, + ObjectTypeVector *parsed_out) { static const RE2 emptyline_or_comment_re("^[ \t]*(#.*)?"); static const RE2 toplevel_object_re("^([a-zA-Z0-9_]+):"); @@ -150,7 +149,7 @@ static bool ParseObjectTypesFromFile(const std::string &filename, } // Validate types and return if successful. -static bool ValidateTypes(ObjectTypeVector *object_types) { +bool ValidateTypes(ObjectTypeVector *object_types) { absl::flat_hash_map typeByName; for (auto &obj : *object_types) { @@ -357,6 +356,7 @@ void GenerateCode(const std::string &filename, fprintf(out, "} // %s\n", gen_namespace.c_str()); } } +} // namespace int main(int argc, char *argv[]) { const auto usage = @@ -386,4 +386,5 @@ int main(int argc, char *argv[]) { GenerateCode(schema_filename, absl::GetFlag(FLAGS_json_header), absl::GetFlag(FLAGS_class_namespace), *objects, out); + fclose(out); } diff --git a/verible/common/lsp/lsp-file-utils_test.cc b/verible/common/lsp/lsp-file-utils_test.cc index 9372dcdcf..d15cf90f1 100644 --- a/verible/common/lsp/lsp-file-utils_test.cc +++ b/verible/common/lsp/lsp-file-utils_test.cc @@ -23,7 +23,7 @@ namespace verible { namespace lsp { -std::string PathPrefix(const std::string &path) { +static std::string PathPrefix(const std::string &path) { #ifdef _WIN32 return absl::StrCat("y:/", path); #else @@ -31,7 +31,7 @@ std::string PathPrefix(const std::string &path) { #endif } -std::string URIPrefix(const std::string &path) { +static std::string URIPrefix(const std::string &path) { #ifdef _WIN32 return absl::StrCat("file:///y%3a/", path); #else diff --git a/verible/common/strings/diff_test.cc b/verible/common/strings/diff_test.cc index 5d7510867..6e4ce9f50 100644 --- a/verible/common/strings/diff_test.cc +++ b/verible/common/strings/diff_test.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -29,7 +28,7 @@ namespace diff { // Print functions copied from external_libs/editscript_test.cc -std::ostream &operator<<(std::ostream &out, Operation operation) { +static std::ostream &operator<<(std::ostream &out, Operation operation) { switch (operation) { case Operation::EQUALS: return (out << "EQUALS"); @@ -41,22 +40,11 @@ std::ostream &operator<<(std::ostream &out, Operation operation) { return out; } -std::ostream &operator<<(std::ostream &out, const diff::Edit &edit) { +static std::ostream &operator<<(std::ostream &out, const diff::Edit &edit) { out << "{" << edit.operation << ",[" << edit.start << "," << edit.end << ")}"; return out; } -std::ostream &operator<<(std::ostream &out, const Edits &edits) { - out << "Edits{"; - std::string outer_delim; - for (auto &edit : edits) { - out << outer_delim << edit; - outer_delim = ","; - } - out << "};"; - return out; -} - } // namespace diff namespace verible { diff --git a/verible/common/text/text-structure.cc b/verible/common/text/text-structure.cc index 54db8e4e8..a41299604 100644 --- a/verible/common/text/text-structure.cc +++ b/verible/common/text/text-structure.cc @@ -78,7 +78,7 @@ static bool TokenLocationLess(const TokenInfo &token, // Makes an iterator-writable copy of items_view without using const_cast. template -std::vector CopyWriteableIterators( +static std::vector CopyWriteableIterators( V &items, const std::vector &items_view) { // precondition: items_view's iterators all point into items array. // postcondition: results's iterators point to the same items as items_view. diff --git a/verible/common/text/text-structure_test.cc b/verible/common/text/text-structure_test.cc index 3e6b6650c..8f90a5661 100644 --- a/verible/common/text/text-structure_test.cc +++ b/verible/common/text/text-structure_test.cc @@ -72,7 +72,7 @@ TEST(FilterTokensTest, EmptyTokens) { } // Create a one-token token stream and syntax tree. -void OneTokenTextStructureView(TextStructureView *view) { +static void OneTokenTextStructureView(TextStructureView *view) { TokenInfo token(1, view->Contents()); view->MutableTokenStream().push_back(token); view->MutableTokenStreamView().push_back(view->TokenStream().begin()); @@ -80,7 +80,7 @@ void OneTokenTextStructureView(TextStructureView *view) { } // Create a two-token token stream, no syntax tree. -void MultiTokenTextStructureViewNoTree(TextStructureView *view) { +static void MultiTokenTextStructureViewNoTree(TextStructureView *view) { const auto contents = view->Contents(); CHECK_GE(contents.length(), 5); auto &stream = view->MutableTokenStream(); @@ -467,7 +467,7 @@ TEST_F(TextStructureViewPublicTest, ExpandSubtreesEmpty) { } // Splits a single token into a syntax tree node with two leaves. -void FakeParseToken(TextStructureView *data, int offset, int node_tag) { +static void FakeParseToken(TextStructureView *data, int offset, int node_tag) { TokenSequence &tokens = data->MutableTokenStream(); tokens.push_back(TokenInfo(11, data->Contents().substr(0, offset))); tokens.push_back(TokenInfo(12, data->Contents().substr(offset))); diff --git a/verible/verilog/CST/module.cc b/verible/verilog/CST/module.cc index 4f16d3762..9c405823c 100644 --- a/verible/verilog/CST/module.cc +++ b/verible/verilog/CST/module.cc @@ -51,7 +51,7 @@ std::vector FindAllProgramDeclarations( return SearchSyntaxTree(root, NodekProgramDeclaration()); } -bool IsModuleOrInterfaceOrProgramDeclaration( +static bool IsModuleOrInterfaceOrProgramDeclaration( const SyntaxTreeNode &declaration) { return declaration.MatchesTagAnyOf({NodeEnum::kModuleDeclaration, NodeEnum::kInterfaceDeclaration, diff --git a/verible/verilog/CST/statement.cc b/verible/verilog/CST/statement.cc index 393c33d18..0dce48cd9 100644 --- a/verible/verilog/CST/statement.cc +++ b/verible/verilog/CST/statement.cc @@ -129,7 +129,7 @@ const SyntaxTreeNode *GetAssertionStatementAssertClause( NodeEnum::kAssertionClause); } -const SyntaxTreeNode *GetAssertionClauseStatementBody( +static const SyntaxTreeNode *GetAssertionClauseStatementBody( const Symbol &assertion_clause) { const auto *body_node = GetGenericStatementBody(MatchNodeEnumOrNull( SymbolCastToNode(assertion_clause), NodeEnum::kAssertionClause)); @@ -154,7 +154,7 @@ const SyntaxTreeNode *GetAssumeStatementAssumeClause( NodeEnum::kAssumeClause); } -const SyntaxTreeNode *GetAssumeClauseStatementBody( +static const SyntaxTreeNode *GetAssumeClauseStatementBody( const Symbol &assume_clause) { const auto *body_node = GetGenericStatementBody(MatchNodeEnumOrNull( SymbolCastToNode(assume_clause), NodeEnum::kAssumeClause)); @@ -197,7 +197,7 @@ const SyntaxTreeNode *GetAssertPropertyStatementAssertClause( NodeEnum::kAssertPropertyClause); } -const SyntaxTreeNode *GetAssertPropertyStatementBody( +static const SyntaxTreeNode *GetAssertPropertyStatementBody( const Symbol &assert_clause) { const auto *body_node = GetGenericStatementBody(MatchNodeEnumOrNull( SymbolCastToNode(assert_clause), NodeEnum::kAssertPropertyClause)); @@ -225,7 +225,7 @@ const SyntaxTreeNode *GetAssumePropertyStatementAssumeClause( NodeEnum::kAssumePropertyClause); } -const SyntaxTreeNode *GetAssumePropertyStatementBody( +static const SyntaxTreeNode *GetAssumePropertyStatementBody( const Symbol &assume_clause) { const auto *body_node = GetGenericStatementBody(MatchNodeEnumOrNull( SymbolCastToNode(assume_clause), NodeEnum::kAssumePropertyClause)); @@ -253,7 +253,7 @@ const SyntaxTreeNode *GetExpectPropertyStatementExpectClause( NodeEnum::kExpectPropertyClause); } -const SyntaxTreeNode *GetExpectPropertyStatementBody( +static const SyntaxTreeNode *GetExpectPropertyStatementBody( const Symbol &expect_clause) { const auto *body_node = GetGenericStatementBody(MatchNodeEnumOrNull( SymbolCastToNode(expect_clause), NodeEnum::kExpectPropertyClause)); @@ -274,7 +274,7 @@ const SyntaxTreeNode *GetExpectPropertyStatementElseClause( NodeEnum::kElseClause); } -const SyntaxTreeNode *GetCoverPropertyStatementBody( +static const SyntaxTreeNode *GetCoverPropertyStatementBody( const Symbol &cover_property) { const auto *body_node = GetGenericStatementBody(MatchNodeEnumOrNull( SymbolCastToNode(cover_property), NodeEnum::kCoverPropertyStatement)); @@ -283,7 +283,7 @@ const SyntaxTreeNode *GetCoverPropertyStatementBody( GetSubtreeAsSymbol(*body_node, NodeEnum::kCoverPropertyBody, 0)); } -const SyntaxTreeNode *GetCoverSequenceStatementBody( +static const SyntaxTreeNode *GetCoverSequenceStatementBody( const Symbol &cover_sequence) { const auto *body_node = GetGenericStatementBody(MatchNodeEnumOrNull( SymbolCastToNode(cover_sequence), NodeEnum::kCoverSequenceStatement)); diff --git a/verible/verilog/CST/type.cc b/verible/verilog/CST/type.cc index aa10e794e..0b38eb2fb 100644 --- a/verible/verilog/CST/type.cc +++ b/verible/verilog/CST/type.cc @@ -350,7 +350,7 @@ const verible::SyntaxTreeLeaf *GetSymbolIdentifierFromEnumName( return verible::GetSubtreeAsLeaf(enum_name, NodeEnum::kEnumName, 0); } -const verible::SyntaxTreeLeaf *GetTypeIdentifierFromInterfaceType( +static const verible::SyntaxTreeLeaf *GetTypeIdentifierFromInterfaceType( const verible::Symbol &interface_type) { return verible::GetSubtreeAsLeaf(interface_type, NodeEnum::kInterfaceType, 2); } diff --git a/verible/verilog/analysis/verilog-linter-configuration.cc b/verible/verilog/analysis/verilog-linter-configuration.cc index 489059a17..140e4494d 100644 --- a/verible/verilog/analysis/verilog-linter-configuration.cc +++ b/verible/verilog/analysis/verilog-linter-configuration.cc @@ -412,7 +412,7 @@ static const verible::EnumNameMap &RuleSetEnumStringMap() { return kRuleSetEnumStringMap; } -std::ostream &operator<<(std::ostream &stream, RuleSet rules) { +static std::ostream &operator<<(std::ostream &stream, RuleSet rules) { return RuleSetEnumStringMap().Unparse(rules, stream); } diff --git a/verible/verilog/formatting/align.cc b/verible/verilog/formatting/align.cc index 96aba27d9..de4cd897a 100644 --- a/verible/verilog/formatting/align.cc +++ b/verible/verilog/formatting/align.cc @@ -234,7 +234,7 @@ class VerilogColumnSchemaScanner : public ColumnSchemaScanner { }; template -std::function +static std::function UnstyledAlignmentCellScannerGenerator() { return [](const FormatStyle &vstyle) { return AlignmentCellScannerGenerator( @@ -243,9 +243,10 @@ UnstyledAlignmentCellScannerGenerator() { } template -std::function -UnstyledAlignmentCellScannerGenerator( - const verible::NonTreeTokensScannerFunction &non_tree_column_scanner) { +std::function static UnstyledAlignmentCellScannerGenerator(const verible::NonTreeTokensScannerFunction + &non_tree_column_scanner) { return [non_tree_column_scanner](const FormatStyle &vstyle) { return AlignmentCellScannerGenerator( [vstyle] { return ScannerType(vstyle); }, non_tree_column_scanner); @@ -1292,8 +1293,8 @@ struct AlignmentGroupHandlers { // Returns the referenced member by value. // TODO(fangism): move this to an STL-style util/functional library template -std::function function_from_pointer_to_member( - MemberType StructType::*member) { +static std::function +function_from_pointer_to_member(MemberType StructType::*member) { return [member](const StructType &obj) { return obj.*member; }; } diff --git a/verible/verilog/formatting/formatter.cc b/verible/verilog/formatting/formatter.cc index 8a99a0397..22bcb564f 100644 --- a/verible/verilog/formatting/formatter.cc +++ b/verible/verilog/formatting/formatter.cc @@ -115,9 +115,10 @@ class Formatter { }; // TODO(b/148482625): make this public/re-usable for general content comparison. -Status VerifyFormatting(const verible::TextStructureView &text_structure, - std::string_view formatted_output, - std::string_view filename) { +// Not declared in any header, but also used in formatter_test +extern Status VerifyFormatting(const verible::TextStructureView &text_structure, + std::string_view formatted_output, + std::string_view filename) { // Verify that the formatted output creates the same lexical // stream (filtered) as the original. If any tokens were lost, fall back to // printing the original source unformatted. diff --git a/verible/verilog/formatting/formatter_test.cc b/verible/verilog/formatting/formatter_test.cc index 0150add93..ba5180254 100644 --- a/verible/verilog/formatting/formatter_test.cc +++ b/verible/verilog/formatting/formatter_test.cc @@ -53,9 +53,9 @@ namespace verilog { namespace formatter { // private, extern function in formatter.cc, directly tested here. -absl::Status VerifyFormatting(const verible::TextStructureView &text_structure, - std::string_view formatted_output, - std::string_view filename); +extern absl::Status VerifyFormatting( + const verible::TextStructureView &text_structure, + std::string_view formatted_output, std::string_view filename); namespace { diff --git a/verible/verilog/formatting/token-annotator.cc b/verible/verilog/formatting/token-annotator.cc index 7a4a063fd..f0f97e7c4 100644 --- a/verible/verilog/formatting/token-annotator.cc +++ b/verible/verilog/formatting/token-annotator.cc @@ -922,11 +922,11 @@ static WithReason BreakDecisionBetween( // Extern linkage for sake of direct testing, though not exposed in public // headers. // TODO(fangism): could move this to a -internal.h header. -void AnnotateFormatToken(const FormatStyle &style, - const PreFormatToken &prev_token, - PreFormatToken *curr_token, - const SyntaxTreeContext &prev_context, - const SyntaxTreeContext &curr_context) { +extern void AnnotateFormatToken(const FormatStyle &style, + const PreFormatToken &prev_token, + PreFormatToken *curr_token, + const SyntaxTreeContext &prev_context, + const SyntaxTreeContext &curr_context) { const auto p = SpacesRequiredBetween(style, prev_token, *curr_token, prev_context, curr_context); curr_token->before.spaces_required = p.spaces_required; diff --git a/verible/verilog/formatting/tree-unwrapper.cc b/verible/verilog/formatting/tree-unwrapper.cc index 6bac8c48f..7198b9ebd 100644 --- a/verible/verilog/formatting/tree-unwrapper.cc +++ b/verible/verilog/formatting/tree-unwrapper.cc @@ -174,7 +174,7 @@ TokenScannerStateStrings() { } // Conventional stream printer (declared in header providing enum). -std::ostream &operator<<(std::ostream &stream, TokenScannerState p) { +static std::ostream &operator<<(std::ostream &stream, TokenScannerState p) { return TokenScannerStateStrings().Unparse(p, stream); } @@ -638,12 +638,12 @@ static const verible::EnumNameMap &ContextHintStrings() { return kContextHintStringMap; } -std::ostream &operator<<(std::ostream &stream, ContextHint p) { +static std::ostream &operator<<(std::ostream &stream, ContextHint p) { return ContextHintStrings().Unparse(p, stream); } -std::ostream &operator<<(std::ostream &stream, - const std::vector &f) { +static std::ostream &operator<<(std::ostream &stream, + const std::vector &f) { return stream << verible::SequenceFormatter(f); } @@ -1623,7 +1623,8 @@ static void AttachSeparatorToPreviousOrNextPartition( partition->Value().SetOrigin(nullptr); } -void AttachSeparatorsToListElementPartitions(TokenPartitionTree *partition) { +static void AttachSeparatorsToListElementPartitions( + TokenPartitionTree *partition) { CHECK_NOTNULL(partition); // Skip the first partition, it can't contain just a separator. for (int i = 1; i < static_cast(partition->Children().size()); ++i) { diff --git a/verible/verilog/tools/diff/verilog-diff.cc b/verible/verilog/tools/diff/verilog-diff.cc index 9e4a29ab3..5e4620a0b 100644 --- a/verible/verilog/tools/diff/verilog-diff.cc +++ b/verible/verilog/tools/diff/verilog-diff.cc @@ -52,15 +52,16 @@ static const verible::EnumNameMap &DiffModeStringMap() { return kDiffModeStringMap; } -std::ostream &operator<<(std::ostream &stream, DiffMode p) { +static std::ostream &operator<<(std::ostream &stream, DiffMode p) { return DiffModeStringMap().Unparse(p, stream); } -bool AbslParseFlag(std::string_view text, DiffMode *mode, std::string *error) { +static bool AbslParseFlag(std::string_view text, DiffMode *mode, + std::string *error) { return DiffModeStringMap().Parse(text, mode, error, "--mode value"); } -std::string AbslUnparseFlag(const DiffMode &mode) { +static std::string AbslUnparseFlag(const DiffMode &mode) { std::ostringstream stream; stream << mode; return stream.str(); diff --git a/verible/verilog/tools/formatter/verilog-format.cc b/verible/verilog/tools/formatter/verilog-format.cc index 0e76de25b..493fbb497 100644 --- a/verible/verilog/tools/formatter/verilog-format.cc +++ b/verible/verilog/tools/formatter/verilog-format.cc @@ -60,8 +60,8 @@ struct LineRanges { LineRanges::storage_type LineRanges::values; // global initializer -bool AbslParseFlag(std::string_view flag_arg, LineRanges * /* unused */, - std::string *error) { +static bool AbslParseFlag(std::string_view flag_arg, LineRanges * /* unused */, + std::string *error) { auto &values = LineRanges::values; // Pre-split strings, so that "--flag v1,v2" and "--flag v1 --flag v2" are // equivalent. @@ -75,7 +75,7 @@ bool AbslParseFlag(std::string_view flag_arg, LineRanges * /* unused */, return true; } -std::string AbslUnparseFlag(LineRanges /* unused */) { +static std::string AbslUnparseFlag(LineRanges /* unused */) { const auto &values = LineRanges::values; return absl::StrJoin(values.begin(), values.end(), ",", absl::StreamFormatter()); diff --git a/verible/verilog/tools/kythe/indexing-facts-tree-extractor.cc b/verible/verilog/tools/kythe/indexing-facts-tree-extractor.cc index 9c3d495a9..ead029857 100644 --- a/verible/verilog/tools/kythe/indexing-facts-tree-extractor.cc +++ b/verible/verilog/tools/kythe/indexing-facts-tree-extractor.cc @@ -1039,8 +1039,8 @@ void IndexingFactsTreeExtractor::ExtractMacroDefinition( facts_tree_context_.top().Children().push_back(std::move(macro_node)); } -Anchor GetMacroAnchorFromTokenInfo(const TokenInfo ¯o_token_info, - std::string_view file_content) { +static Anchor GetMacroAnchorFromTokenInfo(const TokenInfo ¯o_token_info, + std::string_view file_content) { // Strip the prefix "`". // e.g. // `define TEN 0 @@ -1788,7 +1788,7 @@ void IndexingFactsTreeExtractor::ExtractForInitialization( // Returns string_view of `text` with outermost double-quotes removed. // If `text` is not wrapped in quotes, return it as-is. -std::string_view StripOuterQuotes(std::string_view text) { +static std::string_view StripOuterQuotes(std::string_view text) { return absl::StripSuffix(absl::StripPrefix(text, "\""), "\""); } diff --git a/verible/verilog/tools/lint/verilog-lint.cc b/verible/verilog/tools/lint/verilog-lint.cc index d7e4f6a5b..da1ee4649 100644 --- a/verible/verilog/tools/lint/verilog-lint.cc +++ b/verible/verilog/tools/lint/verilog-lint.cc @@ -61,18 +61,18 @@ static const verible::EnumNameMap &AutofixModeEnumStringMap() { return kAutofixModeEnumStringMap; } -std::ostream &operator<<(std::ostream &stream, AutofixMode mode) { +static std::ostream &operator<<(std::ostream &stream, AutofixMode mode) { return AutofixModeEnumStringMap().Unparse(mode, stream); } -std::string AbslUnparseFlag(const AutofixMode &mode) { +static std::string AbslUnparseFlag(const AutofixMode &mode) { std::ostringstream stream; AutofixModeEnumStringMap().Unparse(mode, stream); return stream.str(); } -bool AbslParseFlag(std::string_view text, AutofixMode *mode, - std::string *error) { +static bool AbslParseFlag(std::string_view text, AutofixMode *mode, + std::string *error) { return AutofixModeEnumStringMap().Parse(text, mode, error, "--autofix value"); } diff --git a/verible/verilog/tools/ls/symbol-table-handler.cc b/verible/verilog/tools/ls/symbol-table-handler.cc index 659a4d659..3bc23edaa 100644 --- a/verible/verilog/tools/ls/symbol-table-handler.cc +++ b/verible/verilog/tools/ls/symbol-table-handler.cc @@ -229,7 +229,7 @@ bool SymbolTableHandler::LoadProjectFileList(std::string_view current_dir) { return true; } -const SymbolTableNode *ScanSymbolTreeForDefinitionReferenceComponents( +static const SymbolTableNode *ScanSymbolTreeForDefinitionReferenceComponents( const ReferenceComponentNode *ref, std::string_view symbol) { if (verible::IsSubRange(symbol, ref->Value().identifier)) { return ref->Value().resolved_symbol;