[clang] 385e5f7 - Fix incorrect call to ExprResult::get()

Alex Richardson via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 11 14:24:40 PDT 2020


Author: Alex Richardson
Date: 2020-06-11T22:23:33+01:00
New Revision: 385e5f7e147fcf792085b365cc48380850612025

URL: https://github.com/llvm/llvm-project/commit/385e5f7e147fcf792085b365cc48380850612025
DIFF: https://github.com/llvm/llvm-project/commit/385e5f7e147fcf792085b365cc48380850612025.diff

LOG: Fix incorrect call to ExprResult::get()

Res is already a ExprResult, so if we call .get(), we will convert an
ExprError() result into an unset result. I discovered this in our downstream
CHERI target where this resulted in a crash due to a NULL-dereference.
It appears that this was introduced in SVN revision 201788 (8690a6860a45ba36e39b4ff0dbe434195e125d11)

Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D81608

Added: 
    

Modified: 
    clang/lib/Sema/SemaExpr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0537d09a09eb..6477979e92fe 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -724,7 +724,7 @@ ExprResult Sema::CallExprUnaryConversions(Expr *E) {
   // to function type.
   if (Ty->isFunctionType()) {
     Res = ImpCastExprToType(E, Context.getPointerType(Ty),
-                            CK_FunctionToPointerDecay).get();
+                            CK_FunctionToPointerDecay);
     if (Res.isInvalid())
       return ExprError();
   }


        


More information about the cfe-commits mailing list