Author: emilio Date: Tue Jul 9 07:27:01 2019 New Revision: 365490 URL: http://llvm.org/viewvc/llvm-project?rev=365490&view=rev Log: [libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.
Expression evaluator doesn't work in value-dependent types, so ensure that the precondition it asserts holds. This fixes https://bugs.llvm.org/show_bug.cgi?id=42532 Differential Revision: https://reviews.llvm.org/D64409 Modified: cfe/trunk/test/Index/evaluate-cursor.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/test/Index/evaluate-cursor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/evaluate-cursor.cpp?rev=365490&r1=365489&r2=365490&view=diff ============================================================================== --- cfe/trunk/test/Index/evaluate-cursor.cpp (original) +++ cfe/trunk/test/Index/evaluate-cursor.cpp Tue Jul 9 07:27:01 2019 @@ -21,6 +21,11 @@ unsigned long long HUGE = 1ull << 63; long long HUGE_NEG = -(1ll << 35); +template <typename d> class e { + using f = d; + static const auto g = alignof(f); +}; + // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \ // RUN: -evaluate-cursor-at=%s:8:7 \ // RUN: -evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s @@ -42,3 +47,9 @@ long long HUGE_NEG = -(1ll << 35); // CHECK-LONG: unsigned, Value: 1152921504606846976 // CHECK-LONG: unsigned, Value: 9223372036854775808 // CHECK-LONG: Value: -34359738368 + +// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \ +// RUN: -evaluate-cursor-at=%s:20:20 \ +// RUN: -evaluate-cursor-at=%s:26:21 \ +// RUN: -std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s +// CHECK-DOES-NOT-CRASH: Not Evaluatable Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=365490&r1=365489&r2=365490&view=diff ============================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 9 07:27:01 2019 @@ -3782,6 +3782,8 @@ static const ExprEvalResult* evaluateExp return nullptr; expr = expr->IgnoreParens(); + if (expr->isValueDependent()) + return nullptr; if (!expr->EvaluateAsRValue(ER, ctx)) return nullptr; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits