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:
commit
8acd2b3ab4
@ -31,6 +31,7 @@ struct cmIDEFlagTable
|
|||||||
// old value with semicolons (e.g.
|
// old value with semicolons (e.g.
|
||||||
// /NODEFAULTLIB: =>
|
// /NODEFAULTLIB: =>
|
||||||
// IgnoreDefaultLibraryNames)
|
// IgnoreDefaultLibraryNames)
|
||||||
|
UserFollowing = (1<<5), // expect value in following argument
|
||||||
|
|
||||||
UserValueIgnored = UserValue | UserIgnored,
|
UserValueIgnored = UserValue | UserIgnored,
|
||||||
UserValueRequired = UserValue | UserRequired
|
UserValueRequired = UserValue | UserRequired
|
||||||
|
@ -19,6 +19,7 @@ cmIDEOptions::cmIDEOptions()
|
|||||||
this->DoingDefine = false;
|
this->DoingDefine = false;
|
||||||
this->AllowDefine = true;
|
this->AllowDefine = true;
|
||||||
this->AllowSlash = false;
|
this->AllowSlash = false;
|
||||||
|
this->DoingFollowing = 0;
|
||||||
for(int i=0; i < FlagTableCount; ++i)
|
for(int i=0; i < FlagTableCount; ++i)
|
||||||
{
|
{
|
||||||
this->FlagTable[i] = 0;
|
this->FlagTable[i] = 0;
|
||||||
@ -41,6 +42,14 @@ void cmIDEOptions::HandleFlag(const char* flag)
|
|||||||
return;
|
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.
|
// Look for known arguments.
|
||||||
if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))
|
if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))
|
||||||
{
|
{
|
||||||
@ -99,40 +108,22 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
|
|||||||
(!(entry->special & cmIDEFlagTable::UserRequired) ||
|
(!(entry->special & cmIDEFlagTable::UserRequired) ||
|
||||||
static_cast<int>(strlen(flag+1)) > n))
|
static_cast<int>(strlen(flag+1)) > n))
|
||||||
{
|
{
|
||||||
if(entry->special & cmIDEFlagTable::UserIgnored)
|
this->FlagMapUpdate(entry, flag+n+1);
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
entry_found = true;
|
entry_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(flag+1, entry->commandFlag) == 0)
|
else if(strcmp(flag+1, entry->commandFlag) == 0)
|
||||||
{
|
{
|
||||||
// This flag table entry provides a fixed value.
|
if(entry->special & cmIDEFlagTable::UserFollowing)
|
||||||
this->FlagMap[entry->IDEName] = entry->value;
|
{
|
||||||
|
// 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;
|
entry_found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +141,37 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
|
|||||||
return false;
|
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)
|
void cmIDEOptions::AddDefine(const std::string& def)
|
||||||
{
|
{
|
||||||
|
@ -51,11 +51,13 @@ protected:
|
|||||||
bool DoingDefine;
|
bool DoingDefine;
|
||||||
bool AllowDefine;
|
bool AllowDefine;
|
||||||
bool AllowSlash;
|
bool AllowSlash;
|
||||||
|
cmIDEFlagTable const* DoingFollowing;
|
||||||
enum { FlagTableCount = 16 };
|
enum { FlagTableCount = 16 };
|
||||||
cmIDEFlagTable const* FlagTable[FlagTableCount];
|
cmIDEFlagTable const* FlagTable[FlagTableCount];
|
||||||
void HandleFlag(const char* flag);
|
void HandleFlag(const char* flag);
|
||||||
bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
|
bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
|
||||||
bool& flag_handled);
|
bool& flag_handled);
|
||||||
|
void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
|
||||||
virtual void StoreUnknownFlag(const char* flag) = 0;
|
virtual void StoreUnknownFlag(const char* flag) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,9 +248,9 @@ static cmVS7FlagTable cmVS11CLFlagTable[] =
|
|||||||
{"ForcedUsingFiles", "FU",
|
{"ForcedUsingFiles", "FU",
|
||||||
"Forced #using File",
|
"Forced #using File",
|
||||||
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
||||||
{"PREfastAdditionalOptions", "analyze:",
|
{"PREfastLog", "analyze:log",
|
||||||
"Additional Code Analysis Native options",
|
"Code Analysis Log",
|
||||||
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
"", cmVS7FlagTable::UserFollowing},
|
||||||
{"PREfastAdditionalPlugins", "analyze:plugin",
|
{"PREfastAdditionalPlugins", "analyze:plugin",
|
||||||
"Additional Code Analysis Native plugins",
|
"Additional Code Analysis Native plugins",
|
||||||
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
||||||
@ -283,9 +283,6 @@ static cmVS7FlagTable cmVS11CLFlagTable[] =
|
|||||||
"", cmVS7FlagTable::UserValue},
|
"", cmVS7FlagTable::UserValue},
|
||||||
// Skip [XMLDocumentationFileName] - no command line Switch.
|
// Skip [XMLDocumentationFileName] - no command line Switch.
|
||||||
// Skip [BrowseInformationFile] - no command line Switch.
|
// Skip [BrowseInformationFile] - no command line Switch.
|
||||||
{"PREfastLog", "analyze:log ",
|
|
||||||
"Code Analysis Log",
|
|
||||||
"", cmVS7FlagTable::UserValue},
|
|
||||||
// Skip [AdditionalOptions] - no command line Switch.
|
// Skip [AdditionalOptions] - no command line Switch.
|
||||||
{0,0,0,0,0}
|
{0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
@ -254,9 +254,9 @@ static cmVS7FlagTable cmVS12CLFlagTable[] =
|
|||||||
{"ForcedUsingFiles", "FU",
|
{"ForcedUsingFiles", "FU",
|
||||||
"Forced #using File",
|
"Forced #using File",
|
||||||
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
||||||
{"PREfastAdditionalOptions", "analyze:",
|
{"PREfastLog", "analyze:log",
|
||||||
"Additional Code Analysis Native options",
|
"Code Analysis Log",
|
||||||
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
"", cmVS7FlagTable::UserFollowing},
|
||||||
{"PREfastAdditionalPlugins", "analyze:plugin",
|
{"PREfastAdditionalPlugins", "analyze:plugin",
|
||||||
"Additional Code Analysis Native plugins",
|
"Additional Code Analysis Native plugins",
|
||||||
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
|
||||||
@ -289,9 +289,6 @@ static cmVS7FlagTable cmVS12CLFlagTable[] =
|
|||||||
"", cmVS7FlagTable::UserValue},
|
"", cmVS7FlagTable::UserValue},
|
||||||
// Skip [XMLDocumentationFileName] - no command line Switch.
|
// Skip [XMLDocumentationFileName] - no command line Switch.
|
||||||
// Skip [BrowseInformationFile] - no command line Switch.
|
// Skip [BrowseInformationFile] - no command line Switch.
|
||||||
{"PREfastLog", "analyze:log ",
|
|
||||||
"Code Analysis Log",
|
|
||||||
"", cmVS7FlagTable::UserValue},
|
|
||||||
// Skip [AdditionalOptions] - no command line Switch.
|
// Skip [AdditionalOptions] - no command line Switch.
|
||||||
{0,0,0,0,0}
|
{0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user