r353598 - Fix buildbot failure from r353569.

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 8 18:22:17 PST 2019


Author: efriedma
Date: Fri Feb  8 18:22:17 2019
New Revision: 353598

URL: http://llvm.org/viewvc/llvm-project?rev=353598&view=rev
Log:
Fix buildbot failure from r353569.

I assumed lvalue-to-rvalue conversions of array type would never
happen, but apparently clang-tidy tries in some cases.


Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=353598&r1=353597&r2=353598&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb  8 18:22:17 2019
@@ -3370,8 +3370,15 @@ static bool handleLValueToRValueConversi
     } else if (isa<StringLiteral>(Base) || isa<PredefinedExpr>(Base)) {
       // Special-case character extraction so we don't have to construct an
       // APValue for the whole string.
-      assert(LVal.Designator.Entries.size() == 1 &&
+      assert(LVal.Designator.Entries.size() <= 1 &&
              "Can only read characters from string literals");
+      if (LVal.Designator.Entries.empty()) {
+        // Fail for now for LValue to RValue conversion of an array.
+        // (This shouldn't show up in C/C++, but it could be triggered by a
+        // weird EvaluateAsRValue call from a tool.)
+        Info.FFDiag(Conv);
+        return false;
+      }
       if (LVal.Designator.isOnePastTheEnd()) {
         if (Info.getLangOpts().CPlusPlus11)
           Info.FFDiag(Conv, diag::note_constexpr_access_past_end) << AK_Read;




More information about the cfe-commits mailing list