llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.58k stars 11.81k forks source link

Unable to disable "note" level compiler output. #112131

Open harryjwright opened 6 days ago

harryjwright commented 6 days ago

I am unable to suppress note level information in the compiler output.

Is this intended functionality or am I missing something?

Often, the fix is represented clearly by the preceding error.

As this is a note, I don't think that the -w flag has any control over the output.

Log:

/usr/bin/clang++ -Itest/matrix.p -Itest -I../test -I../include -I../external -I/usr/include/stb -I/usr/include/freetype2 -I/usr/include/libpng16 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -std=c++20 -O0 -g -Wno-unused-variable -ferror-limit=1 -w -DGTEST_HAS_PTHREAD=1 -MD -MQ test/matrix.p/test_Matrix4x4.cc.o -MF test/matrix.p/test_Matrix4x4.cc.o.d -o test/matrix.p/test_Matrix4x4.cc.o -c ../test/test_Matrix4x4.cc

../test/test_Matrix4x4.cc:24:25: error: constexpr variable 'C' must be initialized by a constant expression
   24 |     constexpr Matrix4x4 C = A-B;
      |                         ^   ~~~
../include/Matrix4x4.h:88:47: note: non-constexpr function 'operator[]' cannot be used in a constant expression
   88 |                 matrix[i][j] = matrix[i][j] - B[i][j];
      |                                               ^
../include/Matrix4x4.h:180:5: note: in call to 'result.operator-=(B)'
  180 |     result -= B;
      |     ^~~~~~~~~~~

I am having to scroll a lot to get to the root of an issue.

tbaederr commented 6 days ago

This is working as intended and there is no way to disable only the notes

harryjwright commented 4 days ago

I am using a modern toolchain that is typical for today. I would like to show an example of where the inability to suppress notes can cause headaches when debugging.

[1/2] Compiling C++ object test/camera.p/test_Camera.cc.o
FAILED: test/camera.p/test_Camera.cc.o
/usr/bin/clang++ -Itest/camera.p -Itest -I../test -I../include -I../external -I/usr/include/stb -I/usr/include/freetype2 -I/usr/include/libpng16 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -std=c++20 -O0 -g -Wno-unused-variable -ferror-limit=1 -w -DGTEST_HAS_PTHREAD=1 -MD -MQ test/camera.p/test_Camera.cc.o -MF test/camera.p/test_Camera.cc.o.d -o test/camera.p/test_Camera.cc.o -c ../test/test_Camera.cc
In file included from ../test/test_Camera.cc:1:
/usr/include/gtest/gtest.h:1379:11: error: invalid operands to binary expression ('const glm::vec<4, float>' and 'const std::array<float, 4>')
 1379 |   if (lhs == rhs) {
      |       ~~~ ^  ~~~
/usr/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<glm::vec<4, float>, std::array<float, 4>>' requested here
 1398 |     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
      |            ^
../test/test_Camera.cc:106:9: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<glm::vec<4, float>, std::array<float, 4>, nullptr>' requested here
  106 |         EXPECT_EQ(A[i], B[i]);
      |         ^
/usr/include/gtest/gtest.h:1869:54: note: expanded from macro 'EXPECT_EQ'
 1869 |   EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
      |                                                      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/system_error:449:3: note: candidate function not viable: no known conversion from 'const glm::vec<4, float>' to 'const error_code' for 1st argument
  449 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/system_error:465:3: note: candidate function not viable: no known conversion from 'const glm::vec<4, float>' to 'const error_code' for 1st argument
  465 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/system_error:465:3: note: candidate function (with reversed parameter order) not viable: no known conversion from 'const glm::vec<4, float>' to 'const error_condition' for 1st argument
  465 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/system_error:480:3: note: candidate function not viable: no known conversion from 'const glm::vec<4, float>' to 'const error_condition' for 1st argument
  480 |   operator==(const error_condition& __lhs,
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:324:3: note: candidate function not viable: no known conversion from 'const glm::vec<4, float>' to 'thread::id' for 1st argument
  324 |   operator==(thread::id __x, thread::id __y) noexcept
      |   ^          ~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/variant:1273:18: note: candidate function not viable: no known conversion from 'const glm::vec<4, float>' to 'monostate' for 1st argument
 1273 |   constexpr bool operator==(monostate, monostate) noexcept { return true; }
      |                  ^          ~~~~~~~~~
/usr/include/gtest/gtest.h:1371:13: note: candidate function not viable: no known conversion from 'const glm::vec<4, float>' to 'faketype' for 1st argument
 1371 | inline bool operator==(faketype, faketype) { return true; }
      |             ^          ~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/postypes.h:192:5: note: candidate template ignored: could not match 'fpos' against 'vec'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/allocator.h:237:5: note: candidate template ignored: could not match 'allocator' against 'vec'
  237 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/allocator.h:237:5: note: candidate template ignored: could not match 'allocator' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:534:5: note: candidate template ignored: could not match 'reverse_iterator' against 'vec'
  534 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:593:5: note: candidate template ignored: could not match 'reverse_iterator' against 'vec'
  593 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:1678:5: note: candidate template ignored: could not match 'move_iterator' against 'vec'
 1678 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:1678:5: note: candidate template ignored: could not match 'move_iterator' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:1748:5: note: candidate template ignored: could not match 'move_iterator' against 'vec'
 1748 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_pair.h:812:5: note: candidate template ignored: could not match 'pair' against 'vec'
  812 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/string_view:609:5: note: candidate template ignored: could not match 'basic_string_view' against 'vec'
  609 |     operator==(basic_string_view<_CharT, _Traits> __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/string_view:616:5: note: candidate template ignored: could not match 'basic_string_view' against 'vec'
  616 |     operator==(basic_string_view<_CharT, _Traits> __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/string_view:616:5: note: candidate template ignored: could not match 'basic_string_view' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/basic_string.h:3710:5: note: candidate template ignored: could not match 'basic_string' against 'vec'
 3710 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/basic_string.h:3727:5: note: candidate template ignored: could not match 'basic_string' against 'vec'
 3727 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/basic_string.h:3727:5: note: candidate template ignored: could not match 'basic_string' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/tuple:1919:5: note: candidate template ignored: could not match 'tuple' against 'vec'
 1919 |     operator==(const tuple<_TElements...>& __t,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/tuple:1919:5: note: candidate template ignored: could not match 'tuple' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/streambuf_iterator.h:234:5: note: candidate template ignored: could not match 'istreambuf_iterator' against 'vec'
  234 |     operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:829:5: note: candidate template ignored: could not match 'unique_ptr' against 'vec'
  829 |     operator==(const unique_ptr<_Tp, _Dp>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:829:5: note: candidate template ignored: could not match 'unique_ptr' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:837:5: note: candidate template ignored: could not match 'unique_ptr' against 'vec'
  837 |     operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:837:5: note: candidate template ignored: could not match 'unique_ptr' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr_base.h:1793:5: note: candidate template ignored: could not match '__shared_ptr' against 'vec'
 1793 |     operator==(const __shared_ptr<_Tp1, _Lp>& __a,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr_base.h:1793:5: note: candidate template ignored: could not match '__shared_ptr' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr_base.h:1799:5: note: candidate template ignored: could not match '__shared_ptr' against 'vec'
 1799 |     operator==(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr_base.h:1799:5: note: candidate template ignored: could not match '__shared_ptr' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr.h:555:5: note: candidate template ignored: could not match 'shared_ptr' against 'vec'
  555 |     operator==(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr.h:555:5: note: candidate template ignored: could not match 'shared_ptr' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr.h:561:5: note: candidate template ignored: could not match 'shared_ptr' against 'vec'
  561 |     operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr.h:561:5: note: candidate template ignored: could not match 'shared_ptr' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_set.h:987:5: note: candidate template ignored: could not match 'set' against 'vec'
  987 |     operator==(const set<_Key, _Compare, _Alloc>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_multiset.h:973:5: note: candidate template ignored: could not match 'multiset' against 'vec'
  973 |     operator==(const multiset<_Key, _Compare, _Alloc>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:2040:5: note: candidate template ignored: could not match 'vector' against 'vec'
 2040 |     operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:1236:5: note: candidate template ignored: could not match 'optional' against 'vec'
 1236 |     operator==(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:1296:5: note: candidate template ignored: could not match 'optional' against 'vec'
 1296 |     operator==(const optional<_Tp>& __lhs, nullopt_t) noexcept
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:1296:5: note: candidate template ignored: could not match 'optional' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:1364:5: note: candidate template ignored: could not match 'optional' against 'vec'
 1364 |     operator==(const optional<_Tp>& __lhs, const _Up& __rhs)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/optional:1370:5: note: candidate template ignored: could not match 'optional' against 'array'
 1370 |     operator==(const _Up& __lhs, const optional<_Tp>& __rhs)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/variant:1266:3: note: candidate template ignored: could not match 'variant' against 'vec'
 1266 |   _VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal)
      |   ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/variant:1241:20: note: expanded from macro '_VARIANT_RELATION_FUNCTION_TEMPLATE'
 1241 |     constexpr bool operator __OP(const variant<_Types...>& __lhs, \
      |                    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:737:5: note: candidate template ignored: could not match 'function' against 'vec'
  737 |     operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:737:5: note: candidate template ignored: could not match 'function' against 'array'
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unordered_map.h:2143:5: note: candidate template ignored: could not match 'unordered_map' against 'vec'
 2143 |     operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unordered_map.h:2157:5: note: candidate template ignored: could not match 'unordered_multimap' against 'vec'
 2157 |     operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/array:297:5: note: candidate template ignored: could not match 'array' against 'vec'
  297 |     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_map.h:1513:5: note: candidate template ignored: could not match 'map' against 'vec'
 1513 |     operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_multimap.h:1134:5: note: candidate template ignored: could not match 'multimap' against 'vec'
 1134 |     operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^
/usr/include/glm/./ext/../detail/type_vec4.inl:1114:40: note: candidate template ignored: could not match 'vec' against 'array'
 1114 |         GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2)
      |                                               ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_vec2.inl:889:40: note: candidate template ignored: could not match 2 against 4
  889 |         GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2)
      |                                               ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_vec3.inl:1043:40: note: candidate template ignored: could not match 3 against 4
 1043 |         GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2)
      |                                               ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat2x2.inl:526:26: note: candidate template ignored: could not match 'mat' against 'vec'
  526 |         GLM_FUNC_QUALIFIER bool operator==(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2)
      |                                 ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat2x3.inl:500:26: note: candidate template ignored: could not match 'mat' against 'vec'
  500 |         GLM_FUNC_QUALIFIER bool operator==(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2)
      |                                 ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat2x4.inl:510:26: note: candidate template ignored: could not match 'mat' against 'vec'
  510 |         GLM_FUNC_QUALIFIER bool operator==(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2)
      |                                 ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat3x2.inl:522:26: note: candidate template ignored: could not match 'mat' against 'vec'
  522 |         GLM_FUNC_QUALIFIER bool operator==(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2)
      |                                 ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat3x3.inl:591:40: note: candidate template ignored: could not match 'mat' against 'vec'
  591 |         GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2)
      |                                               ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat3x4.inl:568:26: note: candidate template ignored: could not match 'mat' against 'vec'
  568 |         GLM_FUNC_QUALIFIER bool operator==(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2)
      |                                 ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat4x2.inl:564:26: note: candidate template ignored: could not match 'mat' against 'vec'
  564 |         GLM_FUNC_QUALIFIER bool operator==(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2)
      |                                 ^
/usr/include/glm/./ext/../detail/.././ext/../detail/type_mat4x3.inl:588:26: note: candidate template ignored: could not match 'mat' against 'vec'
  588 |         GLM_FUNC_QUALIFIER bool operator==(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2)
      |                                 ^
/usr/include/glm/./ext/../detail/../detail/../detail/../detail/type_vec1.inl:529:40: note: candidate template ignored: could not match 1 against 4
  529 |         GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2)
      |                                               ^
/usr/include/glm/./ext/../detail/type_mat4x4.inl:692:26: note: candidate template ignored: could not match 'mat' against 'vec'
  692 |         GLM_FUNC_QUALIFIER bool operator==(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2)
      |                                 ^
/usr/include/glm/gtx/../gtx/../gtc/../ext/../detail/type_quat.inl:393:40: note: candidate template ignored: could not match 'qua' against 'vec'
  393 |         GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(qua<T, Q> const& q1, qua<T, Q> const& q2)
      |                                               ^
/usr/include/glm/gtx/../gtx/../gtx/dual_quaternion.inl:205:26: note: candidate template ignored: could not match 'tdualquat' against 'vec'
  205 |         GLM_FUNC_QUALIFIER bool operator==(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2)
      |                                 ^
1 error generated.
ninja: build stopped: subcommand failed.
harryjwright commented 4 days ago

@tbaederr Is there a way to disable the note diagnostic information? From your post it makes it sound like it may be possible with side-effects.

tbaederr commented 4 days ago

No, there is no way to disable the notes. It might be better in certain cases but just outright disabling them would leave you with incomplete diagnostics in a majority of cases. You can disable the code snippets using -fno-caret-diagnostics however.

harryjwright commented 3 days ago

@tbaederr Ok that's unfortunate. Instead of arguing for this functionality from the technical perspective, I am instead arguing for it from the user perspective.

Humans can only hold seven objects in their short-term memory. Overloading someone with what I personally deem unnecessary information isn't user friendly.

I hope this is added in the future. For now I'll switch to g++.