Handle local enum types too.

Thanks to John McCall for pointing this out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182182 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index cbd5588..8a523d6 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -298,11 +298,8 @@
   if (!TT)
     return LI;
 
-  const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TT->getDecl());
-  if (!RD)
-    return LI;
-
-  const FunctionDecl *FD = getOutermostFunctionContext(RD);
+  const Decl *D = TT->getDecl();
+  const FunctionDecl *FD = getOutermostFunctionContext(D);
   if (!FD)
     return LI;
 
diff --git a/test/CodeGenCXX/linkage.cpp b/test/CodeGenCXX/linkage.cpp
index 732c3cf..ce93161 100644
--- a/test/CodeGenCXX/linkage.cpp
+++ b/test/CodeGenCXX/linkage.cpp
@@ -92,3 +92,14 @@
 
   void *h() { return g(); }
 }
+
+namespace test8 {
+  // CHECK-DAG: define linkonce_odr void @_ZN5test81fIZNS_1gEvE1SEEvT_(
+  template <typename T> void f(T) {}
+  inline void *g() {
+    enum S {
+    };
+    return reinterpret_cast<void *>(f<S>);
+  }
+  void *h() { return g(); }
+}