diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2017-04-10 19:16:45 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2017-04-10 19:16:45 +0000 |
commit | f7ce1662202717f774d1697948790f85bf6d8495 (patch) | |
tree | 7cb04b5b93fe47ba5f3d7bad24de1bdb3549e39e /clang/lib/CodeGen | |
parent | ec4880905d1663d0510a3ea6d905de9de2654f74 (diff) | |
download | bcm5719-llvm-f7ce1662202717f774d1697948790f85bf6d8495.tar.gz bcm5719-llvm-f7ce1662202717f774d1697948790f85bf6d8495.zip |
[OPENMP] Fix for PR32333: Crash in call of outlined Function.
If the type of the captured variable is a pointer(s) to variably
modified type, this type was not processed correctly. Need to drill into
the type, find the innermost variably modified array type and convert it
to canonical parameter type.
llvm-svn: 299868
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 71d8ea27143..22269e42c7a 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -227,6 +227,17 @@ static Address castValueFromUintptr(CodeGenFunction &CGF, QualType DstType, return TmpAddr; } +static QualType getCanonicalParamType(ASTContext &C, QualType T) { + if (T->isLValueReferenceType()) { + return C.getLValueReferenceType( + getCanonicalParamType(C, T.getNonReferenceType()), + /*SpelledAsLValue=*/false); + } + if (T->isPointerType()) + return C.getPointerType(getCanonicalParamType(C, T->getPointeeType())); + return C.getCanonicalParamType(T); +} + llvm::Function * CodeGenFunction::GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S) { assert( @@ -266,13 +277,8 @@ CodeGenFunction::GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S) { II = &getContext().Idents.get("vla"); } if (ArgType->isVariablyModifiedType()) { - bool IsReference = ArgType->isLValueReferenceType(); ArgType = - getContext().getCanonicalParamType(ArgType.getNonReferenceType()); - if (IsReference && !ArgType->isPointerType()) { - ArgType = getContext().getLValueReferenceType( - ArgType, /*SpelledAsLValue=*/false); - } + getCanonicalParamType(getContext(), ArgType.getNonReferenceType()); } Args.push_back(ImplicitParamDecl::Create(getContext(), nullptr, FD->getLocation(), II, ArgType)); |