[cfe-commits] r93064 - /cfe/trunk/lib/Lex/PPMacroExpansion.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Jan 9 10:53:11 PST 2010
Author: d0k
Date: Sat Jan 9 12:53:11 2010
New Revision: 93064
URL: http://llvm.org/viewvc/llvm-project?rev=93064&view=rev
Log:
Simplify with StringSwitch.
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=93064&r1=93063&r2=93064&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Sat Jan 9 12:53:11 2010
@@ -18,6 +18,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/FileManager.h"
#include "clang/Lex/LexDiagnostic.h"
+#include "llvm/ADT/StringSwitch.h"
#include <cstdio>
#include <ctime>
using namespace clang;
@@ -481,34 +482,17 @@
static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
const LangOptions &LangOpts = PP.getLangOptions();
- switch (II->getLength()) {
- default: return false;
- case 6:
- if (II->isStr("blocks")) return LangOpts.Blocks;
- return false;
- case 8:
- if (II->isStr("cxx_rtti")) return LangOpts.RTTI;
- return false;
- case 14:
- if (II->isStr("cxx_exceptions")) return LangOpts.Exceptions;
- return false;
- case 19:
- if (II->isStr("objc_nonfragile_abi")) return LangOpts.ObjCNonFragileABI;
- return false;
- case 22:
- if (II->isStr("attribute_overloadable")) return true;
- return false;
- case 25:
- if (II->isStr("attribute_ext_vector_type")) return true;
- return false;
- case 27:
- if (II->isStr("attribute_analyzer_noreturn")) return true;
- return false;
- case 29:
- if (II->isStr("attribute_ns_returns_retained")) return true;
- if (II->isStr("attribute_cf_returns_retained")) return true;
- return false;
- }
+ return llvm::StringSwitch<bool>(II->getName())
+ .Case("blocks", LangOpts.Blocks)
+ .Case("cxx_rtti", LangOpts.RTTI)
+ .Case("cxx_exceptions", LangOpts.Exceptions)
+ .Case("objc_nonfragile_abi", LangOpts.ObjCNonFragileABI)
+ .Case("attribute_overloadable", true)
+ .Case("attribute_ext_vector_type", true)
+ .Case("attribute_analyzer_noreturn", true)
+ .Case("attribute_ns_returns_retained", true)
+ .Case("attribute_cf_returns_retained", true)
+ .Default(false);
}
/// EvaluateHasIncludeCommon - Process a '__has_include("path")'
More information about the cfe-commits
mailing list