Make 'unset_option' work on list options.
authorMikhail Glushenkov <foldr@codedgers.com>
Thu, 22 Oct 2009 04:15:07 +0000 (04:15 +0000)
committerMikhail Glushenkov <foldr@codedgers.com>
Thu, 22 Oct 2009 04:15:07 +0000 (04:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84827 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/LLVMCConfigurationEmitter.cpp

index 4293c95fd2fb6fb993604e9617c62a6a0d3cb88b..f5d1139bb62e33f9e2d1945058f05e1046069054 100644 (file)
@@ -2127,18 +2127,18 @@ class EmitPreprocessOptionsCallback : ActionHandlingCallbackBase {
   void onUnsetOption(Init* i, unsigned IndentLevel, raw_ostream& O) {
     const std::string& OptName = InitPtrToString(i);
     const OptionDescription& OptDesc = OptDescs_.FindOption(OptName);
-    const OptionType::OptionType OptType = OptDesc.Type;
 
-    if (OptType == OptionType::Switch) {
+    if (OptDesc.isSwitch()) {
       O.indent(IndentLevel) << OptDesc.GenVariableName() << " = false;\n";
     }
-    else if (OptType == OptionType::Parameter
-             || OptType == OptionType::Prefix) {
+    else if (OptDesc.isParameter()) {
       O.indent(IndentLevel) << OptDesc.GenVariableName() << " = \"\";\n";
     }
+    else if (OptDesc.isList()) {
+      O.indent(IndentLevel) << OptDesc.GenVariableName() << ".clear();\n";
+    }
     else {
-      throw std::string("'unset_option' can only be applied to "
-                        "switches or parameter/prefix options.");
+      throw "Can't apply 'unset_option' to alias option '" + OptName + "'";
     }
   }