nlohmann has customization points for exception throws. we can use these instead and wrap json exceptions at the source instead of playing a game of whack-a-mole with json errors all over the tree. since nlohmann needs macros set to achieve this we can no longer precompile its headers *and* must forbid including it anywhere without the proper defines or ordering of include directives will break lix with ODR violations, if we see them at all before we get another json-related bug report. a new lint will be in charge of ensuring this doesn't happen. we also re-allow direct calls to nlohmann json parsing since error handling is no longer a problem. we will keep the wrapper for more convenient error context handling though. fixes #1092 Change-Id: I54ecc14f5bec5e2177729b41c3703216e76cc6a3
35 lines
925 B
C++
35 lines
925 B
C++
#pragma once
|
|
///@file
|
|
|
|
#include <clang-tidy/ClangTidyCheck.h>
|
|
#include <clang/ASTMatchers/ASTMatchFinder.h>
|
|
#include <clang/Basic/SourceLocation.h>
|
|
#include <llvm/ADT/StringRef.h>
|
|
|
|
namespace nix::clang_tidy {
|
|
|
|
using namespace clang;
|
|
using namespace clang::tidy;
|
|
using namespace llvm;
|
|
|
|
class ForbiddenIncludesCheck : public ClangTidyCheck {
|
|
public:
|
|
struct Mark {
|
|
SourceLocation loc;
|
|
StringRef name;
|
|
};
|
|
struct Marks {
|
|
std::vector<Mark> loc;
|
|
};
|
|
|
|
std::shared_ptr<Marks> marks;
|
|
|
|
ForbiddenIncludesCheck(StringRef Name, ClangTidyContext *Context)
|
|
: ClangTidyCheck(Name, Context) {}
|
|
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
|
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
|
|
Preprocessor *ModuleExpanderPP) override;
|
|
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
|
};
|
|
}; // namespace nix::clang_tidy
|