clang 20.0.0git
Public Types | Public Member Functions | Public Attributes | List of all members
clang::UnsafeBufferUsageHandler Class Referenceabstract

The interface that lets the caller handle unsafe buffer usage analysis results by overriding this class's handle... methods. More...

#include "clang/Analysis/Analyses/UnsafeBufferUsage.h"

Public Types

using DebugNote = std::pair< SourceLocation, std::string >
 
using DebugNoteList = std::vector< DebugNote >
 
using DebugNoteByVar = std::map< const VarDecl *, DebugNoteList >
 
using FixItList = llvm::SmallVectorImpl< FixItHint >
 This analyses produces large fixits that are organized into lists of primitive fixits (individual insertions/removals/replacements).
 

Public Member Functions

 UnsafeBufferUsageHandler ()=default
 
virtual ~UnsafeBufferUsageHandler ()=default
 
virtual void handleUnsafeOperation (const Stmt *Operation, bool IsRelatedToDecl, ASTContext &Ctx)=0
 Invoked when an unsafe operation over raw pointers is found.
 
virtual void handleUnsafeOperationInContainer (const Stmt *Operation, bool IsRelatedToDecl, ASTContext &Ctx)=0
 Invoked when an unsafe operation with a std container is found.
 
virtual void handleUnsafeVariableGroup (const VarDecl *Variable, const VariableGroupsManager &VarGrpMgr, FixItList &&Fixes, const Decl *D, const FixitStrategy &VarTargetTypes)=0
 Invoked when a fix is suggested against a variable.
 
bool areDebugNotesRequested ()
 
void addDebugNoteForVar (const VarDecl *VD, SourceLocation Loc, std::string Text)
 
void clearDebugNotes ()
 
virtual bool isSafeBufferOptOut (const SourceLocation &Loc) const =0
 
virtual bool ignoreUnsafeBufferInContainer (const SourceLocation &Loc) const =0
 
virtual std::string getUnsafeBufferUsageAttributeTextAt (SourceLocation Loc, StringRef WSSuffix="") const =0
 

Public Attributes

DebugNoteByVar DebugNotesByVar
 

Detailed Description

The interface that lets the caller handle unsafe buffer usage analysis results by overriding this class's handle... methods.

Definition at line 84 of file UnsafeBufferUsage.h.

Member Typedef Documentation

◆ DebugNote

Definition at line 91 of file UnsafeBufferUsage.h.

◆ DebugNoteByVar

Definition at line 93 of file UnsafeBufferUsage.h.

◆ DebugNoteList

Definition at line 92 of file UnsafeBufferUsage.h.

◆ FixItList

This analyses produces large fixits that are organized into lists of primitive fixits (individual insertions/removals/replacements).

Definition at line 103 of file UnsafeBufferUsage.h.

Constructor & Destructor Documentation

◆ UnsafeBufferUsageHandler()

clang::UnsafeBufferUsageHandler::UnsafeBufferUsageHandler ( )
default

◆ ~UnsafeBufferUsageHandler()

virtual clang::UnsafeBufferUsageHandler::~UnsafeBufferUsageHandler ( )
virtualdefault

Member Function Documentation

◆ addDebugNoteForVar()

void clang::UnsafeBufferUsageHandler::addDebugNoteForVar ( const VarDecl VD,
SourceLocation  Loc,
std::string  Text 
)
inline

Definition at line 133 of file UnsafeBufferUsage.h.

References areDebugNotesRequested(), DebugNotesByVar, Loc, and Text.

Referenced by clang::checkUnsafeBufferUsage(), and getFixIts().

◆ areDebugNotesRequested()

bool clang::UnsafeBufferUsageHandler::areDebugNotesRequested ( )
inline

Definition at line 128 of file UnsafeBufferUsage.h.

Referenced by addDebugNoteForVar(), and clearDebugNotes().

◆ clearDebugNotes()

void clang::UnsafeBufferUsageHandler::clearDebugNotes ( )
inline

Definition at line 139 of file UnsafeBufferUsage.h.

References areDebugNotesRequested(), and DebugNotesByVar.

Referenced by clang::checkUnsafeBufferUsage().

◆ getUnsafeBufferUsageAttributeTextAt()

virtual std::string clang::UnsafeBufferUsageHandler::getUnsafeBufferUsageAttributeTextAt ( SourceLocation  Loc,
StringRef  WSSuffix = "" 
) const
pure virtual

◆ handleUnsafeOperation()

virtual void clang::UnsafeBufferUsageHandler::handleUnsafeOperation ( const Stmt Operation,
bool  IsRelatedToDecl,
ASTContext Ctx 
)
pure virtual

Invoked when an unsafe operation over raw pointers is found.

◆ handleUnsafeOperationInContainer()

virtual void clang::UnsafeBufferUsageHandler::handleUnsafeOperationInContainer ( const Stmt Operation,
bool  IsRelatedToDecl,
ASTContext Ctx 
)
pure virtual

Invoked when an unsafe operation with a std container is found.

◆ handleUnsafeVariableGroup()

virtual void clang::UnsafeBufferUsageHandler::handleUnsafeVariableGroup ( const VarDecl Variable,
const VariableGroupsManager VarGrpMgr,
FixItList &&  Fixes,
const Decl D,
const FixitStrategy VarTargetTypes 
)
pure virtual

Invoked when a fix is suggested against a variable.

This function groups all variables that must be fixed together (i.e their types must be changed to the same target type to prevent type mismatches) into a single fixit.

D is the declaration of the callable under analysis that owns Variable and all of its group mates.

Referenced by clang::checkUnsafeBufferUsage().

◆ ignoreUnsafeBufferInContainer()

virtual bool clang::UnsafeBufferUsageHandler::ignoreUnsafeBufferInContainer ( const SourceLocation Loc) const
pure virtual
Returns
true iff unsafe uses in containers should NOT be reported at Loc; false otherwise.

◆ isSafeBufferOptOut()

virtual bool clang::UnsafeBufferUsageHandler::isSafeBufferOptOut ( const SourceLocation Loc) const
pure virtual
Returns
true iff buffer safety is opt-out at Loc; false otherwise.

Member Data Documentation

◆ DebugNotesByVar

DebugNoteByVar clang::UnsafeBufferUsageHandler::DebugNotesByVar

Definition at line 94 of file UnsafeBufferUsage.h.

Referenced by addDebugNoteForVar(), and clearDebugNotes().


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