forked from OSchip/llvm-project
Remove old create(MainFile)?IncludeInsertion overloads
Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D89117
This commit is contained in:
parent
556316cf72
commit
fe4715c47f
|
@ -67,8 +67,10 @@ IncludeSorter &IncludeInserter::getOrCreate(FileID FileID) {
|
|||
}
|
||||
|
||||
llvm::Optional<FixItHint>
|
||||
IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header,
|
||||
bool IsAngled) {
|
||||
IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
|
||||
bool IsAngled = Header.consume_front("<");
|
||||
if (IsAngled != Header.consume_back(">"))
|
||||
return llvm::None;
|
||||
// We assume the same Header will never be included both angled and not
|
||||
// angled.
|
||||
if (!InsertedHeaders[FileID].insert(Header).second)
|
||||
|
@ -77,22 +79,6 @@ IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header,
|
|||
return getOrCreate(FileID).CreateIncludeInsertion(Header, IsAngled);
|
||||
}
|
||||
|
||||
llvm::Optional<FixItHint>
|
||||
IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
|
||||
bool IsAngled = Header.consume_front("<");
|
||||
if (IsAngled != Header.consume_back(">"))
|
||||
return llvm::None;
|
||||
return createIncludeInsertion(FileID, Header, IsAngled);
|
||||
}
|
||||
|
||||
llvm::Optional<FixItHint>
|
||||
IncludeInserter::createMainFileIncludeInsertion(StringRef Header,
|
||||
bool IsAngled) {
|
||||
assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "
|
||||
"registerPreprocessor()?");
|
||||
return createIncludeInsertion(SourceMgr->getMainFileID(), Header, IsAngled);
|
||||
}
|
||||
|
||||
llvm::Optional<FixItHint>
|
||||
IncludeInserter::createMainFileIncludeInsertion(StringRef Header) {
|
||||
assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "
|
||||
|
|
|
@ -66,14 +66,6 @@ public:
|
|||
/// class is used.
|
||||
void registerPreprocessor(Preprocessor *PP);
|
||||
|
||||
/// Creates a \p Header inclusion directive fixit in the File \p FileID.
|
||||
/// Returns ``llvm::None`` on error or if the inclusion directive already
|
||||
/// exists.
|
||||
/// FIXME: This should be removed once the clients are migrated to the
|
||||
/// overload without the ``IsAngled`` parameter.
|
||||
llvm::Optional<FixItHint>
|
||||
createIncludeInsertion(FileID FileID, llvm::StringRef Header, bool IsAngled);
|
||||
|
||||
/// Creates a \p Header inclusion directive fixit in the File \p FileID.
|
||||
/// When \p Header is enclosed in angle brackets, uses angle brackets in the
|
||||
/// inclusion directive, otherwise uses quotes.
|
||||
|
@ -82,18 +74,10 @@ public:
|
|||
llvm::Optional<FixItHint> createIncludeInsertion(FileID FileID,
|
||||
llvm::StringRef Header);
|
||||
|
||||
/// Creates a \p Header inclusion directive fixit in the main file.
|
||||
/// Returns``llvm::None`` on error or if the inclusion directive already
|
||||
/// exists.
|
||||
/// FIXME: This should be removed once the clients are migrated to the
|
||||
/// overload without the ``IsAngled`` parameter.
|
||||
llvm::Optional<FixItHint>
|
||||
createMainFileIncludeInsertion(llvm::StringRef Header, bool IsAngled);
|
||||
|
||||
/// Creates a \p Header inclusion directive fixit in the main file.
|
||||
/// When \p Header is enclosed in angle brackets, uses angle brackets in the
|
||||
/// inclusion directive, otherwise uses quotes.
|
||||
/// Returns``llvm::None`` on error or if the inclusion directive already
|
||||
/// Returns ``llvm::None`` on error or if the inclusion directive already
|
||||
/// exists.
|
||||
llvm::Optional<FixItHint>
|
||||
createMainFileIncludeInsertion(llvm::StringRef Header);
|
||||
|
|
|
@ -95,15 +95,10 @@ void TransformerClangTidyCheck::check(
|
|||
case transformer::EditKind::Range:
|
||||
Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
|
||||
break;
|
||||
case transformer::EditKind::AddInclude: {
|
||||
StringRef FileName = T.Replacement;
|
||||
bool IsAngled = FileName.startswith("<") && FileName.endswith(">");
|
||||
Diag << Inserter.createMainFileIncludeInsertion(
|
||||
IsAngled ? FileName.substr(1, FileName.size() - 2) : FileName,
|
||||
IsAngled);
|
||||
case transformer::EditKind::AddInclude:
|
||||
Diag << Inserter.createMainFileIncludeInsertion(T.Replacement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TransformerClangTidyCheck::storeOptions(
|
||||
|
|
Loading…
Reference in New Issue