clang 10.0.0git

Classes | Public Types | Public Member Functions | List of all members
clang::InMemoryModuleCache Class Reference

In-memory cache for modules. More...

`#include "clang/Serialization/InMemoryModuleCache.h"`

Inheritance diagram for clang::InMemoryModuleCache:
[legend]
Collaboration diagram for clang::InMemoryModuleCache:
[legend]

## Public Types
enum | State { Unknown, Tentative, ToBuild, Final }
| There are four states for a PCM. More...

## Public Member Functions
State | getPCMState (llvm::StringRef Filename) const
| Get the state of the PCM. More...
llvm::MemoryBuffer & | addPCM (llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer)
| Store the PCM under the Filename. More...
llvm::MemoryBuffer & | addBuiltPCM (llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer)
| Store a just-built PCM under the Filename. More...
bool | tryToDropPCM (llvm::StringRef Filename)
| Try to remove a buffer from the cache. More...
void | finalizePCM (llvm::StringRef Filename)
| Mark a PCM as final. More...
llvm::MemoryBuffer * | lookupPCM (llvm::StringRef Filename) const
| Get a pointer to the pCM if it exists; else nullptr. More...
bool | isPCMFinal (llvm::StringRef Filename) const
| Check whether the PCM is final and has been shown to work. More...
bool | shouldBuildPCM (llvm::StringRef Filename) const
| Check whether the PCM is waiting to be built. More...

## Detailed Description

In-memory cache for modules.

This is a cache for modules for use across a compilation, sharing state between the CompilerInstances in an implicit modules build. It must be shared by each CompilerInstance, ASTReader, ASTWriter, and ModuleManager that are coordinating.

Critically, it ensures that a single process has a consistent view of each PCM. This is used by CompilerInstance when building PCMs to ensure that each ModuleManager sees the same files.

Definition at line 30 of file InMemoryModuleCache.h.

## Member Enumeration Documentation

## ◆ State

enum clang::InMemoryModuleCache::State

There are four states for a PCM.

It must monotonically increase.

1. Unknown: the PCM has neither been read from disk nor built.
2. Tentative: the PCM has been read from disk but not yet imported or built. It might work.
3. ToBuild: the PCM read from disk did not work but a new one has not been built yet.
4. Final: indicating that the current PCM was either built in this process or has been successfully imported.

Enumerator
Unknown |
Tentative |
ToBuild |
Final |

Definition at line 57 of file InMemoryModuleCache.h.

## Member Function Documentation

## ◆ addBuiltPCM()

llvm::MemoryBuffer & InMemoryModuleCache::addBuiltPCM | ( | llvm::StringRef | Filename,
|  | std::unique_ptr< llvm::MemoryBuffer > | Buffer
| ) |  |

Store a just-built PCM under the Filename.

Precondition
  state is Unknown or ToBuild.
  state is not Tentative.

Returns
  a reference to the buffer as a convenience.

Definition at line 33 of file InMemoryModuleCache.cpp.

References Filename.

Referenced by clang::ASTWriter::WriteAST().

## ◆ addPCM()

llvm::MemoryBuffer & InMemoryModuleCache::addPCM | ( | llvm::StringRef | Filename,
|  | std::unique_ptr< llvm::MemoryBuffer > | Buffer
| ) |  |

Store the PCM under the Filename.

Precondition
  state is Unknown

Postcondition
  state is Tentative

Returns
  a reference to the buffer as a convenience.

Definition at line 25 of file InMemoryModuleCache.cpp.

## ◆ finalizePCM()

void InMemoryModuleCache::finalizePCM | ( | llvm::StringRef | Filename | ) |

Mark a PCM as final.

Precondition
  state is Tentative or Final.

Postcondition
  state is Final.

Definition at line 73 of file InMemoryModuleCache.cpp.

## ◆ getPCMState()

InMemoryModuleCache::State InMemoryModuleCache::getPCMState | ( | llvm::StringRef | Filename | ) | const

Get the state of the PCM.

Definition at line 15 of file InMemoryModuleCache.cpp.

References Final, Tentative, ToBuild, and Unknown.

Referenced by isPCMFinal(), and shouldBuildPCM().

## ◆ isPCMFinal()

bool InMemoryModuleCache::isPCMFinal | ( | llvm::StringRef | Filename | ) | const

Check whether the PCM is final and has been shown to work.

Returns
  true iff state is Final.

Definition at line 51 of file InMemoryModuleCache.cpp.

References Final, and getPCMState().

## ◆ lookupPCM()

llvm::MemoryBuffer * InMemoryModuleCache::lookupPCM | ( | llvm::StringRef | Filename | ) | const

Get a pointer to the pCM if it exists; else nullptr.

Definition at line 44 of file InMemoryModuleCache.cpp.

## ◆ shouldBuildPCM()

bool InMemoryModuleCache::shouldBuildPCM | ( | llvm::StringRef | Filename | ) | const

Check whether the PCM is waiting to be built.

Returns
  true iff state is ToBuild.

Definition at line 55 of file InMemoryModuleCache.cpp.

References getPCMState(), and ToBuild.

## ◆ tryToDropPCM()

bool InMemoryModuleCache::tryToDropPCM | ( | llvm::StringRef | Filename | ) |

Try to remove a buffer from the cache.

No effect if state is Final.

Precondition
  state is Tentative/Final.

Postcondition
  Tentative => ToBuild or Final => Final.

Returns
  false on success, i.e. if Tentative => ToBuild.

Definition at line 59 of file InMemoryModuleCache.cpp.

The documentation for this class was generated from the following files:

- include/clang/Serialization/InMemoryModuleCache.h
- lib/Serialization/InMemoryModuleCache.cpp