clang  3.9.0
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 <Diagnostic.h>

Collaboration diagram for clang::FixItHint:
[legend]

Public Member Functions

 FixItHint ()
 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
 

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

Constructor & Destructor Documentation

clang::FixItHint::FixItHint ( )
inline

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

Definition at line 70 of file Diagnostic.h.

Member Function Documentation

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

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

Referenced by clang::Sema::ActOnAtEnd(), clang::Sema::ActOnCXXDelete(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnFields(), clang::Sema::ActOnFinishFunctionBody(), clang::Sema::ActOnFinishKNRParamDeclarations(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnMethodDeclaration(), clang::Sema::actOnObjCTypeArgsOrProtocolQualifiers(), clang::Sema::actOnObjCTypeParam(), clang::Sema::ActOnUsingDeclaration(), addFixitForObjCARCConversion(), clang::Sema::AddInitializerToDecl(), applyCocoaAPICheck(), clang::Sema::AtomicPropertySetterGetterRules(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::BuildClassMessage(), clang::Sema::BuildFunctionType(), clang::Sema::BuildInstanceMessage(), clang::Sema::BuildQualifiedDeclarationNameExpr(), clang::Sema::CheckAddressOfOperand(), clang::Sema::CheckARCMethodDecl(), CheckAvailabilitySpecList(), clang::Sema::CheckConstructor(), clang::Sema::CheckConversionDeclarator(), clang::comments::Sema::checkDeprecatedCommand(), clang::Preprocessor::CheckEndOfDirective(), clang::Sema::CheckEquivalentExceptionSpec(), CheckFoldOperand(), clang::Sema::CheckFriendTypeDecl(), clang::Sema::CheckFunctionDeclaration(), clang::Sema::CheckFunctionReturnType(), CheckMemorySizeofForComparison(), clang::Sema::CheckObjCBridgeRelatedConversions(), CheckObjCCollectionLiteralElement(), clang::Sema::CheckParameter(), clang::Sema::checkStringLiteralArgumentAttr(), clang::Sema::CheckSubscriptingKind(), CheckTemplateArgumentAddressOfObjectOrFunction(), clang::Sema::CheckTemplateTypeArgument(), clang::Sema::CheckTypenameType(), checkTypeParamListConsistency(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CheckVariableDeclarationType(), clang::Sema::CheckVirtualDtorCall(), clang::Sema::ConversionToObjCStringLiteralCheck(), ConvertDeclSpecToType(), clang::Sema::CreateBuiltinBinOp(), createFriendTagNNSFixIt(), clang::Sema::CreatePropertyDecl(), clang::Sema::DefaultLvalueConversion(), clang::Sema::DiagnoseAlwaysNonNullPointer(), clang::Sema::DiagnoseAssignmentAsCondition(), DiagnoseCallingConvCast(), clang::Sema::DiagnoseCommaOperator(), DiagnoseDirectIsaAccess(), clang::Sema::DiagnoseEmptyLookup(), diagnoseLogicalNotOnLHSofComparison(), DiagnoseMismatchedNewDelete(), DiagnoseNamespaceInlineMismatch(), DiagnoseNarrowingInInitList(), diagnoseNoViableConversion(), diagnoseObjCLiteralComparison(), clang::Sema::DiagnoseOwningPropertyGetterSynthesis(), clang::Sema::DiagnoseSentinelCalls(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), DiagnoseSwitchLabelsFallthrough(), clang::Sema::DiagnoseUnknownTemplateName(), clang::Sema::DiagnoseUnknownTypeName(), distributeNullabilityTypeAttr(), clang::DeclSpec::Finish(), GetFullTypeForDeclarator(), handleFallThroughAttr(), HelperToDiagnoseMismatchedMethodsInGlobalPool(), isNullPointerValueTemplateArgument(), isTagTypeWithMissingTag(), clang::Sema::LookupInObjCMethod(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), clang::Sema::MaybeSuggestAddingStaticToDecl(), clang::Parser::ParseUnqualifiedId(), clang::InitializationSequence::Perform(), processTypeAttrs(), RebuildForRangeWithDereference(), recoverFromMSUnqualifiedLookup(), clang::Sema::setTagNameForLinkagePurposes(), SuggestInitializationFixit(), SuggestParentheses(), clang::ConversionFixItGenerator::tryToFixConversion(), clang::Sema::tryToRecoverWithCall(), and warnAboutAmbiguousFunction().

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

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

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

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

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

Definition at line 104 of file Diagnostic.h.

References RemoveRange.

Referenced by clang::Sema::ActOnCallExpr(), clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnDependentTemplateName(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnObjCExceptionDecl(), clang::Sema::actOnObjCTypeParam(), clang::Sema::ActOnParamDeclarator(), clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::ActOnTag(), clang::Sema::ActOnTypenameType(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::ActOnVarTemplateSpecialization(), applyCocoaAPICheck(), applyObjCTypeArgs(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::BuildCXXNew(), clang::Sema::CheckConstructorDeclarator(), clang::Sema::CheckConversionDeclarator(), clang::Sema::CheckDestructorDeclarator(), clang::Sema::CheckLogicalOperands(), clang::Sema::CheckMain(), CheckMemorySizeofForComparison(), CheckMoveOnConstruction(), clang::Sema::checkNullabilityTypeSpecifier(), clang::Sema::CheckOverrideControl(), CheckTemplateArgumentAddressOfObjectOrFunction(), checkTypeParamListConsistency(), clang::BalancedDelimiterTracker::consumeClose(), CreateIfFixit(), clang::tooling::fixit::createRemoval(), CreateRemoval(), diagnoseAndRemoveTypeQualifiers(), clang::Sema::DiagnoseEqualityWithExtraParens(), clang::Sema::diagnoseIgnoredQualifiers(), DiagnoseMismatchedNewDelete(), clang::Sema::diagnoseQualifiedDeclaration(), clang::Sema::DiagnoseUnusedExprResult(), DiagUninitUse(), distributeNullabilityTypeAttr(), clang::DeclSpec::Finish(), GenerateFixForUnusedDecl(), GetFullTypeForDeclarator(), LookupMemberExpr(), clang::Sema::ParsedFreeStandingDeclSpec(), clang::Sema::ParseTypedefDecl(), clang::Parser::ParseUnqualifiedId(), processTypeAttrs(), clang::ConversionFixItGenerator::tryToFixConversion(), and warnAboutAmbiguousFunction().

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

Definition at line 109 of file Diagnostic.h.

References CreateRemoval(), and clang::CharSourceRange::getTokenRange().

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 115 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::Sema::ActOnPropertyImplDecl(), clang::Sema::ActOnStartCXXMemberReference(), clang::Sema::ActOnTag(), clang::Sema::ActOnTagTemplateIdType(), clang::comments::Sema::actOnTParamCommandParamNameArg(), addFixitForObjCARCConversion(), clang::Sema::BuildCXXNestedNameSpecifier(), clang::Sema::BuildMemberReferenceExpr(), clang::Sema::BuildObjCBridgedCast(), clang::Sema::BuildOverloadedArrowExpr(), clang::Sema::CheckARCMethodDecl(), CheckArrow(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckLogicalOperands(), clang::Sema::CheckMain(), clang::Sema::CheckMessageArgumentTypes(), clang::Sema::checkNullabilityTypeSpecifier(), clang::Sema::CheckPointerToMemberOperands(), checkTypeParamListConsistency(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CreateBuiltinBinOp(), clang::tooling::fixit::createReplacement(), CreateReplacement(), clang::Sema::DefaultLvalueConversion(), clang::Sema::DiagnoseAssignmentAsCondition(), diagnoseAutoModuleImport(), DiagnoseDirectIsaAccess(), diagnoseDynamicExceptionSpecification(), clang::Sema::DiagnoseEqualityWithExtraParens(), diagnoseObjCLiteralComparison(), DiagnoseReinterpretUpDownCast(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), clang::Sema::diagnoseTypo(), DiagnoseUnusedComparison(), DiagUninitUse(), DoEmitAvailabilityWarning(), emitReplacement(), FixDigraph(), clang::Sema::getDestructorName(), clang::Preprocessor::HandleEndOfFile(), clang::Sema::HandleExprPropertyRefExpr(), handleGlobalAttr(), clang::Sema::isAcceptableTagRedeclaration(), clang::CompilerInstance::loadModule(), LookupMemberExpr(), clang::Sema::ParseObjCSelectorExpression(), clang::comments::Sema::resolveParamCommandIndexes(), and warnAboutAmbiguousFunction().

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

Definition at line 123 of file Diagnostic.h.

References CreateReplacement(), and clang::CharSourceRange::getTokenRange().

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

Member Data Documentation

bool clang::FixItHint::BeforePreviousInsertions
std::string clang::FixItHint::CodeToInsert

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

Definition at line 64 of file Diagnostic.h.

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

CharSourceRange clang::FixItHint::InsertFromRange

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

Definition at line 60 of file Diagnostic.h.

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

CharSourceRange clang::FixItHint::RemoveRange

Code that should be replaced to correct the error.

Empty for an insertion hint.

Definition at line 56 of file Diagnostic.h.

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


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