Skip to content

Commit 90faa80

Browse files
committed
Preprocessor: Cleanup unused functions
1 parent 8c8ad96 commit 90faa80

3 files changed

Lines changed: 0 additions & 84 deletions

File tree

lib/preprocessor.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -643,35 +643,6 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const
643643
false));
644644
}
645645

646-
Preprocessor::HeaderTypes Preprocessor::getHeaderFileName(std::string &str)
647-
{
648-
std::string::size_type i = str.find_first_of("<\"");
649-
if (i == std::string::npos) {
650-
str = "";
651-
return NoHeader;
652-
}
653-
654-
char c = str[i];
655-
if (c == '<')
656-
c = '>';
657-
658-
std::string result;
659-
for (i = i + 1; i < str.length(); ++i) {
660-
if (str[i] == c)
661-
break;
662-
663-
result.append(1, str[i]);
664-
}
665-
666-
// Linux can't open include paths with \ separator, so fix them
667-
std::replace(result.begin(), result.end(), '\\', '/');
668-
669-
str = result;
670-
671-
return (c == '\"') ? UserHeader : SystemHeader;
672-
}
673-
674-
675646
// Report that include is missing
676647
void Preprocessor::missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType)
677648
{

lib/preprocessor.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,6 @@ class CPPCHECKLIB Preprocessor {
164164
*/
165165
static void writeError(const std::string &fileName, const unsigned int linenr, ErrorLogger *errorLogger, const std::string &errorType, const std::string &errorText);
166166

167-
/**
168-
* Remove redundant parentheses from preprocessor commands. This should only be called from read().
169-
* @param str Code processed by read().
170-
* @return code with reduced parentheses
171-
*/
172-
static std::string removeParentheses(const std::string &str);
173-
174-
/**
175-
* Returns the string between double quote characters or \< \> characters.
176-
* @param str e.g. \code#include "menu.h"\endcode or \code#include <menu.h>\endcode
177-
* After function call it will contain e.g. "menu.h" without double quotes.
178-
* @return NoHeader empty string if double quotes or \< \> were not found.
179-
* UserHeader if file surrounded with "" was found
180-
* SystemHeader if file surrounded with \<\> was found
181-
*/
182-
static Preprocessor::HeaderTypes getHeaderFileName(std::string &str);
183167
private:
184168

185169
/**
@@ -190,8 +174,6 @@ class CPPCHECKLIB Preprocessor {
190174
*/
191175
static std::string removeSpaceNearNL(const std::string &str);
192176

193-
static std::string getdef(std::string line, bool def);
194-
195177
public:
196178

197179

test/testpreprocessor.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ class TestPreprocessor : public TestFixture {
7171

7272
return tokens2.stringify();
7373
}
74-
75-
static int getHeaderFileName(std::string &str) {
76-
return Preprocessor::getHeaderFileName(str);
77-
}
7874
};
7975

8076
private:
@@ -197,7 +193,6 @@ class TestPreprocessor : public TestFixture {
197193
TEST_CASE(conditionalDefine);
198194
TEST_CASE(macro_parameters);
199195
TEST_CASE(newline_in_macro);
200-
TEST_CASE(includes);
201196
TEST_CASE(ifdef_ifdefined);
202197

203198
// define and then ifdef
@@ -2001,38 +1996,6 @@ class TestPreprocessor : public TestFixture {
20011996
ASSERT_EQUALS("", errout.str());
20021997
}
20031998

2004-
void includes() const {
2005-
{
2006-
std::string src = "#include a.h";
2007-
ASSERT_EQUALS(OurPreprocessor::NoHeader, OurPreprocessor::getHeaderFileName(src));
2008-
ASSERT_EQUALS("", src);
2009-
}
2010-
2011-
{
2012-
std::string src = "#include \"b.h\"";
2013-
ASSERT_EQUALS(OurPreprocessor::UserHeader, OurPreprocessor::getHeaderFileName(src));
2014-
ASSERT_EQUALS("b.h", src);
2015-
}
2016-
2017-
{
2018-
std::string src = "#include <c.h>";
2019-
ASSERT_EQUALS(OurPreprocessor::SystemHeader, OurPreprocessor::getHeaderFileName(src));
2020-
ASSERT_EQUALS("c.h", src);
2021-
}
2022-
2023-
{
2024-
std::string src = "#include \"d/d.h\"";
2025-
ASSERT_EQUALS(OurPreprocessor::UserHeader, OurPreprocessor::getHeaderFileName(src));
2026-
ASSERT_EQUALS("d/d.h", src);
2027-
}
2028-
2029-
{
2030-
std::string src = "#include \"e\\e.h\"";
2031-
ASSERT_EQUALS(OurPreprocessor::UserHeader, OurPreprocessor::getHeaderFileName(src));
2032-
ASSERT_EQUALS("e/e.h", src);
2033-
}
2034-
}
2035-
20361999
void ifdef_ifdefined() {
20372000
const char filedata[] = "#ifdef ABC\n"
20382001
"A\n"

0 commit comments

Comments
 (0)