Skip to content

Fix clang crash with -print-changed=dot-cfg #148844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cabbaken
Copy link
Contributor

@cabbaken cabbaken commented Jul 15, 2025

Remove unnecessary comparison of Before and After DCData, which will cause an error when create DotCfgDiff.

Fixes: #148579

Remove unnecessary comparison of Before and After `DCData`,
which will cause an error when create `DotCfgDiff`.

Signed-off-by: Ruoyu Qiu <[email protected]>
@cabbaken
Copy link
Contributor Author

I'm sorry I forgot to include a test. I will add it later.

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/Passes/StandardInstrumentations.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index df10da9c8..916dcd32c 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -1799,9 +1799,9 @@ public:
                  StringRef Label, StringRef Colour)
       : Graph(G), N(N), Data{&BD, nullptr}, Label(Label), Colour(Colour) {}
   DotCfgDiffNode(const DotCfgDiffNode &DN)
-      : Graph(DN.Graph), N(DN.N), Data{DN.Data[0], DN.Data[1]},
-        Label(DN.Label), Colour(DN.Colour), EdgesMap(DN.EdgesMap),
-        Children(DN.Children), Edges(DN.Edges) {}
+      : Graph(DN.Graph), N(DN.N), Data{DN.Data[0], DN.Data[1]}, Label(DN.Label),
+        Colour(DN.Colour), EdgesMap(DN.EdgesMap), Children(DN.Children),
+        Edges(DN.Edges) {}
 
   unsigned getIndex() const { return N; }
 
@@ -1959,7 +1959,7 @@ std::string DotCfgDiffNode::getBodyContent() const {
   if (BS.front() == '\n')
     BS1 = BS1.drop_front(1);
   // drop predecessors as they can be big and are redundant
-  if(BS1.str().find(Label) != std::string::npos)
+  if (BS1.str().find(Label) != std::string::npos)
     BS1 = BS1.drop_until([](char C) { return C == '\n'; }).drop_front();
 
   std::string S = "<FONT COLOR=\"" + Colour.str() + "\">" + Label.str() + ":";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Clang] Clang crashed when compiling with -mllvm -print-changed=dot-cfg
1 participant