comparison clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 0572611fdcc8
children
comparison
equal deleted inserted replaced
220:42394fc6a535 221:79ff65ed7e25
844 .Case("include_next", pp_include_next) 844 .Case("include_next", pp_include_next)
845 .Case("if", pp_if) 845 .Case("if", pp_if)
846 .Case("ifdef", pp_ifdef) 846 .Case("ifdef", pp_ifdef)
847 .Case("ifndef", pp_ifndef) 847 .Case("ifndef", pp_ifndef)
848 .Case("elif", pp_elif) 848 .Case("elif", pp_elif)
849 .Case("elifdef", pp_elifdef)
850 .Case("elifndef", pp_elifndef)
849 .Case("else", pp_else) 851 .Case("else", pp_else)
850 .Case("endif", pp_endif) 852 .Case("endif", pp_endif)
851 .Case("pragma", pp_pragma_import) 853 .Case("pragma", pp_pragma_import)
852 .Default(pp_none); 854 .Default(pp_none);
853 if (Kind == pp_none) { 855 if (Kind == pp_none) {
902 bool clang::minimize_source_to_dependency_directives::computeSkippedRanges( 904 bool clang::minimize_source_to_dependency_directives::computeSkippedRanges(
903 ArrayRef<Token> Input, llvm::SmallVectorImpl<SkippedRange> &Range) { 905 ArrayRef<Token> Input, llvm::SmallVectorImpl<SkippedRange> &Range) {
904 struct Directive { 906 struct Directive {
905 enum DirectiveKind { 907 enum DirectiveKind {
906 If, // if/ifdef/ifndef 908 If, // if/ifdef/ifndef
907 Else // elif,else 909 Else // elif/elifdef/elifndef, else
908 }; 910 };
909 int Offset; 911 int Offset;
910 DirectiveKind Kind; 912 DirectiveKind Kind;
911 }; 913 };
912 llvm::SmallVector<Directive, 32> Offsets; 914 llvm::SmallVector<Directive, 32> Offsets;
917 case pp_ifndef: 919 case pp_ifndef:
918 Offsets.push_back({T.Offset, Directive::If}); 920 Offsets.push_back({T.Offset, Directive::If});
919 break; 921 break;
920 922
921 case pp_elif: 923 case pp_elif:
924 case pp_elifdef:
925 case pp_elifndef:
922 case pp_else: { 926 case pp_else: {
923 if (Offsets.empty()) 927 if (Offsets.empty())
924 return true; 928 return true;
925 int PreviousOffset = Offsets.back().Offset; 929 int PreviousOffset = Offsets.back().Offset;
926 Range.push_back({PreviousOffset, T.Offset - PreviousOffset}); 930 Range.push_back({PreviousOffset, T.Offset - PreviousOffset});