From 504c361cb8e89040ddedfbc3ea1d8077924612f9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sun, 9 Mar 2014 22:53:49 -0700 Subject: [PATCH] Make some implicit constructors explicit --- src/compiler/build_tables/rule_can_be_blank.cc | 2 +- src/compiler/rules/character_range.h | 1 + src/compiler/rules/character_set.h | 4 ++-- src/compiler/rules/pattern.cc | 2 +- src/compiler/rules/pattern.h | 2 +- src/compiler/rules/repeat.h | 2 +- src/compiler/rules/string.h | 2 +- src/compiler/rules/symbol.h | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/compiler/build_tables/rule_can_be_blank.cc b/src/compiler/build_tables/rule_can_be_blank.cc index 35ff51a8..652d2995 100644 --- a/src/compiler/build_tables/rule_can_be_blank.cc +++ b/src/compiler/build_tables/rule_can_be_blank.cc @@ -37,7 +37,7 @@ namespace tree_sitter { using CanBeBlank::visit; public: - CanBeBlankRecursive(const PreparedGrammar &grammar) : grammar(grammar) {} + explicit CanBeBlankRecursive(const PreparedGrammar &grammar) : grammar(grammar) {} void visit(const rules::Symbol *rule) { value = grammar.has_definition(*rule) && apply(grammar.rule(*rule)); diff --git a/src/compiler/rules/character_range.h b/src/compiler/rules/character_range.h index 3546f349..22d9126e 100644 --- a/src/compiler/rules/character_range.h +++ b/src/compiler/rules/character_range.h @@ -9,6 +9,7 @@ namespace tree_sitter { struct CharacterRange { char min; char max; + // IMPLICIT_CONSTRUCTORS CharacterRange(char value); CharacterRange(char min, char max); bool operator==(const CharacterRange &other) const; diff --git a/src/compiler/rules/character_set.h b/src/compiler/rules/character_set.h index a79496bf..9bf87bfb 100644 --- a/src/compiler/rules/character_set.h +++ b/src/compiler/rules/character_set.h @@ -13,8 +13,8 @@ namespace tree_sitter { class CharacterSet : public Rule { public: CharacterSet(); - CharacterSet(const std::set &ranges); - CharacterSet(const std::initializer_list &ranges); + explicit CharacterSet(const std::set &ranges); + explicit CharacterSet(const std::initializer_list &ranges); bool operator==(const Rule& other) const; bool operator<(const CharacterSet &) const; diff --git a/src/compiler/rules/pattern.cc b/src/compiler/rules/pattern.cc index 2bf36662..825b642e 100644 --- a/src/compiler/rules/pattern.cc +++ b/src/compiler/rules/pattern.cc @@ -16,7 +16,7 @@ namespace tree_sitter { class PatternParser { public: - PatternParser(const string &input) : + explicit PatternParser(const string &input) : input(input), length(input.length()), position(0) {} diff --git a/src/compiler/rules/pattern.h b/src/compiler/rules/pattern.h index 0e857697..6ca9d438 100644 --- a/src/compiler/rules/pattern.h +++ b/src/compiler/rules/pattern.h @@ -9,7 +9,7 @@ namespace tree_sitter { class Pattern : public Rule { const std::string value; public: - Pattern(const std::string &string); + explicit Pattern(const std::string &string); bool operator==(const Rule& other) const; size_t hash_code() const; diff --git a/src/compiler/rules/repeat.h b/src/compiler/rules/repeat.h index b1ea4d2e..e510f4ea 100644 --- a/src/compiler/rules/repeat.h +++ b/src/compiler/rules/repeat.h @@ -8,7 +8,7 @@ namespace tree_sitter { namespace rules { class Repeat : public Rule { public: - Repeat(rule_ptr content); + explicit Repeat(rule_ptr content); bool operator==(const Rule& other) const; size_t hash_code() const; diff --git a/src/compiler/rules/string.h b/src/compiler/rules/string.h index 8f8d38be..2dc07ecf 100644 --- a/src/compiler/rules/string.h +++ b/src/compiler/rules/string.h @@ -8,7 +8,7 @@ namespace tree_sitter { namespace rules { class String : public Rule { public: - String(std::string value); + explicit String(std::string value); bool operator==(const Rule& other) const; size_t hash_code() const; diff --git a/src/compiler/rules/symbol.h b/src/compiler/rules/symbol.h index ea4abb22..33b4741d 100644 --- a/src/compiler/rules/symbol.h +++ b/src/compiler/rules/symbol.h @@ -16,7 +16,7 @@ namespace tree_sitter { class Symbol : public Rule { public: - Symbol(const std::string &name); + explicit Symbol(const std::string &name); Symbol(const std::string &name, SymbolType type); bool operator==(const Rule& other) const;