fuzzgen-preprocessor compilation error: marked ‘override’, but does not override during cmake build
Getting below error while compiling fuzzgen-preprocessor. Need suggestions to solve the issue, please. I have listed steps that are followed for reference, correct if needed.
cmake --build . [1/2] Building CXX object tools/clang/tools/fuzzgen/CMakeFiles/fuzzgen-preprocessor.dir/preprocessor.cpp.o FAILED: tools/clang/tools/fuzzgen/CMakeFiles/fuzzgen-preprocessor.dir/preprocessor.cpp.o /usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/tools/fuzzgen -I/opt/llvm-project/clang/tools/fuzzgen -I/opt/llvm-project/clang/include -Itools/clang/include -Iinclude -I/opt/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -fno-common -Woverloaded-virtual -fno-strict-aliasing -g -fno-exceptions -fno-rtti -MD -MT tools/clang/tools/fuzzgen/CMakeFiles/fuzzgen-preprocessor.dir/preprocessor.cpp.o -MF tools/clang/tools/fuzzgen/CMakeFiles/fuzzgen-preprocessor.dir/preprocessor.cpp.o.d -o tools/clang/tools/fuzzgen/CMakeFiles/fuzzgen-preprocessor.dir/preprocessor.cpp.o -c /opt/llvm-project/clang/tools/fuzzgen/preprocessor.cpp In file included from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.cpp:41: /opt/llvm-project/clang/tools/fuzzgen/preprocessor.h:210:18: error: ‘virtual void IncludesProcessor::InclusionDirective(clang::SourceLocation, const clang::Token&, llvm::StringRef, bool, clang::CharSourceRange, const clang::FileEntry*, llvm::StringRef, llvm::StringRef, const clang::Module*, clang::SrcMgr::CharacteristicKind)’ marked ‘override’, but does not override 210 | virtual void InclusionDirective(SourceLocation, const Token &, StringRef, bool, CharSourceRange, | ^~~~~~~~~~~~~~~~~~ In file included from /opt/llvm-project/clang/include/clang/Lex/PreprocessingRecord.h:20, from /opt/llvm-project/clang/include/clang/Frontend/ASTUnit.h:25, from /opt/llvm-project/clang/include/clang/Frontend/FrontendAction.h:24, from /opt/llvm-project/clang/include/clang/Frontend/FrontendActions.h:13, from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.h:44, from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.cpp:41: /opt/llvm-project/clang/include/clang/Lex/PPCallbacks.h:120:16: warning: ‘virtual void clang::PPCallbacks::InclusionDirective(clang::SourceLocation, const clang::Token&, llvm::StringRef, bool, clang::CharSourceRange, const clang::FileEntry*, llvm::StringRef, llvm::StringRef, const clang::Module*)’ was hidden [-Woverloaded-virtual] 120 | virtual void InclusionDirective(SourceLocation HashLoc, | ^~~~~~~~~~~~~~~~~~ In file included from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.cpp:41: /opt/llvm-project/clang/tools/fuzzgen/preprocessor.h:210:18: warning: by ‘virtual void IncludesProcessor::InclusionDirective(clang::SourceLocation, const clang::Token&, llvm::StringRef, bool, clang::CharSourceRange, const clang::FileEntry*, llvm::StringRef, llvm::StringRef, const clang::Module*, clang::SrcMgr::CharacteristicKind)’ [-Woverloaded-virtual] 210 | virtual void InclusionDirective(SourceLocation, const Token &, StringRef, bool, CharSourceRange, | ^~~~~~~~~~~~~~~~~~ In file included from /opt/llvm-project/llvm/include/llvm/ADT/STLExtras.h:21, from /opt/llvm-project/llvm/include/llvm/ADT/StringRef.h:13, from /opt/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h:20, from /opt/llvm-project/clang/include/clang/Basic/Diagnostic.h:18, from /opt/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:14, from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.h:43, from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.cpp:41: /opt/llvm-project/llvm/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T = std::pair<void*, long unsigned int>]’: /opt/llvm-project/llvm/include/llvm/Support/Allocator.h:247:33: required from ‘void* llvm::BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>::Allocate(size_t, size_t) [with AllocatorT = llvm::MallocAllocator; long unsigned int SlabSize = 4096; long unsigned int SizeThreshold = 4096; size_t = long unsigned int]’ /opt/llvm-project/clang/include/clang/AST/ASTContext.h:651:42: required from here /opt/llvm-project/llvm/include/llvm/ADT/SmallVector.h:312:11: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<void*, long unsigned int>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] 312 | memcpy(this->end(), &Elt, sizeof(T)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/9/utility:70, from /opt/llvm-project/llvm/include/llvm/Support/type_traits.h:19, from /opt/llvm-project/llvm/include/llvm/Support/Casting.h:19, from /opt/llvm-project/clang/include/clang/Basic/LLVM.h:22, from /opt/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h:18, from /opt/llvm-project/clang/include/clang/Basic/Diagnostic.h:18, from /opt/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:14, from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.h:43, from /opt/llvm-project/clang/tools/fuzzgen/preprocessor.cpp:41: /usr/include/c++/9/bits/stl_pair.h:208:12: note: ‘struct std::pair<void*, long unsigned int>’ declared here 208 | struct pair | ^~~~ ninja: build stopped: subcommand failed.
Steps followed:
- git clone https://github.com/llvm/llvm-project
- git checkout llvmorg-6.0.0
- cd llvm-project
- mkdir build
- cd build
- copy the preprocessor directory under llvm-project/clang/tools as fuzzgen
- Add below line to llvm-project/clang/tools/CMakeLists.txt add_clang_subdirectory(fuzzgen)
- cmake -DLLVM_ENABLE_PROJECTS=clang -G Ninja ../llvm
- cmake --build .
Try to comment out "override" keyword, it works for me.
virtual void InclusionDirective(SourceLocation, const Token &, StringRef, bool, CharSourceRange,
const FileEntry *, StringRef, StringRef, const clang::Module *,
SrcMgr::CharacteristicKind) ;//override;
I also meets with this compilation bug.It works for me deleting the “override” keyword.