clang  14.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"

Collaboration diagram for clang::tooling::SymbolOccurrence:
Collaboration graph
[legend]

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

Enumerator
MatchingSymbol 

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

Note:
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.:

\code
  #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.
  };
\endcode

The user will have to fix their code manually after performing such a
rename.
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 
)

Definition at line 16 of file SymbolOccurrences.cpp.

◆ SymbolOccurrence() [2/2]

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

Member Function Documentation

◆ getKind()

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

Definition at line 69 of file SymbolOccurrences.h.

◆ getNameRanges()

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

Definition at line 71 of file SymbolOccurrences.h.

References NumRanges, and SingleRange.

◆ operator=()

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

Member Data Documentation

◆ NumRanges

unsigned clang::tooling::SymbolOccurrence::NumRanges

Definition at line 82 of file SymbolOccurrences.h.

Referenced by getNameRanges().

◆ SingleRange

SourceRange clang::tooling::SymbolOccurrence::SingleRange

Definition at line 81 of file SymbolOccurrences.h.

Referenced by getNameRanges().


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