]> granicus.if.org Git - clang/commitdiff
Refactor the diagnostic DeclContext printing. No functionality change.
authorRichard Trieu <rtrieu@google.com>
Wed, 27 Aug 2014 03:05:19 +0000 (03:05 +0000)
committerRichard Trieu <rtrieu@google.com>
Wed, 27 Aug 2014 03:05:19 +0000 (03:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216517 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTDiagnostic.cpp

index 8c8b1dff0cbf6011e20f834bb2eff8c6fe517d85..5c73a37275a5cdee0e00148f281fb547d35d0c26 100644 (file)
@@ -342,26 +342,22 @@ void clang::FormatASTNodeDiagnosticArgument(
       assert(DC && "Should never have a null declaration context");
       NeedQuotes = false;
 
+      // FIXME: Get the strings for DeclContext from some localized place
       if (DC->isTranslationUnit()) {
-        // FIXME: Get these strings from some localized place
         if (Context.getLangOpts().CPlusPlus)
           OS << "the global namespace";
         else
           OS << "the global scope";
+      } else if (DC->isClosure()) {
+        OS << "block literal";
+      } else if (isLambdaCallOperator(DC)) {
+        OS << "lambda expression";
       } else if (TypeDecl *Type = dyn_cast<TypeDecl>(DC)) {
         OS << ConvertTypeToDiagnosticString(Context,
                                             Context.getTypeDeclType(Type),
                                             PrevArgs, QualTypeVals);
       } else {
-        // FIXME: Get these strings from some localized place
-        if (isa<BlockDecl>(DC)) {
-          OS << "block literal";
-          break;
-        }
-        if (isLambdaCallOperator(DC)) {
-          OS << "lambda expression";
-          break;
-        }
+        assert(isa<NamedDecl>(DC) && "Expected a NamedDecl");
         NamedDecl *ND = cast<NamedDecl>(DC);
         if (isa<NamespaceDecl>(ND))
           OS << "namespace ";