@@ -23,44 +23,40 @@ namespace {
23
23
class DefaultIncludeSpeller : public IncludeSpeller {
24
24
public:
25
25
std::string operator ()(const Input &Input) const override {
26
- bool IsSystem = false ;
27
- std::string FinalSpelling = Input.HS .suggestPathToFileForDiagnostics (
28
- Input.H .physical (), Input.Main ->tryGetRealPathName (), &IsSystem);
29
- return IsSystem ? " <" + FinalSpelling + " >" : " \" " + FinalSpelling + " \" " ;
26
+ switch (Input.H .kind ()) {
27
+ case Header::Standard:
28
+ return Input.H .standard ().name ().str ();
29
+ case Header::Verbatim:
30
+ return Input.H .verbatim ().str ();
31
+ case Header::Physical:
32
+ bool IsSystem = false ;
33
+ std::string FinalSpelling = Input.HS .suggestPathToFileForDiagnostics (
34
+ Input.H .physical (), Input.Main ->tryGetRealPathName (), &IsSystem);
35
+ return IsSystem ? " <" + FinalSpelling + " >" : " \" " + FinalSpelling + " \" " ;
36
+ }
30
37
}
31
38
};
32
39
33
- std::string spellPhysicalHeader (const IncludeSpeller::Input &Input) {
34
- static auto Spellers = [] {
35
- llvm::SmallVector<std::unique_ptr<include_cleaner::IncludeSpeller>> Result;
40
+ } // namespace
41
+
42
+ std::string spellHeader (const IncludeSpeller::Input &Input) {
43
+ static auto *Spellers = [] {
44
+ auto *Result =
45
+ new llvm::SmallVector<std::unique_ptr<include_cleaner::IncludeSpeller>>;
36
46
for (const auto &Strategy :
37
47
include_cleaner::IncludeSpellingStrategy::entries ())
38
- Result. push_back (Strategy.instantiate ());
39
- Result. push_back (std::make_unique<DefaultIncludeSpeller>());
48
+ Result-> push_back (Strategy.instantiate ());
49
+ Result-> push_back (std::make_unique<DefaultIncludeSpeller>());
40
50
return Result;
41
51
}();
42
52
43
53
std::string Spelling;
44
- for (const auto &Speller : Spellers) {
54
+ for (const auto &Speller : * Spellers) {
45
55
Spelling = (*Speller)(Input);
46
56
if (!Spelling.empty ())
47
57
break ;
48
58
}
49
59
return Spelling;
50
60
}
51
- } // namespace
52
61
53
- std::string spellHeader (const IncludeSpeller::Input &Input) {
54
- const Header &H = Input.H ;
55
- switch (H.kind ()) {
56
- case Header::Standard:
57
- return H.standard ().name ().str ();
58
- case Header::Verbatim:
59
- return H.verbatim ().str ();
60
- case Header::Physical:
61
- // Spelling physical headers allows for various plug-in strategies.
62
- return spellPhysicalHeader (Input);
63
- }
64
- llvm_unreachable (" Unknown Header kind" );
65
- }
66
62
} // namespace clang::include_cleaner
0 commit comments