ImportProject: Only expose Cppcheck Visual Studio defines for Cppcheck

This commit is contained in:
Daniel Marjamäki 2017-08-08 22:26:42 +02:00
parent f42e7da295
commit 9861240e79
3 changed files with 8 additions and 5 deletions

View File

@ -93,7 +93,7 @@ unsigned int CppCheck::check(const ImportProject::FileSettings &fs)
{
CppCheck temp(_errorLogger, _useGlobalSuppressions);
temp._settings = _settings;
temp._settings.userDefines = fs.defines;
temp._settings.userDefines = fs.cppcheckDefines();
temp._settings.includePaths = fs.includePaths;
// TODO: temp._settings.userUndefs = fs.undefs;
if (fs.platformType != Settings::Unspecified) {

View File

@ -495,15 +495,14 @@ void ImportProject::importVcxproj(const std::string &filename, std::map<std::str
FileSettings fs;
fs.filename = Path::simplifyPath(Path::isAbsolute(*c) ? *c : Path::getPathFromFilename(filename) + *c);
fs.cfg = p->name;
fs.defines = "_MSC_VER=1900;_WIN32=1";
fs.defines = "_WIN32=1";
if (p->platform == ProjectConfiguration::Win32)
fs.platformType = cppcheck::Platform::Win32W;
else if (p->platform == ProjectConfiguration::x64) {
fs.platformType = cppcheck::Platform::Win64;
fs.defines += ";_WIN64=1";
}
if (useOfMfc)
fs.defines += ";__AFXWIN_H__";
fs.useMfc = useOfMfc;
std::string additionalIncludePaths;
for (std::list<ItemDefinitionGroup>::const_iterator i = itemDefinitionGroupList.begin(); i != itemDefinitionGroupList.end(); ++i) {
if (!i->conditionIsTrue(*p))

View File

@ -40,15 +40,19 @@ class CPPCHECKLIB ImportProject {
public:
/** File settings. Multiple configurations for a file is allowed. */
struct FileSettings {
FileSettings() : platformType(cppcheck::Platform::Unspecified) {}
FileSettings() : platformType(cppcheck::Platform::Unspecified), useMfc(false) {}
std::string cfg;
std::string filename;
std::string defines;
std::string cppcheckDefines() const {
return useMfc ? (defines + ";_MSC_VER=1900;__AFXWIN_H__=1") : defines;
}
std::set<std::string> undefs;
std::list<std::string> includePaths;
std::list<std::string> systemIncludePaths;
std::string standard;
cppcheck::Platform::PlatformType platformType;
bool useMfc;
void setDefines(std::string defs);
void setIncludePaths(const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string> &variables);