diff --git a/llvm.changes b/llvm.changes index 5c206fd..c6dddeb 100644 --- a/llvm.changes +++ b/llvm.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Jan 8 15:16:56 UTC 2013 - llunak@suse.com + +- fix incorrect line numbers after -frewrite-includes (PR#14795) +- do not incorrectly warn about pragmas in -frewrite-includes + (PR#14831) + ------------------------------------------------------------------- Mon Dec 31 09:29:12 UTC 2012 - dmueller@suse.com diff --git a/llvm.spec b/llvm.spec index 4e98094..db97fda 100644 --- a/llvm.spec +++ b/llvm.spec @@ -1,7 +1,7 @@ # # spec file for package llvm # -# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -44,6 +44,8 @@ Patch6: arm_suse_support.diff Patch7: disable_neon_in_armv7.diff # PATCH-FIX-UPSTREAM python-ulimit.patch Upstream r169695 Patch8: python-ulimit.patch +Patch9: pr14795.patch +Patch10: pr14831.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf BuildRequires: automake @@ -142,6 +144,8 @@ This package contains vim plugins for LLVM like syntax highlighting. %patch7 -p0 %endif %patch8 -p1 +%patch9 -p0 +%patch10 -p0 # We hardcode i586 rm tools/clang/test/Driver/x86_features.c diff --git a/pr14795.patch b/pr14795.patch new file mode 100644 index 0000000..4b8d950 --- /dev/null +++ b/pr14795.patch @@ -0,0 +1,76 @@ +From 6be9a72888dd0ed22f53c5d46773aa188c0873c2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= +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 + diff --git a/pr14831.patch b/pr14831.patch new file mode 100644 index 0000000..de85d4a --- /dev/null +++ b/pr14831.patch @@ -0,0 +1,39 @@ +From 08c9add28c1a5b3c80b910d268a2f0a9f4d72995 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= +Date: Mon, 7 Jan 2013 12:37:28 +0100 +Subject: [PATCH] do not warn about "unknown" pragmas in -frewrite-includes + (pr#14831) + +--- + lib/Rewrite/Frontend/InclusionRewriter.cpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp +index 9d1bec9..dad15fa 100644 +--- tools/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp ++++ tools/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp +@@ -13,6 +13,7 @@ + //===----------------------------------------------------------------------===// + + #include "clang/Rewrite/Frontend/Rewriters.h" ++#include "clang/Lex/Pragma.h" + #include "clang/Lex/Preprocessor.h" + #include "clang/Basic/SourceManager.h" + #include "clang/Frontend/PreprocessorOutputOptions.h" +@@ -344,6 +345,13 @@ void clang::RewriteIncludesInInput(Preprocessor &PP, raw_ostream *OS, + InclusionRewriter *Rewrite = new InclusionRewriter(PP, *OS, + Opts.ShowLineMarkers); + PP.addPPCallbacks(Rewrite); ++ // Ignore all pragmas, otherwise there will be warnings about unknown pragmas ++ // (because there's nothing to handle them). ++ PP.AddPragmaHandler(new EmptyPragmaHandler()); ++ // Ignore also all pragma in all namespaces created ++ // in Preprocessor::RegisterBuiltinPragmas(). ++ PP.AddPragmaHandler("GCC",new EmptyPragmaHandler()); ++ PP.AddPragmaHandler("clang",new EmptyPragmaHandler()); + + // First let the preprocessor process the entire file and call callbacks. + // Callbacks will record which #include's were actually performed. +-- +1.7.10.4 +