003 File Manager
Current Path:
/usr/src/contrib/llvm-project/clang/lib/Lex
usr
/
src
/
contrib
/
llvm-project
/
clang
/
lib
/
Lex
/
📁
..
📄
DependencyDirectivesSourceMinimizer.cpp
(26.47 KB)
📄
HeaderMap.cpp
(8.71 KB)
📄
HeaderSearch.cpp
(67.87 KB)
📄
Lexer.cpp
(140.91 KB)
📄
LiteralSupport.cpp
(65.36 KB)
📄
MacroArgs.cpp
(11.38 KB)
📄
MacroInfo.cpp
(8.52 KB)
📄
ModuleMap.cpp
(97.57 KB)
📄
PPCaching.cpp
(5.62 KB)
📄
PPCallbacks.cpp
(1.16 KB)
📄
PPConditionalDirectiveRecord.cpp
(4.6 KB)
📄
PPDirectives.cpp
(121.49 KB)
📄
PPExpressions.cpp
(34.13 KB)
📄
PPLexerChange.cpp
(32.21 KB)
📄
PPMacroExpansion.cpp
(71.65 KB)
📄
Pragma.cpp
(64.85 KB)
📄
PreprocessingRecord.cpp
(18.37 KB)
📄
Preprocessor.cpp
(51.56 KB)
📄
PreprocessorLexer.cpp
(1.69 KB)
📄
ScratchBuffer.cpp
(3.26 KB)
📄
TokenConcatenation.cpp
(11.9 KB)
📄
TokenLexer.cpp
(43.47 KB)
📄
UnicodeCharSets.h
(12.83 KB)
Editing: PPConditionalDirectiveRecord.cpp
//===--- PPConditionalDirectiveRecord.h - Preprocessing Directives-*- C++ -*-=// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // 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 = llvm::lower_bound( CondDirectiveLocs, 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 = llvm::lower_bound( CondDirectiveLocs, 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); }
Upload File
Create Folder