Optimization: check against previous file name and use its FileEntry.

This commit is contained in:
Axel Naumann 2014-10-02 14:20:51 +02:00 committed by sftnight
parent f03fa76597
commit 6d7401e81f

View File

@ -60,6 +60,8 @@ namespace cling {
bool m_IsStoringState;
AutoloadCallback::FwdDeclsMap* m_Map;
clang::Preprocessor* m_PP;
clang::FileEntry* m_PrevFE;
std::string m_PrevFileName;
private:
void InsertIntoAutoloadingState (Decl* decl, llvm::StringRef annotation) {
@ -76,24 +78,25 @@ namespace cling {
bool isAngled = false;
const DirectoryLookup* LookupFrom = 0;
const DirectoryLookup* CurDir = 0;
FE = m_PP->LookupFile(fileNameLoc,
annotation.drop_front(lenAnnoTag), isAngled,
LookupFrom, CurDir, /*SearchPath*/0,
/*RelativePath*/ 0, /*suggestedModule*/0,
/*SkipCache*/false, /*OpenFile*/ false,
/*CacheFail*/ false);
if (m_PrevFE && m_PrevFileName == annotation.drop_front(lenAnnoTag))
FE = m_PrevFE;
else
FE = m_PP->LookupFile(fileNameLoc,
annotation.drop_front(lenAnnoTag), isAngled,
LookupFrom, CurDir, /*SearchPath*/0,
/*RelativePath*/ 0, /*suggestedModule*/0,
/*SkipCache*/false, /*OpenFile*/ false,
/*CacheFail*/ false);
assert(FE && "Must have a valid FileEntry");
if (m_Map->find(FE) == m_Map->end())
(*m_Map)[FE] = std::vector<Decl*>();
(*m_Map)[FE].push_back(decl);
auto& Vec = (*m_Map)[FE];
Vec.push_back(decl);
}
public:
AutoloadingVisitor() : m_IsStoringState(false), m_Map(0) {}
AutoloadingVisitor():
m_IsStoringState(false), m_Map(0), m_PP(0), m_PrevFE(0) {}
void RemoveDefaultArgsOf(Decl* D) {
//D = D->getMostRecentDecl();
TraverseDecl(D);