From f2a3dd9d1acb252dd40c35859f9a148c2d0ff823 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 14:54:28 -0400 Subject: [PATCH 1/3] cmIDEOptions: Factor FlagMap update out to separate method This will allow it to be re-used in other code paths. --- Source/cmIDEOptions.cxx | 59 ++++++++++++++++++++++------------------- Source/cmIDEOptions.h | 1 + 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index e03223f76..eda1ef676 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -99,33 +99,7 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, (!(entry->special & cmIDEFlagTable::UserRequired) || static_cast(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::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; } } @@ -150,6 +124,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::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) { diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 691893f6d..82c1a25ea 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -56,6 +56,7 @@ protected: 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; }; From 650199e7ca5821c160e5124e79aaf81141a7918f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 14:56:08 -0400 Subject: [PATCH 2/3] VS: Support mapping flags with values following separately (#14858) Add a "UserFollowing" special flag table entry indicator to say that a flag expects a value in a following argument. Teach cmIDEOptions to handle such flags. --- Source/cmIDEFlagTable.h | 1 + Source/cmIDEOptions.cxx | 21 +++++++++++++++++++-- Source/cmIDEOptions.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h index e372c0a15..d9a045d6b 100644 --- a/Source/cmIDEFlagTable.h +++ b/Source/cmIDEFlagTable.h @@ -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 diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index eda1ef676..1f3c066cd 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -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] == '/')) { @@ -105,8 +114,16 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, } 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; } diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 82c1a25ea..e7749ec03 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -51,6 +51,7 @@ protected: bool DoingDefine; bool AllowDefine; bool AllowSlash; + cmIDEFlagTable const* DoingFollowing; enum { FlagTableCount = 16 }; cmIDEFlagTable const* FlagTable[FlagTableCount]; void HandleFlag(const char* flag); From e8633e66785eb2f3618d7b31bfd22f26e7a38055 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 14:59:20 -0400 Subject: [PATCH 3/3] VS: Fix /analyze:log flag mapping (#14858) Fix the VS 11 and VS 12 flag table entries for this flag. It requires a value in the following argument. Also drop the general "/analyze:" flag table entry so that such flags will be passed through as plain additional options. This is necessary because some such options have following values and some do not but not all have .vcxproj elements to hold the values. --- Source/cmVS11CLFlagTable.h | 9 +++------ Source/cmVS12CLFlagTable.h | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h index 5ab8ebbb3..a61ab1609 100644 --- a/Source/cmVS11CLFlagTable.h +++ b/Source/cmVS11CLFlagTable.h @@ -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} }; diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h index 8f5131989..0a7916f1b 100644 --- a/Source/cmVS12CLFlagTable.h +++ b/Source/cmVS12CLFlagTable.h @@ -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} };