clang 19.0.0git
Public Types | Public Member Functions | List of all members
clang::tooling::SymbolOccurrence Class Reference

An occurrence of a symbol in the source. More...

#include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h"

Public Types

enum  OccurrenceKind { MatchingSymbol }

Public Member Functions

 SymbolOccurrence (const SymbolName &Name, OccurrenceKind Kind, ArrayRef< SourceLocation > Locations)
 SymbolOccurrence (SymbolOccurrence &&)=default
SymbolOccurrenceoperator= (SymbolOccurrence &&)=default
OccurrenceKind getKind () const
ArrayRef< SourceRangegetNameRanges () const

Detailed Description

An occurrence of a symbol in the source.

Occurrences can have difference kinds, that describe whether this occurrence is an exact semantic match, or whether this is a weaker textual match that's not guaranteed to represent the exact declaration.

A single occurrence of a symbol can span more than one source range. For example, Objective-C selectors can contain multiple argument labels:

[object selectorPiece1: ... selectorPiece2: ...];
// ^~~ range 0 ~~ ^~~ range 1 ~~

We have to replace the text in both range 0 and range 1 when renaming the Objective-C method 'selectorPiece1:selectorPiece2'.

Definition at line 39 of file SymbolOccurrences.h.

Member Enumeration Documentation

◆ OccurrenceKind


This occurrence is an exact match and can be renamed automatically.

Symbol occurrences in macro arguments that expand to different
declarations get marked as exact matches, and thus the renaming engine
will rename them e.g.:

  #define MACRO(x) x + ns::x
  int foo(int var) {
    return MACRO(var); // var is renamed automatically here when
                       // either var or ns::var is renamed.

The user will have to fix their code manually after performing such a
FIXME: The rename verifier should notify user about this issue. 

Definition at line 41 of file SymbolOccurrences.h.

Constructor & Destructor Documentation

◆ SymbolOccurrence() [1/2]

SymbolOccurrence::SymbolOccurrence ( const SymbolName Name,
OccurrenceKind  Kind,
ArrayRef< SourceLocation Locations 

◆ SymbolOccurrence() [2/2]

clang::tooling::SymbolOccurrence::SymbolOccurrence ( SymbolOccurrence &&  )

Member Function Documentation

◆ getKind()

OccurrenceKind clang::tooling::SymbolOccurrence::getKind ( ) const

Definition at line 69 of file SymbolOccurrences.h.

◆ getNameRanges()

ArrayRef< SourceRange > clang::tooling::SymbolOccurrence::getNameRanges ( ) const

Definition at line 71 of file SymbolOccurrences.h.

References NumRanges, and SingleRange.

◆ operator=()

SymbolOccurrence & clang::tooling::SymbolOccurrence::operator= ( SymbolOccurrence &&  )

Member Data Documentation

◆ NumRanges

unsigned clang::tooling::SymbolOccurrence::NumRanges

Definition at line 82 of file SymbolOccurrences.h.

Referenced by getNameRanges(), and SymbolOccurrence().

◆ SingleRange

SourceRange clang::tooling::SymbolOccurrence::SingleRange

Definition at line 81 of file SymbolOccurrences.h.

Referenced by getNameRanges(), and SymbolOccurrence().

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