3

I installed LLVM on MacOS 10.13 using homebrew:

brew install --with-toolchain llvm

Then I exported required variables, based on this guide.

export PATH="/usr/local/opt/llvm/bin:$PATH"
export CC=/usr/local/opt/llvm/bin/clang
export CXX=/usr/local/opt/llvm/bin/clang++
export LLVM_OPTIONS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib "\
"-I/usr/local/opt/llvm/include -I/usr/local/opt/llvm/include/c++/v1/"

When running clang-tidy:

clang-tidy myheaderlib.h -- $LLVM_OPTIONS

I get errors, all of them are related to standard files:

/usr/local/opt/llvm/include/c++/v1/iosfwd:96:1: error: unknown type name '_LIBCPP_BEGIN_NAMESPACE_STD'
/usr/local/opt/llvm/include/c++/v1/iosfwd:100:1: error: unknown type name 'template'
...

What may be the cause?

compor
  • 2,239
  • 1
  • 19
  • 29
Fedorov7890
  • 1,173
  • 13
  • 28
  • I found out that clang-tidy treats myheaderlib.h as C code. __cplusplus along with other C++ related macros are not defined. – Fedorov7890 Aug 30 '18 at 10:27

1 Answers1

1

As I discovered, the problem was that clang-tidy by default treats .h files as C headers. Renaming it to myheaderlib.hpp fixed the issue. I'd still love to hear how to properly configure clang-tidy so that language can be specified regardless to the file extension.

Fedorov7890
  • 1,173
  • 13
  • 28