Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.3
llvm
pr14795.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pr14795.patch of Package llvm
From 6be9a72888dd0ed22f53c5d46773aa188c0873c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lunak@suse.cz> Date: Fri, 4 Jan 2013 21:10:49 +0100 Subject: [PATCH] fix line info in -frewrite-includes after skipped #if block --- lib/Rewrite/Frontend/InclusionRewriter.cpp | 20 +++++++++++++++++++- test/Frontend/rewrite-includes.c | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp index 9d1bec9..91dabcc 100644 --- tools/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp +++ tools/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp @@ -275,14 +275,21 @@ bool InclusionRewriter::Process(FileID FileId, // TODO: Consider adding a switch that strips possibly unimportant content, // such as comments, to reduce the size of repro files. + bool NeedLineInfo = false; while (RawToken.isNot(tok::eof)) { + if (RawToken.isAtStartOfLine() && NeedLineInfo) { + OutputContentUpTo(FromFile, NextToWrite, + SM.getFileOffset(RawToken.getLocation()), EOL, Line); + WriteLineInfo(FileName, Line, FileType, EOL); + NeedLineInfo = false; + } if (RawToken.is(tok::hash) && RawToken.isAtStartOfLine()) { RawLex.setParsingPreprocessorDirective(true); Token HashToken = RawToken; RawLex.LexFromRawLexer(RawToken); if (RawToken.is(tok::raw_identifier)) PP.LookUpIdentifierInfo(RawToken); - if (RawToken.is(tok::identifier)) { + if (RawToken.getIdentifierInfo() != NULL) { switch (RawToken.getIdentifierInfo()->getPPKeywordID()) { case tok::pp_include: case tok::pp_include_next: @@ -323,6 +330,17 @@ bool InclusionRewriter::Process(FileID FileId, } break; } + case tok::pp_endif: + case tok::pp_elif: + case tok::pp_else: { + // We surround every #include by #if 0 to comment it out, but that + // changes line numbers. These are fixed up right after that, but + // the whole #include could be inside a preprocessor conditional + // that is not processed. So it is necessary to fix the line + // numbers one the next line after each #else/#endif as well. + NeedLineInfo = true; + break; + } default: break; } diff --git a/test/Frontend/rewrite-includes.c b/test/Frontend/rewrite-includes.c index 546a2c4..f2f929c 100644 --- tools/clang/test/Frontend/rewrite-includes.c +++ tools/clang/test/Frontend/rewrite-includes.c @@ -47,11 +47,13 @@ A(1,2) // CHECK-NEXT: {{^}}included_line3{{$}} // CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c" 2{{$}} // CHECK-NEXT: {{^}}#else{{$}} +// CHECK-NEXT: {{^}}# 11 "{{.*}}rewrite-includes.c"{{$}} // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} // CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}} // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} // CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}} // CHECK-NEXT: {{^}}#endif{{$}} +// CHECK-NEXT: {{^}}# 13 "{{.*}}rewrite-includes.c"{{$}} // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} // CHECK-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}} // CHECK-NEXT: {{^}} {{$}} -- 1.7.10.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor