-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clangd] Allow specifying what headers are always included via "" or <> #67749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ | |
namespace clang { | ||
namespace clangd { | ||
|
||
using HeaderFilter = llvm::ArrayRef<std::function<bool(llvm::StringRef)>>; | ||
|
||
/// Returns true if \p Include is literal include like "path" or <path>. | ||
bool isLiteralInclude(llvm::StringRef Include); | ||
|
||
|
@@ -211,10 +213,12 @@ class IncludeInserter { | |
// include path of non-verbatim header will not be shortened. | ||
IncludeInserter(StringRef FileName, StringRef Code, | ||
const format::FormatStyle &Style, StringRef BuildDir, | ||
HeaderSearch *HeaderSearchInfo) | ||
HeaderSearch *HeaderSearchInfo, HeaderFilter QuotedHeaders, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're taking How confident are we that this is ok from a lifetime point of view, i.e. the Would it be better to copy the vector instead? Each element is a function which stores a shared_ptr to a vector of regexes, so we wouldn't be copying the regexes themselves. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how much difference that makes. The ArrayRef usage is based on other code I've seen around, and while the config lives for a while, the IncludeInserter is only briefly used to add an include. |
||
HeaderFilter AngledHeaders) | ||
: FileName(FileName), Code(Code), BuildDir(BuildDir), | ||
HeaderSearchInfo(HeaderSearchInfo), | ||
Inserter(FileName, Code, Style.IncludeStyle) {} | ||
Inserter(FileName, Code, Style.IncludeStyle), | ||
QuotedHeaders(QuotedHeaders), AngledHeaders(AngledHeaders) {} | ||
|
||
void addExisting(const Inclusion &Inc); | ||
|
||
|
@@ -258,6 +262,8 @@ class IncludeInserter { | |
HeaderSearch *HeaderSearchInfo = nullptr; | ||
llvm::StringSet<> IncludedHeaders; // Both written and resolved. | ||
tooling::HeaderIncludes Inserter; // Computers insertion replacement. | ||
HeaderFilter QuotedHeaders; | ||
HeaderFilter AngledHeaders; | ||
}; | ||
|
||
} // namespace clangd | ||
|
Uh oh!
There was an error while loading. Please reload this page.