clang API Documentation
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the problem. More...
#include <Diagnostic.h>
Public Member Functions | |
FixItHint () | |
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. Empty for an insertion hint. | |
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 |
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 51 of file Diagnostic.h.
clang::FixItHint::FixItHint | ( | ) | [inline] |
Empty code modification hint, indicating that no code modification is known.
Definition at line 69 of file Diagnostic.h.
static FixItHint clang::FixItHint::CreateInsertion | ( | SourceLocation | InsertionLoc, |
StringRef | Code, | ||
bool | BeforePreviousInsertions = false |
||
) | [inline, static] |
Create a code modification hint that inserts the given code string at a specific location.
Definition at line 77 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::ActOnFinishKNRParamDeclarations(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnMethodDeclaration(), clang::Sema::ActOnStartOfFunctionDef(), clang::Sema::ActOnUsingDeclaration(), addFixitForObjCARCConversion(), clang::Sema::AddInitializerToDecl(), applyCocoaAPICheck(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::BuildClassMessage(), clang::Sema::BuildFunctionType(), clang::Sema::BuildInstanceMessage(), clang::Sema::BuildQualifiedDeclarationNameExpr(), clang::Sema::CheckAddressOfOperand(), clang::Sema::CheckARCMethodDecl(), clang::Sema::CheckConstructor(), 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(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CheckVariableDeclarationType(), clang::Sema::ConversionToObjCStringLiteralCheck(), ConvertDeclSpecToType(), clang::Sema::CreateBuiltinBinOp(), createFriendTagNNSFixIt(), clang::Sema::CreatePropertyDecl(), clang::Sema::DefaultLvalueConversion(), clang::Sema::DiagnoseAlwaysNonNullPointer(), clang::Sema::DiagnoseAssignmentAsCondition(), DiagnoseDirectIsaAccess(), clang::Sema::DiagnoseDtorReference(), clang::Sema::DiagnoseEmptyLookup(), diagnoseLogicalNotOnLHSofComparison(), DiagnoseNamespaceInlineMismatch(), DiagnoseNarrowingInInitList(), diagnoseNoViableConversion(), diagnoseObjCLiteralComparison(), clang::Sema::DiagnoseSentinelCalls(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), DiagnoseSwitchLabelsFallthrough(), clang::Sema::DiagnoseUnknownTemplateName(), clang::Sema::DiagnoseUnknownTypeName(), clang::DeclSpec::Finish(), GetFullTypeForDeclarator(), handleFallThroughAttr(), HelperToDiagnoseMismatchedMethodsInGlobalPool(), isNullPointerValueTemplateArgument(), isTagTypeWithMissingTag(), clang::Sema::LookupInObjCMethod(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), maybeEmitZeroInitializationFixit(), clang::Sema::MaybeSuggestAddingStaticToDecl(), clang::Sema::ParseTypedefDecl(), clang::Parser::ParseUnqualifiedId(), RebuildForRangeWithDereference(), recoverFromMSUnqualifiedLookup(), SuggestInitializationFixit(), SuggestParentheses(), clang::ConversionFixItGenerator::tryToFixConversion(), clang::Sema::tryToRecoverWithCall(), and warnAboutAmbiguousFunction().
static FixItHint clang::FixItHint::CreateInsertionFromRange | ( | SourceLocation | InsertionLoc, |
CharSourceRange | FromRange, | ||
bool | BeforePreviousInsertions = false |
||
) | [inline, static] |
Create a code modification hint that inserts the given code from FromRange
at a specific location.
Definition at line 90 of file Diagnostic.h.
References BeforePreviousInsertions, clang::CharSourceRange::getCharRange(), InsertFromRange, and RemoveRange.
Referenced by applyCocoaAPICheck().
static FixItHint clang::FixItHint::CreateRemoval | ( | CharSourceRange | RemoveRange | ) | [inline, static] |
Create a code modification hint that removes the given source range.
Definition at line 103 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::ActOnParamDeclarator(), clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::ActOnTag(), clang::Sema::ActOnTypenameType(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::ActOnVarTemplateSpecialization(), applyCocoaAPICheck(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::BuildCXXNew(), clang::Sema::CheckConstructorDeclarator(), clang::Sema::CheckDestructorDeclarator(), clang::Sema::CheckLogicalOperands(), clang::Sema::CheckMain(), clang::Sema::CheckOverrideControl(), CheckTemplateArgumentAddressOfObjectOrFunction(), CreateIfFixit(), CreateRemoval(), clang::Sema::DiagnoseEqualityWithExtraParens(), clang::Sema::diagnoseIgnoredQualifiers(), clang::Sema::diagnoseQualifiedDeclaration(), clang::Sema::DiagnoseUnusedExprResult(), DiagUninitUse(), clang::DeclSpec::Finish(), GenerateFixForUnusedDecl(), GetFullTypeForDeclarator(), LookupMemberExpr(), clang::Sema::ParsedFreeStandingDeclSpec(), clang::Sema::ParseTypedefDecl(), clang::Parser::ParseUnqualifiedId(), clang::ConversionFixItGenerator::tryToFixConversion(), and warnAboutAmbiguousFunction().
static FixItHint clang::FixItHint::CreateRemoval | ( | SourceRange | RemoveRange | ) | [inline, static] |
Definition at line 108 of file Diagnostic.h.
References CreateRemoval(), and clang::CharSourceRange::getTokenRange().
static FixItHint clang::FixItHint::CreateReplacement | ( | CharSourceRange | RemoveRange, |
StringRef | Code | ||
) | [inline, static] |
Create a code modification hint that replaces the given source range with the given code string.
Definition at line 114 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::AtomicPropertySetterGetterRules(), 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::CheckPointerToMemberOperands(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CreateBuiltinBinOp(), CreateReplacement(), clang::Sema::DefaultLvalueConversion(), clang::Sema::DiagnoseAssignmentAsCondition(), DiagnoseDirectIsaAccess(), diagnoseDynamicExceptionSpecification(), clang::Sema::DiagnoseEqualityWithExtraParens(), diagnoseObjCLiteralComparison(), DiagnoseReinterpretUpDownCast(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), clang::Sema::diagnoseTypo(), DiagnoseUnusedComparison(), DiagUninitUse(), 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 | ||
) | [inline, static] |
Definition at line 122 of file Diagnostic.h.
References CreateReplacement(), and clang::CharSourceRange::getTokenRange().
bool clang::FixItHint::isNull | ( | ) | const [inline] |
Definition at line 71 of file Diagnostic.h.
References clang::CharSourceRange::isValid(), and RemoveRange.
Referenced by clang::Sema::DiagnoseAssignmentResult(), and clang::operator<<().
Definition at line 65 of file Diagnostic.h.
Referenced by CreateInsertion(), CreateInsertionFromRange(), clang::FixItRewriter::HandleDiagnostic(), makeStandaloneFixIt(), and mergeFixits().
std::string clang::FixItHint::CodeToInsert |
The actual code to insert at the insertion location, as a string.
Definition at line 63 of file Diagnostic.h.
Referenced by CreateInsertion(), CreateReplacement(), clang::FixItRewriter::HandleDiagnostic(), makeStandaloneFixIt(), and mergeFixits().
Code in the specific range that should be inserted in the insertion location.
Definition at line 59 of file Diagnostic.h.
Referenced by CreateInsertionFromRange(), clang::FixItRewriter::HandleDiagnostic(), makeStandaloneFixIt(), and mergeFixits().
Code that should be replaced to correct the error. Empty for an insertion hint.
Definition at line 55 of file Diagnostic.h.
Referenced by CreateInsertion(), CreateInsertionFromRange(), CreateRemoval(), CreateReplacement(), DiagUninitUse(), clang::FixItRewriter::HandleDiagnostic(), isNull(), makeStandaloneFixIt(), and mergeFixits().