Skip to content

[Clang] Separate implicit int conversion on negation sign to new diagnostic group #139429

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

Merged
merged 4 commits into from
Jun 2, 2025

Conversation

YutongZhuu
Copy link
Contributor

@YutongZhuu YutongZhuu commented May 11, 2025

This PR reverts a change made in #126846.

#126846 introduced an -Wimplicit-int-conversion diagnosis for

int8_t x = something;
x = -x; // warning here

This is technically correct since -x could have a width of 9, but this pattern is common in codebases.

Reverting this change would also introduce the false positive I fixed in #126846:

bool b(signed char c) {
  return -c >= 128; // -c can be 128
}

This false positive is uncommon, so I think it makes sense to revert the change.

@YutongZhuu YutongZhuu changed the title Make UO_Minus and UO_Not having the same logic in TryGetExprRange Suppress a -Wimplicit-int-conversion introduced in #126846 May 11, 2025
@YutongZhuu YutongZhuu changed the title Suppress a -Wimplicit-int-conversion introduced in #126846 [Clang] Suppress a -Wimplicit-int-conversionwarning introduced in #126846 May 11, 2025
@YutongZhuu YutongZhuu marked this pull request as ready for review May 11, 2025 17:47
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels May 11, 2025
@llvmbot
Copy link
Member

llvmbot commented May 11, 2025

@llvm/pr-subscribers-clang

Author: Yutong Zhu (YutongZhuu)

Changes

This PR reverts a change made in #126846.

#126846 introduced an -Wimplicit-int-conversion diagnosis for

int8_t x = something;
x = -x; // warning here

This is technically correct since -x could have a width of 9, but this pattern is common in codebases.

Reverting this change would also introduce the false positive I fixed in #126846:

bool b(signed char c) {
  return -c >= 128; // -c can be 128
}

This false positive is uncommon, so I think it makes sense to revert the change.


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

3 Files Affected:

  • (modified) clang/docs/ReleaseNotes.rst (+3)
  • (modified) clang/lib/Sema/SemaChecking.cpp (+5-19)
  • (modified) clang/test/Sema/compare.c (+3-20)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 11f62bc881b03..edbcbea7828b2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -352,6 +352,9 @@ Improvements to Clang's diagnostics
 - Now correctly diagnose a tentative definition of an array with static
   storage duration in pedantic mode in C. (#GH50661)
 
+- The -Wimplicit-int-conversion warning no longer triggers for direct assignments between integer types narrower than int. 
+  However, -Wsign-compare can now incorrectly produce a warning when comparing a value to another with just one more bit of width.
+
 Improvements to Clang's time-trace
 ----------------------------------
 
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index bffd0dd461d3d..084c3dbdecb20 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10626,25 +10626,7 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E,
     case UO_AddrOf: // should be impossible
       return IntRange::forValueOfType(C, GetExprType(E));
 
-    case UO_Minus: {
-      if (E->getType()->isUnsignedIntegerType()) {
-        return TryGetExprRange(C, UO->getSubExpr(), MaxWidth, InConstantContext,
-                               Approximate);
-      }
-
-      std::optional<IntRange> SubRange = TryGetExprRange(
-          C, UO->getSubExpr(), MaxWidth, InConstantContext, Approximate);
-
-      if (!SubRange)
-        return std::nullopt;
-
-      // If the range was previously non-negative, we need an extra bit for the
-      // sign bit. If the range was not non-negative, we need an extra bit
-      // because the negation of the most-negative value is one bit wider than
-      // that value.
-      return IntRange(SubRange->Width + 1, false);
-    }
-
+    case UO_Minus:
     case UO_Not: {
       if (E->getType()->isUnsignedIntegerType()) {
         return TryGetExprRange(C, UO->getSubExpr(), MaxWidth, InConstantContext,
@@ -10659,6 +10641,10 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E,
 
       // The width increments by 1 if the sub-expression cannot be negative
       // since it now can be.
+      // This isn't technically correct for UO_Minus since we need an extra bit
+      // because the negation of the most-negative value is one bit wider than
+      // the original value. However, the correct version triggers many unwanted
+      // warnings.
       return IntRange(SubRange->Width + (int)SubRange->NonNegative, false);
     }
 
diff --git a/clang/test/Sema/compare.c b/clang/test/Sema/compare.c
index fdae3bc19841e..f8c4694b8730e 100644
--- a/clang/test/Sema/compare.c
+++ b/clang/test/Sema/compare.c
@@ -454,16 +454,6 @@ int test20(int n) {
 }
 #endif
 
-int test21(short n) {
-  return -n == 32768; // no-warning
-}
-
-#if TEST == 1
-int test22(short n) {
-  return -n == 65536; // expected-warning {{result of comparison of 17-bit signed value == 65536 is always false}}
-}
-#endif
-
 int test23(unsigned short n) {
   return ~n == 32768; // no-warning
 }
@@ -471,13 +461,6 @@ int test23(unsigned short n) {
 int test24(short n) {
   return ~n == 32767; // no-warning
 }
-
-#if TEST == 1
-int test25(unsigned short n) {
-  return ~n == 65536; // expected-warning {{result of comparison of 17-bit signed value == 65536 is always false}}
-}
-
-int test26(short n) {
-  return ~n == 32768; // expected-warning {{result of comparison of 16-bit signed value == 32768 is always false}}
-}
-#endif
+unsigned char test25(unsigned char n) {
+  return -n; // no-warning
+}
\ No newline at end of file

@cor3ntin
Copy link
Contributor

If that warning is disruptive, maybe we should consider making it a separate warning that people can disable independently? It is certainly a potential source of bugs, so I'm not sure removing it entirely is the right approach
@AaronBallman

@AaronBallman
Copy link
Collaborator

I think it makes sense to split this off into its own warning group so it can be controlled separately from -Wimplicit-int-conversion. It is a common code pattern, but it can still hide bugs that can be hard to spot when the values are on the edge of the range of representable values for the type.

@YutongZhuu
Copy link
Contributor Author

YutongZhuu commented May 12, 2025

I think it makes sense to split this off into its own warning group so it can be controlled separately from -Wimplicit-int-conversion. It is a common code pattern, but it can still hide bugs that can be hard to spot when the values are on the edge of the range of representable values for the type.

You mean we should keep my previous changes and separate this pattern

int8_t x = something; 
x = -x;

to a new warning flag?

@AaronBallman
Copy link
Collaborator

I think it makes sense to split this off into its own warning group so it can be controlled separately from -Wimplicit-int-conversion. It is a common code pattern, but it can still hide bugs that can be hard to spot when the values are on the edge of the range of representable values for the type.

You mean we should keep my previous changes and separate this pattern

int8_t x = something; 
x = -x;

to a new warning flag?

Correct. Perhaps something like -Wimplicit-int-conversion-on-negation which is grouped under -Wimplicit-int-conversion?

@YutongZhuu YutongZhuu changed the title [Clang] Suppress a -Wimplicit-int-conversionwarning introduced in #126846 [Clang] Separate implicit int conversion on negation sign to new diagnostic group May 15, 2025
@YutongZhuu
Copy link
Contributor Author

If that warning is disruptive, maybe we should consider making it a separate warning that people can disable independently? It is certainly a potential source of bugs, so I'm not sure removing it entirely is the right approach @AaronBallman

H

If that warning is disruptive, maybe we should consider making it a separate warning that people can disable independently? It is certainly a potential source of bugs, so I'm not sure removing it entirely is the right approach @AaronBallman

Hi, could you check if this is what you suggested?

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

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

The direction looks good.
Can you add more tests, with different integer types? Thanks

Comment on lines 12094 to 12099
if (const auto *UO = dyn_cast<UnaryOperator>(E)) {
return DiagnoseImpCast(*this, E, T, CC,
diag::warn_impcast_integer_precision_on_negation);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We should check which operator it is. Did you try to add tests with

unsigned char test_diag(unsigned char x) {
    return +x;
}```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, that was a mistake.

Comment on lines 1 to 37
// RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion
// RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion -Wno-implicit-int-conversion-on-negation -DNO_DIAG

#ifdef NO_DIAG
unsigned char test_no_diag(unsigned char x) {
return -x; // expected-no-diagnostics
}
#else
unsigned char test_diag(unsigned char x) {
return -x; // expected-warning {{implicit conversion loses integer precision: 'int' to 'unsigned char' on negation}}
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion
// RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion -Wno-implicit-int-conversion-on-negation -DNO_DIAG
#ifdef NO_DIAG
unsigned char test_no_diag(unsigned char x) {
return -x; // expected-no-diagnostics
}
#else
unsigned char test_diag(unsigned char x) {
return -x; // expected-warning {{implicit conversion loses integer precision: 'int' to 'unsigned char' on negation}}
}
#endif
// RUN: %clang_cc1 %s -verify=nowarn -Wimplicit-int-conversion
// RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion -Wno-implicit-int-conversion-on-negation -DNO_DIAG
// nowarn-no-diagnostics
unsigned char test_no_diag(unsigned char x) {
return -x; // expected-warning {{implicit conversion loses integer precision: 'int' to 'unsigned char' on negation}}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't able to get this to work, if you are worried about code duplication, is the current version better?

Copy link

github-actions bot commented May 16, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@YutongZhuu YutongZhuu requested a review from cor3ntin May 16, 2025 18:21
@YutongZhuu
Copy link
Contributor Author

@cor3ntin Hi, sorry to bother, I think this is ready for review :)

@cor3ntin cor3ntin requested a review from AaronBallman May 28, 2025 05:42
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

Thank you for working on this!

Comment on lines 355 to 356
- Split diagnosis of implicit integer comparison on negation to a new diagnostic group ``-Wimplicit-int-comparison-on-negation``,
so user can turn it off independently.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Split diagnosis of implicit integer comparison on negation to a new diagnostic group ``-Wimplicit-int-comparison-on-negation``,
so user can turn it off independently.
- Split diagnosis of implicit integer comparison on negation to a new
diagnostic group ``-Wimplicit-int-comparison-on-negation``, grouped under
``-Wimplicit-int-conversion``, so user can turn it off independently.

@@ -0,0 +1,64 @@
// RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion
// RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion -Wno-implicit-int-conversion-on-negation -DNO_DIAG
Copy link
Collaborator

Choose a reason for hiding this comment

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

A better approach than using -D is to specify a prefix to -verify: https://clang.llvm.org/docs/InternalsManual.html#verifying-diagnostics

Then you can have one comment for the -no-diagnostics RUN line and skip all the preprocessor code for the other RUN line.

char test_char(char x) {
return -x;
#ifndef NO_DIAG
// expected-warning@-2 {{implicit conversion loses integer precision}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this actually checking for the new diagnostic ("on negation")? If so, you should update the expected warning to include the whole diagnostic text.

@AaronBallman AaronBallman requested a review from zygoloid May 28, 2025 16:49
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM aside from a request for another test

Comment on lines +18 to +20
unsigned short test_unsigned_short(unsigned short x) {
return -x; // expected-warning {{implicit conversion loses integer precision: 'int' to 'unsigned short' on negation}}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

One last test and I think we're good:

unsigned _BitInt(16) test_unsigned_bit_int(unsigned _BitInt(16) x) {
  return -x;
}

this should not diagnose because _BitInt does not undergo promotion.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM! Failing docs build in precommit CI appears to be unrelated

@YutongZhuu
Copy link
Contributor Author

LGTM! Failing docs build in precommit CI appears to be unrelated

Hi, I don't have commit access, so I might need you to merge it for me :)

@AaronBallman AaronBallman merged commit 0ada5c7 into llvm:main Jun 2, 2025
11 of 12 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 2, 2025

LLVM Buildbot has detected a new failure on builder clang-m68k-linux-cross running on suse-gary-m68k-cross while building clang at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/10928

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
...
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Sema/Sema.h:839:7: warning: ‘clang::Sema’ declared with greater visibility than the type of its field ‘clang::Sema::ExtVectorDecls’ [-Wattributes]
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Sema/Sema.h:839:7: warning: ‘clang::Sema’ declared with greater visibility than the type of its field ‘clang::Sema::DelegatingCtorDecls’ [-Wattributes]
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Serialization/ASTReader.h:245:16: warning: ‘virtual bool clang::ASTReaderListener::visitInputFile(llvm::StringRef, llvm::StringRef, bool, bool, bool)’ was hidden [-Woverloaded-virtual=]
  245 |   virtual bool visitInputFile(StringRef FilenameAsRequested, StringRef Filename,
      |                ^~~~~~~~~~~~~~
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Serialization/ASTReader.h:306:8: note:   by ‘virtual bool clang::ChainedASTReaderListener::visitInputFile(llvm::StringRef, bool, bool, bool)’
  306 |   bool visitInputFile(StringRef Filename, bool isSystem,
      |        ^~~~~~~~~~~~~~
[261/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp.o
[262/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/AST/ASTImporterTest.cpp.o
FAILED: tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/AST/ASTImporterTest.cpp.o 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/unittests -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Tooling -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googletest/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/AST/ASTImporterTest.cpp.o -MF tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/AST/ASTImporterTest.cpp.o.d -o tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/AST/ASTImporterTest.cpp.o -c /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/AST/ASTImporterTest.cpp
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
[263/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RefactoringActionRulesTest.cpp.o
[264/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/ReplacementsYamlTest.cpp.o
[265/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/Syntax/MutationsTest.cpp.o
[266/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/Attr.cpp.o
[267/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp.o
[268/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp.o
[269/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/ParenExpr.cpp.o
[270/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp.o
[271/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/TraversalScope.cpp.o
[272/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTestDeclVisitor.cpp.o
[273/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp.o
[274/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/Syntax/TreeTestBase.cpp.o
[275/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/InitListExprPostOrder.cpp.o
[276/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RangeSelectorTest.cpp.o
[277/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/ToolingTest.cpp.o
[278/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/Syntax/SynthesisTest.cpp.o
[279/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/ASTMatchers/ASTMatchersNodeTest.cpp.o
[280/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RefactoringCallbacksTest.cpp.o
[281/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/Syntax/TreeTest.cpp.o
[282/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/SourceCodeBuildersTest.cpp.o
[283/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/Syntax/BuildTreeTest.cpp.o
[284/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RefactoringTest.cpp.o
[285/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/SourceCodeTest.cpp.o
[286/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/StencilTest.cpp.o
[287/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp.o
[288/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/CallbacksCallExpr.cpp.o
[289/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp.o
[290/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/CallbacksCompoundAssignOperator.cpp.o
[291/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp.o
[292/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/RecursiveASTVisitorTests/CallbacksLeaf.cpp.o
[293/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Tooling/TransformerTest.cpp.o
[294/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/ASTMatchers/ASTMatchersNarrowingTest.cpp.o
[295/412] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/ASTMatchers/ASTMatchersTraversalTest.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 2, 2025

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-ubuntu running on as-builder-9 while building clang at step 16 "test-check-lldb-api".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/195/builds/9873

Here is the relevant piece of the build log for the reference
Step 16 (test-check-lldb-api) failure: Test just built components: check-lldb-api completed (failure)
...
PASS: lldb-api :: types/TestCharTypeExpr.py (1270 of 1279)
PASS: lldb-api :: types/TestIntegerType.py (1271 of 1279)
PASS: lldb-api :: types/TestRecursiveTypes.py (1272 of 1279)
UNSUPPORTED: lldb-api :: windows/launch/missing-dll/TestMissingDll.py (1273 of 1279)
PASS: lldb-api :: types/TestIntegerTypeExpr.py (1274 of 1279)
PASS: lldb-api :: types/TestShortType.py (1275 of 1279)
PASS: lldb-api :: types/TestShortTypeExpr.py (1276 of 1279)
PASS: lldb-api :: types/TestLongTypes.py (1277 of 1279)
PASS: lldb-api :: types/TestLongTypesExpr.py (1278 of 1279)
TIMEOUT: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py (1279 of 1279)
******************** TEST 'lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py' FAILED ********************
Script:
--
/usr/bin/python3.12 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --libcxx-include-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1 --libcxx-include-target-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu --arch aarch64 --build-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb --compiler /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang --dsymutil /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --lldb-obj-root /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb --lldb-libs-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --cmake-build-type Release --platform-url connect://jetson-agx-2198.lab.llvm.org:1234 --platform-working-dir /home/ubuntu/lldb-tests --sysroot /mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name remote-linux --skip-category=lldb-server /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/python_api/process/cancel_attach -p TestCancelAttach.py
--
Exit Code: -9
Timeout: Reached timeout of 600 seconds

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 0ada5c7b1a52afb668bc42dd2d5573e5805433d1)
  clang revision 0ada5c7b1a52afb668bc42dd2d5573e5805433d1
  llvm revision 0ada5c7b1a52afb668bc42dd2d5573e5805433d1

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx arguments
FAIL: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_scripted_implementation (TestCancelAttach.AttachCancelTestCase.test_scripted_implementation)

--

********************
Slowest Tests:
--------------------------------------------------------------------------
600.04s: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py
180.97s: lldb-api :: commands/command/script_alias/TestCommandScriptAlias.py
70.51s: lldb-api :: commands/process/attach/TestProcessAttach.py
39.35s: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
35.32s: lldb-api :: functionalities/completion/TestCompletion.py
34.59s: lldb-api :: functionalities/single-thread-step/TestSingleThreadStepTimeout.py
23.42s: lldb-api :: python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
22.11s: lldb-api :: commands/statistics/basic/TestStats.py
20.67s: lldb-api :: functionalities/gdb_remote_client/TestPlatformClient.py
18.08s: lldb-api :: commands/dwim-print/TestDWIMPrint.py
16.76s: lldb-api :: functionalities/thread/state/TestThreadStates.py
14.74s: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
14.55s: lldb-api :: commands/expression/expr-in-syscall/TestExpressionInSyscall.py
14.28s: lldb-api :: functionalities/inline-stepping/TestInlineStepping.py

@@ -352,6 +352,10 @@ Improvements to Clang's diagnostics
- Now correctly diagnose a tentative definition of an array with static
storage duration in pedantic mode in C. (#GH50661)

- Split diagnosis of implicit integer comparison on negation to a new
diagnostic group ``-Wimplicit-int-comparison-on-negation``, grouped under
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo here: it spells -Wimplicit-int-conversion-on-negation in the actual implementation

DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
…nostic group (llvm#139429)

This PR reverts a change made in llvm#126846. 

llvm#126846 introduced an ``-Wimplicit-int-conversion`` diagnosis for 
```c++
int8_t x = something;
x = -x; // warning here
```

This is technically correct since -x could have a width of 9, but this
pattern is common in codebases.

Reverting this change would also introduce the false positive I fixed in
llvm#126846:
```c++
bool b(signed char c) {
  return -c >= 128; // -c can be 128
}
```

This false positive is uncommon, so I think it makes sense to revert the
change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants