You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
INPUTS
bindings
cmake
docs
examples
include
lib
ARCMigrate
AST
ASTMatchers
Analysis
Basic
CodeGen
CrossTU
Driver
Edit
Format
Frontend
FrontendTool
Headers
Index
Lex
CMakeLists.txt
HeaderMap.cpp
HeaderSearch.cpp
Lexer.cpp.REMOVED.git-id
LiteralSupport.cpp
MacroArgs.cpp
MacroInfo.cpp
ModuleMap.cpp
PPCaching.cpp
PPCallbacks.cpp
PPConditionalDirectiveRecord.cpp
PPDirectives.cpp.REMOVED.git-id
PPExpressions.cpp
PPLexerChange.cpp
PPMacroExpansion.cpp
PTHLexer.cpp
Pragma.cpp
PreprocessingRecord.cpp
Preprocessor.cpp
PreprocessorLexer.cpp
ScratchBuffer.cpp
TokenConcatenation.cpp
TokenLexer.cpp
UnicodeCharSets.h
Parse
Rewrite
Sema
Serialization
StaticAnalyzer
Tooling
CMakeLists.txt
runtime
tools
unittests
utils
www
.arcconfig
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
INSTALL.txt
LICENSE.TXT
ModuleInfo.txt
NOTES.txt
README.txt
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
123 lines
4.7 KiB
C++
123 lines
4.7 KiB
C++
![]() |
//===--- PPConditionalDirectiveRecord.h - Preprocessing Directives-*- C++ -*-=//
|
||
|
//
|
||
|
// The LLVM Compiler Infrastructure
|
||
|
//
|
||
|
// This file is distributed under the University of Illinois Open Source
|
||
|
// License. See LICENSE.TXT for details.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
//
|
||
|
// This file implements the PPConditionalDirectiveRecord class, which maintains
|
||
|
// a record of conditional directive regions.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
#include "clang/Lex/PPConditionalDirectiveRecord.h"
|
||
|
#include "llvm/Support/Capacity.h"
|
||
|
|
||
|
using namespace clang;
|
||
|
|
||
|
PPConditionalDirectiveRecord::PPConditionalDirectiveRecord(SourceManager &SM)
|
||
|
: SourceMgr(SM) {
|
||
|
CondDirectiveStack.push_back(SourceLocation());
|
||
|
}
|
||
|
|
||
|
bool PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(
|
||
|
SourceRange Range) const {
|
||
|
if (Range.isInvalid())
|
||
|
return false;
|
||
|
|
||
|
CondDirectiveLocsTy::const_iterator
|
||
|
low = std::lower_bound(CondDirectiveLocs.begin(), CondDirectiveLocs.end(),
|
||
|
Range.getBegin(), CondDirectiveLoc::Comp(SourceMgr));
|
||
|
if (low == CondDirectiveLocs.end())
|
||
|
return false;
|
||
|
|
||
|
if (SourceMgr.isBeforeInTranslationUnit(Range.getEnd(), low->getLoc()))
|
||
|
return false;
|
||
|
|
||
|
CondDirectiveLocsTy::const_iterator
|
||
|
upp = std::upper_bound(low, CondDirectiveLocs.end(),
|
||
|
Range.getEnd(), CondDirectiveLoc::Comp(SourceMgr));
|
||
|
SourceLocation uppRegion;
|
||
|
if (upp != CondDirectiveLocs.end())
|
||
|
uppRegion = upp->getRegionLoc();
|
||
|
|
||
|
return low->getRegionLoc() != uppRegion;
|
||
|
}
|
||
|
|
||
|
SourceLocation PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(
|
||
|
SourceLocation Loc) const {
|
||
|
if (Loc.isInvalid())
|
||
|
return SourceLocation();
|
||
|
if (CondDirectiveLocs.empty())
|
||
|
return SourceLocation();
|
||
|
|
||
|
if (SourceMgr.isBeforeInTranslationUnit(CondDirectiveLocs.back().getLoc(),
|
||
|
Loc))
|
||
|
return CondDirectiveStack.back();
|
||
|
|
||
|
CondDirectiveLocsTy::const_iterator
|
||
|
low = std::lower_bound(CondDirectiveLocs.begin(), CondDirectiveLocs.end(),
|
||
|
Loc, CondDirectiveLoc::Comp(SourceMgr));
|
||
|
assert(low != CondDirectiveLocs.end());
|
||
|
return low->getRegionLoc();
|
||
|
}
|
||
|
|
||
|
void PPConditionalDirectiveRecord::addCondDirectiveLoc(
|
||
|
CondDirectiveLoc DirLoc) {
|
||
|
// Ignore directives in system headers.
|
||
|
if (SourceMgr.isInSystemHeader(DirLoc.getLoc()))
|
||
|
return;
|
||
|
|
||
|
assert(CondDirectiveLocs.empty() ||
|
||
|
SourceMgr.isBeforeInTranslationUnit(CondDirectiveLocs.back().getLoc(),
|
||
|
DirLoc.getLoc()));
|
||
|
CondDirectiveLocs.push_back(DirLoc);
|
||
|
}
|
||
|
|
||
|
void PPConditionalDirectiveRecord::If(SourceLocation Loc,
|
||
|
SourceRange ConditionRange,
|
||
|
ConditionValueKind ConditionValue) {
|
||
|
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
|
||
|
CondDirectiveStack.push_back(Loc);
|
||
|
}
|
||
|
|
||
|
void PPConditionalDirectiveRecord::Ifdef(SourceLocation Loc,
|
||
|
const Token &MacroNameTok,
|
||
|
const MacroDefinition &MD) {
|
||
|
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
|
||
|
CondDirectiveStack.push_back(Loc);
|
||
|
}
|
||
|
|
||
|
void PPConditionalDirectiveRecord::Ifndef(SourceLocation Loc,
|
||
|
const Token &MacroNameTok,
|
||
|
const MacroDefinition &MD) {
|
||
|
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
|
||
|
CondDirectiveStack.push_back(Loc);
|
||
|
}
|
||
|
|
||
|
void PPConditionalDirectiveRecord::Elif(SourceLocation Loc,
|
||
|
SourceRange ConditionRange,
|
||
|
ConditionValueKind ConditionValue,
|
||
|
SourceLocation IfLoc) {
|
||
|
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
|
||
|
CondDirectiveStack.back() = Loc;
|
||
|
}
|
||
|
|
||
|
void PPConditionalDirectiveRecord::Else(SourceLocation Loc,
|
||
|
SourceLocation IfLoc) {
|
||
|
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
|
||
|
CondDirectiveStack.back() = Loc;
|
||
|
}
|
||
|
|
||
|
void PPConditionalDirectiveRecord::Endif(SourceLocation Loc,
|
||
|
SourceLocation IfLoc) {
|
||
|
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
|
||
|
assert(!CondDirectiveStack.empty());
|
||
|
CondDirectiveStack.pop_back();
|
||
|
}
|
||
|
|
||
|
size_t PPConditionalDirectiveRecord::getTotalMemory() const {
|
||
|
return llvm::capacity_in_bytes(CondDirectiveLocs);
|
||
|
}
|