Coverage Report

Created: 2023-11-11 10:31

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Tooling/Refactoring/Rename/SymbolName.h
Line
Count
Source
1
//===--- SymbolName.h - Clang refactoring library -------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLING_REFACTORING_RENAME_SYMBOLNAME_H
10
#define LLVM_CLANG_TOOLING_REFACTORING_RENAME_SYMBOLNAME_H
11
12
#include "clang/Basic/LLVM.h"
13
#include "llvm/ADT/ArrayRef.h"
14
#include "llvm/ADT/SmallVector.h"
15
#include "llvm/ADT/StringRef.h"
16
17
namespace clang {
18
namespace tooling {
19
20
/// A name of a symbol.
21
///
22
/// Symbol's name can be composed of multiple strings. For example, Objective-C
23
/// methods can contain multiple argument labels:
24
///
25
/// \code
26
/// - (void) myMethodNamePiece: (int)x anotherNamePieces:(int)y;
27
/// //       ^~ string 0 ~~~~~         ^~ string 1 ~~~~~
28
/// \endcode
29
class SymbolName {
30
public:
31
169
  explicit SymbolName(StringRef Name) {
32
    // While empty symbol names are valid (Objective-C selectors can have empty
33
    // name pieces), occurrences Objective-C selectors are created using an
34
    // array of strings instead of just one string.
35
169
    assert(!Name.empty() && "Invalid symbol name!");
36
169
    this->Name.push_back(Name.str());
37
169
  }
38
39
1.83k
  ArrayRef<std::string> getNamePieces() const { return Name; }
40
41
private:
42
  llvm::SmallVector<std::string, 1> Name;
43
};
44
45
} // end namespace tooling
46
} // end namespace clang
47
48
#endif // LLVM_CLANG_TOOLING_REFACTORING_RENAME_SYMBOLNAME_H