38#ifndef CLANG_LIB_FORMAT_MACROS_H
39#define CLANG_LIB_FORMAT_MACROS_H
44#include "llvm/ADT/DenseMap.h"
50struct UnwrappedLineNode;
99 llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
104 bool defined(StringRef Name)
const;
111 bool hasArity(StringRef Name,
unsigned Arity)
const;
125 void parseDefinition(
const std::string &Macro);
129 llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator;
132 llvm::StringMap<llvm::DenseMap<int, Definition>> FunctionLike;
133 llvm::StringMap<Definition> ObjectLike;
180 const llvm::DenseMap<
FormatToken *, std::unique_ptr<UnwrappedLine>>
196 bool finished()
const {
return ActiveExpansions.empty(); }
230 void prepareParent(
FormatToken *ExpandedParent,
bool First,
unsigned Level);
236 bool processNextReconstructed();
239 struct ReconstructedLine;
243 void debug(
const ReconstructedLine &
Line,
int Level);
244 ReconstructedLine &parentLine();
245 ReconstructedLine *currentLine();
246 void debugParentMap()
const;
249 enum ReconstructorState {
254 ReconstructorState State = Start;
260 LineNode() =
default;
261 LineNode(FormatToken *Tok) : Tok(Tok) {}
262 FormatToken *Tok =
nullptr;
263 SmallVector<std::unique_ptr<ReconstructedLine>> Children;
269 struct ReconstructedLine {
270 explicit ReconstructedLine(
unsigned Level) :
Level(
Level) {}
272 SmallVector<std::unique_ptr<LineNode>> Tokens;
284 ReconstructedLine Result;
288 SmallVector<ReconstructedLine *> ActiveReconstructedLines;
313 llvm::DenseMap<FormatToken *, FormatToken *>
314 SpelledParentToReconstructedParent;
322 std::list<UnwrappedLineNode>::iterator SpelledI;
324 std::list<UnwrappedLineNode>::iterator SpelledE;
328 SmallVector<Expansion> ActiveExpansions;
330 struct MacroCallState {
331 MacroCallState(ReconstructedLine *Line, FormatToken *ParentLastToken,
332 FormatToken *MacroCallLParen);
334 ReconstructedLine *Line;
352 FormatToken *ParentLastToken;
355 FormatToken *MacroCallLParen;
371 SmallVector<MacroCallState> MacroCallStructure;
375 const llvm::DenseMap<FormatToken *, std::unique_ptr<UnwrappedLine>>
Implements an efficient mapping from strings to IdentifierInfo nodes.
This class handles loading and caching of source files into memory.
Token - This structure provides full information about a lexed token.
The JSON file list parser is used to communicate input to InstallAPI.