diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-20 05:12:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-20 05:12:36 +0000 |
commit | 9cf9f868a5a39099d6a9cf57d5d5693c30486d8d (patch) | |
tree | e0fc9891c2ae9d4f8a8264295f9539dead53b1e9 /lib/Sema/Sema.cpp | |
parent | adaaad3715c9c26cdcfdfe3401a13d7b4423ddcf (diff) |
code cleanup, convert if tree to switch etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84599 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 5d5a57632f..6e9362f28c 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -154,15 +154,19 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val, std::string S; bool NeedQuotes = true; - if (Kind == Diagnostic::ak_qualtype) { + + switch (Kind) { + default: assert(0 && "unknown ArgumentKind"); + case Diagnostic::ak_qualtype: { assert(ModLen == 0 && ArgLen == 0 && "Invalid modifier for QualType argument"); QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast<void*>(Val))); S = ConvertTypeToDiagnosticString(Context, Ty); NeedQuotes = false; - } else if (Kind == Diagnostic::ak_declarationname) { - + break; + } + case Diagnostic::ak_declarationname: { DeclarationName N = DeclarationName::getFromOpaqueInteger(Val); S = N.getAsString(); @@ -173,7 +177,9 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val, else assert(ModLen == 0 && ArgLen == 0 && "Invalid modifier for DeclarationName argument"); - } else if (Kind == Diagnostic::ak_nameddecl) { + break; + } + case Diagnostic::ak_nameddecl: { bool Qualified; if (ModLen == 1 && Modifier[0] == 'q' && ArgLen == 0) Qualified = true; @@ -182,22 +188,22 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val, "Invalid modifier for NamedDecl* argument"); Qualified = false; } - reinterpret_cast<NamedDecl*>(Val)->getNameForDiagnostic(S, - Context.PrintingPolicy, - Qualified); - } else if (Kind == Diagnostic::ak_nestednamespec) { + reinterpret_cast<NamedDecl*>(Val)-> + getNameForDiagnostic(S, Context.PrintingPolicy, Qualified); + break; + } + case Diagnostic::ak_nestednamespec: { llvm::raw_string_ostream OS(S); - reinterpret_cast<NestedNameSpecifier*> (Val)->print(OS, - Context.PrintingPolicy); + reinterpret_cast<NestedNameSpecifier*>(Val)->print(OS, + Context.PrintingPolicy); NeedQuotes = false; - } else { - assert(Kind == Diagnostic::ak_declcontext); + break; + } + case Diagnostic::ak_declcontext: { DeclContext *DC = reinterpret_cast<DeclContext *> (Val); - NeedQuotes = false; - if (!DC) { - assert(false && "Should never have a null declaration context"); - S = "unknown context"; - } else if (DC->isTranslationUnit()) { + assert(DC && "Should never have a null declaration context"); + + if (DC->isTranslationUnit()) { // FIXME: Get these strings from some localized place if (Context.getLangOptions().CPlusPlus) S = "the global namespace"; @@ -205,7 +211,6 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val, S = "the global scope"; } else if (TypeDecl *Type = dyn_cast<TypeDecl>(DC)) { S = ConvertTypeToDiagnosticString(Context, Context.getTypeDeclType(Type)); - NeedQuotes = false; } else { // FIXME: Get these strings from some localized place NamedDecl *ND = cast<NamedDecl>(DC); @@ -219,8 +224,10 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val, S += "'"; ND->getNameForDiagnostic(S, Context.PrintingPolicy, true); S += "'"; - NeedQuotes = false; } + NeedQuotes = false; + break; + } } if (NeedQuotes) |