Open
Description
With the repro described below, clang reports an error with a location in STLExtras.h
but does not relate it back to line 897 of the main source file CodeGenRegisters.cpp
which I claim "caused" the error.
The repro is a slightly modified LLVM source repo at: https://github.com/jayfoad/llvm-project/tree/clang-diagnostic-repro
To provoke the error, use cmake and ninja to build the llvm-tblgen
target.
FAILED: utils/TableGen/Common/CMakeFiles/obj.LLVMTableGenCommon.dir/CodeGenRegisters.cpp.o
/usr/lib/ccache/clang++ -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/home/jayfoad2/llvm-release/utils/TableGen/Common -I/home/jayfoad2/git/llvm-project/llvm/utils/TableGen/Common -I/home/jayfoad2/llvm-release/include -I/home/jayfoad2/git/llvm-project/llvm/include -I/home/jayfoad2/git/llvm-project/llvm/utils/TableGen/Common/.. -I/home/jayfoad2/git/llvm-project/llvm/utils/TableGen/Basic/.. -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT utils/TableGen/Common/CMakeFiles/obj.LLVMTableGenCommon.dir/CodeGenRegisters.cpp.o -MF utils/TableGen/Common/CMakeFiles/obj.LLVMTableGenCommon.dir/CodeGenRegisters.cpp.o.d -o utils/TableGen/Common/CMakeFiles/obj.LLVMTableGenCommon.dir/CodeGenRegisters.cpp.o -c /home/jayfoad2/git/llvm-project/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
In file included from /home/jayfoad2/git/llvm-project/llvm/utils/TableGen/Common/CodeGenRegisters.cpp:14:
In file included from /home/jayfoad2/git/llvm-project/llvm/utils/TableGen/Common/CodeGenRegisters.h:17:
In file included from /home/jayfoad2/git/llvm-project/llvm/utils/TableGen/Common/CodeGenHwModes.h:14:
In file included from /home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/DenseMap.h:20:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:2288:23: error: indirection requires pointer operand ('unsigned int' invalid)
2288 | return func(*lhs, *rhs);
| ^~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_algo.h:2243:37: note: in instantiation of function template specialization 'llvm::deref<std::less<void>>::operator()<const llvm::CodeGenRegister *const, const unsigned int>' requested here
2243 | return __i != __last && !bool(__comp(__val, *__i));
| ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:2007:15: note: in instantiation of function template specialization 'std::binary_search<__gnu_cxx::__normal_iterator<const unsigned int *, std::vector<unsigned int>>, const llvm::CodeGenRegister *, llvm::deref<std::less<void>>>' requested here
2007 | return std::binary_search(adl_begin(Range), adl_end(Range),
| ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:2288:17: error: indirection requires pointer operand ('unsigned int' invalid)
2288 | return func(*lhs, *rhs);
| ^~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/predefined_ops.h:196:16: note: in instantiation of function template specialization 'llvm::deref<std::less<void>>::operator()<const unsigned int, const llvm::CodeGenRegister *const>' requested here
196 | { return bool(_M_comp(*__it, __val)); }
| ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_algobase.h:1501:8: note: in instantiation of function template specialization '__gnu_cxx::__ops::_Iter_comp_val<llvm::deref<std::less<void>>>::operator()<__gnu_cxx::__normal_iterator<const unsigned int *, std::vector<unsigned int>>, const llvm::CodeGenRegister *const>' requested here
1501 | if (__comp(__middle, __val))
| ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_algo.h:2241:9: note: in instantiation of function template specialization 'std::__lower_bound<__gnu_cxx::__normal_iterator<const unsigned int *, std::vector<unsigned int>>, const llvm::CodeGenRegister *, __gnu_cxx::__ops::_Iter_comp_val<llvm::deref<std::less<void>>>>' requested here
2241 | = std::__lower_bound(__first, __last, __val,
| ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:2007:15: note: in instantiation of function template specialization 'std::binary_search<__gnu_cxx::__normal_iterator<const unsigned int *, std::vector<unsigned int>>, const llvm::CodeGenRegister *, llvm::deref<std::less<void>>>' requested here
2007 | return std::binary_search(adl_begin(Range), adl_end(Range),
| ^
2 errors generated.
ninja: build stopped: cannot make progress due to previous errors.