Fixed #4608 (false positive: (style) struct or union member is never used.)
This commit is contained in:
parent
4c23f0101a
commit
d7a52eaecd
10
lib/path.cpp
10
lib/path.cpp
|
@ -206,7 +206,13 @@ bool Path::isCPP(const std::string &path)
|
|||
return(getFilenameExtension(path) == ".C");
|
||||
}
|
||||
|
||||
bool Path::acceptFile(const std::string &filename)
|
||||
bool Path::acceptFile(const std::string &path)
|
||||
{
|
||||
return(Path::isCPP(filename) || Path::isC(filename));
|
||||
return !Path::isHeader(path) && (Path::isCPP(path) || Path::isC(path));
|
||||
}
|
||||
|
||||
bool Path::isHeader(const std::string &path)
|
||||
{
|
||||
const std::string extension = getFilenameExtensionInLowerCase(path);
|
||||
return (extension.compare(0, 2, ".h") == 0);
|
||||
}
|
||||
|
|
16
lib/path.h
16
lib/path.h
|
@ -104,24 +104,32 @@ public:
|
|||
/**
|
||||
* @brief Check if the file extension indicates that it's a C/C++ source file.
|
||||
* Check if the file has source file extension: *.c;*.cpp;*.cxx;*.c++;*.cc;*.txx
|
||||
* @param filename filename to check
|
||||
* @param path filename to check. path info is optional
|
||||
* @return returns true if the file extension indicates it should be checked
|
||||
*/
|
||||
static bool acceptFile(const std::string &filename);
|
||||
|
||||
/**
|
||||
* @brief Identify language based on file extension.
|
||||
* @param extensionInLowerCase e.g. ".c"
|
||||
* @param path filename to check. path info is optional
|
||||
* @return true if extension is meant for C files
|
||||
*/
|
||||
static bool isC(const std::string &extensionInLowerCase);
|
||||
static bool isC(const std::string &path);
|
||||
|
||||
/**
|
||||
* @brief Identify language based on file extension.
|
||||
* @param extensionInLowerCase e.g. ".cpp"
|
||||
* @param path filename to check. path info is optional
|
||||
* @return true if extension is meant for C++ files
|
||||
*/
|
||||
static bool isCPP(const std::string &extensionInLowerCase);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Is filename a header based on file extension
|
||||
* @param path filename to check. path info is optional
|
||||
* @return true if filename extension is meant for headers
|
||||
*/
|
||||
static bool isHeader(const std::string &path);
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -74,6 +74,10 @@ private:
|
|||
ASSERT(Path::acceptFile("index")==false);
|
||||
ASSERT(Path::acceptFile("")==false);
|
||||
ASSERT(Path::acceptFile("C")==false);
|
||||
|
||||
// don't accept any headers
|
||||
ASSERT_EQUALS(false, Path::acceptFile("index.h"));
|
||||
ASSERT_EQUALS(false, Path::acceptFile("index.hpp"));
|
||||
}
|
||||
|
||||
void getRelative() const {
|
||||
|
|
Loading…
Reference in New Issue