clang-tools
11.0.0
clang-tools-extra
clangd
CollectMacros.cpp
Go to the documentation of this file.
1
//===--- CollectMacros.cpp ---------------------------------------*- C++-*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
CollectMacros.h
"
10
#include "clang/Basic/SourceLocation.h"
11
#include "clang/Lex/Lexer.h"
12
13
namespace
clang
{
14
namespace
clangd {
15
16
void
CollectMainFileMacros::add(
const
Token &MacroNameTok,
17
const
MacroInfo *MI) {
18
if
(!InMainFile)
19
return
;
20
auto
Loc
= MacroNameTok.getLocation();
21
if
(
Loc
.isInvalid() ||
Loc
.isMacroID())
22
return
;
23
24
auto
Name
= MacroNameTok.getIdentifierInfo()->getName();
25
Out.
Names
.insert(
Name
);
26
auto
Range
=
halfOpenToRange
(
27
SM, CharSourceRange::getCharRange(
Loc
, MacroNameTok.getEndLoc()));
28
if
(
auto
SID =
getSymbolID
(
Name
, MI, SM))
29
Out.
MacroRefs
[*SID].push_back(
Range
);
30
else
31
Out.
UnknownMacros
.push_back(
Range
);
32
}
33
}
// namespace clangd
34
}
// namespace clang
Range
CharSourceRange Range
SourceRange for the file name.
Definition:
IncludeOrderCheck.cpp:38
clang::clangd::MainFileMacros::MacroRefs
llvm::DenseMap< SymbolID, std::vector< Range > > MacroRefs
Definition:
CollectMacros.h:28
clang::clangd::MainFileMacros::Names
llvm::StringSet Names
Definition:
CollectMacros.h:25
clang::clangd::halfOpenToRange
Range halfOpenToRange(const SourceManager &SM, CharSourceRange R)
Definition:
SourceCode.cpp:471
CollectMacros.h
Name
static constexpr llvm::StringLiteral Name
Definition:
UppercaseLiteralSuffixCheck.cpp:27
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ApplyReplacements.h:27
clang::clangd::getSymbolID
llvm::Optional< SymbolID > getSymbolID(const Decl *D)
Gets the symbol ID for a declaration, if possible.
Definition:
AST.cpp:285
Loc
SourceLocation Loc
'#' location in the include directive
Definition:
IncludeOrderCheck.cpp:37
clang::clangd::MainFileMacros::UnknownMacros
std::vector< Range > UnknownMacros
Definition:
CollectMacros.h:32
Generated on Tue Jul 28 2020 16:14:01 for clang-tools by
1.8.16