clang 19.0.0git
Public Member Functions | List of all members
clang::SourceMgrAdapter Class Reference

An adapter that can be used to translate diagnostics from one or more llvm::SourceMgr instances to a ,. More...

#include "clang/Basic/SourceMgrAdapter.h"

Public Member Functions

 SourceMgrAdapter (SourceManager &SM, DiagnosticsEngine &Diagnostics, unsigned ErrorDiagID, unsigned WarningDiagID, unsigned NoteDiagID, OptionalFileEntryRef DefaultFile=std::nullopt)
 Create a new SourceMgr adaptor that maps to the given source manager and diagnostics engine.
 
 ~SourceMgrAdapter ()
 
SourceLocation mapLocation (const llvm::SourceMgr &LLVMSrcMgr, llvm::SMLoc Loc)
 Map a source location in the given LLVM source manager to its corresponding location in the Clang source manager.
 
SourceRange mapRange (const llvm::SourceMgr &LLVMSrcMgr, llvm::SMRange Range)
 Map a source range in the given LLVM source manager to its corresponding range in the Clang source manager.
 
void handleDiag (const llvm::SMDiagnostic &Diag)
 Handle the given diagnostic from an LLVM source manager.
 
llvm::SourceMgr::DiagHandlerTy getDiagHandler ()
 Retrieve the diagnostic handler to use with the underlying SourceMgr.
 
void * getDiagContext ()
 Retrieve the context to use with the diagnostic handler produced by getDiagHandler().
 

Detailed Description

An adapter that can be used to translate diagnostics from one or more llvm::SourceMgr instances to a ,.

Definition at line 30 of file SourceMgrAdapter.h.

Constructor & Destructor Documentation

◆ SourceMgrAdapter()

SourceMgrAdapter::SourceMgrAdapter ( SourceManager SM,
DiagnosticsEngine Diagnostics,
unsigned  ErrorDiagID,
unsigned  WarningDiagID,
unsigned  NoteDiagID,
OptionalFileEntryRef  DefaultFile = std::nullopt 
)

Create a new SourceMgr adaptor that maps to the given source manager and diagnostics engine.

Definition at line 24 of file SourceMgrAdapter.cpp.

◆ ~SourceMgrAdapter()

SourceMgrAdapter::~SourceMgrAdapter ( )

Definition at line 33 of file SourceMgrAdapter.cpp.

Member Function Documentation

◆ getDiagContext()

void * clang::SourceMgrAdapter::getDiagContext ( )
inline

Retrieve the context to use with the diagnostic handler produced by getDiagHandler().

Definition at line 80 of file SourceMgrAdapter.h.

◆ getDiagHandler()

llvm::SourceMgr::DiagHandlerTy clang::SourceMgrAdapter::getDiagHandler ( )
inline

Retrieve the diagnostic handler to use with the underlying SourceMgr.

Definition at line 74 of file SourceMgrAdapter.h.

◆ handleDiag()

void SourceMgrAdapter::handleDiag ( const llvm::SMDiagnostic &  Diag)

Handle the given diagnostic from an LLVM source manager.

Definition at line 91 of file SourceMgrAdapter.cpp.

References clang::FixItHint::CreateReplacement(), Diag(), clang::SourceLocation::getLocWithOffset(), Loc, mapLocation(), mapRange(), Range, and clang::DiagnosticsEngine::Report().

◆ mapLocation()

SourceLocation SourceMgrAdapter::mapLocation ( const llvm::SourceMgr &  LLVMSrcMgr,
llvm::SMLoc  Loc 
)

Map a source location in the given LLVM source manager to its corresponding location in the Clang source manager.

Definition at line 35 of file SourceMgrAdapter.cpp.

References clang::SrcMgr::C_User, clang::SourceManager::createFileID(), clang::SourceManager::getLocForStartOfFile(), clang::SourceLocation::getLocWithOffset(), clang::SourceManager::getOrCreateFileID(), clang::SourceLocation::isValid(), and Loc.

Referenced by handleDiag(), and mapRange().

◆ mapRange()

SourceRange SourceMgrAdapter::mapRange ( const llvm::SourceMgr &  LLVMSrcMgr,
llvm::SMRange  Range 
)

Map a source range in the given LLVM source manager to its corresponding range in the Clang source manager.

Definition at line 81 of file SourceMgrAdapter.cpp.

References clang::SourceRange::isValid(), mapLocation(), and Range.

Referenced by handleDiag().


The documentation for this class was generated from the following files: