Merge topic 'vs-flag-with-following-value'

e8633e66 VS: Fix /analyze:log flag mapping (#14858)
650199e7 VS: Support mapping flags with values following separately (#14858)
f2a3dd9d cmIDEOptions: Factor FlagMap update out to separate method
This commit is contained in:
Brad King 2014-04-03 12:51:40 -04:00 committed by CMake Topic Stage
commit 8acd2b3ab4
5 changed files with 60 additions and 41 deletions

View File

@ -31,6 +31,7 @@ struct cmIDEFlagTable
// old value with semicolons (e.g.
// /NODEFAULTLIB: =>
// IgnoreDefaultLibraryNames)
UserFollowing = (1<<5), // expect value in following argument
UserValueIgnored = UserValue | UserIgnored,
UserValueRequired = UserValue | UserRequired

View File

@ -19,6 +19,7 @@ cmIDEOptions::cmIDEOptions()
this->DoingDefine = false;
this->AllowDefine = true;
this->AllowSlash = false;
this->DoingFollowing = 0;
for(int i=0; i < FlagTableCount; ++i)
{
this->FlagTable[i] = 0;
@ -41,6 +42,14 @@ void cmIDEOptions::HandleFlag(const char* flag)
return;
}
// If the last option expected a following value, this is it.
if(this->DoingFollowing)
{
this->FlagMapUpdate(this->DoingFollowing, flag);
this->DoingFollowing = 0;
return;
}
// Look for known arguments.
if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))
{
@ -99,40 +108,22 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
(!(entry->special & cmIDEFlagTable::UserRequired) ||
static_cast<int>(strlen(flag+1)) > n))
{
if(entry->special & cmIDEFlagTable::UserIgnored)
{
// Ignore the user-specified value.
this->FlagMap[entry->IDEName] = entry->value;
}
else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
{
const char *new_value = flag+1+n;
std::map<std::string,std::string>::iterator itr;
itr = this->FlagMap.find(entry->IDEName);
if(itr != this->FlagMap.end())
{
// Append to old value (if present) with semicolons;
itr->second += ";";
itr->second += new_value;
}
else
{
this->FlagMap[entry->IDEName] = new_value;
}
}
else
{
// Use the user-specified value.
this->FlagMap[entry->IDEName] = flag+1+n;
}
this->FlagMapUpdate(entry, flag+n+1);
entry_found = true;
}
}
else if(strcmp(flag+1, entry->commandFlag) == 0)
{
// This flag table entry provides a fixed value.
this->FlagMap[entry->IDEName] = entry->value;
if(entry->special & cmIDEFlagTable::UserFollowing)
{
// This flag expects a value in the following argument.
this->DoingFollowing = entry;
}
else
{
// This flag table entry provides a fixed value.
this->FlagMap[entry->IDEName] = entry->value;
}
entry_found = true;
}
@ -150,6 +141,37 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
return false;
}
//----------------------------------------------------------------------------
void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
const char* new_value)
{
if(entry->special & cmIDEFlagTable::UserIgnored)
{
// Ignore the user-specified value.
this->FlagMap[entry->IDEName] = entry->value;
}
else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
{
std::map<std::string,std::string>::iterator itr;
itr = this->FlagMap.find(entry->IDEName);
if(itr != this->FlagMap.end())
{
// Append to old value (if present) with semicolons;
itr->second += ";";
itr->second += new_value;
}
else
{
this->FlagMap[entry->IDEName] = new_value;
}
}
else
{
// Use the user-specified value.
this->FlagMap[entry->IDEName] = new_value;
}
}
//----------------------------------------------------------------------------
void cmIDEOptions::AddDefine(const std::string& def)
{

View File

@ -51,11 +51,13 @@ protected:
bool DoingDefine;
bool AllowDefine;
bool AllowSlash;
cmIDEFlagTable const* DoingFollowing;
enum { FlagTableCount = 16 };
cmIDEFlagTable const* FlagTable[FlagTableCount];
void HandleFlag(const char* flag);
bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
bool& flag_handled);
void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
virtual void StoreUnknownFlag(const char* flag) = 0;
};

View File

@ -248,9 +248,9 @@ static cmVS7FlagTable cmVS11CLFlagTable[] =
{"ForcedUsingFiles", "FU",
"Forced #using File",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"PREfastAdditionalOptions", "analyze:",
"Additional Code Analysis Native options",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"PREfastLog", "analyze:log",
"Code Analysis Log",
"", cmVS7FlagTable::UserFollowing},
{"PREfastAdditionalPlugins", "analyze:plugin",
"Additional Code Analysis Native plugins",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
@ -283,9 +283,6 @@ static cmVS7FlagTable cmVS11CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
// Skip [XMLDocumentationFileName] - no command line Switch.
// Skip [BrowseInformationFile] - no command line Switch.
{"PREfastLog", "analyze:log ",
"Code Analysis Log",
"", cmVS7FlagTable::UserValue},
// Skip [AdditionalOptions] - no command line Switch.
{0,0,0,0,0}
};

View File

@ -254,9 +254,9 @@ static cmVS7FlagTable cmVS12CLFlagTable[] =
{"ForcedUsingFiles", "FU",
"Forced #using File",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"PREfastAdditionalOptions", "analyze:",
"Additional Code Analysis Native options",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"PREfastLog", "analyze:log",
"Code Analysis Log",
"", cmVS7FlagTable::UserFollowing},
{"PREfastAdditionalPlugins", "analyze:plugin",
"Additional Code Analysis Native plugins",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
@ -289,9 +289,6 @@ static cmVS7FlagTable cmVS12CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
// Skip [XMLDocumentationFileName] - no command line Switch.
// Skip [BrowseInformationFile] - no command line Switch.
{"PREfastLog", "analyze:log ",
"Code Analysis Log",
"", cmVS7FlagTable::UserValue},
// Skip [AdditionalOptions] - no command line Switch.
{0,0,0,0,0}
};