Closed jackua22 closed 5 months ago
@llvm/issue-subscribers-clang-tidy
Author: None (jackua22)
No crash here: https://godbolt.org/z/qrYThsb6P
My report is about clang-tidy, not about clang++.
But good point. I extracted only these headers, adna ran tidy. Without -I options it takes tbb headers from /usr/include on RHEL 7 and does not crash.
With tbb 2020.3, tidy crashes like before
/grid/common/test/llvm-v17.0.6d1rh74_lnx86/bin/clang-tidy '--checks=readability-duplicate-include' tbb.cpp -- -std=c++17 -stdlib=libc++ -I/.../include
My report is about clang-tidy, not about clang++.
You could see tidy report in the bottom half
With tbb 2020.3, tidy crashes like before
include/tbb/internal/_allocator_traits.h:31:2: current parser token 'include'
points to the
#include __TBB_STD_SWAP_HEADER
and looks like could be reproduced with
#define INC "t.h"
#include "t.h"
#include INC
Candidate patch: https://github.com/llvm/llvm-project/pull/87433
reproduced locally at 92eaf036bf22ecc276146cd073208e6a867af8d4 using https://github.com/oneapi-src/oneTBB/releases/tag/v2020.3 includes and
$ cat 87303.cc
#include <tbb/concurrent_vector.h>
$ clang-tidy 87303.cc --checks='-*,readability-duplicate-include' -- -I/tmp/tbb-2020.3-lin/tbb/include
clang-tidy: /home/mike/git/hub/com/llvm-project/clang/lib/Basic/SourceManager.cpp:865: FileID clang::SourceManager::getFileIDLoaded(SourceLocation::UIntTy) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/mike/git/hub/com/llvm-project/build/bin/clang-tidy 87303.cc --checks=-*,readability-duplicate-include -- -I/tmp/tbb-2020.3-lin/tbb/include
1. /tmp/tbb-2020.3-lin/tbb/include/internal/_allocator_traits.h:31:2: current parser token 'include'
2. /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/streambuf_iterator.h:39:1: parsing namespace 'std'
#0 0x000062351ab53f46 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/mike/git/hub/com/llvm-project/build/bin/clang-tidy+0x23adf46)
#1 0x000062351ab5194e llvm::sys::RunSignalHandlers() (/home/mike/git/hub/com/llvm-project/build/bin/clang-tidy+0x23ab94e)
#2 0x000062351ab547b4 SignalHandler(int) Signals.cpp:0:0
#3 0x000072054365a770 (/usr/lib/libc.so.6+0x3c770)
#4 0x00007205436ab32c (/usr/lib/libc.so.6+0x8d32c)
#5 0x000072054365a6c8 raise (/usr/lib/libc.so.6+0x3c6c8)
#6 0x00007205436424b8 abort (/usr/lib/libc.so.6+0x244b8)
#7 0x00007205436423dc (/usr/lib/libc.so.6+0x243dc)
#8 0x0000720543652d46 (/usr/lib/libc.so.6+0x34d46)
#9 0x000062351b2f32ac (/home/mike/git/hub/com/llvm-project/build/bin/clang-tidy+0x2b4d2ac)
#10 0x000062351b2f3e1a clang::SourceManager::getSpellingLineNumber(clang::SourceLocation, bool*) const (/home/mike/git/hub/com/llvm-project/build/bin/clang-tidy+0x2b4de1a)
#11 0x000062351b9db715 clang::tidy::readability::advanceBeyondCurrentLine(clang::SourceManager const&, clang::SourceLocation, int) DuplicateIncludeCheck.cpp:0:0
#12 0x000062351b9db186 clang::tidy::readability::(anonymous namespace)::DuplicateIncludeCallbacks::InclusionDirective(clang::SourceLocation, clang::Token const&, llvm::StringRef, bool, clang::CharSourceRange, clang::CustomizableOptional<clang::FileEntryRef>, llvm::StringRef, llvm::StringRef, clang::Module const*, clang::SrcMgr::CharacteristicKind) DuplicateIncludeCheck.cpp:0:
and
$ cat t.cc
#define INC "inc.h"
#include "inc.h"
#include INC
$ clang-tidy t.cc --checks='-*,readability-duplicate-include'
clang-tidy: /home/mike/git/hub/com/llvm-project/clang/lib/Basic/SourceManager.cpp:865: FileID clang::SourceManager::getFileIDLoaded(SourceLocation::UIntTy) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/mike/git/hub/com/llvm-project/build/bin/clang-tidy t.cc --checks=-*,readability-duplicate-include
1. /tmp/t.cc:4:2: current parser token 'include'
The crash is the same with llvm 17 and llvm 18. The output looks like
The first several includes are