clang  7.0.0svn
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::FixItHint Class Reference

Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the problem. More...

#include "clang/Basic/Diagnostic.h"

Collaboration diagram for clang::FixItHint:
Collaboration graph
[legend]

Public Member Functions

 FixItHint ()=default
 Empty code modification hint, indicating that no code modification is known. More...
 
bool isNull () const
 

Static Public Member Functions

static FixItHint CreateInsertion (SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
 Create a code modification hint that inserts the given code string at a specific location. More...
 
static FixItHint CreateInsertionFromRange (SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
 Create a code modification hint that inserts the given code from FromRange at a specific location. More...
 
static FixItHint CreateRemoval (CharSourceRange RemoveRange)
 Create a code modification hint that removes the given source range. More...
 
static FixItHint CreateRemoval (SourceRange RemoveRange)
 
static FixItHint CreateReplacement (CharSourceRange RemoveRange, StringRef Code)
 Create a code modification hint that replaces the given source range with the given code string. More...
 
static FixItHint CreateReplacement (SourceRange RemoveRange, StringRef Code)
 

Public Attributes

CharSourceRange RemoveRange
 Code that should be replaced to correct the error. More...
 
CharSourceRange InsertFromRange
 Code in the specific range that should be inserted in the insertion location. More...
 
std::string CodeToInsert
 The actual code to insert at the insertion location, as a string. More...
 
bool BeforePreviousInsertions = false
 

Detailed Description

Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the problem.

This kind of hint should be used when we are certain that the introduction, removal, or modification of a particular (small!) amount of code will correct a compilation error. The compiler should also provide full recovery from such errors, such that suppressing the diagnostic output can still result in successful compilation.

Definition at line 66 of file Diagnostic.h.

Constructor & Destructor Documentation

◆ FixItHint()

clang::FixItHint::FixItHint ( )
default

Empty code modification hint, indicating that no code modification is known.

Member Function Documentation

◆ CreateInsertion()

static FixItHint clang::FixItHint::CreateInsertion ( SourceLocation  InsertionLoc,
StringRef  Code,
bool  BeforePreviousInsertions = false 
)
inlinestatic

Create a code modification hint that inserts the given code string at a specific location.

Definition at line 92 of file Diagnostic.h.

References BeforePreviousInsertions, CodeToInsert, clang::CharSourceRange::getCharRange(), and RemoveRange.

Referenced by clang::Sema::ActOnCXXDelete(), clang::Sema::ActOnModuleDecl(), addConstexprToLambdaDeclSpecifier(), addContextSensitiveTypeNullability(), addFixitForObjCARCConversion(), clang::Sema::BuildClassMessage(), clang::Sema::BuildInstanceMessage(), clang::Sema::BuildQualifiedDeclarationNameExpr(), clang::Sema::CheckARCMethodDecl(), CheckArrayDesignatorSyntax(), CheckAvailabilitySpecList(), clang::Sema::CheckConversionDeclarator(), clang::Preprocessor::CheckEndOfDirective(), clang::Sema::CheckFriendTypeDecl(), clang::Sema::CheckFunctionReturnType(), clang::Sema::CheckObjCBridgeRelatedConversions(), CheckObjCCollectionLiteralElement(), clang::Sema::checkStringLiteralArgumentAttr(), clang::Sema::CheckSubscriptingKind(), CheckTemplateArgumentAddressOfObjectOrFunction(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CheckVariableDeclarationType(), clang::Sema::CheckVirtualDtorCall(), clang::Sema::ConversionToObjCStringLiteralCheck(), clang::Parser::Diag(), clang::InitializationSequence::Diagnose(), DiagnoseCallingConvCast(), clang::Sema::DiagnoseCommaOperator(), diagnoseLogicalNotOnLHSofCheck(), DiagnoseMismatchedNewDelete(), DiagnoseNarrowingInInitList(), diagnoseNoViableConversion(), diagnoseObjCLiteralComparison(), clang::Sema::DiagnoseOwningPropertyGetterSynthesis(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), DiagnoseSwitchLabelsFallthrough(), clang::Sema::DiagnoseUnterminatedPragmaPack(), clang::DiagnosticRenderer::DiagnosticRenderer(), distributeNullabilityTypeAttr(), findPlaceholderEnd(), fixItNullability(), clang::Sema::GetFormatStringType(), getMissingDeclaratorIdLoc(), IsCommonTypo(), isValidAfterIdentifierInDeclarator(), clang::Parser::ObjCTypeParamListScope::leave(), clang::Sema::MaybeSuggestAddingStaticToDecl(), clang::Parser::ParseConstraintExpression(), clang::Parser::ParseUnqualifiedId(), clang::InitializationSequence::Perform(), processTypeAttrs(), clang::Lexer::ReadToEndOfLine(), SuggestInitializationFixit(), SuggestParentheses(), takeDeclAttributes(), and warnAboutRedundantParens().

◆ CreateInsertionFromRange()

static FixItHint clang::FixItHint::CreateInsertionFromRange ( SourceLocation  InsertionLoc,
CharSourceRange  FromRange,
bool  BeforePreviousInsertions = false 
)
inlinestatic

Create a code modification hint that inserts the given code from FromRange at a specific location.

Definition at line 105 of file Diagnostic.h.

References BeforePreviousInsertions, clang::CharSourceRange::getCharRange(), InsertFromRange, and RemoveRange.

Referenced by clang::Sema::CheckConversionDeclarator(), and getMissingDeclaratorIdLoc().

◆ CreateRemoval() [1/2]

static FixItHint clang::FixItHint::CreateRemoval ( CharSourceRange  RemoveRange)
inlinestatic

◆ CreateRemoval() [2/2]

static FixItHint clang::FixItHint::CreateRemoval ( SourceRange  RemoveRange)
inlinestatic

Definition at line 123 of file Diagnostic.h.

References clang::CharSourceRange::getTokenRange().

◆ CreateReplacement() [1/2]

static FixItHint clang::FixItHint::CreateReplacement ( CharSourceRange  RemoveRange,
StringRef  Code 
)
inlinestatic

◆ CreateReplacement() [2/2]

static FixItHint clang::FixItHint::CreateReplacement ( SourceRange  RemoveRange,
StringRef  Code 
)
inlinestatic

Definition at line 137 of file Diagnostic.h.

References clang::CharSourceRange::getTokenRange().

◆ isNull()

bool clang::FixItHint::isNull ( ) const
inline

Member Data Documentation

◆ BeforePreviousInsertions

bool clang::FixItHint::BeforePreviousInsertions = false

◆ CodeToInsert

std::string clang::FixItHint::CodeToInsert

The actual code to insert at the insertion location, as a string.

Definition at line 78 of file Diagnostic.h.

Referenced by CreateInsertion(), CreateReplacement(), clang::FixItRewriter::HandleDiagnostic(), and makeStandaloneFixIt().

◆ InsertFromRange

CharSourceRange clang::FixItHint::InsertFromRange

Code in the specific range that should be inserted in the insertion location.

Definition at line 74 of file Diagnostic.h.

Referenced by CreateInsertionFromRange(), clang::FixItRewriter::HandleDiagnostic(), and makeStandaloneFixIt().

◆ RemoveRange

CharSourceRange clang::FixItHint::RemoveRange

Code that should be replaced to correct the error.

Empty for an insertion hint.

Definition at line 70 of file Diagnostic.h.

Referenced by CreateInsertion(), CreateInsertionFromRange(), CreateRemoval(), CreateReplacement(), clang::FixItRewriter::HandleDiagnostic(), and makeStandaloneFixIt().


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