}
void StringFindStartswithCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- IncludeInserter = llvm::make_unique<clang::tidy::utils::IncludeInserter>(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
- Compiler.getPreprocessor().addPPCallbacks(
- IncludeInserter->CreatePPCallbacks());
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ IncludeInserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(IncludeInserter->CreatePPCallbacks());
}
void StringFindStartswithCheck::storeOptions(
public:
using ClangTidyCheck::ClangTidyCheck;
StringFindStartswithCheck(StringRef Name, ClangTidyContext *Context);
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
this);
}
-void LambdaFunctionNameCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- llvm::make_unique<MacroExpansionsWithFileAndLine>(
- &SuppressMacroExpansions));
+void LambdaFunctionNameCheck::registerPPCallbacks(
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(llvm::make_unique<MacroExpansionsWithFileAndLine>(
+ &SuppressMacroExpansions));
}
void LambdaFunctionNameCheck::check(const MatchFinder::MatchResult &Result) {
LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
}
}
-void MacroParenthesesCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- llvm::make_unique<MacroParenthesesPPCallbacks>(
- &Compiler.getPreprocessor(), this));
+void MacroParenthesesCheck::registerPPCallbacks(
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(llvm::make_unique<MacroParenthesesPPCallbacks>(PP, this));
}
} // namespace bugprone
public:
MacroParenthesesCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
};
} // namespace bugprone
}
void MacroRepeatedSideEffectsCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- ::llvm::make_unique<MacroRepeatedPPCallbacks>(
- *this, Compiler.getPreprocessor()));
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(::llvm::make_unique<MacroRepeatedPPCallbacks>(*this, *PP));
}
} // namespace bugprone
public:
MacroRepeatedSideEffectsCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
};
} // namespace bugprone
};
} // namespace
-void SetLongJmpCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+void SetLongJmpCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
// This checker only applies to C++, where exception handling is a superior
// solution to setjmp/longjmp calls.
if (!getLangOpts().CPlusPlus)
// Per [headers]p5, setjmp must be exposed as a macro instead of a function,
// despite the allowance in C for setjmp to also be an extern function.
- Compiler.getPreprocessor().addPPCallbacks(
- llvm::make_unique<SetJmpMacroCallbacks>(*this));
+ PP->addPPCallbacks(llvm::make_unique<SetJmpMacroCallbacks>(*this));
}
void SetLongJmpCheck::registerMatchers(MatchFinder *Finder) {
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
};
} // namespace cert
Options.store(Opts, "IgnoreCommandLineMacros", IgnoreCommandLineMacros);
}
-void MacroUsageCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+void MacroUsageCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
if (!getLangOpts().CPlusPlus11)
return;
- Compiler.getPreprocessor().addPPCallbacks(
- llvm::make_unique<MacroUsageCallbacks>(this, Compiler.getSourceManager(),
- AllowedRegexp, CheckCapsOnly,
- IgnoreCommandLineMacros));
+ PP->addPPCallbacks(llvm::make_unique<MacroUsageCallbacks>(
+ this, SM, AllowedRegexp, CheckCapsOnly, IgnoreCommandLineMacros));
}
void MacroUsageCheck::warnMacro(const MacroDirective *MD, StringRef MacroName) {
CheckCapsOnly(Options.get("CheckCapsOnly", 0)),
IgnoreCommandLineMacros(Options.get("IgnoreCommandLineMacros", 1)) {}
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void warnMacro(const MacroDirective *MD, StringRef MacroName);
void warnNaming(const MacroDirective *MD, StringRef MacroName);
}
void ProBoundsConstantArrayIndexCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
if (!getLangOpts().CPlusPlus)
return;
- Inserter.reset(new utils::IncludeInserter(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
- Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+ Inserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(Inserter->CreatePPCallbacks());
}
void ProBoundsConstantArrayIndexCheck::registerMatchers(MatchFinder *Finder) {
public:
ProBoundsConstantArrayIndexCheck(StringRef Name, ClangTidyContext *Context);
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
class RestrictedIncludesPPCallbacks : public PPCallbacks {
public:
explicit RestrictedIncludesPPCallbacks(RestrictSystemIncludesCheck &Check,
- SourceManager &SM)
+ const SourceManager &SM)
: Check(Check), SM(SM) {}
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
llvm::SmallDenseMap<FileID, FileIncludes> IncludeDirectives;
RestrictSystemIncludesCheck &Check;
- SourceManager &SM;
+ const SourceManager &SM;
};
void RestrictedIncludesPPCallbacks::InclusionDirective(
}
void RestrictSystemIncludesCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- llvm::make_unique<RestrictedIncludesPPCallbacks>(
- *this, Compiler.getSourceManager()));
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(
+ llvm::make_unique<RestrictedIncludesPPCallbacks>(*this, SM));
}
void RestrictSystemIncludesCheck::storeOptions(
AllowedIncludes(Options.get("Includes", "*")),
AllowedIncludesGlobList(AllowedIncludes) {}
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
bool contains(StringRef FileName) {
return AllowedIncludesGlobList.contains(FileName);
} // namespace
void AvoidUnderscoreInGoogletestNameCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- llvm::make_unique<AvoidUnderscoreInGoogletestNameCallback>(
- &Compiler.getPreprocessor(), this));
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(
+ llvm::make_unique<AvoidUnderscoreInGoogletestNameCallback>(PP, this));
}
} // namespace readability
public:
using ClangTidyCheck::ClangTidyCheck;
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
};
} // namespace readability
Handler(llvm::make_unique<TodoCommentHandler>(
*this, Context->getOptions().User)) {}
-void TodoCommentCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addCommentHandler(Handler.get());
+void TodoCommentCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
+ PP->addCommentHandler(Handler.get());
}
} // namespace readability
class TodoCommentCheck : public ClangTidyCheck {
public:
TodoCommentCheck(StringRef Name, ClangTidyContext *Context);
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
private:
class TodoCommentHandler;
namespace {
class IncludeOrderPPCallbacks : public PPCallbacks {
public:
- explicit IncludeOrderPPCallbacks(ClangTidyCheck &Check, SourceManager &SM)
+ explicit IncludeOrderPPCallbacks(ClangTidyCheck &Check,
+ const SourceManager &SM)
: LookForMainModule(true), Check(Check), SM(SM) {}
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
bool LookForMainModule;
ClangTidyCheck &Check;
- SourceManager &SM;
+ const SourceManager &SM;
};
} // namespace
-void IncludeOrderCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- ::llvm::make_unique<IncludeOrderPPCallbacks>(
- *this, Compiler.getSourceManager()));
+void IncludeOrderCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(::llvm::make_unique<IncludeOrderPPCallbacks>(*this, SM));
}
static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
public:
IncludeOrderCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
};
} // namespace llvm
};
} // namespace
-void DeprecatedHeadersCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- if (this->getLangOpts().CPlusPlus) {
- Compiler.getPreprocessor().addPPCallbacks(
- ::llvm::make_unique<IncludeModernizePPCallbacks>(*this,
- this->getLangOpts()));
+void DeprecatedHeadersCheck::registerPPCallbacks(
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ if (getLangOpts().CPlusPlus) {
+ PP->addPPCallbacks(
+ ::llvm::make_unique<IncludeModernizePPCallbacks>(*this, getLangOpts()));
}
}
public:
DeprecatedHeadersCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
};
} // namespace modernize
return LangOpts.CPlusPlus11;
}
-void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+void MakeSmartPtrCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
if (isLanguageVersionSupported(getLangOpts())) {
- Inserter = llvm::make_unique<utils::IncludeInserter>(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
- Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+ Inserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(Inserter->CreatePPCallbacks());
}
}
MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
StringRef MakeSmartPtrFunctionName);
void registerMatchers(ast_matchers::MatchFinder *Finder) final;
- void registerPPCallbacks(clang::CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
this);
}
-void PassByValueCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+void PassByValueCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
// Only register the preprocessor callbacks for C++; the functionality
// currently does not provide any benefit to other languages, despite being
// benign.
if (getLangOpts().CPlusPlus) {
- Inserter.reset(new utils::IncludeInserter(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
- Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+ Inserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(Inserter->CreatePPCallbacks());
}
}
public:
PassByValueCheck(StringRef Name, ClangTidyContext *Context);
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
- void registerPPCallbacks(clang::CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
this);
}
-void ReplaceAutoPtrCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+void ReplaceAutoPtrCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
// Only register the preprocessor callbacks for C++; the functionality
// currently does not provide any benefit to other languages, despite being
// benign.
if (!getLangOpts().CPlusPlus)
return;
- Inserter.reset(new utils::IncludeInserter(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
- Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+ Inserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(Inserter->CreatePPCallbacks());
}
void ReplaceAutoPtrCheck::check(const MatchFinder::MatchResult &Result) {
ReplaceAutoPtrCheck(StringRef Name, ClangTidyContext *Context);
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
}
void ReplaceRandomShuffleCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- IncludeInserter = llvm::make_unique<utils::IncludeInserter>(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
- Compiler.getPreprocessor().addPPCallbacks(
- IncludeInserter->CreatePPCallbacks());
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ IncludeInserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(IncludeInserter->CreatePPCallbacks());
}
void ReplaceRandomShuffleCheck::storeOptions(
class ReplaceRandomShuffleCheck : public ClangTidyCheck {
public:
ReplaceRandomShuffleCheck(StringRef Name, ClangTidyContext *Context);
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
}
}
-void MoveConstructorInitCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- Inserter.reset(new utils::IncludeInserter(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
- Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+void MoveConstructorInitCheck::registerPPCallbacks(
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ Inserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(Inserter->CreatePPCallbacks());
}
void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
- void registerPPCallbacks(clang::CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
private:
Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
void TypePromotionInMathFnCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- IncludeInserter = llvm::make_unique<utils::IncludeInserter>(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
- Compiler.getPreprocessor().addPPCallbacks(
- IncludeInserter->CreatePPCallbacks());
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ IncludeInserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(IncludeInserter->CreatePPCallbacks());
}
void TypePromotionInMathFnCheck::storeOptions(
public:
TypePromotionInMathFnCheck(StringRef Name, ClangTidyContext *Context);
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
}
void UnnecessaryValueParamCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- Inserter.reset(new utils::IncludeInserter(
- Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
- Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ Inserter = llvm::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
+ IncludeStyle);
+ PP->addPPCallbacks(Inserter->CreatePPCallbacks());
}
void UnnecessaryValueParamCheck::storeOptions(
UnnecessaryValueParamCheck(StringRef Name, ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void onEndOfTranslationUnit() override;
} // namespace
void RedundantPreprocessorCheck::registerPPCallbacks(
- CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- ::llvm::make_unique<RedundantPreprocessorCallbacks>(
- *this, Compiler.getPreprocessor()));
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(
+ ::llvm::make_unique<RedundantPreprocessorCallbacks>(*this, *PP));
}
} // namespace readability
public:
RedundantPreprocessorCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
};
} // namespace readability
};
} // namespace
-void HeaderGuardCheck::registerPPCallbacks(CompilerInstance &Compiler) {
- Compiler.getPreprocessor().addPPCallbacks(
- llvm::make_unique<HeaderGuardPPCallbacks>(&Compiler.getPreprocessor(),
- this));
+void HeaderGuardCheck::registerPPCallbacks(const SourceManager &SM,
+ Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) {
+ PP->addPPCallbacks(llvm::make_unique<HeaderGuardPPCallbacks>(PP, this));
}
bool HeaderGuardCheck::shouldSuggestEndifComment(StringRef FileName) {
utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
HeaderFileExtensions, ',');
}
- void registerPPCallbacks(CompilerInstance &Compiler) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
/// Returns ``true`` if the check should suggest inserting a trailing comment
/// on the ``#endif`` of the header guard. It will use the same name as
///
/// class MyCheck : public ClangTidyCheck {
/// public:
-/// void registerPPCallbacks(CompilerInstance& Compiler) override {
-/// Inserter = llvm::make_unique<IncludeInserter>(&Compiler.getSourceManager(),
-/// &Compiler.getLangOpts());
-/// Compiler.getPreprocessor().addPPCallbacks(
-/// Inserter->CreatePPCallbacks());
+/// void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+/// Preprocessor *ModuleExpanderPP) override {
+/// Inserter = llvm::make_unique<IncludeInserter>(
+/// SM, getLangOpts(), utils::IncludeSorter::IS_Google);
+/// PP->addPPCallbacks(Inserter->CreatePPCallbacks());
/// }
///
/// void registerMatchers(ast_matchers::MatchFinder* Finder) override { ... }
Context.setCurrentFile(File);
Context.setASTContext(&Compiler.getASTContext());
+ Preprocessor *PP = &Compiler.getPreprocessor();
for (auto &Check : Checks) {
Check->registerMatchers(&Finder);
Check->registerPPCallbacks(Compiler);
+ Check->registerPPCallbacks(Compiler.getSourceManager(), PP, PP);
}
return Finder.newASTConsumer();
}
IncludeInserterCheckBase(StringRef CheckName, ClangTidyContext *Context)
: ClangTidyCheck(CheckName, Context) {}
- void registerPPCallbacks(CompilerInstance &Compiler) override {
- Inserter.reset(new utils::IncludeInserter(
- Compiler.getSourceManager(),
- Compiler.getLangOpts(),
- utils::IncludeSorter::IS_Google));
- Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override {
+ Inserter = llvm::make_unique<utils::IncludeInserter>(
+ SM, getLangOpts(), utils::IncludeSorter::IS_Google);
+ PP->addPPCallbacks(Inserter->CreatePPCallbacks());
}
void registerMatchers(ast_matchers::MatchFinder *Finder) override {