[clangd] Get rid of regexes in CanonicalIncludes
Summary: Replace them with suffix mappings. Reviewers: ioeric, kbobyrev Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51088 llvm-svn: 340410
This commit is contained in:
parent
7413e985ea
commit
22abe49fff
File diff suppressed because it is too large
Load Diff
|
@ -40,8 +40,10 @@ public:
|
||||||
/// Adds a string-to-string mapping from \p Path to \p CanonicalPath.
|
/// Adds a string-to-string mapping from \p Path to \p CanonicalPath.
|
||||||
void addMapping(llvm::StringRef Path, llvm::StringRef CanonicalPath);
|
void addMapping(llvm::StringRef Path, llvm::StringRef CanonicalPath);
|
||||||
|
|
||||||
/// Maps all files matching \p RE to \p CanonicalPath
|
/// Maps files with last path components matching \p Suffix to \p
|
||||||
void addRegexMapping(llvm::StringRef RE, llvm::StringRef CanonicalPath);
|
/// CanonicalPath.
|
||||||
|
void addPathSuffixMapping(llvm::StringRef Suffix,
|
||||||
|
llvm::StringRef CanonicalPath);
|
||||||
|
|
||||||
/// Sets the canonical include for any symbol with \p QualifiedName.
|
/// Sets the canonical include for any symbol with \p QualifiedName.
|
||||||
/// Symbol mappings take precedence over header mappings.
|
/// Symbol mappings take precedence over header mappings.
|
||||||
|
@ -55,17 +57,15 @@ public:
|
||||||
llvm::StringRef QualifiedName) const;
|
llvm::StringRef QualifiedName) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// A map from header patterns to header names. This needs to be mutable so
|
/// A map from full include path to a canonical path.
|
||||||
// that we can match again a Regex in a const function member.
|
llvm::StringMap<std::string> FullPathMapping;
|
||||||
// FIXME(ioeric): All the regexes we have so far are suffix matches. The
|
/// A map from a suffix (one or components of a path) to a canonical path.
|
||||||
// performance could be improved by allowing only suffix matches instead of
|
llvm::StringMap<std::string> SuffixHeaderMapping;
|
||||||
// arbitrary regexes.
|
/// Maximum number of path components stored in a key of SuffixHeaderMapping.
|
||||||
mutable std::vector<std::pair<llvm::Regex, std::string>>
|
/// Used to reduce the number of lookups into SuffixHeaderMapping.
|
||||||
RegexHeaderMappingTable;
|
int MaxSuffixComponents = 0;
|
||||||
// A map from fully qualified symbol names to header names.
|
/// A map from fully qualified symbol names to header names.
|
||||||
llvm::StringMap<std::string> SymbolMapping;
|
llvm::StringMap<std::string> SymbolMapping;
|
||||||
// Guards Regex matching as it's not thread-safe.
|
|
||||||
mutable std::mutex RegexMutex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns a CommentHandler that parses pragma comment on include files to
|
/// Returns a CommentHandler that parses pragma comment on include files to
|
||||||
|
|
Loading…
Reference in New Issue