From 90faa8059038746a89c5a52144412e56de4718cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 25 Jul 2016 14:29:02 +0200 Subject: [PATCH] Preprocessor: Cleanup unused functions --- lib/preprocessor.cpp | 29 ----------------------------- lib/preprocessor.h | 18 ------------------ test/testpreprocessor.cpp | 37 ------------------------------------- 3 files changed, 84 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index e4a0a498e..33951e595 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -643,35 +643,6 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const false)); } -Preprocessor::HeaderTypes Preprocessor::getHeaderFileName(std::string &str) -{ - std::string::size_type i = str.find_first_of("<\""); - if (i == std::string::npos) { - str = ""; - return NoHeader; - } - - char c = str[i]; - if (c == '<') - c = '>'; - - std::string result; - for (i = i + 1; i < str.length(); ++i) { - if (str[i] == c) - break; - - result.append(1, str[i]); - } - - // Linux can't open include paths with \ separator, so fix them - std::replace(result.begin(), result.end(), '\\', '/'); - - str = result; - - return (c == '\"') ? UserHeader : SystemHeader; -} - - // Report that include is missing void Preprocessor::missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType) { diff --git a/lib/preprocessor.h b/lib/preprocessor.h index e5d6a8d87..f217ba0d4 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -164,22 +164,6 @@ public: */ static void writeError(const std::string &fileName, const unsigned int linenr, ErrorLogger *errorLogger, const std::string &errorType, const std::string &errorText); - /** - * Remove redundant parentheses from preprocessor commands. This should only be called from read(). - * @param str Code processed by read(). - * @return code with reduced parentheses - */ - static std::string removeParentheses(const std::string &str); - - /** - * Returns the string between double quote characters or \< \> characters. - * @param str e.g. \code#include "menu.h"\endcode or \code#include \endcode - * After function call it will contain e.g. "menu.h" without double quotes. - * @return NoHeader empty string if double quotes or \< \> were not found. - * UserHeader if file surrounded with "" was found - * SystemHeader if file surrounded with \<\> was found - */ - static Preprocessor::HeaderTypes getHeaderFileName(std::string &str); private: /** @@ -190,8 +174,6 @@ private: */ static std::string removeSpaceNearNL(const std::string &str); - static std::string getdef(std::string line, bool def); - public: diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 8ee8a0368..26ef9ca68 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -71,10 +71,6 @@ public: return tokens2.stringify(); } - - static int getHeaderFileName(std::string &str) { - return Preprocessor::getHeaderFileName(str); - } }; private: @@ -197,7 +193,6 @@ private: TEST_CASE(conditionalDefine); TEST_CASE(macro_parameters); TEST_CASE(newline_in_macro); - TEST_CASE(includes); TEST_CASE(ifdef_ifdefined); // define and then ifdef @@ -2001,38 +1996,6 @@ private: ASSERT_EQUALS("", errout.str()); } - void includes() const { - { - std::string src = "#include a.h"; - ASSERT_EQUALS(OurPreprocessor::NoHeader, OurPreprocessor::getHeaderFileName(src)); - ASSERT_EQUALS("", src); - } - - { - std::string src = "#include \"b.h\""; - ASSERT_EQUALS(OurPreprocessor::UserHeader, OurPreprocessor::getHeaderFileName(src)); - ASSERT_EQUALS("b.h", src); - } - - { - std::string src = "#include "; - ASSERT_EQUALS(OurPreprocessor::SystemHeader, OurPreprocessor::getHeaderFileName(src)); - ASSERT_EQUALS("c.h", src); - } - - { - std::string src = "#include \"d/d.h\""; - ASSERT_EQUALS(OurPreprocessor::UserHeader, OurPreprocessor::getHeaderFileName(src)); - ASSERT_EQUALS("d/d.h", src); - } - - { - std::string src = "#include \"e\\e.h\""; - ASSERT_EQUALS(OurPreprocessor::UserHeader, OurPreprocessor::getHeaderFileName(src)); - ASSERT_EQUALS("e/e.h", src); - } - } - void ifdef_ifdefined() { const char filedata[] = "#ifdef ABC\n" "A\n"