diff --git a/generator/annotator.cpp b/generator/annotator.cpp index a07bb69..a9f532f 100644 --- a/generator/annotator.cpp +++ b/generator/annotator.cpp @@ -50,6 +50,7 @@ #include "stringbuilder.h" #include "projectmanager.h" +#include "compat.h" namespace { @@ -1091,14 +1092,14 @@ void Annotator::syntaxHighlight(Generator &generator, clang::FileID FID, clang:: // Chop off the u part of u8 prefix ++TokOffs; --TokLen; - // FALL THROUGH to chop the 8 + LLVM_FALLTHROUGH; case tok::wide_string_literal: case tok::utf16_string_literal: case tok::utf32_string_literal: // Chop off the L, u, U or 8 prefix ++TokOffs; --TokLen; - // FALL THROUGH. + LLVM_FALLTHROUGH; case tok::string_literal: // FIXME: Exclude the optional ud-suffix from the highlighted range. generator.addTag("q", {}, TokOffs, TokLen); @@ -1109,6 +1110,7 @@ void Annotator::syntaxHighlight(Generator &generator, clang::FileID FID, clang:: case tok::utf32_char_constant: ++TokOffs; --TokLen; + LLVM_FALLTHROUGH; case tok::char_constant: generator.addTag("kbd", {}, TokOffs, TokLen); break; diff --git a/generator/compat.h b/generator/compat.h index 4446565..2814cef 100644 --- a/generator/compat.h +++ b/generator/compat.h @@ -31,3 +31,7 @@ template struct MaybeUnique { }; template MaybeUnique maybe_unique(T* val) { return {val}; } +#ifndef LLVM_FALLTHROUGH +#define LLVM_FALLTHROUGH +#endif + diff --git a/generator/main.cpp b/generator/main.cpp index d7afc6e..c3dacf1 100644 --- a/generator/main.cpp +++ b/generator/main.cpp @@ -127,6 +127,7 @@ struct BrowserDiagnosticClient : clang::DiagnosticConsumer { switch(DiagLevel) { case clang::DiagnosticsEngine::Fatal: std::cerr << "FATAL "; + LLVM_FALLTHROUGH; case clang::DiagnosticsEngine::Error: std::cerr << "Error: " << locationToString(Info.getLocation(), annotator.getSourceMgr()) << ": " << diag.c_str() << std::endl; @@ -304,8 +305,17 @@ static bool proceedCommand(std::vector command, llvm::StringRef Dir } int main(int argc, const char **argv) { + std::string ErrorMessage; std::unique_ptr Compilations( - clang::tooling::FixedCompilationDatabase::loadFromCommandLine(argc, argv)); + clang::tooling::FixedCompilationDatabase::loadFromCommandLine(argc, argv +#if CLANG_VERSION_MAJOR >= 5 + , ErrorMessage +#endif + )); + if (!ErrorMessage.empty()) { + std::cerr << ErrorMessage << std::endl; + ErrorMessage = {}; + } llvm::cl::ParseCommandLineOptions(argc, argv); @@ -341,7 +351,6 @@ int main(int argc, const char **argv) { if (!Compilations && llvm::sys::fs::exists(BuildPath)) { - std::string ErrorMessage; if (llvm::sys::fs::is_directory(BuildPath)) { Compilations = std::unique_ptr( clang::tooling::CompilationDatabase::loadFromDirectory(BuildPath, ErrorMessage)); diff --git a/generator/preprocessorcallback.cpp b/generator/preprocessorcallback.cpp index 45bc9d1..1e4d9b8 100644 --- a/generator/preprocessorcallback.cpp +++ b/generator/preprocessorcallback.cpp @@ -188,7 +188,11 @@ void PreprocessorCallback::MacroDefined(const clang::Token& MacroNameTok, const annotator.generator(FID).addTag("dfn", "class=\"macro\" id=\""% ref %"\" data-ref=\"" % ref % "\"", sm.getFileOffset(loc), MacroNameTok.getLength()); } -void PreprocessorCallback::MacroUndefined(const clang::Token& MacroNameTok, PreprocessorCallback::MyMacroDefinition MD) +void PreprocessorCallback::MacroUndefined(const clang::Token& MacroNameTok, PreprocessorCallback::MyMacroDefinition MD +#if CLANG_VERSION_MAJOR >= 5 + , const clang::MacroDirective * +#endif + ) { clang::SourceLocation loc = MacroNameTok.getLocation(); if (!loc.isValid() || !loc.isFileID()) diff --git a/generator/preprocessorcallback.h b/generator/preprocessorcallback.h index b7925ee..d1c6549 100644 --- a/generator/preprocessorcallback.h +++ b/generator/preprocessorcallback.h @@ -54,7 +54,11 @@ class PreprocessorCallback : public clang::PPCallbacks { void MacroDefined(const clang::Token &MacroNameTok, const clang::MacroDirective *MD) override; - void MacroUndefined(const clang::Token &MacroNameTok, MyMacroDefinition MD) override; + void MacroUndefined(const clang::Token &MacroNameTok, MyMacroDefinition MD +#if CLANG_VERSION_MAJOR >= 5 + , const clang::MacroDirective * +#endif + ) override; bool FileNotFound(llvm::StringRef FileName, llvm::SmallVectorImpl &RecoveryPath) override; void InclusionDirective(clang::SourceLocation HashLoc, const clang::Token& IncludeTok, llvm::StringRef FileName,