Skip to content

Conversation

@thevinster
Copy link
Contributor

Clang returns an error when compiling this file with c++20

error: ISO C++20 does not permit initialization of char array with UTF-8 string literal

It seems like c++20 treats u8strings differently than strings (probably needs char8_t).
Make this a string to fix the error.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang:analysis labels Mar 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 7, 2024

@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: Vincent Lee (thevinster)

Changes

Clang returns an error when compiling this file with c++20

error: ISO C++20 does not permit initialization of char array with UTF-8 string literal

It seems like c++20 treats u8strings differently than strings (probably needs char8_t).
Make this a string to fix the error.


Full diff: https://github.com/llvm/llvm-project/pull/84291.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp (+1-1)
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index ff4e18de2c70f1..d9f40d28859f5e 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -500,7 +500,7 @@ class HTMLLogger : public Logger {
     for (unsigned I = 0; I < CFG.getNumBlockIDs(); ++I) {
       std::string Name = blockID(I);
       // Rightwards arrow, vertical line
-      char ConvergenceMarker[] = u8"\\n\u2192\u007c";
+      char ConvergenceMarker[] = "\\n\u2192\u007c";
       if (BlockConverged[I])
         Name += ConvergenceMarker;
       GraphS << "  " << blockID(I) << " [id=" << blockID(I) << " label=\""

Copy link
Contributor

@martinboehme martinboehme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the breeakage!

@martinboehme martinboehme merged commit 6e79f77 into llvm:main Mar 7, 2024
std::string Name = blockID(I);
// Rightwards arrow, vertical line
char ConvergenceMarker[] = u8"\\n\u2192\u007c";
char ConvergenceMarker[] = "\\n\u2192\u007c";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thevinster @martinboehme This change now fails on MSVC builds:

warning C4566: character represented by universal-character-name '\u2192' cannot be represented in the current code page (1252)

Maybe try this instead?

const char *ConvergenceMarker = (const char*)u8"\\n\u2192\u007c";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Will revert and re-land with your suggestion. Sorry for the breakage!

martinboehme added a commit that referenced this pull request Mar 7, 2024
martinboehme added a commit that referenced this pull request Mar 7, 2024
martinboehme added a commit to martinboehme/llvm-project that referenced this pull request Mar 7, 2024
@martinboehme
Copy link
Contributor

New attempt: #84302

martinboehme added a commit that referenced this pull request Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:analysis clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants