[clang] 63e3fe1 - Revert "[clang][Interp] Implement String- and CharacterLiterals"
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 28 04:34:58 PDT 2022
Author: Timm Bäder
Date: 2022-10-28T13:34:37+02:00
New Revision: 63e3fe10882476696d8a05907dfe627bd61638a3
URL: https://github.com/llvm/llvm-project/commit/63e3fe10882476696d8a05907dfe627bd61638a3
DIFF: https://github.com/llvm/llvm-project/commit/63e3fe10882476696d8a05907dfe627bd61638a3.diff
LOG: Revert "[clang][Interp] Implement String- and CharacterLiterals"
This reverts commit 6fa1795d1fd4770f9f5c00f5a30937d68c3feb17.
This breaks a windows builder:
../../clang/lib/AST/Interp/ByteCodeExprGen.h(236,11): error: call to constructor of 'clang::interp::APInt' (aka 'llvm::APInt') is ambiguous
APInt WrappedValue(getIntWidth(Ty), Value, std::is_signed<T>::value);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../clang/lib/AST/Interp/ByteCodeExprGen.cpp(409,16): note: in instantiation of function template specialization 'clang::interp::ByteCodeExprGen<clang::interp::ByteCodeEmitter>::emitConst<unsigned int>' requested here
return this->emitConst(E, E->getValue());
^
../../clang/lib/AST/Interp/ByteCodeExprGen.cpp(1149,16): note: in instantiation of member function 'clang::interp::ByteCodeExprGen<clang::interp::ByteCodeEmitter>::VisitCharacterLiteral' requested here
template class ByteCodeExprGen<ByteCodeEmitter>;
^
../../llvm/include\llvm/ADT/APInt.h(108,3): note: candidate constructor
APInt(unsigned numBits, uint64_t val, bool isSigned = false)
^
../../llvm/include\llvm/ADT/APInt.h(134,3): note: candidate constructor
APInt(unsigned numBits, unsigned numWords, const uint64_t bigVal[]);
^
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/test/AST/Interp/literals.cpp
clang/test/Lexer/char-escapes.c
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 7e00fc4f707e9..9472f1aed9178 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -397,18 +397,6 @@ bool ByteCodeExprGen<Emitter>::VisitAbstractConditionalOperator(
return true;
}
-template <class Emitter>
-bool ByteCodeExprGen<Emitter>::VisitStringLiteral(const StringLiteral *E) {
- unsigned StringIndex = P.createGlobalString(E);
- return this->emitGetPtrGlobal(StringIndex, E);
-}
-
-template <class Emitter>
-bool ByteCodeExprGen<Emitter>::VisitCharacterLiteral(
- const CharacterLiteral *E) {
- return this->emitConst(E, E->getValue());
-}
-
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/true);
return this->Visit(E);
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 1759d17d3288f..a254a1baee8f9 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -83,8 +83,6 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E);
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E);
bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E);
- bool VisitStringLiteral(const StringLiteral *E);
- bool VisitCharacterLiteral(const CharacterLiteral *E);
protected:
bool visitExpr(const Expr *E) override;
diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index ca76be9b0bf94..f0083e63f35d9 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -278,46 +278,3 @@ namespace bitOr {
static_assert((0 | gimme(12)) == 12, "");
static_assert((12 | true) == 13, "");
};
-
-namespace strings {
- constexpr const char *S = "abc";
- static_assert(S[0] == 97, "");
- static_assert(S[1] == 98, "");
- static_assert(S[2] == 99, "");
- static_assert(S[3] == 0, "");
-
- static_assert("foobar"[2] == 'o', "");
- static_assert(2["foobar"] == 'o', "");
-
- constexpr const wchar_t *wide = L"bar";
- static_assert(wide[0] == L'b', "");
-
- constexpr const char32_t *u32 = U"abc";
- static_assert(u32[1] == U'b', "");
-
- constexpr char32_t c = U'\U0001F60E';
- static_assert(c == 0x0001F60EL, "");
-
- constexpr char k = -1;
- static_assert(k == -1, "");
-
- static_assert('\N{LATIN CAPITAL LETTER E}' == 'E', "");
- static_assert('\t' == 9, "");
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wmultichar"
- constexpr int mc = 'abc';
- static_assert(mc == 'abc', "");
- __WCHAR_TYPE__ wm = L'abc'; // ref-error{{wide character literals may not contain multiple characters}} \
- // expected-error{{wide character literals may not contain multiple characters}}
- __WCHAR_TYPE__ wu = u'abc'; // ref-error{{Unicode character literals may not contain multiple characters}} \
- // expected-error{{Unicode character literals may not contain multiple characters}}
- __WCHAR_TYPE__ wU = U'abc'; // ref-error{{Unicode character literals may not contain multiple characters}} \
- // expected-error{{Unicode character literals may not contain multiple characters}}
-#if __cplusplus > 201103L
- __WCHAR_TYPE__ wu8 = u8'abc'; // ref-error{{Unicode character literals may not contain multiple characters}} \
- // expected-error{{Unicode character literals may not contain multiple characters}}
-#endif
-
-#pragma clang diagnostic pop
-};
diff --git a/clang/test/Lexer/char-escapes.c b/clang/test/Lexer/char-escapes.c
index 11e25a6d251fe..32a1c6140d53c 100644
--- a/clang/test/Lexer/char-escapes.c
+++ b/clang/test/Lexer/char-escapes.c
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fsyntax-only -pedantic -fexperimental-new-constant-interpreter -verify %s
int test['\\' == 92 ? 1 : -1];
int test['\"' == 34 ? 1 : -1];
More information about the cfe-commits
mailing list