Skip to content

Commit c76edaa

Browse files
committed
[clang-tidy] Prune dead code. NFC.
1 parent f392b75 commit c76edaa

File tree

9 files changed

+8
-194
lines changed

9 files changed

+8
-194
lines changed

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,6 @@ static constexpr std::pair<StringRef, IdentifierNamingCheck::CaseType>
109109
{"Camel_Snake_Case", IdentifierNamingCheck::CT_CamelSnakeCase},
110110
{"camel_Snake_Back", IdentifierNamingCheck::CT_CamelSnakeBack}};
111111

112-
namespace {
113-
/// Callback supplies macros to IdentifierNamingCheck::checkMacro
114-
class IdentifierNamingCheckPPCallbacks : public PPCallbacks {
115-
public:
116-
IdentifierNamingCheckPPCallbacks(Preprocessor *PP,
117-
IdentifierNamingCheck *Check)
118-
: PP(PP), Check(Check) {}
119-
120-
/// MacroDefined calls checkMacro for macros in the main file
121-
void MacroDefined(const Token &MacroNameTok,
122-
const MacroDirective *MD) override {
123-
Check->checkMacro(PP->getSourceManager(), MacroNameTok, MD->getMacroInfo());
124-
}
125-
126-
/// MacroExpands calls expandMacro for macros in the main file
127-
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
128-
SourceRange /*Range*/,
129-
const MacroArgs * /*Args*/) override {
130-
Check->expandMacro(MacroNameTok, MD.getMacroInfo());
131-
}
132-
133-
private:
134-
Preprocessor *PP;
135-
IdentifierNamingCheck *Check;
136-
};
137-
} // namespace
138-
139112
IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
140113
ClangTidyContext *Context)
141114
: RenamerClangTidyCheck(Name, Context),

clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,40 +70,6 @@ constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
7070
return DeclRefs;
7171
}
7272

73-
// Finds all DeclRefExprs where a const method is called on VarDecl or VarDecl
74-
// is the a const reference or value argument to a CallExpr or CXXConstructExpr.
75-
SmallPtrSet<const DeclRefExpr *, 16>
76-
constReferenceDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl,
77-
ASTContext &Context) {
78-
auto DeclRefToVar =
79-
declRefExpr(to(varDecl(equalsNode(&VarDecl)))).bind("declRef");
80-
auto ConstMethodCallee = callee(cxxMethodDecl(isConst()));
81-
// Match method call expressions where the variable is referenced as the this
82-
// implicit object argument and opertor call expression for member operators
83-
// where the variable is the 0-th argument.
84-
auto Matches =
85-
match(decl(forEachDescendant(expr(
86-
anyOf(cxxMemberCallExpr(ConstMethodCallee, on(DeclRefToVar)),
87-
cxxOperatorCallExpr(ConstMethodCallee,
88-
hasArgument(0, DeclRefToVar)))))),
89-
Decl, Context);
90-
SmallPtrSet<const DeclRefExpr *, 16> DeclRefs;
91-
extractNodesByIdTo(Matches, "declRef", DeclRefs);
92-
auto ConstReferenceOrValue =
93-
qualType(anyOf(referenceType(pointee(qualType(isConstQualified()))),
94-
unless(anyOf(referenceType(), pointerType()))));
95-
auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
96-
DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
97-
Matches = match(decl(forEachDescendant(callExpr(UsedAsConstRefOrValueArg))),
98-
Decl, Context);
99-
extractNodesByIdTo(Matches, "declRef", DeclRefs);
100-
Matches =
101-
match(decl(forEachDescendant(cxxConstructExpr(UsedAsConstRefOrValueArg))),
102-
Decl, Context);
103-
extractNodesByIdTo(Matches, "declRef", DeclRefs);
104-
return DeclRefs;
105-
}
106-
10773
bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt,
10874
ASTContext &Context) {
10975
// Collect all DeclRefExprs to the loop variable and all CallExprs and

clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ llvm::SmallPtrSet<const DeclRefExpr *, 16>
4141
constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
4242
ASTContext &Context);
4343

44-
/// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Decl`` where
45-
/// ``VarDecl`` is guaranteed to be accessed in a const fashion.
46-
llvm::SmallPtrSet<const DeclRefExpr *, 16>
47-
constReferenceDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl,
48-
ASTContext &Context);
49-
5044
/// Returns ``true`` if ``DeclRefExpr`` is the argument of a copy-constructor
5145
/// call expression within ``Decl``.
5246
bool isCopyConstructorArgument(const DeclRefExpr &DeclRef, const Decl &Decl,

clang-tools-extra/clang-tidy/utils/FixItHintUtils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ namespace fixit {
2121
/// Creates fix to make ``VarDecl`` a reference by adding ``&``.
2222
FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context);
2323

24-
/// Creates fix to make ``VarDecl`` const qualified.
25-
FixItHint changeVarDeclToConst(const VarDecl &Var);
26-
2724
/// This enum defines where the qualifier shall be preferably added.
2825
enum class QualifierPolicy {
2926
Left, // Add the qualifier always to the left side, if that is possible.

clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class IncludeInserterCallback : public PPCallbacks {
3737
IncludeInserter::IncludeInserter(const SourceManager &SourceMgr,
3838
const LangOptions &LangOpts,
3939
IncludeSorter::IncludeStyle Style)
40-
: SourceMgr(SourceMgr), LangOpts(LangOpts), Style(Style) {}
40+
: SourceMgr(SourceMgr), Style(Style) {}
4141

4242
IncludeInserter::~IncludeInserter() {}
4343

@@ -52,7 +52,7 @@ IncludeSorter &IncludeInserter::getOrCreate(FileID FileID) {
5252
if (!Entry) {
5353
// If it wasn't found, Entry will be default constructed to nullptr.
5454
Entry = std::make_unique<IncludeSorter>(
55-
&SourceMgr, &LangOpts, FileID,
55+
&SourceMgr, FileID,
5656
SourceMgr.getFilename(SourceMgr.getLocForStartOfFile(FileID)), Style);
5757
}
5858
return *Entry;

clang-tools-extra/clang-tidy/utils/IncludeInserter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class IncludeInserter {
7676
llvm::DenseMap<FileID, std::unique_ptr<IncludeSorter>> IncludeSorterByFile;
7777
llvm::DenseMap<FileID, std::set<std::string>> InsertedHeaders;
7878
const SourceManager &SourceMgr;
79-
const LangOptions &LangOpts;
8079
const IncludeSorter::IncludeStyle Style;
8180
friend class IncludeInserterCallback;
8281
};

clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp

Lines changed: 4 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,10 @@ DetermineIncludeKind(StringRef CanonicalFile, StringRef IncludeFile,
8383
} // namespace
8484

8585
IncludeSorter::IncludeSorter(const SourceManager *SourceMgr,
86-
const LangOptions *LangOpts, const FileID FileID,
87-
StringRef FileName, IncludeStyle Style)
88-
: SourceMgr(SourceMgr), LangOpts(LangOpts), Style(Style),
89-
CurrentFileID(FileID), CanonicalFile(MakeCanonicalName(FileName, Style)) {
90-
}
86+
const FileID FileID, StringRef FileName,
87+
IncludeStyle Style)
88+
: SourceMgr(SourceMgr), Style(Style), CurrentFileID(FileID),
89+
CanonicalFile(MakeCanonicalName(FileName, Style)) {}
9190

9291
void IncludeSorter::AddInclude(StringRef FileName, bool IsAngled,
9392
SourceLocation HashLocation,
@@ -175,106 +174,6 @@ Optional<FixItHint> IncludeSorter::CreateIncludeInsertion(StringRef FileName,
175174
IncludeStmt);
176175
}
177176

178-
std::vector<FixItHint> IncludeSorter::GetEdits() {
179-
if (SourceLocations.empty())
180-
return {};
181-
182-
typedef std::map<int, std::pair<SourceRange, std::string>>
183-
FileLineToSourceEditMap;
184-
FileLineToSourceEditMap Edits;
185-
auto SourceLocationIterator = SourceLocations.begin();
186-
auto SourceLocationIteratorEnd = SourceLocations.end();
187-
188-
// Compute the Edits that need to be done to each line to add, replace, or
189-
// delete inclusions.
190-
for (int IncludeKind = 0; IncludeKind < IK_InvalidInclude; ++IncludeKind) {
191-
std::sort(IncludeBucket[IncludeKind].begin(),
192-
IncludeBucket[IncludeKind].end());
193-
for (const auto &IncludeEntry : IncludeBucket[IncludeKind]) {
194-
auto &Location = IncludeLocations[IncludeEntry];
195-
SourceRangeVector::iterator LocationIterator = Location.begin();
196-
SourceRangeVector::iterator LocationIteratorEnd = Location.end();
197-
SourceRange FirstLocation = *LocationIterator;
198-
199-
// If the first occurrence of a particular include is on the current
200-
// source line we are examining, leave it alone.
201-
if (FirstLocation == *SourceLocationIterator)
202-
++LocationIterator;
203-
204-
// Add the deletion Edits for any (remaining) instances of this inclusion,
205-
// and remove their Locations from the source Locations to be processed.
206-
for (; LocationIterator != LocationIteratorEnd; ++LocationIterator) {
207-
int LineNumber =
208-
SourceMgr->getSpellingLineNumber(LocationIterator->getBegin());
209-
Edits[LineNumber] = std::make_pair(*LocationIterator, "");
210-
SourceLocationIteratorEnd =
211-
std::remove(SourceLocationIterator, SourceLocationIteratorEnd,
212-
*LocationIterator);
213-
}
214-
215-
if (FirstLocation == *SourceLocationIterator) {
216-
// Do nothing except move to the next source Location (Location of an
217-
// inclusion in the original, unchanged source file).
218-
++SourceLocationIterator;
219-
continue;
220-
}
221-
222-
// Add (or append to) the replacement text for this line in source file.
223-
int LineNumber =
224-
SourceMgr->getSpellingLineNumber(SourceLocationIterator->getBegin());
225-
if (Edits.find(LineNumber) == Edits.end()) {
226-
Edits[LineNumber].first =
227-
SourceRange(SourceLocationIterator->getBegin());
228-
}
229-
StringRef SourceText = Lexer::getSourceText(
230-
CharSourceRange::getCharRange(FirstLocation), *SourceMgr, *LangOpts);
231-
Edits[LineNumber].second.append(SourceText.data(), SourceText.size());
232-
}
233-
234-
// Clear the bucket.
235-
IncludeBucket[IncludeKind].clear();
236-
}
237-
238-
// Go through the single-line Edits and combine them into blocks of Edits.
239-
int CurrentEndLine = 0;
240-
SourceRange CurrentRange;
241-
std::string CurrentText;
242-
std::vector<FixItHint> Fixes;
243-
for (const auto &LineEdit : Edits) {
244-
// If the current edit is on the next line after the previous edit, add it
245-
// to the current block edit.
246-
if (LineEdit.first == CurrentEndLine + 1 &&
247-
CurrentRange.getBegin() != CurrentRange.getEnd()) {
248-
SourceRange EditRange = LineEdit.second.first;
249-
if (EditRange.getBegin() != EditRange.getEnd()) {
250-
++CurrentEndLine;
251-
CurrentRange.setEnd(EditRange.getEnd());
252-
}
253-
CurrentText += LineEdit.second.second;
254-
// Otherwise report the current block edit and start a new block.
255-
} else {
256-
if (CurrentEndLine) {
257-
Fixes.push_back(FixItHint::CreateReplacement(
258-
CharSourceRange::getCharRange(CurrentRange), CurrentText));
259-
}
260-
261-
CurrentEndLine = LineEdit.first;
262-
CurrentRange = LineEdit.second.first;
263-
CurrentText = LineEdit.second.second;
264-
}
265-
}
266-
// Finally, report the current block edit if there is one.
267-
if (CurrentEndLine) {
268-
Fixes.push_back(FixItHint::CreateReplacement(
269-
CharSourceRange::getCharRange(CurrentRange), CurrentText));
270-
}
271-
272-
// Reset the remaining internal state.
273-
SourceLocations.clear();
274-
IncludeLocations.clear();
275-
return Fixes;
276-
}
277-
278177
llvm::ArrayRef<std::pair<StringRef, IncludeSorter::IncludeStyle>>
279178
IncludeSorter::getMapping() {
280179
static constexpr std::pair<StringRef, IncludeSorter::IncludeStyle> Mapping[] =

clang-tools-extra/clang-tidy/utils/IncludeSorter.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,13 @@ class IncludeSorter {
3838

3939
/// ``IncludeSorter`` constructor; takes the FileID and name of the file to be
4040
/// processed by the sorter.
41-
IncludeSorter(const SourceManager *SourceMgr, const LangOptions *LangOpts,
42-
const FileID FileID, StringRef FileName, IncludeStyle Style);
43-
44-
/// Returns the ``SourceManager``-specific file ID for the file being handled
45-
/// by the sorter.
46-
const FileID current_FileID() const { return CurrentFileID; }
41+
IncludeSorter(const SourceManager *SourceMgr, const FileID FileID,
42+
StringRef FileName, IncludeStyle Style);
4743

4844
/// Adds the given include directive to the sorter.
4945
void AddInclude(StringRef FileName, bool IsAngled,
5046
SourceLocation HashLocation, SourceLocation EndLocation);
5147

52-
/// Returns the edits needed to sort the current set of includes and reset the
53-
/// internal state (so that different blocks of includes are sorted separately
54-
/// within the same file).
55-
std::vector<FixItHint> GetEdits();
56-
5748
/// Creates a quoted inclusion directive in the right sort order. Returns None
5849
/// on error or if header inclusion directive for header already exists.
5950
Optional<FixItHint> CreateIncludeInsertion(StringRef FileName, bool IsAngled);
@@ -62,7 +53,6 @@ class IncludeSorter {
6253
typedef SmallVector<SourceRange, 1> SourceRangeVector;
6354

6455
const SourceManager *SourceMgr;
65-
const LangOptions *LangOpts;
6656
const IncludeStyle Style;
6757
FileID CurrentFileID;
6858
/// The file name stripped of common suffixes.

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ class NameLookup {
195195
NameLookup() : NameLookup(nullptr) {}
196196

197197
bool hasMultipleResolutions() const { return Data.getInt(); }
198-
bool hasDecl() const {
199-
assert(!hasMultipleResolutions() && "Found multiple decls");
200-
return Data.getPointer() != nullptr;
201-
}
202198
const NamedDecl *getDecl() const {
203199
assert(!hasMultipleResolutions() && "Found multiple decls");
204200
return Data.getPointer();

0 commit comments

Comments
 (0)