Changeset View
Changeset View
Standalone View
Standalone View
clang/include/clang/Lex/HeaderSearch.h
Show All 14 Lines | |||||
#include "clang/Basic/SourceLocation.h" | #include "clang/Basic/SourceLocation.h" | ||||
#include "clang/Basic/SourceManager.h" | #include "clang/Basic/SourceManager.h" | ||||
#include "clang/Lex/DirectoryLookup.h" | #include "clang/Lex/DirectoryLookup.h" | ||||
#include "clang/Lex/HeaderMap.h" | #include "clang/Lex/HeaderMap.h" | ||||
#include "clang/Lex/ModuleMap.h" | #include "clang/Lex/ModuleMap.h" | ||||
#include "llvm/ADT/ArrayRef.h" | #include "llvm/ADT/ArrayRef.h" | ||||
#include "llvm/ADT/DenseMap.h" | #include "llvm/ADT/DenseMap.h" | ||||
#include "llvm/ADT/SetVector.h" | |||||
#include "llvm/ADT/SmallSet.h" | |||||
#include "llvm/ADT/SmallString.h" | |||||
#include "llvm/ADT/StringMap.h" | #include "llvm/ADT/StringMap.h" | ||||
#include "llvm/ADT/StringSet.h" | |||||
#include "llvm/ADT/StringRef.h" | #include "llvm/ADT/StringRef.h" | ||||
#include "llvm/ADT/StringSet.h" | |||||
#include "llvm/Support/Allocator.h" | #include "llvm/Support/Allocator.h" | ||||
#include <cassert> | #include <cassert> | ||||
#include <cstddef> | #include <cstddef> | ||||
#include <memory> | #include <memory> | ||||
#include <string> | #include <string> | ||||
#include <utility> | #include <utility> | ||||
#include <vector> | #include <vector> | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | struct HeaderFileInfo { | ||||
/// getControllingMacro() is able to load a controlling macro from | /// getControllingMacro() is able to load a controlling macro from | ||||
/// external storage. | /// external storage. | ||||
const IdentifierInfo *ControllingMacro = nullptr; | const IdentifierInfo *ControllingMacro = nullptr; | ||||
/// If this header came from a framework include, this is the name | /// If this header came from a framework include, this is the name | ||||
/// of the framework. | /// of the framework. | ||||
StringRef Framework; | StringRef Framework; | ||||
/// List of aliases that this header is known as. | |||||
/// Most headers should only have at most one alias, but a handful | |||||
/// have two. | |||||
llvm::SetVector<llvm::SmallString<32>, | |||||
llvm::SmallVector<llvm::SmallString<32>, 2>, | |||||
llvm::SmallSet<llvm::SmallString<32>, 2>> | |||||
Aliases; | |||||
rsmith: This is a very heavyweight thing to include in `HeaderFileInfo` -- it looks like this member… | |||||
Good idea. I'll follow up with a patch some time this week. cjdb: Good idea. I'll follow up with a patch some time this week. | |||||
HeaderFileInfo() | HeaderFileInfo() | ||||
: isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), | : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), | ||||
External(false), isModuleHeader(false), isCompilingModuleHeader(false), | External(false), isModuleHeader(false), isCompilingModuleHeader(false), | ||||
Resolved(false), IndexHeaderMapHeader(false), IsValid(false) {} | Resolved(false), IndexHeaderMapHeader(false), IsValid(false) {} | ||||
/// Retrieve the controlling macro for this header file, if | /// Retrieve the controlling macro for this header file, if | ||||
/// any. | /// any. | ||||
const IdentifierInfo * | const IdentifierInfo * | ||||
▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
/// Mark the specified file as a system header, e.g. due to | /// Mark the specified file as a system header, e.g. due to | ||||
/// \#pragma GCC system_header. | /// \#pragma GCC system_header. | ||||
void MarkFileSystemHeader(const FileEntry *File) { | void MarkFileSystemHeader(const FileEntry *File) { | ||||
getFileInfo(File).DirInfo = SrcMgr::C_System; | getFileInfo(File).DirInfo = SrcMgr::C_System; | ||||
} | } | ||||
void AddFileAlias(const FileEntry *File, StringRef Alias) { | |||||
getFileInfo(File).Aliases.insert(Alias); | |||||
} | |||||
Is the logic here is just "if it's not already here add it?" If so, I think maybe you should just make Aliases a set (either a StringSet or SmallSet). Do you care about order? zoecarver: Is the logic here is just "if it's not already here add it?" If so, I think maybe you should… | |||||
Yes. I was going to use StringSet, but need operator[] for diagnostics. SetVector was my next choice, but it was giving me some serious complaints about a DeepMap or something. I guess I could copy the StringSet's contents into a SmallVector at the diagnostic site, but I really don't expect headers to have more than two aliases? cjdb: Yes. I was going to use `StringSet`, but need `operator[]` for diagnostics. `SetVector` was my… | |||||
/// Mark the specified file as part of a module. | /// Mark the specified file as part of a module. | ||||
void MarkFileModuleHeader(const FileEntry *FE, | void MarkFileModuleHeader(const FileEntry *FE, | ||||
ModuleMap::ModuleHeaderRole Role, | ModuleMap::ModuleHeaderRole Role, | ||||
bool isCompilingModuleHeader); | bool isCompilingModuleHeader); | ||||
/// Increment the count for the number of times the specified | /// Increment the count for the number of times the specified | ||||
/// FileEntry has been entered. | /// FileEntry has been entered. | ||||
void IncrementIncludeCount(const FileEntry *File) { | void IncrementIncludeCount(const FileEntry *File) { | ||||
▲ Show 20 Lines • Show All 366 Lines • Show Last 20 Lines |
This is a very heavyweight thing to include in HeaderFileInfo -- it looks like this member will add a couple of hundred bytes to the struct. Please consider a more efficient way of storing these, such as storing a map from header to aliases in HeaderSearch and only including a single bit here to say if there are any aliases for a header (so we can avoid checking the map in the common case).