2010-01-04 22:18:44 +03:00
|
|
|
//===- ExternalPreprocessorSource.h - Abstract Macro Interface --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the ExternalPreprocessorSource interface, which enables
|
|
|
|
// construction of macro definitions from some external source.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CLANG_LEX_EXTERNAL_PREPROCESSOR_SOURCE_H
|
|
|
|
#define LLVM_CLANG_LEX_EXTERNAL_PREPROCESSOR_SOURCE_H
|
|
|
|
|
|
|
|
namespace clang {
|
2013-01-12 20:54:37 +04:00
|
|
|
|
|
|
|
class IdentifierInfo;
|
|
|
|
|
2010-01-04 22:18:44 +03:00
|
|
|
/// \brief Abstract interface for external sources of preprocessor
|
|
|
|
/// information.
|
|
|
|
///
|
2010-08-19 03:56:43 +04:00
|
|
|
/// This abstract class allows an external sources (such as the \c ASTReader)
|
2010-01-04 22:18:44 +03:00
|
|
|
/// to provide additional macro definitions.
|
|
|
|
class ExternalPreprocessorSource {
|
|
|
|
public:
|
|
|
|
virtual ~ExternalPreprocessorSource();
|
|
|
|
|
|
|
|
/// \brief Read the set of macros defined by this external macro source.
|
|
|
|
virtual void ReadDefinedMacros() = 0;
|
2010-10-30 04:23:06 +04:00
|
|
|
|
Make the loading of information attached to an IdentifierInfo from an
AST file more lazy, so that we don't eagerly load that information for
all known identifiers each time a new AST file is loaded. The eager
reloading made some sense in the context of precompiled headers, since
very few identifiers were defined before PCH load time. With modules,
however, a huge amount of code can get parsed before we see an
@import, so laziness becomes important here.
The approach taken to make this information lazy is fairly simple:
when we load a new AST file, we mark all of the existing identifiers
as being out-of-date. Whenever we want to access information that may
come from an AST (e.g., whether the identifier has a macro definition,
or what top-level declarations have that name), we check the
out-of-date bit and, if it's set, ask the AST reader to update the
IdentifierInfo from the AST files. The update is a merge, and we now
take care to merge declarations before/after imports with declarations
from multiple imports.
The results of this optimization are fairly dramatic. On a small
application that brings in 14 non-trivial modules, this takes modules
from being > 3x slower than a "perfect" PCH file down to 30% slower
for a full rebuild. A partial rebuild (where the PCH file or modules
can be re-used) is down to 7% slower. Making the PCH file just a
little imperfect (e.g., adding two smallish modules used by a bunch of
.m files that aren't in the PCH file) tips the scales in favor of the
modules approach, with 24% faster partial rebuilds.
This is just a first step; the lazy scheme could possibly be improved
by adding versioning, so we don't search into modules we already
searched. Moreover, we'll need similar lazy schemes for all of the
other lookup data structures, such as DeclContexts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143100 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-27 13:33:13 +04:00
|
|
|
/// \brief Update an out-of-date identifier.
|
|
|
|
virtual void updateOutOfDateIdentifier(IdentifierInfo &II) = 0;
|
2010-01-04 22:18:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-01-05 01:04:01 +03:00
|
|
|
#endif // LLVM_CLANG_LEX_EXTERNAL_PREPROCESSOR_SOURCE_H
|