[PATCH] D16552: Let clang not error out on `const std::vector<int> empty_vec; ` with libstdc++5.3.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 16 15:36:32 PST 2016


rsmith added a comment.

The direction here looks fine to me.


================
Comment at: lib/Sema/SemaInit.cpp:369
@@ +368,3 @@
+       ND = dyn_cast<NamespaceDecl>(ND->getParent())) {
+    if (S.getStdNamespace()->InEnclosingNamespaceSetOf(ND))
+      return true;
----------------
I wonder if this recursion through non-inline namespaces is really warranted; can we replace the call to this function with `R->isInStdNamespace()`?

================
Comment at: lib/Sema/SemaInit.cpp:434-435
@@ -424,10 +433,4 @@
         SemaRef.SourceMgr.isInSystemHeader(CtorDecl->getLocation())) {
-      bool IsInStd = false;
-      for (NamespaceDecl *ND = dyn_cast<NamespaceDecl>(R->getDeclContext());
-           ND && !IsInStd; ND = dyn_cast<NamespaceDecl>(ND->getParent())) {
-        if (SemaRef.getStdNamespace()->InEnclosingNamespaceSetOf(ND))
-          IsInStd = true;
-      }
-
-      if (IsInStd && llvm::StringSwitch<bool>(R->getName()) 
+      if (IsContainedInNamespaceStd(SemaRef, R) &&
+          llvm::StringSwitch<bool>(R->getName())
               .Cases("basic_string", "deque", "forward_list", true)
----------------
(Please commit this separately if you still want to make this change.)


http://reviews.llvm.org/D16552





More information about the cfe-commits mailing list