Revert "[clang-diff] Fix assertion error when dealing with wide strings"
authorDouglas Yung <douglas.yung@sony.com>
Tue, 7 Jun 2022 21:58:10 +0000 (14:58 -0700)
committerDouglas Yung <douglas.yung@sony.com>
Tue, 7 Jun 2022 21:58:10 +0000 (14:58 -0700)
This reverts commit e80748ff8840a10bd7c7336eb5e98664480ba1ba.

This was causing a test failure on a buildbot: https://lab.llvm.org/buildbot/#/builders/139/builds/22964

clang/lib/Tooling/ASTDiff/ASTDiff.cpp
clang/test/Tooling/clang-diff-ast.cpp

index 786def5..0821863 100644 (file)
@@ -16,7 +16,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/PriorityQueue.h"
-#include "llvm/Support/ConvertUTF.h"
 
 #include <limits>
 #include <memory>
@@ -464,29 +463,8 @@ std::string SyntaxTree::Impl::getStmtValue(const Stmt *S) const {
   }
   if (auto *D = dyn_cast<DeclRefExpr>(S))
     return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
-  if (auto *String = dyn_cast<StringLiteral>(S)) {
-    if (String->isWide() || String->isUTF16() || String->isUTF32()) {
-      std::string UTF8Str;
-      unsigned int NumChars = String->getLength();
-      const char *Bytes = String->getBytes().data();
-      if (String->isWide()) {
-        const auto *Chars = reinterpret_cast<const wchar_t *>(Bytes);
-        if (!convertWideToUTF8({Chars, NumChars}, UTF8Str))
-          return "";
-      } else if (String->isUTF16()) {
-        const auto *Chars = reinterpret_cast<const UTF16 *>(Bytes);
-        if (!convertUTF16ToUTF8String({Chars, NumChars}, UTF8Str))
-          return "";
-      } else {
-        assert(String->isUTF32() && "Unsupported string encoding.");
-        const auto *Chars = reinterpret_cast<const UTF32 *>(Bytes);
-        if (!convertUTF32ToUTF8String({Chars, NumChars}, UTF8Str))
-          return "";
-      }
-      return UTF8Str;
-    }
+  if (auto *String = dyn_cast<StringLiteral>(S))
     return std::string(String->getString());
-  }
   if (auto *B = dyn_cast<CXXBoolLiteralExpr>(S))
     return B->getValue() ? "true" : "false";
   return "";
index e67128a..a8efda5 100644 (file)
@@ -47,12 +47,6 @@ class X : Base {
     if (i == 0)
       // CHECK: StringLiteral: foo(
       return "foo";
-    // CHECK: StringLiteral: wide(
-    (void)L"wide";
-    // CHECK: StringLiteral: utf-16(
-    (void)u"utf-16";
-    // CHECK: StringLiteral: utf-32(
-    (void)U"utf-32";
     // CHECK-NOT: ImplicitCastExpr
     return 0;
   }