r219795 - Turned Sema::HandleDelayedAvailabilityCheck into a static function; NFC.

Aaron Ballman aaron at aaronballman.com
Wed Oct 15 08:37:52 PDT 2014


Author: aaronballman
Date: Wed Oct 15 10:37:51 2014
New Revision: 219795

URL: http://llvm.org/viewvc/llvm-project?rev=219795&view=rev
Log:
Turned Sema::HandleDelayedAvailabilityCheck into a static function; NFC.

Did a bit of drive-by reformatting as well since it required rearranging some other static functions in the file.

Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=219795&r1=219794&r2=219795&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct 15 10:37:51 2014
@@ -3267,8 +3267,6 @@ public:
                                const ObjCPropertyDecl  *ObjCProperty,
                                bool ObjCPropertyAccess);
 
-  void HandleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx);
-
   bool makeUnavailableInSystemHeader(SourceLocation loc,
                                      StringRef message);
 

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=219795&r1=219794&r2=219795&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Oct 15 10:37:51 2014
@@ -4911,61 +4911,6 @@ static void handleDelayedForbiddenType(S
   diag.Triggered = true;
 }
 
-void Sema::PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
-  assert(DelayedDiagnostics.getCurrentPool());
-  DelayedDiagnosticPool &poppedPool = *DelayedDiagnostics.getCurrentPool();
-  DelayedDiagnostics.popWithoutEmitting(state);
-
-  // When delaying diagnostics to run in the context of a parsed
-  // declaration, we only want to actually emit anything if parsing
-  // succeeds.
-  if (!decl) return;
-
-  // We emit all the active diagnostics in this pool or any of its
-  // parents.  In general, we'll get one pool for the decl spec
-  // and a child pool for each declarator; in a decl group like:
-  //   deprecated_typedef foo, *bar, baz();
-  // only the declarator pops will be passed decls.  This is correct;
-  // we really do need to consider delayed diagnostics from the decl spec
-  // for each of the different declarations.
-  const DelayedDiagnosticPool *pool = &poppedPool;
-  do {
-    for (DelayedDiagnosticPool::pool_iterator
-           i = pool->pool_begin(), e = pool->pool_end(); i != e; ++i) {
-      // This const_cast is a bit lame.  Really, Triggered should be mutable.
-      DelayedDiagnostic &diag = const_cast<DelayedDiagnostic&>(*i);
-      if (diag.Triggered)
-        continue;
-
-      switch (diag.Kind) {
-      case DelayedDiagnostic::Deprecation:
-      case DelayedDiagnostic::Unavailable:
-        // Don't bother giving deprecation/unavailable diagnostics if
-        // the decl is invalid.
-        if (!decl->isInvalidDecl())
-          HandleDelayedAvailabilityCheck(diag, decl);
-        break;
-
-      case DelayedDiagnostic::Access:
-        HandleDelayedAccessCheck(diag, decl);
-        break;
-
-      case DelayedDiagnostic::ForbiddenType:
-        handleDelayedForbiddenType(*this, diag, decl);
-        break;
-      }
-    }
-  } while ((pool = pool->getParent()));
-}
-
-/// Given a set of delayed diagnostics, re-emit them as if they had
-/// been delayed in the current context instead of in the given pool.
-/// Essentially, this just moves them to the current pool.
-void Sema::redelayDiagnostics(DelayedDiagnosticPool &pool) {
-  DelayedDiagnosticPool *curPool = DelayedDiagnostics.getCurrentPool();
-  assert(curPool && "re-emitting in undelayed context not supported");
-  curPool->steal(pool);
-}
 
 static bool isDeclDeprecated(Decl *D) {
   do {
@@ -4989,17 +4934,12 @@ static bool isDeclUnavailable(Decl *D) {
   return false;
 }
 
-static void
-DoEmitAvailabilityWarning(Sema &S,
-                          DelayedDiagnostic::DDKind K,
-                          Decl *Ctx,
-                          const NamedDecl *D,
-                          StringRef Message,
-                          SourceLocation Loc,
-                          const ObjCInterfaceDecl *UnknownObjCClass,
-                          const ObjCPropertyDecl *ObjCProperty,
-                          bool ObjCPropertyAccess) {
-
+static void DoEmitAvailabilityWarning(Sema &S, DelayedDiagnostic::DDKind K,
+                                      Decl *Ctx, const NamedDecl *D,
+                                      StringRef Message, SourceLocation Loc,
+                                      const ObjCInterfaceDecl *UnknownObjCClass,
+                                      const ObjCPropertyDecl *ObjCProperty,
+                                      bool ObjCPropertyAccess) {
   // Diagnostics for deprecated or unavailable.
   unsigned diag, diag_message, diag_fwdclass_message;
 
@@ -5011,30 +4951,30 @@ DoEmitAvailabilityWarning(Sema &S,
 
   // Don't warn if our current context is deprecated or unavailable.
   switch (K) {
-    case DelayedDiagnostic::Deprecation:
-      if (isDeclDeprecated(Ctx))
-        return;
-      diag = !ObjCPropertyAccess ? diag::warn_deprecated
-                                 : diag::warn_property_method_deprecated;
-      diag_message = diag::warn_deprecated_message;
-      diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
-      property_note_select = /* deprecated */ 0;
-      available_here_select_kind = /* deprecated */ 2;
-      break;
-
-    case DelayedDiagnostic::Unavailable:
-      if (isDeclUnavailable(Ctx))
-        return;
-      diag = !ObjCPropertyAccess ? diag::err_unavailable
-                                 : diag::err_property_method_unavailable;
-      diag_message = diag::err_unavailable_message;
-      diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
-      property_note_select = /* unavailable */ 1;
-      available_here_select_kind = /* unavailable */ 0;
-      break;
+  case DelayedDiagnostic::Deprecation:
+    if (isDeclDeprecated(Ctx))
+      return;
+    diag = !ObjCPropertyAccess ? diag::warn_deprecated
+                               : diag::warn_property_method_deprecated;
+    diag_message = diag::warn_deprecated_message;
+    diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
+    property_note_select = /* deprecated */ 0;
+    available_here_select_kind = /* deprecated */ 2;
+    break;
+
+  case DelayedDiagnostic::Unavailable:
+    if (isDeclUnavailable(Ctx))
+      return;
+    diag = !ObjCPropertyAccess ? diag::err_unavailable
+                               : diag::err_property_method_unavailable;
+    diag_message = diag::err_unavailable_message;
+    diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
+    property_note_select = /* unavailable */ 1;
+    available_here_select_kind = /* unavailable */ 0;
+    break;
 
-    default:
-      llvm_unreachable("Neither a deprecation or unavailable kind");
+  default:
+    llvm_unreachable("Neither a deprecation or unavailable kind");
   }
 
   DeclarationName Name = D->getDeclName();
@@ -5042,34 +4982,86 @@ DoEmitAvailabilityWarning(Sema &S,
     S.Diag(Loc, diag_message) << Name << Message;
     if (ObjCProperty)
       S.Diag(ObjCProperty->getLocation(), diag::note_property_attribute)
-        << ObjCProperty->getDeclName() << property_note_select;
+          << ObjCProperty->getDeclName() << property_note_select;
   } else if (!UnknownObjCClass) {
     S.Diag(Loc, diag) << Name;
     if (ObjCProperty)
       S.Diag(ObjCProperty->getLocation(), diag::note_property_attribute)
-        << ObjCProperty->getDeclName() << property_note_select;
+          << ObjCProperty->getDeclName() << property_note_select;
   } else {
     S.Diag(Loc, diag_fwdclass_message) << Name;
     S.Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
   }
 
   S.Diag(D->getLocation(), diag::note_availability_specified_here)
-    << D << available_here_select_kind;
+      << D << available_here_select_kind;
 }
 
-void Sema::HandleDelayedAvailabilityCheck(DelayedDiagnostic &DD,
-                                          Decl *Ctx) {
+static void handleDelayedAvailabilityCheck(Sema &S, DelayedDiagnostic &DD,
+                                           Decl *Ctx) {
   DD.Triggered = true;
-  DoEmitAvailabilityWarning(*this,
-                            (DelayedDiagnostic::DDKind) DD.Kind,
-                            Ctx,
-                            DD.getDeprecationDecl(),
-                            DD.getDeprecationMessage(),
-                            DD.Loc,
-                            DD.getUnknownObjCClass(),
+  DoEmitAvailabilityWarning(S, (DelayedDiagnostic::DDKind)DD.Kind, Ctx,
+                            DD.getDeprecationDecl(), DD.getDeprecationMessage(),
+                            DD.Loc, DD.getUnknownObjCClass(),
                             DD.getObjCProperty(), false);
 }
 
+void Sema::PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
+  assert(DelayedDiagnostics.getCurrentPool());
+  DelayedDiagnosticPool &poppedPool = *DelayedDiagnostics.getCurrentPool();
+  DelayedDiagnostics.popWithoutEmitting(state);
+
+  // When delaying diagnostics to run in the context of a parsed
+  // declaration, we only want to actually emit anything if parsing
+  // succeeds.
+  if (!decl) return;
+
+  // We emit all the active diagnostics in this pool or any of its
+  // parents.  In general, we'll get one pool for the decl spec
+  // and a child pool for each declarator; in a decl group like:
+  //   deprecated_typedef foo, *bar, baz();
+  // only the declarator pops will be passed decls.  This is correct;
+  // we really do need to consider delayed diagnostics from the decl spec
+  // for each of the different declarations.
+  const DelayedDiagnosticPool *pool = &poppedPool;
+  do {
+    for (DelayedDiagnosticPool::pool_iterator
+           i = pool->pool_begin(), e = pool->pool_end(); i != e; ++i) {
+      // This const_cast is a bit lame.  Really, Triggered should be mutable.
+      DelayedDiagnostic &diag = const_cast<DelayedDiagnostic&>(*i);
+      if (diag.Triggered)
+        continue;
+
+      switch (diag.Kind) {
+      case DelayedDiagnostic::Deprecation:
+      case DelayedDiagnostic::Unavailable:
+        // Don't bother giving deprecation/unavailable diagnostics if
+        // the decl is invalid.
+        if (!decl->isInvalidDecl())
+          handleDelayedAvailabilityCheck(*this, diag, decl);
+        break;
+
+      case DelayedDiagnostic::Access:
+        HandleDelayedAccessCheck(diag, decl);
+        break;
+
+      case DelayedDiagnostic::ForbiddenType:
+        handleDelayedForbiddenType(*this, diag, decl);
+        break;
+      }
+    }
+  } while ((pool = pool->getParent()));
+}
+
+/// Given a set of delayed diagnostics, re-emit them as if they had
+/// been delayed in the current context instead of in the given pool.
+/// Essentially, this just moves them to the current pool.
+void Sema::redelayDiagnostics(DelayedDiagnosticPool &pool) {
+  DelayedDiagnosticPool *curPool = DelayedDiagnostics.getCurrentPool();
+  assert(curPool && "re-emitting in undelayed context not supported");
+  curPool->steal(pool);
+}
+
 void Sema::EmitAvailabilityWarning(AvailabilityDiagnostic AD,
                                    NamedDecl *D, StringRef Message,
                                    SourceLocation Loc,





More information about the cfe-commits mailing list