aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/clang-format/git-clang-format34
-rw-r--r--tools/driver/driver.cpp55
-rw-r--r--tools/libclang/CXCompilationDatabase.cpp31
-rw-r--r--tools/libclang/CXType.cpp16
-rwxr-xr-xtools/scan-build/libexec/ccc-analyzer3
5 files changed, 85 insertions, 54 deletions
diff --git a/tools/clang-format/git-clang-format b/tools/clang-format/git-clang-format
index 3d1ba8a3c107..71b9124149fc 100755
--- a/tools/clang-format/git-clang-format
+++ b/tools/clang-format/git-clang-format
@@ -20,7 +20,7 @@ clang-format on the changes in current files or a specific commit.
For further details, run:
git clang-format -h
-Requires Python 2.7
+Requires Python 2.7 or Python 3
"""
from __future__ import print_function
@@ -258,7 +258,7 @@ def get_object_type(value):
stdout, stderr = p.communicate()
if p.returncode != 0:
return None
- return stdout.strip()
+ return convert_string(stdout.strip())
def compute_diff_and_extract_lines(commits, files):
@@ -301,6 +301,7 @@ def extract_lines(patch_file):
list of line `Range`s."""
matches = {}
for line in patch_file:
+ line = convert_string(line)
match = re.search(r'^\+\+\+\ [^/]+/(.*)', line)
if match:
filename = match.group(1).rstrip('\r\n')
@@ -385,7 +386,7 @@ def create_tree(input_lines, mode):
with temporary_index_file():
p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
for line in input_lines:
- p.stdin.write('%s\0' % line)
+ p.stdin.write(to_bytes('%s\0' % line))
p.stdin.close()
if p.wait() != 0:
die('`%s` failed' % ' '.join(cmd))
@@ -440,7 +441,7 @@ def clang_format_to_blob(filename, line_ranges, revision=None,
die('`%s` failed' % ' '.join(clang_format_cmd))
if git_show and git_show.wait() != 0:
die('`%s` failed' % ' '.join(git_show_cmd))
- return stdout.rstrip('\r\n')
+ return convert_string(stdout).rstrip('\r\n')
@contextlib.contextmanager
@@ -527,6 +528,10 @@ def run(*args, **kwargs):
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
stdout, stderr = p.communicate(input=stdin)
+
+ stdout = convert_string(stdout)
+ stderr = convert_string(stderr)
+
if p.returncode == 0:
if stderr:
if verbose:
@@ -547,5 +552,26 @@ def die(message):
sys.exit(2)
+def to_bytes(str_input):
+ # Encode to UTF-8 to get binary data.
+ if isinstance(str_input, bytes):
+ return str_input
+ return str_input.encode('utf-8')
+
+
+def to_string(bytes_input):
+ if isinstance(bytes_input, str):
+ return bytes_input
+ return bytes_input.encode('utf-8')
+
+
+def convert_string(bytes_input):
+ try:
+ return to_string(bytes_input.decode('utf-8'))
+ except AttributeError: # 'str' object has no attribute 'decode'.
+ return str(bytes_input)
+ except UnicodeError:
+ return str(bytes_input)
+
if __name__ == '__main__':
main()
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index 626d006ac0d8..4bd3b228d0ff 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -454,40 +454,41 @@ int main(int argc_, const char **argv_) {
SetBackdoorDriverOutputsFromEnvVars(TheDriver);
std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(argv));
- int Res = 0;
- SmallVector<std::pair<int, const Command *>, 4> FailingCommands;
- if (C.get())
+ int Res = 1;
+ if (C.get()) {
+ SmallVector<std::pair<int, const Command *>, 4> FailingCommands;
Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
- // Force a crash to test the diagnostics.
- if (TheDriver.GenReproducer) {
- Diags.Report(diag::err_drv_force_crash)
+ // Force a crash to test the diagnostics.
+ if (TheDriver.GenReproducer) {
+ Diags.Report(diag::err_drv_force_crash)
<< !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
- // Pretend that every command failed.
- FailingCommands.clear();
- for (const auto &J : C->getJobs())
- if (const Command *C = dyn_cast<Command>(&J))
- FailingCommands.push_back(std::make_pair(-1, C));
- }
+ // Pretend that every command failed.
+ FailingCommands.clear();
+ for (const auto &J : C->getJobs())
+ if (const Command *C = dyn_cast<Command>(&J))
+ FailingCommands.push_back(std::make_pair(-1, C));
+ }
- for (const auto &P : FailingCommands) {
- int CommandRes = P.first;
- const Command *FailingCommand = P.second;
- if (!Res)
- Res = CommandRes;
-
- // If result status is < 0, then the driver command signalled an error.
- // If result status is 70, then the driver command reported a fatal error.
- // On Windows, abort will return an exit code of 3. In these cases,
- // generate additional diagnostic information if possible.
- bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+ for (const auto &P : FailingCommands) {
+ int CommandRes = P.first;
+ const Command *FailingCommand = P.second;
+ if (!Res)
+ Res = CommandRes;
+
+ // If result status is < 0, then the driver command signalled an error.
+ // If result status is 70, then the driver command reported a fatal error.
+ // On Windows, abort will return an exit code of 3. In these cases,
+ // generate additional diagnostic information if possible.
+ bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
#ifdef LLVM_ON_WIN32
- DiagnoseCrash |= CommandRes == 3;
+ DiagnoseCrash |= CommandRes == 3;
#endif
- if (DiagnoseCrash) {
- TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
- break;
+ if (DiagnoseCrash) {
+ TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
+ break;
+ }
}
}
diff --git a/tools/libclang/CXCompilationDatabase.cpp b/tools/libclang/CXCompilationDatabase.cpp
index c122ec8a6db4..2ca532659d37 100644
--- a/tools/libclang/CXCompilationDatabase.cpp
+++ b/tools/libclang/CXCompilationDatabase.cpp
@@ -145,36 +145,23 @@ clang_CompileCommand_getArg(CXCompileCommand CCmd, unsigned Arg)
unsigned
clang_CompileCommand_getNumMappedSources(CXCompileCommand CCmd)
{
- if (!CCmd)
- return 0;
-
- return static_cast<CompileCommand *>(CCmd)->MappedSources.size();
+ // Left here for backward compatibility. No mapped sources exists in the C++
+ // backend anymore.
+ return 0;
}
CXString
clang_CompileCommand_getMappedSourcePath(CXCompileCommand CCmd, unsigned I)
{
- if (!CCmd)
- return cxstring::createNull();
-
- CompileCommand *Cmd = static_cast<CompileCommand *>(CCmd);
-
- if (I >= Cmd->MappedSources.size())
- return cxstring::createNull();
-
- return cxstring::createRef(Cmd->MappedSources[I].first.c_str());
+ // Left here for backward compatibility. No mapped sources exists in the C++
+ // backend anymore.
+ return cxstring::createNull();
}
CXString
clang_CompileCommand_getMappedSourceContent(CXCompileCommand CCmd, unsigned I)
{
- if (!CCmd)
- return cxstring::createNull();
-
- CompileCommand *Cmd = static_cast<CompileCommand *>(CCmd);
-
- if (I >= Cmd->MappedSources.size())
- return cxstring::createNull();
-
- return cxstring::createRef(Cmd->MappedSources[I].second.c_str());
+ // Left here for backward compatibility. No mapped sources exists in the C++
+ // backend anymore.
+ return cxstring::createNull();
}
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index 16e993e2ac01..f20581453e0e 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -59,6 +59,13 @@ static CXTypeKind GetBuiltinTypeKind(const BuiltinType *BT) {
BTCASE(ObjCId);
BTCASE(ObjCClass);
BTCASE(ObjCSel);
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) BTCASE(Id);
+#include "clang/Basic/OpenCLImageTypes.def"
+#undef IMAGE_TYPE
+ BTCASE(OCLSampler);
+ BTCASE(OCLEvent);
+ BTCASE(OCLQueue);
+ BTCASE(OCLReserveID);
default:
return CXType_Unexposed;
}
@@ -94,6 +101,7 @@ static CXTypeKind GetTypeKind(QualType T) {
TKCASE(MemberPointer);
TKCASE(Auto);
TKCASE(Elaborated);
+ TKCASE(Pipe);
default:
return CXType_Unexposed;
}
@@ -535,6 +543,14 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) {
TKIND(MemberPointer);
TKIND(Auto);
TKIND(Elaborated);
+ TKIND(Pipe);
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
+#include "clang/Basic/OpenCLImageTypes.def"
+#undef IMAGE_TYPE
+ TKIND(OCLSampler);
+ TKIND(OCLEvent);
+ TKIND(OCLQueue);
+ TKIND(OCLReserveID);
}
#undef TKIND
return cxstring::createRef(s);
diff --git a/tools/scan-build/libexec/ccc-analyzer b/tools/scan-build/libexec/ccc-analyzer
index bfda1d326f90..b0ec7e7e7487 100755
--- a/tools/scan-build/libexec/ccc-analyzer
+++ b/tools/scan-build/libexec/ccc-analyzer
@@ -385,7 +385,8 @@ my %CompilerLinkerOptionMap = (
'-target' => 1,
'-v' => 0,
'-mmacosx-version-min' => 0, # This is really a 1 argument, but always has '='
- '-miphoneos-version-min' => 0 # This is really a 1 argument, but always has '='
+ '-miphoneos-version-min' => 0, # This is really a 1 argument, but always has '='
+ '--target' => 0
);
my %IgnoredOptionMap = (