28#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H
29#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H
32#include "clang/Basic/TokenKinds.h"
68 clang::tok::PPKeywordKind
Kind = clang::tok::pp_not_keyword;
79 std::vector<std::pair<Directive, DirectiveTree>>
Branches;
90 using Chunk = std::variant<Code, Directive, Conditional>;
A complete sequence of Tokens representing a source file.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
void chooseConditionalBranches(DirectiveTree &Tree, const TokenStream &Code)
Selects a "taken" branch for each conditional directive in the file.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
A range of code (and possibly comments) containing no directives.
A preprocessor conditional section.
Directive End
The directive terminating the conditional, should be #endif.
std::vector< std::pair< Directive, DirectiveTree > > Branches
The sequence of directives that introduce top-level alternative parses.
std::optional< unsigned > Taken
The index of the conditional branch we chose as active.
A preprocessor directive.
clang::tok::PPKeywordKind Kind
Token::Range Tokens
Raw tokens making up the directive, starting with #.
Describes the structure of a source file, as seen by the preprocessor.
TokenStream stripDirectives(const TokenStream &) const
Produce a parseable token stream by stripping all directive tokens.
std::vector< Chunk > Chunks
static DirectiveTree parse(const TokenStream &)
Extract preprocessor structure by examining the raw tokens.
std::variant< Code, Directive, Conditional > Chunk
Some piece of the file. {One of Code, Directive, Conditional}.
A half-open range of tokens within a stream.