[cfe-dev] clang finds errors in its own header files

icloud via cfe-dev cfe-dev at lists.llvm.org
Fri Dec 23 13:40:11 PST 2016


Hi Don,

I removed the extra "-I" directives but I still get the same result.

> Hi Paul:
>
> Why are you explicitly including .../c++/4.2.1?
>
> If clang was compiled correctly, it should be able to find it's own 
> c++ headers -- on OSX, that's most likely libc++ headers.  Try running:
>
> |clang++ -v -c -x c++ - < /dev/null|
> hth...
> don
>

> On Fri, Dec 23, 2016 at 10:12 AM, icloud via cfe-dev 
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>
> I am writing a parser for c++.
>
> I am developing on a Mac. OS X Sierra 10.12.1
>
> I am frustrated by the fact that I cannot compile even the simplest 
> c++ code because clang 4.0 finds errors in the clang headers 
> themselves! for example:
>
> #include "clang/AST/ASTContext.h"
> #include "clang/AST/ASTConsumer.h"
> #include "clang/AST/
> #include "clang/RecursiveASTVisitor.h"
> #include "clang/Frontend/ASTConsumers.h"
> #include "clang/Frontend/FrontendActions.h"
> #include "clang/Frontend/CompilerInstance.h"
> #include "clang/Tooling/CommonOptionsParser.h"
> #include "clang/Tooling/Tooling.h"
> #include "clang/Rewrite/Core/Rewriter.h"
> #include "llvm/Support/raw_ostream.h"
> #include <string>
> #include <memory>
>
>
> int main( void )
> {
>     return 0;
> }
>
>
> ---
>
I have been trying to solve this by examining others' Makefiles but to 
no avail.
This is the result of my latest effort:

  50%] Building CXX object CMakeFiles/testProject.dir/main.cpp.o
In file included from /Users/paul/Temp/test/src/main.cpp:1:
In file included from /usr/local/include/clang/AST/AST.h:18:
In file included from /usr/local/include/clang/AST/ASTContext.h:18:
In file included from /usr/local/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/include/clang/AST/Decl.h:17:
In file included from /usr/local/include/clang/AST/APValue.h:18:
In file included from /usr/local/include/llvm/ADT/APFloat.h:20:
In file included from /usr/local/include/llvm/ADT/APInt.h:20:
/usr/local/include/llvm/Support/MathExtras.h:248:1: error: unknown type 
name 'constexpr'
constexpr inline uint32_t Hi_32(uint64_t Value) {
^
/usr/local/include/llvm/Support/MathExtras.h:248:11: error: expected 
unqualified-id
constexpr inline uint32_t Hi_32(uint64_t Value) {
           ^
/usr/local/include/llvm/Support/MathExtras.h:253:1: error: unknown type 
name 'constexpr'
constexpr inline uint32_t Lo_32(uint64_t Value) {
^
/usr/local/include/llvm/Support/MathExtras.h:253:11: error: expected 
unqualified-id
constexpr inline uint32_t Lo_32(uint64_t Value) {
           ^
/usr/local/include/llvm/Support/MathExtras.h:259:1: error: unknown type 
name 'constexpr'
constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) {
^
/usr/local/include/llvm/Support/MathExtras.h:259:11: error: expected 
unqualified-id
constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) {
           ^
/usr/local/include/llvm/Support/MathExtras.h:264:23: error: unknown type 
name 'constexpr'
template <unsigned N> constexpr inline bool isInt(int64_t x) {
                       ^
/usr/local/include/llvm/Support/MathExtras.h:264:33: error: expected 
unqualified-id
template <unsigned N> constexpr inline bool isInt(int64_t x) {
                                 ^
/usr/local/include/llvm/Support/MathExtras.h:710:10: error: use of 
undeclared identifier 'alignTo'
   return alignTo(Value, Align) - Value;
          ^
/usr/local/include/llvm/Support/MathExtras.h:715:23: error: unknown type 
name 'constexpr'
template <unsigned B> constexpr inline int32_t SignExtend32(uint32_t X) {
                       ^
/usr/local/include/llvm/Support/MathExtras.h:715:33: error: expected 
unqualified-id
template <unsigned B> constexpr inline int32_t SignExtend32(uint32_t X) {
                                 ^
In file included from /Users/paul/Temp/test/src/main.cpp:1:
In file included from /usr/local/include/clang/AST/AST.h:18:
In file included from /usr/local/include/clang/AST/ASTContext.h:18:
In file included from /usr/local/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/include/clang/AST/Decl.h:17:
In file included from /usr/local/include/clang/AST/APValue.h:18:
In file included from /usr/local/include/llvm/ADT/APFloat.h:20:
/usr/local/include/llvm/ADT/APInt.h:393:14: error: use of undeclared 
identifier 'isPowerOf2_64'
       return isPowerOf2_64(VAL);
              ^
/usr/local/include/llvm/ADT/APInt.h:1387:20: error: no member named 
'countTrailingOnes' in namespace 'llvm'; did you mean 'countTrailingZeros'?
       return llvm::countTrailingOnes(VAL);
              ~~~~~~^
/usr/local/include/llvm/Support/MathExtras.h:111:13: note: 
'countTrailingZeros' declared here
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
             ^
In file included from /Users/paul/Temp/test/src/main.cpp:1:
In file included from /usr/local/include/clang/AST/AST.h:18:
In file included from /usr/local/include/clang/AST/ASTContext.h:18:
In file included from /usr/local/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/include/clang/AST/Decl.h:17:
In file included from /usr/local/include/clang/AST/APValue.h:18:
In file included from /usr/local/include/llvm/ADT/APFloat.h:20:
/usr/local/include/llvm/ADT/APInt.h:1399:20: error: no member named 
'countPopulation' in namespace 'llvm'
       return llvm::countPopulation(VAL);
              ~~~~~~^
In file included from /Users/paul/Temp/test/src/main.cpp:1:
In file included from /usr/local/include/clang/AST/AST.h:18:
In file included from /usr/local/include/clang/AST/ASTContext.h:18:
In file included from /usr/local/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/include/clang/AST/Decl.h:17:
In file included from /usr/local/include/clang/AST/APValue.h:18:
/usr/local/include/llvm/ADT/APFloat.h:661:15: error: union member 'IEEE' 
has a non-trivial copy constructor
     IEEEFloat IEEE;
               ^
/usr/local/include/llvm/ADT/APFloat.h:224:3: note: because type 
'llvm::detail::IEEEFloat' has a user-provided copy constructor
   IEEEFloat(const IEEEFloat &);
   ^
/usr/local/include/llvm/ADT/APFloat.h:662:19: error: union member 
'Double' has a non-trivial copy constructor
     DoubleAPFloat Double;
                   ^
/usr/local/include/llvm/ADT/APFloat.h:617:3: note: because type 
'llvm::detail::DoubleAPFloat' has a user-provided copy constructor
   DoubleAPFloat(const DoubleAPFloat &RHS);
   ^
/usr/local/include/llvm/ADT/APFloat.h:750:35: error: too many arguments 
provided to function-like macro invocation
                   std::is_same<T, DoubleAPFloat>::value, "");
                                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:596:9: 
note: macro 'static_assert' defined here
#define static_assert(__b, __m) \
         ^
In file included from /Users/paul/Temp/test/src/main.cpp:1:
In file included from /usr/local/include/clang/AST/AST.h:18:
In file included from /usr/local/include/clang/AST/ASTContext.h:18:
In file included from /usr/local/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/include/clang/AST/Decl.h:17:
In file included from /usr/local/include/clang/AST/APValue.h:18:
/usr/local/include/llvm/ADT/APFloat.h:749:5: error: use of undeclared 
identifier 'static_assert'
     static_assert(std::is_same<T, IEEEFloat>::value ||
     ^
In file included from /Users/paul/Temp/test/src/main.cpp:1:
In file included from /usr/local/include/clang/AST/AST.h:18:
In file included from /usr/local/include/clang/AST/ASTContext.h:18:
In file included from /usr/local/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/include/clang/AST/Decl.h:17:
In file included from /usr/local/include/clang/AST/APValue.h:20:
In file included from /usr/local/include/llvm/ADT/PointerIntPair.h:18:
/usr/local/include/llvm/Support/PointerLikeTypeTraits.h:45:61: error: 
'T' does not refer to a value
   enum { NumLowBitsAvailable = detail::ConstantLog2<alignof(T)>::value };
                                                             ^
/usr/local/include/llvm/Support/PointerLikeTypeTraits.h:40:20: note: 
declared here
template <typename T> class PointerLikeTypeTraits<T *> {
                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/testProject.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/testProject.dir/all] Error 2
make: *** [all] Error 2

> Help will be greatly appreciated.

-- 

Paul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161223/04100707/attachment.html>


More information about the cfe-dev mailing list