[llvm-branch-commits] [clang] 544ffda - [WIP][OpenMP] Do not crash if no auxiliary target was given

Johannes Doerfert via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 3 23:58:46 PDT 2020


Author: Johannes Doerfert
Date: 2020-04-04T01:56:18-05:00
New Revision: 544ffda5ec21371d3fdace2c11378993e56f6b5b

URL: https://github.com/llvm/llvm-project/commit/544ffda5ec21371d3fdace2c11378993e56f6b5b
DIFF: https://github.com/llvm/llvm-project/commit/544ffda5ec21371d3fdace2c11378993e56f6b5b.diff

LOG: [WIP][OpenMP] Do not crash if no auxiliary target was given

Added: 
    

Modified: 
    clang/lib/AST/ASTContext.cpp
    clang/lib/AST/ItaniumMangle.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 06513fc4b234..bafbfde01e26 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1652,11 +1652,11 @@ const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const {
   case BuiltinType::Float:      return Target->getFloatFormat();
   case BuiltinType::Double:     return Target->getDoubleFormat();
   case BuiltinType::LongDouble:
-    if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)
+    if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice && AuxTarget)
       return AuxTarget->getLongDoubleFormat();
     return Target->getLongDoubleFormat();
   case BuiltinType::Float128:
-    if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)
+    if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice && AuxTarget)
       return AuxTarget->getFloat128Format();
     return Target->getFloat128Format();
   }
@@ -2032,7 +2032,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
     case BuiltinType::Float16:
     case BuiltinType::Half:
       if (Target->hasFloat16Type() || !getLangOpts().OpenMP ||
-          !getLangOpts().OpenMPIsDevice) {
+          !getLangOpts().OpenMPIsDevice || !AuxTarget) {
         Width = Target->getHalfWidth();
         Align = Target->getHalfAlign();
       } else {
@@ -2051,7 +2051,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
       Align = Target->getDoubleAlign();
       break;
     case BuiltinType::LongDouble:
-      if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
+      if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice && AuxTarget &&
           (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
            Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
         Width = AuxTarget->getLongDoubleWidth();
@@ -2063,7 +2063,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
       break;
     case BuiltinType::Float128:
       if (Target->hasFloat128Type() || !getLangOpts().OpenMP ||
-          !getLangOpts().OpenMPIsDevice) {
+          !getLangOpts().OpenMPIsDevice || !AuxTarget) {
         Width = Target->getFloat128Width();
         Align = Target->getFloat128Align();
       } else {

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index cb7bd61574ef..1b32738212e3 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2731,18 +2731,22 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
     Out << 'd';
     break;
   case BuiltinType::LongDouble: {
-    const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
-                                   getASTContext().getLangOpts().OpenMPIsDevice
-                               ? getASTContext().getAuxTargetInfo()
-                               : &getASTContext().getTargetInfo();
+    const TargetInfo *TI =
+        getASTContext().getLangOpts().OpenMP &&
+                getASTContext().getLangOpts().OpenMPIsDevice &&
+                getASTContext().getAuxTargetInfo()
+            ? getASTContext().getAuxTargetInfo()
+            : &getASTContext().getTargetInfo();
     Out << TI->getLongDoubleMangling();
     break;
   }
   case BuiltinType::Float128: {
-    const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
-                                   getASTContext().getLangOpts().OpenMPIsDevice
-                               ? getASTContext().getAuxTargetInfo()
-                               : &getASTContext().getTargetInfo();
+    const TargetInfo *TI =
+        getASTContext().getLangOpts().OpenMP &&
+                getASTContext().getLangOpts().OpenMPIsDevice &&
+                getASTContext().getAuxTargetInfo()
+            ? getASTContext().getAuxTargetInfo()
+            : &getASTContext().getTargetInfo();
     Out << TI->getFloat128Mangling();
     break;
   }


        


More information about the llvm-branch-commits mailing list