Update prebuilt Clang to match Android kernel.
Bug: 132428451
Change-Id: I8f6e2cb23f381fc0c02ddea99b867e58e925e5be
diff --git a/linux-x64/clang/share/clang/clang-format-diff.py b/linux-x64/clang/share/clang/clang-format-diff.py
index ce4c1d6..3ba0abe 100755
--- a/linux-x64/clang/share/clang/clang-format-diff.py
+++ b/linux-x64/clang/share/clang/clang-format-diff.py
@@ -2,10 +2,9 @@
#
#===- clang-format-diff.py - ClangFormat Diff Reformatter ----*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# 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
#
#===------------------------------------------------------------------------===#
@@ -21,16 +20,18 @@
svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
"""
+from __future__ import absolute_import, division, print_function
import argparse
import difflib
import re
import subprocess
import sys
-try:
- from StringIO import StringIO
-except ImportError:
- from io import StringIO
+
+if sys.version_info.major >= 3:
+ from io import StringIO
+else:
+ from io import BytesIO as StringIO
def main():
@@ -65,7 +66,7 @@
filename = None
lines_by_file = {}
for line in sys.stdin:
- match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
+ match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
if match:
filename = match.group(2)
if filename == None:
@@ -78,7 +79,7 @@
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
continue
- match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
+ match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
if match:
start_line = int(match.group(1))
line_count = 1
diff --git a/linux-x64/clang/share/clang/clang-format-sublime.py b/linux-x64/clang/share/clang/clang-format-sublime.py
index 16ff56e..5ea9a27 100755
--- a/linux-x64/clang/share/clang/clang-format-sublime.py
+++ b/linux-x64/clang/share/clang/clang-format-sublime.py
@@ -12,7 +12,7 @@
# It operates on the current, potentially unsaved buffer and does not create
# or save any files. To revert a formatting, just undo.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
import sublime
import sublime_plugin
import subprocess
diff --git a/linux-x64/clang/share/clang/clang-format.py b/linux-x64/clang/share/clang/clang-format.py
index 5fe592a..fe068bd 100755
--- a/linux-x64/clang/share/clang/clang-format.py
+++ b/linux-x64/clang/share/clang/clang-format.py
@@ -25,7 +25,7 @@
#
# It operates on the current, potentially unsaved buffer and does not create
# or save any files. To revert a formatting, just undo.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
import difflib
import json
diff --git a/linux-x64/clang/share/clang/clang-include-fixer.el b/linux-x64/clang/share/clang/clang-include-fixer.el
index c3a3bba..1512402 100755
--- a/linux-x64/clang/share/clang/clang-include-fixer.el
+++ b/linux-x64/clang/share/clang/clang-include-fixer.el
@@ -93,8 +93,12 @@
buffer as only argument."
(unless buffer-file-name
(user-error "clang-include-fixer works only in buffers that visit a file"))
- (let ((process (if (fboundp 'make-process)
- ;; Prefer using ‘make-process’ if available, because
+ (let ((process (if (and (fboundp 'make-process)
+ ;; ‘make-process’ doesn’t support remote files
+ ;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28691).
+ (not (find-file-name-handler default-directory
+ 'start-file-process)))
+ ;; Prefer using ‘make-process’ if possible, because
;; ‘start-process’ doesn’t allow us to separate the
;; standard error from the output.
(clang-include-fixer--make-process callback args)
@@ -125,7 +129,7 @@
:stderr stderr)))
(defun clang-include-fixer--start-process (callback args)
- "Start a new clang-incude-fixer process using `start-process'.
+ "Start a new clang-incude-fixer process using `start-file-process'.
CALLBACK is called after the process finishes successfully; it is
called with a single argument, the buffer where standard output
has been inserted. ARGS is a list of additional command line
@@ -133,7 +137,7 @@
(let* ((stdin (current-buffer))
(stdout (generate-new-buffer "*clang-include-fixer output*"))
(process-connection-type nil)
- (process (apply #'start-process "clang-include-fixer" stdout
+ (process (apply #'start-file-process "clang-include-fixer" stdout
(clang-include-fixer--command args))))
(set-process-coding-system process 'utf-8-unix 'utf-8-unix)
(set-process-query-on-exit-flag process nil)
@@ -156,7 +160,7 @@
,(format "-input=%s" clang-include-fixer-init-string)
"-stdin"
,@args
- ,(buffer-file-name)))
+ ,(clang-include-fixer--file-local-name buffer-file-name)))
(defun clang-include-fixer--sentinel (stdin stdout stderr callback)
"Return a process sentinel for clang-include-fixer processes.
@@ -446,5 +450,11 @@
(defalias 'clang-include-fixer--format-message
(if (fboundp 'format-message) 'format-message 'format))
+;; ‘file-local-name’ is new in Emacs 26.1. Provide a fallback for older
+;; versions.
+(defalias 'clang-include-fixer--file-local-name
+ (if (fboundp 'file-local-name) #'file-local-name
+ (lambda (file) (or (file-remote-p file 'localname) file))))
+
(provide 'clang-include-fixer)
;;; clang-include-fixer.el ends here
diff --git a/linux-x64/clang/share/clang/clang-rename.py b/linux-x64/clang/share/clang/clang-rename.py
index 0cb8a26..3381c52 100755
--- a/linux-x64/clang/share/clang/clang-rename.py
+++ b/linux-x64/clang/share/clang/clang-rename.py
@@ -22,7 +22,7 @@
name if the cursor points to a valid symbol.
'''
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
import vim
import subprocess
import sys
diff --git a/linux-x64/clang/share/clang/clang-tidy-diff.py b/linux-x64/clang/share/clang/clang-tidy-diff.py
index f2c15e5..cf6db4a 100755
--- a/linux-x64/clang/share/clang/clang-tidy-diff.py
+++ b/linux-x64/clang/share/clang/clang-tidy-diff.py
@@ -2,10 +2,9 @@
#
#===- clang-tidy-diff.py - ClangTidy Diff Checker ------------*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# 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
#
#===------------------------------------------------------------------------===#
@@ -57,6 +56,9 @@
default='')
parser.add_argument('-path', dest='build_path',
help='Path used to read a compile command database.')
+ parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
+ help='Create a yaml file to store suggested fixes in, '
+ 'which can be applied with clang-apply-replacements.')
parser.add_argument('-extra-arg', dest='extra_arg',
action='append', default=[],
help='Additional argument to append to the compiler '
@@ -122,6 +124,8 @@
command.append('-line-filter=' + quote + line_filter_json + quote)
if args.fix:
command.append('-fix')
+ if args.export_fixes:
+ command.append('-export-fixes=' + args.export_fixes)
if args.checks != '':
command.append('-checks=' + quote + args.checks + quote)
if args.quiet:
diff --git a/linux-x64/clang/share/clang/run-clang-tidy.py b/linux-x64/clang/share/clang/run-clang-tidy.py
index 93635cb..5ec40f2 100755
--- a/linux-x64/clang/share/clang/run-clang-tidy.py
+++ b/linux-x64/clang/share/clang/run-clang-tidy.py
@@ -2,10 +2,9 @@
#
#===- run-clang-tidy.py - Parallel clang-tidy runner ---------*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# 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
#
#===------------------------------------------------------------------------===#
# FIXME: Integrate with clang-tidy-diff.py
diff --git a/linux-x64/clang/share/clang/run-find-all-symbols.py b/linux-x64/clang/share/clang/run-find-all-symbols.py
index 461d959..5e9dde7 100755
--- a/linux-x64/clang/share/clang/run-find-all-symbols.py
+++ b/linux-x64/clang/share/clang/run-find-all-symbols.py
@@ -2,10 +2,9 @@
#
#=- run-find-all-symbols.py - Parallel find-all-symbols runner -*- python -*-=#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# 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
#
#===------------------------------------------------------------------------===#
diff --git a/linux-x64/clang/share/man/man1/scan-build.1 b/linux-x64/clang/share/man/man1/scan-build.1
index cf7e7b1..4f3cd8d 100755
--- a/linux-x64/clang/share/man/man1/scan-build.1
+++ b/linux-x64/clang/share/man/man1/scan-build.1
@@ -1,5 +1,6 @@
-.\" This file is distributed under the University of Illinois Open Source
-.\" License. See LICENSE.TXT for details.
+.\" 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
.\" $Id$
.Dd May 25, 2012
.Dt SCAN-BUILD 1
diff --git a/linux-x64/clang/share/opt-viewer/opt-diff.py b/linux-x64/clang/share/opt-viewer/opt-diff.py
index f3bfd18..36e81a5 100755
--- a/linux-x64/clang/share/opt-viewer/opt-diff.py
+++ b/linux-x64/clang/share/opt-viewer/opt-diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
diff --git a/linux-x64/clang/share/opt-viewer/opt-stats.py b/linux-x64/clang/share/opt-viewer/opt-stats.py
index 03de23b..f4ee3a7 100755
--- a/linux-x64/clang/share/opt-viewer/opt-stats.py
+++ b/linux-x64/clang/share/opt-viewer/opt-stats.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
diff --git a/linux-x64/clang/share/opt-viewer/opt-viewer.py b/linux-x64/clang/share/opt-viewer/opt-viewer.py
index 4887043..4c10588 100755
--- a/linux-x64/clang/share/opt-viewer/opt-viewer.py
+++ b/linux-x64/clang/share/opt-viewer/opt-viewer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
@@ -72,7 +72,10 @@
file_text = stream.read()
if self.no_highlight:
- html_highlighted = file_text.decode('utf-8')
+ if sys.version_info.major >= 3:
+ html_highlighted = file_text
+ else:
+ html_highlighted = file_text.decode('utf-8')
else:
html_highlighted = highlight(
file_text,
@@ -117,12 +120,26 @@
indent = line[:max(r.Column, 1) - 1]
indent = re.sub('\S', ' ', indent)
+ # Create expanded message and link if we have a multiline message.
+ lines = r.message.split('\n')
+ if len(lines) > 1:
+ expand_link = '<a style="text-decoration: none;" href="" onclick="toggleExpandedMessage(this); return false;">+</a>'
+ message = lines[0]
+ expand_message = u'''
+<div class="full-info" style="display:none;">
+ <div class="col-left"><pre style="display:inline">{}</pre></div>
+ <div class="expanded col-left"><pre>{}</pre></div>
+</div>'''.format(indent, '\n'.join(lines[1:]))
+ else:
+ expand_link = ''
+ expand_message = ''
+ message = r.message
print(u'''
<tr>
<td></td>
<td>{r.RelativeHotness}</td>
<td class=\"column-entry-{r.color}\">{r.PassWithDiffPrefix}</td>
-<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\"> {r.message} </span></td>
+<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\">{expand_link} {message} </span>{expand_message}</td>
<td class=\"column-entry-yellow\">{inlining_context}</td>
</tr>'''.format(**locals()), file=self.stream)
@@ -136,6 +153,23 @@
<meta charset="utf-8" />
<head>
<link rel='stylesheet' type='text/css' href='style.css'>
+<script type="text/javascript">
+/* Simple helper to show/hide the expanded message of a remark. */
+function toggleExpandedMessage(e) {{
+ var FullTextElems = e.parentElement.parentElement.getElementsByClassName("full-info");
+ if (!FullTextElems || FullTextElems.length < 1) {{
+ return false;
+ }}
+ var FullText = FullTextElems[0];
+ if (FullText.style.display == 'none') {{
+ e.innerHTML = '-';
+ FullText.style.display = 'block';
+ }} else {{
+ e.innerHTML = '+';
+ FullText.style.display = 'none';
+ }}
+}}
+</script>
</head>
<body>
<div class="centered">
@@ -205,7 +239,7 @@
</html>''', file=self.stream)
-def _render_file(source_dir, output_dir, ctx, no_highlight, entry):
+def _render_file(source_dir, output_dir, ctx, no_highlight, entry, filter_):
global context
context = ctx
filename, remarks = entry
@@ -310,6 +344,11 @@
'--demangler',
help='Set the demangler to be used (defaults to %s)' % optrecord.Remark.default_demangler)
+ parser.add_argument(
+ '--filter',
+ default='',
+ help='Only display remarks from passes matching filter expression')
+
# Do not make this a global variable. Values needed to be propagated through
# to individual classes and functions to be portable with multiprocessing across
# Windows and non-Windows.
@@ -325,7 +364,7 @@
sys.exit(1)
all_remarks, file_remarks, should_display_hotness = \
- optrecord.gather_results(files, args.jobs, print_progress)
+ optrecord.gather_results(files, args.jobs, print_progress, args.filter)
map_remarks(all_remarks)
diff --git a/linux-x64/clang/share/opt-viewer/optpmap.py b/linux-x64/clang/share/opt-viewer/optpmap.py
index db6b079..8124c8c 100755
--- a/linux-x64/clang/share/opt-viewer/optpmap.py
+++ b/linux-x64/clang/share/opt-viewer/optpmap.py
@@ -14,7 +14,7 @@
def _wrapped_func(func_and_args):
- func, argument, should_print_progress = func_and_args
+ func, argument, should_print_progress, filter_ = func_and_args
if should_print_progress:
with _current.get_lock():
@@ -22,10 +22,10 @@
sys.stdout.write('\r\t{} of {}'.format(_current.value, _total.value))
sys.stdout.flush()
- return func(argument)
+ return func(argument, filter_)
-def pmap(func, iterable, processes, should_print_progress, *args, **kwargs):
+def pmap(func, iterable, processes, should_print_progress, filter_=None, *args, **kwargs):
"""
A parallel map function that reports on its progress.
@@ -40,9 +40,9 @@
_current = multiprocessing.Value('i', 0)
_total = multiprocessing.Value('i', len(iterable))
- func_and_args = [(func, arg, should_print_progress,) for arg in iterable]
+ func_and_args = [(func, arg, should_print_progress, filter_) for arg in iterable]
if processes == 1:
- result = map(_wrapped_func, func_and_args, *args, **kwargs)
+ result = list(map(_wrapped_func, func_and_args, *args, **kwargs))
else:
pool = multiprocessing.Pool(initializer=_init,
initargs=(_current, _total,),
diff --git a/linux-x64/clang/share/opt-viewer/optrecord.py b/linux-x64/clang/share/opt-viewer/optrecord.py
index 8cf22ee..e952d1b 100755
--- a/linux-x64/clang/share/opt-viewer/optrecord.py
+++ b/linux-x64/clang/share/opt-viewer/optrecord.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
@@ -24,6 +24,8 @@
except:
pass
+import re
+
import optpmap
try:
@@ -263,18 +265,24 @@
return "red"
-def get_remarks(input_file):
+def get_remarks(input_file, filter_):
max_hotness = 0
all_remarks = dict()
file_remarks = defaultdict(functools.partial(defaultdict, list))
with open(input_file) as f:
docs = yaml.load_all(f, Loader=Loader)
+
+ filter_e = re.compile(filter_)
for remark in docs:
remark.canonicalize()
# Avoid remarks withoug debug location or if they are duplicated
if not hasattr(remark, 'DebugLoc') or remark.key in all_remarks:
continue
+
+ if filter_ and not filter_e.search(remark.Pass):
+ continue
+
all_remarks[remark.key] = remark
file_remarks[remark.File][remark.Line].append(remark)
@@ -289,13 +297,13 @@
return max_hotness, all_remarks, file_remarks
-def gather_results(filenames, num_jobs, should_print_progress):
+def gather_results(filenames, num_jobs, should_print_progress, filter_):
if should_print_progress:
print('Reading YAML files...')
if not Remark.demangler_proc:
Remark.set_demangler(Remark.default_demangler)
remarks = optpmap.pmap(
- get_remarks, filenames, num_jobs, should_print_progress)
+ get_remarks, filenames, num_jobs, should_print_progress, filter_)
max_hotness = max(entry[0] for entry in remarks)
def merge_file_remarks(file_remarks_job, all_remarks, merged):
diff --git a/linux-x64/clang/share/opt-viewer/style.css b/linux-x64/clang/share/opt-viewer/style.css
index 0d3347c..550c7e1 100755
--- a/linux-x64/clang/share/opt-viewer/style.css
+++ b/linux-x64/clang/share/opt-viewer/style.css
@@ -139,6 +139,16 @@
td:last-child {
border-right: none;
}
+.expanded {
+ background-color: #f2f2f2;
+ padding-top: 5px;
+ padding-left: 5px;
+}
+.col-left {
+ float: left;
+ margin-bottom: -99999px;
+ padding-bottom: 99999px;
+}
/* Generated with pygmentize -S colorful -f html >> style.css */
diff --git a/linux-x64/clang/share/scan-view/Reporter.py b/linux-x64/clang/share/scan-view/Reporter.py
index 800af03..b1ff161 100644
--- a/linux-x64/clang/share/scan-view/Reporter.py
+++ b/linux-x64/clang/share/scan-view/Reporter.py
@@ -16,7 +16,7 @@
# Collect information about a bug.
-class BugReport:
+class BugReport(object):
def __init__(self, title, description, files):
self.title = title
self.description = description
@@ -37,7 +37,7 @@
# ReporterParameter
#===------------------------------------------------------------------------===#
-class ReporterParameter:
+class ReporterParameter(object):
def __init__(self, n):
self.name = n
def getName(self):
@@ -75,12 +75,12 @@
# Reporters
#===------------------------------------------------------------------------===#
-class EmailReporter:
+class EmailReporter(object):
def getName(self):
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):
@@ -143,12 +143,12 @@
return "Message sent!"
-class BugzillaReporter:
+class BugzillaReporter(object):
def getName(self):
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
@@ -174,7 +174,7 @@
else:
return '7'
-class RadarReporter:
+class RadarReporter(object):
@staticmethod
def isAvailable():
# FIXME: Find this .scpt better
@@ -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] + [os.path.abspath(f) for f in report.files]
# print >>sys.stderr, args
try:
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
diff --git a/linux-x64/clang/share/scan-view/ScanView.py b/linux-x64/clang/share/scan-view/ScanView.py
index 7dc0351..c40366b 100644
--- a/linux-x64/clang/share/scan-view/ScanView.py
+++ b/linux-x64/clang/share/scan-view/ScanView.py
@@ -1,10 +1,24 @@
-import BaseHTTPServer
-import SimpleHTTPServer
+from __future__ import print_function
+try:
+ from http.server import HTTPServer, SimpleHTTPRequestHandler
+except ImportError:
+ from BaseHTTPServer import HTTPServer
+ from SimpleHTTPServer import SimpleHTTPRequestHandler
import os
import sys
-import urllib, urlparse
+try:
+ from urlparse import urlparse
+ from urllib import unquote
+except ImportError:
+ from urllib.parse import urlparse, unquote
+
import posixpath
-import StringIO
+
+if sys.version_info.major >= 3:
+ from io import StringIO, BytesIO
+else:
+ from io import BytesIO, BytesIO as StringIO
+
import re
import shutil
import threading
@@ -13,7 +27,10 @@
import itertools
import Reporter
-import ConfigParser
+try:
+ import configparser
+except ImportError:
+ import ConfigParser as configparser
###
# Various patterns matched or replaced by server.
@@ -96,25 +113,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 = StringIO()
import traceback
- print >>s,'<b>Unhandled Exception</b><br><pre>'
- traceback.print_exc(e,file=s)
- print >>s,'</pre>'
+ print('<b>Unhandled Exception</b><br><pre>', file=s)
+ traceback.print_exc(file=s)
+ print('</pre>', file=s)
self.status = s.getvalue()
-class ScanViewServer(BaseHTTPServer.HTTPServer):
+class ScanViewServer(HTTPServer):
def __init__(self, address, handler, root, reporters, options):
- BaseHTTPServer.HTTPServer.__init__(self, address, handler)
+ HTTPServer.__init__(self, address, handler)
self.root = root
self.reporters = reporters
self.options = options
@@ -123,7 +140,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 +172,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)
+ 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)
+ 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 = unquote(name.replace('+', ' '))
+ value = unquote(value.replace('+', ' '))
item = fields.get(name)
if item is None:
fields[name] = [value]
@@ -200,20 +217,20 @@
item.append(value)
return fields
-class ScanViewRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+class ScanViewRequestHandler(SimpleHTTPRequestHandler):
server_version = "ScanViewServer/" + __version__
dynamic_mtime = time.time()
def do_HEAD(self):
try:
- SimpleHTTPServer.SimpleHTTPRequestHandler.do_HEAD(self)
- except Exception,e:
+ 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:
+ SimpleHTTPRequestHandler.do_GET(self)
+ except Exception as e:
self.handle_exception(e)
def do_POST(self):
@@ -230,7 +247,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,9 +280,9 @@
def handle_exception(self, exc):
import traceback
- s = StringIO.StringIO()
- print >>s, "INTERNAL ERROR\n"
- traceback.print_exc(exc, s)
+ s = StringIO()
+ print("INTERNAL ERROR\n", file=s)
+ traceback.print_exc(file=s)
f = self.send_string(s.getvalue(), 'text/plain')
if f:
self.copyfile(f, self.wfile)
@@ -410,8 +427,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:
@@ -422,13 +439,13 @@
return self.send_string(res, 'text/plain')
def get_report_context(self, report):
- class Context:
+ class Context(object):
pass
if report is None or report == 'None':
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 +489,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 +518,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 +561,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 +664,9 @@
fields = {}
self.fields = fields
- o = urlparse.urlparse(self.path)
+ o = urlparse(self.path)
self.fields = parse_query(o.query, fields)
- path = posixpath.normpath(urllib.unquote(o.path))
+ path = posixpath.normpath(unquote(o.path))
# Split the components and strip the root prefix.
components = path.split('/')[1:]
@@ -690,8 +707,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):
@@ -727,15 +744,16 @@
return f
def send_string(self, s, ctype='text/html', headers=True, mtime=None):
+ encoded_s = s.encode()
if headers:
self.send_response(200)
self.send_header("Content-type", ctype)
- self.send_header("Content-Length", str(len(s)))
+ self.send_header("Content-Length", str(len(encoded_s)))
if mtime is None:
mtime = self.dynamic_mtime
self.send_header("Last-Modified", self.date_time_string(mtime))
self.end_headers()
- return StringIO.StringIO(s)
+ return BytesIO(encoded_s)
def send_patched_file(self, path, ctype):
# Allow a very limited set of variables. This is pretty gross.
diff --git a/linux-x64/clang/share/scan-view/startfile.py b/linux-x64/clang/share/scan-view/startfile.py
index f58dbee..9eb548b 100644
--- a/linux-x64/clang/share/scan-view/startfile.py
+++ b/linux-x64/clang/share/scan-view/startfile.py
@@ -110,7 +110,10 @@
# Platform support for Unix
else:
- import commands
+ try:
+ from commands import getoutput
+ except ImportError:
+ from subprocess import getoutput
# @WARNING: use the private API of the webbrowser module
from webbrowser import _iscommand
@@ -125,7 +128,7 @@
def detect_kde_version(self):
kde_version = None
try:
- info = commands.getoutput('kde-config --version')
+ info = getoutput('kde-config --version')
for line in info.splitlines():
if line.startswith('KDE'):
@@ -158,7 +161,7 @@
desktop_environment = 'gnome'
else:
try:
- info = commands.getoutput('xprop -root _DT_SAVE_MODE')
+ info = getoutput('xprop -root _DT_SAVE_MODE')
if ' = "xfce4"' in info:
desktop_environment = 'xfce'
except (OSError, RuntimeError):
@@ -189,7 +192,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