[clang] Silence some warnings when building clang with external llvm
If you build clang with builtin_llvm=OFF you might get flooded with so many warnings that it's unsustainable.
This commit suggests to silence these kind of warnings. Note that there are still some warnings left, but not to the point that the output is completely flooding.
This is an upstreamed patch of what is done for nikpkgs: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/science/misc/root/default.nix#L200
The warnings look for example like this:
| ~~~~~~~~~~~~~~^~
/usr/lib/llvm16/include/llvm/TableGen/Record.h: In constructor 'llvm::IntRecTy::IntRecTy(llvm::RecordKeeper&)':
/usr/lib/llvm16/include/llvm/TableGen/Record.h:153:26: warning: declaration of 'RK' shadows a member of 'llvm::IntRecTy' [-Wshadow]
153 | IntRecTy(RecordKeeper &RK) : RecTy(IntRecTyKind, RK) {}
| ~~~~~~~~~~~~~~^~
/usr/lib/llvm16/include/llvm/TableGen/Record.h:74:17: note: shadowed declaration is here
74 | RecordKeeper &RK;
| ^~
/usr/lib/llvm16/include/llvm/TableGen/Record.h: In constructor 'llvm::IntRecTy::IntRecTy(llvm::RecordKeeper&)':
/usr/lib/llvm16/include/llvm/TableGen/Record.h:153:26: warning: declaration of 'RK' shadows a member of 'llvm::IntRecTy' [-Wshadow]
153 | IntRecTy(RecordKeeper &RK) : RecTy(IntRecTyKind, RK) {}
| ~~~~~~~~~~~~~~^~
/usr/lib/llvm16/include/llvm/TableGen/Record.h:1061:9: note: shadowed declaration is here
1061 | Init *Expr;
| ^~~~
/usr/lib/llvm16/include/llvm/ADT/SmallVector.h: In instantiation of 'llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::SmallVectorTemplateCommon(size_t) [with T = llvm::RecordVal; <template-parameter-1-2> = void; size_t = long unsigned int]':
/usr/lib/llvm16/include/llvm/ADT/SmallVector.h:339:75: required from 'llvm::SmallVectorTemplateBase<T, <anonymous> >::SmallVectorTemplateBase(size_t) [with T = llvm::RecordVal; bool <anonymous> = false; size_t = long unsigned int]'
/usr/lib/llvm16/include/llvm/ADT/SmallVector.h:592:37: required from 'llvm::SmallVectorImpl<T>::SmallVectorImpl(unsigned int) [with T = llvm::RecordVal]'
/usr/lib/llvm16/include/llvm/ADT/SmallVector.h:1202:39: required from 'llvm::SmallVector<T, N>::SmallVector() [with T = llvm::RecordVal; unsigned int N = 0]'
/usr/lib/llvm16/include/llvm/TableGen/Record.h:1626:22: required from here
/usr/lib/llvm16/include/llvm/ADT/SmallVector.h:138:36: warning: declaration of 'Size' shadows a member of 'llvm::SmallVectorTemplateCommon<llvm::RecordVal, void>' [-Wshadow]
138 | SmallVectorTemplateCommon(size_t Size) : Base(getFirstEl(), Size) {}
| ~~~~~~~^~~~
/usr/lib/llvm16/include/llvm/TableGen/Record.h:74:17: note: shadowed declaration is here
74 | RecordKeeper &RK;
Test Results
11 files 11 suites 2d 7h 27m 30s :stopwatch: 2 635 tests 2 635 :white_check_mark: 0 :zzz: 0 :x: 27 419 runs 27 419 :white_check_mark: 0 :zzz: 0 :x:
Results for commit c88aebb6.
:recycle: This comment has been updated with latest results.
For the case of builtin_llvm=OFF builtin_clang=ON, there is an easier solution by properly (re)setting LLVM_ENABLE_WARNINGS: https://github.com/root-project/root/pull/15527
Closing in favor of a better solution #15527.