================
@@ -73,15 +74,43 @@ class HeaderIncludes {
/// same category in the code that should be sorted after \p IncludeName. If
/// \p IncludeName already exists (with exactly the same spelling), this
/// returns std::nullopt.
- std::optional<tooling::Replacement> insert(llvm::StringRef Header,
- bool IsAngled,
+ std::optional<tooling::Replacement> insert(StringRef Header, bool IsAngled,
IncludeDirective Directive) const;
+ /// Represents a single header directive to be inserted in a batch operation.
+ ///
+ /// Usage:
+ /// - HeaderToInsert("<vector>") -> inserts #include <vector>
+ /// (auto-detects angled)
+ /// - HeaderToInsert("\"foo.h\"") -> inserts #include "foo.h"
+ /// (auto-detects quoted)
+ /// - HeaderToInsert("<foo>", IncludeDirective::Import) -> inserts #import
+ /// <foo>
+ /// - HeaderToInsert("foo.h", IncludeDirective::Include,
/*IsAngled=*/false)
+ /// -> explicit IsAngled
+ struct HeaderToInsert {
+ // The header name, with any surrounding quotes or brackets removed.
+ std::string Header;
+ // Whether to insert #include or #import.
+ IncludeDirective Directive;
+ // Whether to use <> or "" for the header. If not set, the default is
+ // determined by the header name.
+ bool IsAngled;
+
+ HeaderToInsert(StringRef RawOrSpelledHeader,
+ IncludeDirective Directive = IncludeDirective::Include,
+ std::optional<bool> IsAngled = std::nullopt);
----------------
dmaclach wrote:
Done
https://github.com/llvm/llvm-project/pull/212852
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits