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

[clang-tidy] several const changes #896

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

neheb
Copy link
Contributor

@neheb neheb commented Jun 15, 2020

No description provided.

include/yaml-cpp/emitter.h Outdated Show resolved Hide resolved
@@ -90,7 +90,7 @@ class Scanner {
bool InBlockContext() const { return m_flows.empty(); }
std::size_t GetFlowLevel() const { return m_flows.size(); }

Token::TYPE GetStartTokenFor(IndentMarker::INDENT_TYPE type) const;
static Token::TYPE GetStartTokenFor(IndentMarker::INDENT_TYPE type);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is only used in the .cpp file; can you just put it in an anonymous namespace there (rather than making it a static member function)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses INDENT_TYPE , which is declared private.

src/scanner.h Outdated Show resolved Hide resolved
src/scanner.h Outdated Show resolved Hide resolved
@neheb
Copy link
Contributor Author

neheb commented Jun 16, 2020

Couldn't figure out how to move the GetStartTokenFor function in the namespace.

@jbeder
Copy link
Owner

jbeder commented Jun 17, 2020

What was the problem when trying to move GetStartTokenFor into the cpp file?

@neheb
Copy link
Contributor Author

neheb commented Jun 17, 2020

src/scanner.cpp:22:69: error: definition of ‘YAML::Token::TYPE YAML::Scanner::GetStartTokenFor(YAML::Scanner::IndentMarker::INDENT_TYPE)’ is not in namespace enclosing ‘YAML::Scanner’ [-fpermissive]
   22 | Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) {
      |                                                                     ^
src/scanner.cpp:22:13: error: no declaration matches ‘YAML::Token::TYPE YAML::Scanner::GetStartTokenFor(YAML::Scanner::IndentMarker::INDENT_TYPE)’
   22 | Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) {
      |             ^~~~~~~
src/scanner.cpp:22:13: note: no functions named ‘YAML::Token::TYPE YAML::Scanner::GetStartTokenFor(YAML::Scanner::IndentMarker::INDENT_TYPE)’
In file included from src/scanner.cpp:5:
src/scanner.h:30:7: note: ‘class YAML::Scanner’ defined here
   30 | class Scanner {
      |       ^~~~~~~
src/scanner.cpp:22:39: error: ‘struct YAML::Scanner::IndentMarker’ is private within this context
   22 | Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) {
      |                                       ^~~~~~~~~~~~
In file included from src/scanner.cpp:5:
src/scanner.h:48:10: note: declared private here
   48 |   struct IndentMarker {
      |          ^~~~~~~~~~~~
src/scanner.cpp: In member function ‘YAML::Scanner::IndentMarker* YAML::Scanner::PushIndentTo(int, YAML::Scanner::IndentMarker::INDENT_TYPE)’:
src/scanner.cpp:300:34: error: ‘GetStartTokenFor’ was not declared in this scope
  300 |   indent.pStartToken = PushToken(GetStartTokenFor(type));
      |                                  ^~~~~~~~~~~~~~~~
[5/9] Building CXX object CMakeFiles/yaml-cpp.dir/src/singledocparser.cpp.o

@neheb
Copy link
Contributor Author

neheb commented Sep 29, 2020

Rebased.

@neheb neheb force-pushed the const branch 3 times, most recently from f92d321 to f359277 Compare September 30, 2020 00:12
neheb added 4 commits April 22, 2021 18:59
Found with readability-const-return-type

Signed-off-by: Rosen Penev <[email protected]>
Found with readability-make-member-function-const

Signed-off-by: Rosen Penev <[email protected]>
Found with readability-convert-member-functions-to-static

Signed-off-by: Rosen Penev <[email protected]>
Found with readability-string-compare

Signed-off-by: Rosen Penev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants