Skip to content

Commit

Permalink
Use ASTContext's printing policy, reuse the Sema variable. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvassilev committed Dec 17, 2024
1 parent 38fd6d1 commit 63841be
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tools/ClangPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,10 @@ namespace clad {
request.Function = request.Function->getDefinition();
request.UpdateDiffParamsInfo(m_CI.getSema());
const FunctionDecl* FD = request.Function;
// set up printing policy
clang::LangOptions LangOpts;
LangOpts.CPlusPlus = true;
clang::PrintingPolicy Policy(LangOpts);
Policy.Bool = true;
ASTContext& C = S.getASTContext();
clang::PrintingPolicy Policy = C.getPrintingPolicy();
// Our testsuite expects 'a<b<c> >' rather than 'a<b<c>>'.
Policy.SplitTemplateClosers = true;
// if enabled, print source code of the original functions
if (m_DO.DumpSourceFn) {
FD->print(llvm::outs(), Policy);
Expand All @@ -183,11 +182,9 @@ namespace clad {
std::string Err;
if (llvm::sys::DynamicLibrary::
LoadLibraryPermanently(m_DO.CustomModelName.c_str(), &Err)) {
auto& SemaInst = m_CI.getSema();
unsigned diagID = SemaInst.Diags.getCustomDiagID(
unsigned diagID = S.Diags.getCustomDiagID(
DiagnosticsEngine::Error, "Failed to load '%0', %1. Aborting.");
clang::Sema::SemaDiagnosticBuilder stream = SemaInst.Diag(noLoc,
diagID);
clang::Sema::SemaDiagnosticBuilder stream = S.Diag(noLoc, diagID);
stream << m_DO.CustomModelName << Err;
return nullptr;
}
Expand Down

0 comments on commit 63841be

Please sign in to comment.