Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
sergesanspaille | 6b5d94a6bd | |
sergesanspaille | 358169aac7 | |
sergesanspaille | 4fdd308673 | |
sergesanspaille | 77598dc4d7 | |
sergesanspaille | 36f33bdfe5 | |
sergesanspaille | 0a9c3de7a9 | |
sergesanspaille | 580aaa14a1 | |
Tom Stellard | 6c49bf25f9 | |
Tom Stellard | 2e6c311e78 |
|
@ -0,0 +1,122 @@
|
|||
From b9d6dba608ab50d2e4a1b0f2318a5d1b390fc702 Mon Sep 17 00:00:00 2001
|
||||
From: Vedant Kumar <vsk@apple.com>
|
||||
Date: Tue, 18 Dec 2018 21:05:03 +0000
|
||||
Subject: [PATCH] [CodeGen] Handle mixed-width ops in mixed-sign
|
||||
mul-with-overflow lowering
|
||||
|
||||
The special lowering for __builtin_mul_overflow introduced in r320902
|
||||
fixed an ICE seen when passing mixed-sign operands to the builtin.
|
||||
|
||||
This patch extends the special lowering to cover mixed-width, mixed-sign
|
||||
operands. In a few common scenarios, calls to muloti4 will no longer be
|
||||
emitted.
|
||||
|
||||
This should address the latest comments in PR34920 and work around the
|
||||
link failure seen in:
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1657544
|
||||
|
||||
Testing:
|
||||
- check-clang
|
||||
- A/B output comparison with: https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D55843
|
||||
|
||||
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349542 91177308-0d34-0410-b5e6-96231b3b80d8
|
||||
---
|
||||
lib/CodeGen/CGBuiltin.cpp | 19 ++++++++++++++-----
|
||||
test/CodeGen/builtins-overflow.c | 21 +++++++++++++++++++++
|
||||
2 files changed, 35 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
|
||||
index 0770c20..4303a7a 100644
|
||||
--- a/lib/CodeGen/CGBuiltin.cpp
|
||||
+++ b/lib/CodeGen/CGBuiltin.cpp
|
||||
@@ -1077,7 +1077,7 @@ static bool isSpecialMixedSignMultiply(unsigned BuiltinID,
|
||||
WidthAndSignedness Op2Info,
|
||||
WidthAndSignedness ResultInfo) {
|
||||
return BuiltinID == Builtin::BI__builtin_mul_overflow &&
|
||||
- Op1Info.Width == Op2Info.Width && Op1Info.Width >= ResultInfo.Width &&
|
||||
+ std::max(Op1Info.Width, Op2Info.Width) >= ResultInfo.Width &&
|
||||
Op1Info.Signed != Op2Info.Signed;
|
||||
}
|
||||
|
||||
@@ -1098,11 +1098,20 @@ EmitCheckedMixedSignMultiply(CodeGenFunction &CGF, const clang::Expr *Op1,
|
||||
const clang::Expr *UnsignedOp = Op1Info.Signed ? Op2 : Op1;
|
||||
llvm::Value *Signed = CGF.EmitScalarExpr(SignedOp);
|
||||
llvm::Value *Unsigned = CGF.EmitScalarExpr(UnsignedOp);
|
||||
+ unsigned SignedOpWidth = Op1Info.Signed ? Op1Info.Width : Op2Info.Width;
|
||||
+ unsigned UnsignedOpWidth = Op1Info.Signed ? Op2Info.Width : Op1Info.Width;
|
||||
+
|
||||
+ // One of the operands may be smaller than the other. If so, [s|z]ext it.
|
||||
+ if (SignedOpWidth < UnsignedOpWidth)
|
||||
+ Signed = CGF.Builder.CreateSExt(Signed, Unsigned->getType(), "op.sext");
|
||||
+ if (UnsignedOpWidth < SignedOpWidth)
|
||||
+ Unsigned = CGF.Builder.CreateZExt(Unsigned, Signed->getType(), "op.zext");
|
||||
|
||||
llvm::Type *OpTy = Signed->getType();
|
||||
llvm::Value *Zero = llvm::Constant::getNullValue(OpTy);
|
||||
Address ResultPtr = CGF.EmitPointerWithAlignment(ResultArg);
|
||||
llvm::Type *ResTy = ResultPtr.getElementType();
|
||||
+ unsigned OpWidth = std::max(Op1Info.Width, Op2Info.Width);
|
||||
|
||||
// Take the absolute value of the signed operand.
|
||||
llvm::Value *IsNegative = CGF.Builder.CreateICmpSLT(Signed, Zero);
|
||||
@@ -1120,8 +1129,8 @@ EmitCheckedMixedSignMultiply(CodeGenFunction &CGF, const clang::Expr *Op1,
|
||||
if (ResultInfo.Signed) {
|
||||
// Signed overflow occurs if the result is greater than INT_MAX or lesser
|
||||
// than INT_MIN, i.e when |Result| > (INT_MAX + IsNegative).
|
||||
- auto IntMax = llvm::APInt::getSignedMaxValue(ResultInfo.Width)
|
||||
- .zextOrSelf(Op1Info.Width);
|
||||
+ auto IntMax =
|
||||
+ llvm::APInt::getSignedMaxValue(ResultInfo.Width).zextOrSelf(OpWidth);
|
||||
llvm::Value *MaxResult =
|
||||
CGF.Builder.CreateAdd(llvm::ConstantInt::get(OpTy, IntMax),
|
||||
CGF.Builder.CreateZExt(IsNegative, OpTy));
|
||||
@@ -1139,9 +1148,9 @@ EmitCheckedMixedSignMultiply(CodeGenFunction &CGF, const clang::Expr *Op1,
|
||||
llvm::Value *Underflow = CGF.Builder.CreateAnd(
|
||||
IsNegative, CGF.Builder.CreateIsNotNull(UnsignedResult));
|
||||
Overflow = CGF.Builder.CreateOr(UnsignedOverflow, Underflow);
|
||||
- if (ResultInfo.Width < Op1Info.Width) {
|
||||
+ if (ResultInfo.Width < OpWidth) {
|
||||
auto IntMax =
|
||||
- llvm::APInt::getMaxValue(ResultInfo.Width).zext(Op1Info.Width);
|
||||
+ llvm::APInt::getMaxValue(ResultInfo.Width).zext(OpWidth);
|
||||
llvm::Value *TruncOverflow = CGF.Builder.CreateICmpUGT(
|
||||
UnsignedResult, llvm::ConstantInt::get(OpTy, IntMax));
|
||||
Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
|
||||
diff --git a/test/CodeGen/builtins-overflow.c b/test/CodeGen/builtins-overflow.c
|
||||
index 57f90eb..79a3186 100644
|
||||
--- a/test/CodeGen/builtins-overflow.c
|
||||
+++ b/test/CodeGen/builtins-overflow.c
|
||||
@@ -339,6 +339,27 @@ long long test_smulll_overflow(long long x, long long y) {
|
||||
return result;
|
||||
}
|
||||
|
||||
+int test_mixed_sign_mul_overflow_sext_signed_op(int x, unsigned long long y) {
|
||||
+// CHECK: @test_mixed_sign_mul_overflow_sext_signed_op
|
||||
+// CHECK: [[SignedOp:%.*]] = sext i32 %0 to i64
|
||||
+// CHECK: [[IsNeg:%.*]] = icmp slt i64 [[SignedOp]], 0
|
||||
+ int result;
|
||||
+ if (__builtin_mul_overflow(x, y, &result))
|
||||
+ return LongErrorCode;
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+int test_mixed_sign_mul_overflow_zext_unsigned_op(long long x, unsigned y) {
|
||||
+// CHECK: @test_mixed_sign_mul_overflow_zext_unsigned_op
|
||||
+// CHECK: [[UnsignedOp:%.*]] = zext i32 %1 to i64
|
||||
+// CHECK: [[IsNeg:%.*]] = icmp slt i64 %0, 0
|
||||
+// CHECK: @llvm.umul.with.overflow.i64({{.*}}, i64 [[UnsignedOp]])
|
||||
+ int result;
|
||||
+ if (__builtin_mul_overflow(x, y, &result))
|
||||
+ return LongErrorCode;
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
int test_mixed_sign_mull_overflow(int x, unsigned y) {
|
||||
// CHECK: @test_mixed_sign_mull_overflow
|
||||
// CHECK: [[IsNeg:%.*]] = icmp slt i32 [[Op1:%.*]], 0
|
||||
--
|
||||
1.8.3.1
|
||||
|
|
@ -1,17 +1,7 @@
|
|||
From c760f8d703af0c67774681b5a259d5dd3a1e5a77 Mon Sep 17 00:00:00 2001
|
||||
From: Tom Stellard <tstellar@redhat.com>
|
||||
Date: Wed, 19 Sep 2018 08:53:10 -0700
|
||||
Subject: [PATCH] Convert scan-view to python3 using 2to3
|
||||
|
||||
---
|
||||
tools/scan-view/bin/scan-view | 24 ++++++++++++------------
|
||||
1 file changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/tools/scan-view/bin/scan-view b/tools/scan-view/bin/scan-view
|
||||
index 1b6e8ba..ca3dac5 100755
|
||||
--- a/tools/scan-view/bin/scan-view
|
||||
+++ b/tools/scan-view/bin/scan-view
|
||||
@@ -7,9 +7,9 @@ import sys
|
||||
diff -r -u cfe-7.0.1.src.orig/tools/scan-view/bin/scan-view cfe-7.0.1.src/tools/scan-view/bin/scan-view
|
||||
--- cfe-7.0.1.src.orig/tools/scan-view/bin/scan-view 2019-01-25 06:33:02.331385931 +0000
|
||||
+++ cfe-7.0.1.src/tools/scan-view/bin/scan-view 2019-01-25 06:34:16.207696772 +0000
|
||||
@@ -7,9 +7,9 @@
|
||||
import imp
|
||||
import os
|
||||
import posixpath
|
||||
|
@ -23,7 +13,7 @@ index 1b6e8ba..ca3dac5 100755
|
|||
import webbrowser
|
||||
|
||||
# How long to wait for server to start.
|
||||
@@ -27,7 +27,7 @@ kMaxPortsToTry = 100
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
def url_is_up(url):
|
||||
try:
|
||||
|
@ -32,7 +22,7 @@ index 1b6e8ba..ca3dac5 100755
|
|||
except IOError:
|
||||
return False
|
||||
o.close()
|
||||
@@ -35,7 +35,7 @@ def url_is_up(url):
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
|
||||
def start_browser(port, options):
|
||||
|
@ -41,7 +31,7 @@ index 1b6e8ba..ca3dac5 100755
|
|||
import webbrowser
|
||||
|
||||
url = 'http://%s:%d' % (options.host, port)
|
||||
@@ -52,10 +52,10 @@ def start_browser(port, options):
|
||||
@@ -52,10 +52,10 @@
|
||||
sys.stderr.flush()
|
||||
time.sleep(kSleepTimeout)
|
||||
else:
|
||||
|
@ -54,7 +44,7 @@ index 1b6e8ba..ca3dac5 100755
|
|||
webbrowser.open(url)
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ def run(port, options, root):
|
||||
@@ -69,9 +69,9 @@
|
||||
|
||||
import ScanView
|
||||
try:
|
||||
|
@ -67,7 +57,7 @@ index 1b6e8ba..ca3dac5 100755
|
|||
httpd = ScanView.create_server((options.host, port),
|
||||
options, root)
|
||||
httpd.serve_forever()
|
||||
@@ -80,9 +80,9 @@ def run(port, options, root):
|
||||
@@ -80,9 +80,9 @@
|
||||
|
||||
|
||||
def port_is_open(port):
|
||||
|
@ -79,7 +69,7 @@ index 1b6e8ba..ca3dac5 100755
|
|||
except:
|
||||
return False
|
||||
t.server_close()
|
||||
@@ -135,7 +135,7 @@ def main():
|
||||
@@ -135,7 +135,7 @@
|
||||
# Kick off thread to wait for server and start web browser, if
|
||||
# requested.
|
||||
if args.startBrowser:
|
||||
|
@ -88,6 +78,334 @@ index 1b6e8ba..ca3dac5 100755
|
|||
|
||||
run(port, args, args.root)
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
diff -r -u cfe-7.0.1.src.orig/tools/scan-view/share/Reporter.py cfe-7.0.1.src/tools/scan-view/share/Reporter.py
|
||||
--- cfe-7.0.1.src.orig/tools/scan-view/share/Reporter.py 2019-01-25 06:33:02.331385931 +0000
|
||||
+++ cfe-7.0.1.src/tools/scan-view/share/Reporter.py 2019-01-25 06:34:16.262697004 +0000
|
||||
@@ -80,7 +80,7 @@
|
||||
return 'Email'
|
||||
|
||||
def getParameters(self):
|
||||
- return map(lambda x:TextParameter(x),['To', 'From', 'SMTP Server', 'SMTP Port'])
|
||||
+ return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP Port']]
|
||||
|
||||
# Lifted from python email module examples.
|
||||
def attachFile(self, outer, path):
|
||||
@@ -148,7 +148,7 @@
|
||||
return 'Bugzilla'
|
||||
|
||||
def getParameters(self):
|
||||
- return map(lambda x:TextParameter(x),['URL','Product'])
|
||||
+ return [TextParameter(x) for x in ['URL','Product']]
|
||||
|
||||
def fileReport(self, report, parameters):
|
||||
raise NotImplementedError
|
||||
@@ -211,7 +211,7 @@
|
||||
|
||||
script = os.path.join(os.path.dirname(__file__),'../share/scan-view/FileRadar.scpt')
|
||||
args = ['osascript', script, component, componentVersion, classification, personID, report.title,
|
||||
- report.description, diagnosis, config] + map(os.path.abspath, report.files)
|
||||
+ report.description, diagnosis, config] + list(map(os.path.abspath, report.files))
|
||||
# print >>sys.stderr, args
|
||||
try:
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
diff -r -u cfe-7.0.1.src.orig/tools/scan-view/share/ScanView.py cfe-7.0.1.src/tools/scan-view/share/ScanView.py
|
||||
--- cfe-7.0.1.src.orig/tools/scan-view/share/ScanView.py 2019-01-25 06:33:02.331385931 +0000
|
||||
+++ cfe-7.0.1.src/tools/scan-view/share/ScanView.py 2019-01-25 06:34:16.423697681 +0000
|
||||
@@ -1,10 +1,10 @@
|
||||
-import BaseHTTPServer
|
||||
-import SimpleHTTPServer
|
||||
+import http.server
|
||||
+import http.server
|
||||
import os
|
||||
import sys
|
||||
-import urllib, urlparse
|
||||
+import urllib.request, urllib.parse, urllib.error, urllib.parse
|
||||
import posixpath
|
||||
-import StringIO
|
||||
+import io
|
||||
import re
|
||||
import shutil
|
||||
import threading
|
||||
@@ -13,7 +13,8 @@
|
||||
import itertools
|
||||
|
||||
import Reporter
|
||||
-import ConfigParser
|
||||
+import configparser
|
||||
+import importlib
|
||||
|
||||
###
|
||||
# Various patterns matched or replaced by server.
|
||||
@@ -96,25 +97,25 @@
|
||||
result = None
|
||||
try:
|
||||
if self.server.options.debug:
|
||||
- print >>sys.stderr, "%s: SERVER: submitting bug."%(sys.argv[0],)
|
||||
+ print("%s: SERVER: submitting bug."%(sys.argv[0],), file=sys.stderr)
|
||||
self.status = self.reporter.fileReport(self.report, self.parameters)
|
||||
self.success = True
|
||||
time.sleep(3)
|
||||
if self.server.options.debug:
|
||||
- print >>sys.stderr, "%s: SERVER: submission complete."%(sys.argv[0],)
|
||||
- except Reporter.ReportFailure,e:
|
||||
+ print("%s: SERVER: submission complete."%(sys.argv[0],), file=sys.stderr)
|
||||
+ except Reporter.ReportFailure as e:
|
||||
self.status = e.value
|
||||
- except Exception,e:
|
||||
- s = StringIO.StringIO()
|
||||
+ except Exception as e:
|
||||
+ s = io.StringIO()
|
||||
import traceback
|
||||
- print >>s,'<b>Unhandled Exception</b><br><pre>'
|
||||
+ print('<b>Unhandled Exception</b><br><pre>', file=s)
|
||||
traceback.print_exc(e,file=s)
|
||||
- print >>s,'</pre>'
|
||||
+ print('</pre>', file=s)
|
||||
self.status = s.getvalue()
|
||||
|
||||
-class ScanViewServer(BaseHTTPServer.HTTPServer):
|
||||
+class ScanViewServer(http.server.HTTPServer):
|
||||
def __init__(self, address, handler, root, reporters, options):
|
||||
- BaseHTTPServer.HTTPServer.__init__(self, address, handler)
|
||||
+ http.server.HTTPServer.__init__(self, address, handler)
|
||||
self.root = root
|
||||
self.reporters = reporters
|
||||
self.options = options
|
||||
@@ -123,7 +124,7 @@
|
||||
self.load_config()
|
||||
|
||||
def load_config(self):
|
||||
- self.config = ConfigParser.RawConfigParser()
|
||||
+ self.config = configparser.RawConfigParser()
|
||||
|
||||
# Add defaults
|
||||
self.config.add_section('ScanView')
|
||||
@@ -155,44 +156,44 @@
|
||||
def halt(self):
|
||||
self.halted = True
|
||||
if self.options.debug:
|
||||
- print >>sys.stderr, "%s: SERVER: halting." % (sys.argv[0],)
|
||||
+ print("%s: SERVER: halting." % (sys.argv[0],), file=sys.stderr)
|
||||
|
||||
def serve_forever(self):
|
||||
while not self.halted:
|
||||
if self.options.debug > 1:
|
||||
- print >>sys.stderr, "%s: SERVER: waiting..." % (sys.argv[0],)
|
||||
+ print("%s: SERVER: waiting..." % (sys.argv[0],), file=sys.stderr)
|
||||
try:
|
||||
self.handle_request()
|
||||
- except OSError,e:
|
||||
- print 'OSError',e.errno
|
||||
+ except OSError as e:
|
||||
+ print('OSError',e.errno)
|
||||
|
||||
def finish_request(self, request, client_address):
|
||||
if self.options.autoReload:
|
||||
import ScanView
|
||||
- self.RequestHandlerClass = reload(ScanView).ScanViewRequestHandler
|
||||
- BaseHTTPServer.HTTPServer.finish_request(self, request, client_address)
|
||||
+ self.RequestHandlerClass = importlib.reload(ScanView).ScanViewRequestHandler
|
||||
+ http.server.HTTPServer.finish_request(self, request, client_address)
|
||||
|
||||
def handle_error(self, request, client_address):
|
||||
# Ignore socket errors
|
||||
info = sys.exc_info()
|
||||
if info and isinstance(info[1], socket.error):
|
||||
if self.options.debug > 1:
|
||||
- print >>sys.stderr, "%s: SERVER: ignored socket error." % (sys.argv[0],)
|
||||
+ print("%s: SERVER: ignored socket error." % (sys.argv[0],), file=sys.stderr)
|
||||
return
|
||||
- BaseHTTPServer.HTTPServer.handle_error(self, request, client_address)
|
||||
+ http.server.HTTPServer.handle_error(self, request, client_address)
|
||||
|
||||
# Borrowed from Quixote, with simplifications.
|
||||
def parse_query(qs, fields=None):
|
||||
if fields is None:
|
||||
fields = {}
|
||||
- for chunk in filter(None, qs.split('&')):
|
||||
+ for chunk in [_f for _f in qs.split('&') if _f]:
|
||||
if '=' not in chunk:
|
||||
name = chunk
|
||||
value = ''
|
||||
else:
|
||||
name, value = chunk.split('=', 1)
|
||||
- name = urllib.unquote(name.replace('+', ' '))
|
||||
- value = urllib.unquote(value.replace('+', ' '))
|
||||
+ name = urllib.parse.unquote(name.replace('+', ' '))
|
||||
+ value = urllib.parse.unquote(value.replace('+', ' '))
|
||||
item = fields.get(name)
|
||||
if item is None:
|
||||
fields[name] = [value]
|
||||
@@ -200,20 +201,20 @@
|
||||
item.append(value)
|
||||
return fields
|
||||
|
||||
-class ScanViewRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
+class ScanViewRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
server_version = "ScanViewServer/" + __version__
|
||||
dynamic_mtime = time.time()
|
||||
|
||||
def do_HEAD(self):
|
||||
try:
|
||||
- SimpleHTTPServer.SimpleHTTPRequestHandler.do_HEAD(self)
|
||||
- except Exception,e:
|
||||
+ http.server.SimpleHTTPRequestHandler.do_HEAD(self)
|
||||
+ except Exception as e:
|
||||
self.handle_exception(e)
|
||||
|
||||
def do_GET(self):
|
||||
try:
|
||||
- SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
|
||||
- except Exception,e:
|
||||
+ http.server.SimpleHTTPRequestHandler.do_GET(self)
|
||||
+ except Exception as e:
|
||||
self.handle_exception(e)
|
||||
|
||||
def do_POST(self):
|
||||
@@ -230,7 +231,7 @@
|
||||
if f:
|
||||
self.copyfile(f, self.wfile)
|
||||
f.close()
|
||||
- except Exception,e:
|
||||
+ except Exception as e:
|
||||
self.handle_exception(e)
|
||||
|
||||
def log_message(self, format, *args):
|
||||
@@ -263,8 +264,8 @@
|
||||
|
||||
def handle_exception(self, exc):
|
||||
import traceback
|
||||
- s = StringIO.StringIO()
|
||||
- print >>s, "INTERNAL ERROR\n"
|
||||
+ s = io.StringIO()
|
||||
+ print("INTERNAL ERROR\n", file=s)
|
||||
traceback.print_exc(exc, s)
|
||||
f = self.send_string(s.getvalue(), 'text/plain')
|
||||
if f:
|
||||
@@ -410,8 +411,8 @@
|
||||
|
||||
import startfile
|
||||
if self.server.options.debug:
|
||||
- print >>sys.stderr, '%s: SERVER: opening "%s"'%(sys.argv[0],
|
||||
- file)
|
||||
+ print('%s: SERVER: opening "%s"'%(sys.argv[0],
|
||||
+ file), file=sys.stderr)
|
||||
|
||||
status = startfile.open(file)
|
||||
if status:
|
||||
@@ -428,7 +429,7 @@
|
||||
data = self.load_crashes()
|
||||
# Don't allow empty reports.
|
||||
if not data:
|
||||
- raise ValueError, 'No crashes detected!'
|
||||
+ raise ValueError('No crashes detected!')
|
||||
c = Context()
|
||||
c.title = 'clang static analyzer failures'
|
||||
|
||||
@@ -472,7 +473,7 @@
|
||||
# Check that this is a valid report.
|
||||
path = posixpath.join(self.server.root, 'report-%s.html' % report)
|
||||
if not posixpath.exists(path):
|
||||
- raise ValueError, 'Invalid report ID'
|
||||
+ raise ValueError('Invalid report ID')
|
||||
keys = self.load_report(report)
|
||||
c = Context()
|
||||
c.title = keys.get('DESC','clang error (unrecognized')
|
||||
@@ -501,7 +502,7 @@
|
||||
# report is None is used for crashes
|
||||
try:
|
||||
c = self.get_report_context(report)
|
||||
- except ValueError, e:
|
||||
+ except ValueError as e:
|
||||
return self.send_error(400, e.message)
|
||||
|
||||
title = c.title
|
||||
@@ -544,7 +545,7 @@
|
||||
"""%(r.getName(),display,r.getName(),options))
|
||||
reporterSelections = '\n'.join(reporterSelections)
|
||||
reporterOptionsDivs = '\n'.join(reporterOptions)
|
||||
- reportersArray = '[%s]'%(','.join([`r.getName()` for r in self.server.reporters]))
|
||||
+ reportersArray = '[%s]'%(','.join([repr(r.getName()) for r in self.server.reporters]))
|
||||
|
||||
if c.files:
|
||||
fieldSize = min(5, len(c.files))
|
||||
@@ -647,9 +648,9 @@
|
||||
fields = {}
|
||||
self.fields = fields
|
||||
|
||||
- o = urlparse.urlparse(self.path)
|
||||
+ o = urllib.parse.urlparse(self.path)
|
||||
self.fields = parse_query(o.query, fields)
|
||||
- path = posixpath.normpath(urllib.unquote(o.path))
|
||||
+ path = posixpath.normpath(urllib.parse.unquote(o.path))
|
||||
|
||||
# Split the components and strip the root prefix.
|
||||
components = path.split('/')[1:]
|
||||
@@ -690,8 +691,8 @@
|
||||
path = posixpath.join(self.server.root, relpath)
|
||||
|
||||
if self.server.options.debug > 1:
|
||||
- print >>sys.stderr, '%s: SERVER: sending path "%s"'%(sys.argv[0],
|
||||
- path)
|
||||
+ print('%s: SERVER: sending path "%s"'%(sys.argv[0],
|
||||
+ path), file=sys.stderr)
|
||||
return self.send_path(path)
|
||||
|
||||
def send_404(self):
|
||||
@@ -735,7 +736,7 @@
|
||||
mtime = self.dynamic_mtime
|
||||
self.send_header("Last-Modified", self.date_time_string(mtime))
|
||||
self.end_headers()
|
||||
- return StringIO.StringIO(s)
|
||||
+ return io.StringIO(s)
|
||||
|
||||
def send_patched_file(self, path, ctype):
|
||||
# Allow a very limited set of variables. This is pretty gross.
|
||||
diff -r -u cfe-7.0.1.src.orig/tools/scan-view/share/startfile.py cfe-7.0.1.src/tools/scan-view/share/startfile.py
|
||||
--- cfe-7.0.1.src.orig/tools/scan-view/share/startfile.py 2019-01-25 06:33:02.331385931 +0000
|
||||
+++ cfe-7.0.1.src/tools/scan-view/share/startfile.py 2019-01-25 06:34:16.457697824 +0000
|
||||
@@ -70,7 +70,7 @@
|
||||
return not returncode
|
||||
|
||||
def open(self, filename):
|
||||
- if isinstance(filename, basestring):
|
||||
+ if isinstance(filename, str):
|
||||
cmdline = self.args + [filename]
|
||||
else:
|
||||
# assume it is a sequence
|
||||
@@ -110,7 +110,7 @@
|
||||
# Platform support for Unix
|
||||
else:
|
||||
|
||||
- import commands
|
||||
+ import subprocess
|
||||
|
||||
# @WARNING: use the private API of the webbrowser module
|
||||
from webbrowser import _iscommand
|
||||
@@ -125,7 +125,7 @@
|
||||
def detect_kde_version(self):
|
||||
kde_version = None
|
||||
try:
|
||||
- info = commands.getoutput('kde-config --version')
|
||||
+ info = subprocess.getoutput('kde-config --version')
|
||||
|
||||
for line in info.splitlines():
|
||||
if line.startswith('KDE'):
|
||||
@@ -158,7 +158,7 @@
|
||||
desktop_environment = 'gnome'
|
||||
else:
|
||||
try:
|
||||
- info = commands.getoutput('xprop -root _DT_SAVE_MODE')
|
||||
+ info = subprocess.getoutput('xprop -root _DT_SAVE_MODE')
|
||||
if ' = "xfce4"' in info:
|
||||
desktop_environment = 'xfce'
|
||||
except (OSError, RuntimeError):
|
||||
@@ -189,7 +189,7 @@
|
||||
return _controllers[controller_name].open
|
||||
|
||||
except KeyError:
|
||||
- if _controllers.has_key('xdg-open'):
|
||||
+ if 'xdg-open' in _controllers:
|
||||
return _controllers['xdg-open'].open
|
||||
else:
|
||||
return webbrowser.open
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
From 375167e36f900483c5ab28d86cb57b703f90fee2 Mon Sep 17 00:00:00 2001
|
||||
From: Serge Guelton <sguelton@redhat.com>
|
||||
Date: Fri, 1 Feb 2019 06:11:44 +0000
|
||||
Subject: [PATCH] Fix isInSystemMacro to handle pasted macros
|
||||
|
||||
Token pasted by the preprocessor (through ##) have a Spelling pointing to scratch buffer.
|
||||
As a result they are not recognized at system macro, even though the pasting happened in
|
||||
a system macro. Fix that by looking into the parent macro if the original lookup finds a
|
||||
scratch buffer.
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D55782
|
||||
|
||||
This effectively fixes https://bugs.llvm.org/show_bug.cgi?id=35268,
|
||||
|
||||
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352838 91177308-0d34-0410-b5e6-96231b3b80d8
|
||||
---
|
||||
include/clang/Basic/SourceManager.h | 18 +++++++++++++++++-
|
||||
test/Misc/no-warn-in-system-macro.c | 13 +++++++++++++
|
||||
test/Misc/no-warn-in-system-macro.c.inc | 9 +++++++++
|
||||
test/Misc/warn-in-system-macro-def.c | 21 +++++++++++++++++++++
|
||||
test/Misc/warn-in-system-macro-def.c.inc | 4 ++++
|
||||
5 files changed, 64 insertions(+), 1 deletion(-)
|
||||
create mode 100644 test/Misc/no-warn-in-system-macro.c
|
||||
create mode 100644 test/Misc/no-warn-in-system-macro.c.inc
|
||||
create mode 100644 test/Misc/warn-in-system-macro-def.c
|
||||
create mode 100644 test/Misc/warn-in-system-macro-def.c.inc
|
||||
|
||||
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
|
||||
index ba829a8773..b45357e645 100644
|
||||
--- a/include/clang/Basic/SourceManager.h
|
||||
+++ b/include/clang/Basic/SourceManager.h
|
||||
@@ -1428,6 +1428,12 @@ public:
|
||||
return getFileID(Loc) == getMainFileID();
|
||||
}
|
||||
|
||||
+ /// Returns whether \p Loc is located in a <scratch space> file.
|
||||
+ bool isWrittenInScratchSpace(SourceLocation Loc) const {
|
||||
+ StringRef Filename(getPresumedLoc(Loc).getFilename());
|
||||
+ return Filename.equals("<scratch space>");
|
||||
+ }
|
||||
+
|
||||
/// Returns if a SourceLocation is in a system header.
|
||||
bool isInSystemHeader(SourceLocation Loc) const {
|
||||
return isSystem(getFileCharacteristic(Loc));
|
||||
@@ -1440,7 +1446,17 @@
|
||||
|
||||
/// Returns whether \p Loc is expanded from a macro in a system header.
|
||||
bool isInSystemMacro(SourceLocation loc) const {
|
||||
- return loc.isMacroID() && isInSystemHeader(getSpellingLoc(loc));
|
||||
+ if(!loc.isMacroID())
|
||||
+ return false;
|
||||
+
|
||||
+ // This happens when the macro is the result of a paste, in that case
|
||||
+ // its spelling is the scratch memory, so we take the parent context.
|
||||
+ if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
|
||||
+ return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
|
||||
+ }
|
||||
+ else {
|
||||
+ return isInSystemHeader(getSpellingLoc(loc));
|
||||
+ }
|
||||
}
|
||||
|
||||
/// The size of the SLocEntry that \p FID represents.
|
||||
diff --git a/test/Misc/no-warn-in-system-macro.c b/test/Misc/no-warn-in-system-macro.c
|
||||
new file mode 100644
|
||||
index 0000000000..a319b14c9c
|
||||
--- /dev/null
|
||||
+++ b/test/Misc/no-warn-in-system-macro.c
|
||||
@@ -0,0 +1,13 @@
|
||||
+// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s 2>&1 | FileCheck -allow-empty %s
|
||||
+// CHECK-NOT: warning:
|
||||
+
|
||||
+#include <no-warn-in-system-macro.c.inc>
|
||||
+
|
||||
+int main(void)
|
||||
+{
|
||||
+ double foo = 1.0;
|
||||
+
|
||||
+ if (isnan(foo))
|
||||
+ return 1;
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/test/Misc/no-warn-in-system-macro.c.inc b/test/Misc/no-warn-in-system-macro.c.inc
|
||||
new file mode 100644
|
||||
index 0000000000..3cbe7dfc16
|
||||
--- /dev/null
|
||||
+++ b/test/Misc/no-warn-in-system-macro.c.inc
|
||||
@@ -0,0 +1,9 @@
|
||||
+extern int __isnanf(float f);
|
||||
+extern int __isnan(double f);
|
||||
+extern int __isnanl(long double f);
|
||||
+#define isnan(x) \
|
||||
+ (sizeof (x) == sizeof (float) \
|
||||
+ ? __isnanf (x) \
|
||||
+ : sizeof (x) == sizeof (double) \
|
||||
+ ? __isnan (x) : __isnanl (x))
|
||||
+
|
||||
diff --git a/test/Misc/warn-in-system-macro-def.c b/test/Misc/warn-in-system-macro-def.c
|
||||
new file mode 100644
|
||||
index 0000000000..b295130702
|
||||
--- /dev/null
|
||||
+++ b/test/Misc/warn-in-system-macro-def.c
|
||||
@@ -0,0 +1,21 @@
|
||||
+// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s 2>&1 | FileCheck -allow-empty %s
|
||||
+// CHECK: warning:
|
||||
+// CHECK: expanded from macro 'ISNAN'
|
||||
+// CHECK: expanded from macro 'isnan'
|
||||
+
|
||||
+#include <warn-in-system-macro-def.c.inc>
|
||||
+
|
||||
+#define isnan(x) \
|
||||
+ (sizeof (x) == sizeof (float) \
|
||||
+ ? __isnanf (x) \
|
||||
+ : sizeof (x) == sizeof (double) \
|
||||
+ ? __isnan (x) : __isnanl (x))
|
||||
+
|
||||
+int main(void)
|
||||
+{
|
||||
+ double foo = 1.0;
|
||||
+
|
||||
+ if (ISNAN(foo))
|
||||
+ return 1;
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/test/Misc/warn-in-system-macro-def.c.inc b/test/Misc/warn-in-system-macro-def.c.inc
|
||||
new file mode 100644
|
||||
index 0000000000..5c7e60275a
|
||||
--- /dev/null
|
||||
+++ b/test/Misc/warn-in-system-macro-def.c.inc
|
||||
@@ -0,0 +1,4 @@
|
||||
+extern int __isnanf(float f);
|
||||
+extern int __isnan(double f);
|
||||
+extern int __isnanl(long double f);
|
||||
+#define ISNAN isnan
|
||||
--
|
||||
2.20.1
|
||||
|
24
clang.spec
24
clang.spec
|
@ -58,7 +58,7 @@
|
|||
|
||||
Name: %pkg_name
|
||||
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
|
||||
Release: 1%{?rc_ver:.rc%{rc_ver}}%{?dist}
|
||||
Release: 6%{?rc_ver:.rc%{rc_ver}}%{?dist}
|
||||
Summary: A C language family front-end for LLVM
|
||||
|
||||
License: NCSA
|
||||
|
@ -74,6 +74,10 @@ Patch4: 0001-gtest-reorg.patch
|
|||
Patch5: 0001-Don-t-prefer-python2.7.patch
|
||||
Patch6: 0001-Convert-clang-format-diff.py-to-python3-using-2to3.patch
|
||||
Patch7: 0001-Convert-scan-view-to-python3-using-2to3.patch
|
||||
#rhbz#1657544
|
||||
Patch8: 0001-CodeGen-Handle-mixed-width-ops-in-mixed-sign-mul-wit.patch
|
||||
#rhbz#1472437
|
||||
Patch9: 0001-Fix-isInSystemMacro-to-handle-pasted-macros.patch
|
||||
|
||||
# clang-tools-extra patches
|
||||
Patch100: 0001-Convert-run-find-all-symbols.py-to-python3-using-2to.patch
|
||||
|
@ -111,6 +115,8 @@ BuildRequires: libatomic
|
|||
|
||||
# We need python3-devel for pathfix.py.
|
||||
BuildRequires: python3-devel
|
||||
# We still need python2-devel for python2-clang
|
||||
BuildRequires: python2-devel
|
||||
|
||||
# Needed for %%multilib_fix_c_header
|
||||
BuildRequires: multilib-rpm-config
|
||||
|
@ -217,6 +223,8 @@ pathfix.py -i %{__python3} -pn \
|
|||
%patch5 -p1 -b .no-python2
|
||||
%patch6 -p1 -b .clang-format-diff-py3
|
||||
%patch7 -p1 -b .scan-view-py3
|
||||
%patch8 -p1 -b .mul-overflow-fix
|
||||
%patch9 -p1 -b .in-macro-fix
|
||||
|
||||
mv ../%{clang_tools_srcdir} tools/extra
|
||||
|
||||
|
@ -416,6 +424,20 @@ false
|
|||
|
||||
%endif
|
||||
%changelog
|
||||
* Sun Mar 10 2019 sguelton@redhat.com - 7.0.1-6
|
||||
- Rebuild with forgotten patch
|
||||
|
||||
* Tue Feb 26 2019 sguelton@redhat.com - 7.0.1-5
|
||||
- Fix for rhbz#1472437
|
||||
|
||||
* Mon Feb 25 2019 sguelton@redhat.com - 7.0.1-4
|
||||
- Update patch for Python3 port of scan-view
|
||||
|
||||
* Tue Feb 19 2019 sguelton@redhat.com - 7.0.1-3
|
||||
- Fix for rhbz#1672798
|
||||
|
||||
* Wed Dec 19 2018 Tom Stellard <tstellar@redhat.com> - 7.0.1-2
|
||||
- Fix for rhbz#1657544
|
||||
|
||||
* Tue Dec 18 2018 sguelton@redhat.com - 7.0.1-1
|
||||
- 7.0.1
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
--- !Policy
|
||||
product_versions:
|
||||
- fedora-*
|
||||
decision_context: bodhi_update_push_testing
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: org.centos.prod.ci.pipeline.allpackages-build.package.test.functional.complete}
|
||||
--- !Policy
|
||||
product_versions:
|
||||
- fedora-*
|
||||
decision_context: bodhi_update_push_stable
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: org.centos.prod.ci.pipeline.allpackages-build.package.test.functional.complete}
|
|
@ -0,0 +1,17 @@
|
|||
// Test case from rhbz#1657544
|
||||
|
||||
#include <charconv>
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
size_t r=0;
|
||||
const char *begin = argv[1];
|
||||
const char *end = begin + strlen(begin);
|
||||
from_chars(begin, end, r);
|
||||
cout << r << '\n';
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
set -x
|
||||
|
||||
tmp_cpp=`mktemp -t XXXXX.cpp`
|
||||
tmp_dir=`mktemp -d`
|
||||
echo 'int main(int argc, char*argv[]) { while(argc--) new int(); return 0; }' > $tmp_cpp
|
||||
scan-build -o $tmp_dir clang++ -c $tmp_cpp -o /dev/null
|
||||
(scan-view --no-browser $tmp_dir/* & WPID=$! && sleep 10s && kill $WPID)
|
||||
|
|
@ -18,3 +18,7 @@
|
|||
- llvm-abi-test-suite:
|
||||
dir: ./
|
||||
run: cd /usr/share/llvm-test-suite/ABI-Testsuite/ && python2 linux-x86.py clang test -v --path /usr/lib64/llvm/ -j 1
|
||||
- rhbz#1657544:
|
||||
dir: ./from_chars
|
||||
run: clang++ from_chars.cpp && ./a.out 100 | grep 100
|
||||
- rhbz_1647130
|
||||
|
|
Loading…
Reference in New Issue