[OPENMP] Do not crash on codegen for CXX member functions.
Non-static member functions should not be emitted as a standalone
functions, this leads to compiler crash.
llvm-svn: 331206
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 33dfe71..0500f23 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -898,6 +898,9 @@
static llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy>
isDeclareTargetDeclaration(const ValueDecl *VD) {
+ if (const auto *MD = dyn_cast<CXXMethodDecl>(VD))
+ if (!MD->isStatic())
+ return llvm::None;
for (const Decl *D : VD->redecls()) {
if (!D->hasAttrs())
continue;