Fix pr18174.

Clang outputs LLVM one top level decl at a time. This combined with the
visibility computation code looking for the newest NamespaceDecl would cause
it to produce different results for nested namespaces.

The two options for producing consistent results are
* Delay codegen of anything inside a namespace until the end of the file.
* Don't look for the newest NamespaceDecl.

This patch implements the second option.
This matches the gcc behavior too.

llvm-svn: 196712
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index c75cf20..83f2c53 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -976,7 +976,7 @@
                            kind);
 
   // Use the most recent declaration.
-  if (!IsMostRecent) {
+  if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
     const NamedDecl *MostRecent = ND->getMostRecentDecl();
     if (MostRecent != ND)
       return getExplicitVisibilityAux(MostRecent, kind, true);