class FixItHint

Declaration

class FixItHint { /* full declaration omitted */ };

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.

Declared at: clang/include/clang/Basic/Diagnostic.h:71

Member Variables

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

Method Overview

  • public static clang::FixItHint CreateInsertion(clang::SourceLocation InsertionLoc, llvm::StringRef Code, bool BeforePreviousInsertions = false)
  • public static clang::FixItHint CreateInsertionFromRange(clang::SourceLocation InsertionLoc, clang::CharSourceRange FromRange, bool BeforePreviousInsertions = false)
  • public static clang::FixItHint CreateRemoval(clang::CharSourceRange RemoveRange)
  • public static clang::FixItHint CreateRemoval(clang::SourceRange RemoveRange)
  • public static clang::FixItHint CreateReplacement(clang::CharSourceRange RemoveRange, llvm::StringRef Code)
  • public static clang::FixItHint CreateReplacement(clang::SourceRange RemoveRange, llvm::StringRef Code)
  • public FixItHint()
  • public bool isNull() const

Methods

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

Description

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

Declared at: clang/include/clang/Basic/Diagnostic.h:97

Parameters

clang::SourceLocation InsertionLoc
llvm::StringRef Code
bool BeforePreviousInsertions = false

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

Description

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

Declared at: clang/include/clang/Basic/Diagnostic.h:110

Parameters

clang::SourceLocation InsertionLoc
clang::CharSourceRange FromRange
bool BeforePreviousInsertions = false

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

Description

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

Declared at: clang/include/clang/Basic/Diagnostic.h:123

Parameters

clang::CharSourceRange RemoveRange

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

Declared at: clang/include/clang/Basic/Diagnostic.h:128

Parameters

clang::SourceRange RemoveRange

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

Description

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

Declared at: clang/include/clang/Basic/Diagnostic.h:134

Parameters

clang::CharSourceRange RemoveRange
llvm::StringRef Code

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

Declared at: clang/include/clang/Basic/Diagnostic.h:142

Parameters

clang::SourceRange RemoveRange
llvm::StringRef Code

FixItHint()

Description

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

Declared at: clang/include/clang/Basic/Diagnostic.h:89

bool isNull() const

Declared at: clang/include/clang/Basic/Diagnostic.h:91