clang 20.0.0git
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"

Public Member Functions

 FixItHint ()=default
 Empty code modification hint, indicating that no code modification is known.
 
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.
 
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.
 
static FixItHint CreateRemoval (CharSourceRange RemoveRange)
 Create a code modification hint that removes the given source range.
 
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.
 
static FixItHint CreateReplacement (SourceRange RemoveRange, StringRef Code)
 

Public Attributes

CharSourceRange RemoveRange
 Code that should be replaced to correct the error.
 
CharSourceRange InsertFromRange
 Code in the specific range that should be inserted in the insertion location.
 
std::string CodeToInsert
 The actual code to insert at the insertion location, as a string.
 
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 71 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 97 of file Diagnostic.h.

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

Referenced by clang::SemaObjC::ActOnAtEnd(), clang::Sema::ActOnCXXDelete(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnFields(), clang::Sema::ActOnFinishFunctionBody(), clang::Sema::ActOnFinishKNRParamDeclarations(), clang::Sema::ActOnFriendTypeDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::SemaObjC::ActOnMethodDeclaration(), clang::Sema::ActOnModuleDecl(), clang::SemaObjC::actOnObjCTypeArgsOrProtocolQualifiers(), clang::SemaObjC::actOnObjCTypeParam(), clang::Sema::ActOnPrivateModuleFragmentDecl(), clang::Sema::ActOnStartExportDecl(), clang::Sema::ActOnTemplateIdType(), clang::Sema::ActOnUsingDeclaration(), addFixitForObjCARCConversion(), clang::Sema::AddInitializerToDecl(), clang::SemaObjC::adornBoolConversionDiagWithTernaryFixit(), applyCocoaAPICheck(), clang::SemaObjC::AtomicPropertySetterGetterRules(), clang::Sema::BuildAnonymousStructOrUnion(), clang::SemaObjC::BuildClassMessage(), clang::Sema::BuildFunctionType(), clang::SemaObjC::BuildInstanceMessage(), buildLambdaCaptureFixit(), clang::Sema::BuildLambdaExpr(), buildLambdaThisCaptureFixit(), clang::Sema::BuildQualifiedDeclarationNameExpr(), clang::Sema::BuildUsingDeclaration(), clang::SemaObjC::CheckARCMethodDecl(), CheckAvailabilitySpecList(), clang::Sema::CheckCompletedCXXClass(), clang::Sema::CheckCompleteVariableDeclaration(), clang::Sema::CheckConstructor(), clang::Sema::CheckConversionDeclarator(), clang::SemaObjC::CheckConversionToObjCLiteral(), clang::Preprocessor::CheckEndOfDirective(), clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::CheckExplicitlyDefaultedComparison(), CheckFoldOperand(), clang::Sema::CheckFunctionDeclaration(), clang::Sema::CheckFunctionReturnType(), CheckLValueConstantExpression(), CheckMemorySizeofForComparison(), clang::SemaObjC::CheckObjCBridgeRelatedConversions(), CheckObjCCollectionLiteralElement(), clang::Sema::CheckParameter(), clang::Sema::checkStringLiteralArgumentAttr(), clang::SemaObjC::CheckSubscriptingKind(), CheckTemplateArgumentAddressOfObjectOrFunction(), clang::Sema::CheckTemplateTypeArgument(), clang::Sema::CheckTypenameType(), checkTypeParamListConsistency(), clang::Sema::CheckUseOfCXXMethodAsAddressOfOperand(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CheckVariableDeclarationType(), clang::Sema::CheckVirtualDtorCall(), ConvertDeclSpecToType(), clang::Sema::CreateBuiltinBinOp(), createDataFixit(), createFriendTagNNSFixIt(), createOverloadsForFixedParams(), clang::SemaObjC::CreatePropertyDecl(), clang::Sema::DefaultLvalueConversion(), clang::SemaObjC::DefaultSynthesizeProperties(), clang::InitializationSequence::Diagnose(), clang::Sema::DiagnoseAlwaysNonNullPointer(), clang::Sema::DiagnoseAssignmentAsCondition(), DiagnoseCallingConvCast(), clang::Sema::DiagnoseCommaOperator(), clang::Sema::DiagnoseDependentMemberLookup(), DiagnoseDirectIsaAccess(), DiagnosedUnqualifiedCallsToStdFunctions(), DiagnoseForRangeConstVariableCopies(), diagnoseImplicitlyRetainedSelf(), diagnoseInstanceReference(), DiagnoseInvalidRedeclaration(), diagnoseLogicalNotOnLHSofCheck(), DiagnoseMismatchedNewDelete(), diagnoseMissingConstinit(), DiagnoseNamespaceInlineMismatch(), DiagnoseNarrowingInInitList(), diagnoseNoViableConversion(), diagnoseObjCLiteralComparison(), clang::SemaObjC::DiagnoseOwningPropertyGetterSynthesis(), DiagnoseSelfAssignment(), clang::Sema::DiagnoseSelfMove(), clang::Sema::DiagnoseSentinelCalls(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), DiagnoseSwitchLabelsFallthrough(), clang::Sema::DiagnoseUnknownTemplateName(), clang::Sema::DiagnoseUnknownTypeName(), clang::Sema::DiagnoseUnterminatedPragmaAlignPack(), distributeNullabilityTypeAttr(), DoEmitAvailabilityWarning(), clang::DeclSpec::Finish(), fixItNullability(), FixVarInitializerWithSpan(), clang::Sema::getDestructorName(), UUCAddAssignGadget::getFixits(), GetFullTypeForDeclarator(), getStaticAssertNoMessageFixIt(), clang::Sema::getTypeName(), handleFallThroughAttr(), HelperToDiagnoseMismatchedMethodsInGlobalPool(), isNullPointerValueTemplateArgument(), isTagTypeWithMissingTag(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), clang::Sema::MaybeSuggestAddingStaticToDecl(), clang::Parser::ParseConstraintLogicalAndExpression(), clang::Parser::ParseUnqualifiedId(), clang::InitializationSequence::Perform(), processTypeAttrs(), RebuildForRangeWithDereference(), recoverFromMSUnqualifiedLookup(), clang::Sema::setTagNameForLinkagePurposes(), SuggestInitializationFixit(), SuggestParentheses(), clang::ConversionFixItGenerator::tryToFixConversion(), clang::Sema::tryToRecoverWithCall(), warnAboutAmbiguousFunction(), warnAboutRedundantParens(), and WarnUndefinedMethod().

◆ 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 110 of file Diagnostic.h.

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

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

◆ CreateRemoval() [1/2]

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

Create a code modification hint that removes the given source range.

Definition at line 123 of file Diagnostic.h.

References RemoveRange.

Referenced by clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnDecompositionDeclarator(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnLambdaExpressionAfterIntroducer(), clang::Sema::ActOnNonTypeTemplateParameter(), clang::SemaObjC::ActOnObjCExceptionDecl(), clang::SemaObjC::actOnObjCTypeParam(), clang::Sema::ActOnParamDeclarator(), clang::Sema::ActOnPragmaAttributeAttribute(), clang::Sema::ActOnStringLiteral(), clang::Sema::ActOnTag(), clang::Sema::ActOnTemplateName(), clang::Sema::ActOnTypenameType(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::ActOnVarTemplateSpecialization(), applyCocoaAPICheck(), clang::applyObjCTypeArgs(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::BuildCallExpr(), clang::Sema::BuildCXXNew(), clang::Sema::CheckConstructorDeclarator(), clang::Sema::CheckConversionDeclarator(), clang::Sema::CheckDestructorDeclarator(), clang::Sema::CheckLogicalOperands(), clang::Sema::CheckMain(), CheckMemorySizeofForComparison(), CheckMoveOnConstruction(), CheckNullabilityTypeSpecifier(), clang::Sema::CheckOverrideControl(), CheckTemplateArgumentAddressOfObjectOrFunction(), checkTypeParamListConsistency(), clang::BalancedDelimiterTracker::consumeClose(), CreateIfFixit(), clang::tooling::fixit::createRemoval(), CreateRemoval(), diagnoseAndRemoveTypeQualifiers(), clang::Sema::DiagnoseEqualityWithExtraParens(), DiagnoseForRangeReferenceVariableCopies(), clang::Sema::diagnoseIgnoredQualifiers(), DiagnoseInvalidRedeclaration(), diagnoseInvalidUnicodeCodepointInIdentifier(), DiagnoseMismatchedNewDelete(), diagnoseMissingConstinit(), clang::Sema::diagnoseQualifiedDeclaration(), clang::Sema::DiagnoseUnusedExprResult(), clang::Sema::DiagnoseUnusedLambdaCapture(), DiagUninitUse(), distributeNullabilityTypeAttr(), clang::DeclSpec::Finish(), FixVarInitializerWithSpan(), GenerateFixForUnusedDecl(), clang::Sema::getDestructorName(), DerefSimplePtrArithFixableGadget::getFixits(), GetFullTypeForDeclarator(), LookupMemberExpr(), clang::Sema::ParsedFreeStandingDeclSpec(), clang::Sema::ParseTypedefDecl(), clang::Parser::ParseUnqualifiedId(), processTypeAttrs(), tryConsumeLambdaSpecifierToken(), clang::ConversionFixItGenerator::tryToFixConversion(), warnAboutAmbiguousFunction(), warnAboutRedundantParens(), and warnBracedScalarInit().

◆ CreateRemoval() [2/2]

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

◆ CreateReplacement() [1/2]

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

Create a code modification hint that replaces the given source range with the given code string.

Definition at line 134 of file Diagnostic.h.

References CodeToInsert, and RemoveRange.

Referenced by clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnComment(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnGCCAsmStmt(), clang::comments::Sema::actOnParamCommandDirectionArg(), clang::SemaObjC::ActOnPropertyImplDecl(), clang::Sema::ActOnStartCXXMemberReference(), clang::Sema::ActOnTag(), clang::Sema::ActOnTagTemplateIdType(), clang::comments::Sema::actOnTParamCommandParamNameArg(), addFixitForObjCARCConversion(), AnalyzeImplicitConversions(), clang::SemaObjC::BuildClassMessage(), clang::Sema::BuildCXXNestedNameSpecifier(), clang::SemaObjC::BuildInstanceMessage(), clang::Sema::BuildMemberReferenceExpr(), clang::SemaObjC::BuildObjCBridgedCast(), clang::Sema::BuildOverloadedArrowExpr(), clang::Sema::BuildPseudoDestructorExpr(), checkAliasedGlobal(), clang::SemaObjC::CheckARCMethodDecl(), CheckArrow(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckExplicitlyDefaultedComparison(), clang::Sema::CheckExplicitlyDefaultedSpecialMember(), clang::Sema::checkLiteralOperatorId(), clang::Sema::CheckLogicalOperands(), clang::Sema::CheckMain(), clang::SemaObjC::CheckMessageArgumentTypes(), CheckNullabilityTypeSpecifier(), clang::Sema::CheckPointerToMemberOperands(), clang::Sema::CheckPtrComparisonWithNullChar(), checkTypeParamListConsistency(), clang::Sema::CheckUsingDeclQualifier(), clang::SemaCodeCompletion::CodeCompleteMemberReferenceExpr(), clang::Sema::CreateBuiltinBinOp(), clang::tooling::fixit::createReplacement(), CreateReplacement(), clang::Sema::DefaultLvalueConversion(), clang::Sema::DiagnoseAssignmentAsCondition(), DiagnoseBaseOrMemInitializerOrder(), DiagnoseDirectIsaAccess(), diagnoseDynamicExceptionSpecification(), clang::Sema::DiagnoseEqualityWithExtraParens(), diagnoseFrameworkInclude(), DiagnoseInvalidUnicodeCharacterName(), DiagnoseNullConversion(), diagnoseObjCLiteralComparison(), DiagnoseReinterpretUpDownCast(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), clang::Sema::diagnoseTypo(), DiagnoseUnusedComparison(), diagnoseXorMisusedAsPow(), clang::Sema::diagnoseZeroToNullptrConversion(), DiagUninitUse(), DoEmitAvailabilityWarning(), emitReplacement(), FixDigraph(), fixLocalVarDeclWithSpan(), fixParamWithSpan(), fixSeparateAttrArgAndNumber(), fixUPCAddressofArraySubscriptWithSpan(), fixVarDeclWithArray(), clang::Sema::getDestructorName(), DerefSimplePtrArithFixableGadget::getFixits(), UPCPreIncrementGadget::getFixits(), UUCAddAssignGadget::getFixits(), getStaticAssertNoMessageFixIt(), clang::SourceMgrAdapter::handleDiag(), clang::Preprocessor::HandleEndOfFile(), clang::SemaObjC::HandleExprPropertyRefExpr(), handleFormatAttr(), handleGlobalAttr(), clang::Sema::isAcceptableTagRedeclaration(), clang::CompilerInstance::loadModule(), LookupMemberExpr(), clang::SemaObjC::ParseObjCSelectorExpression(), and warnAboutAmbiguousFunction().

◆ CreateReplacement() [2/2]

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

◆ 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 83 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 79 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 75 of file Diagnostic.h.

Referenced by clang::internal::anyConflict(), CreateInsertion(), CreateInsertionFromRange(), CreateRemoval(), CreateReplacement(), DiagUninitUse(), clang::FixItRewriter::HandleDiagnostic(), isNull(), makeStandaloneFixIt(), and overlapWithMacro().


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