-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
2,388 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import shutil | ||
import subprocess | ||
|
||
if shutil.which("perf") is not None: | ||
config.available_features.add("perf") | ||
if shutil.which("perf") is not None and subprocess.run(["perf", "record", "-e", "cycles:u", "-o", "/dev/null", "--", "perf", "--version"], capture_output=True).returncode == 0: | ||
config.available_features.add("perf") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//===- GuessTargetAndModeCompilationDatabase.cpp --------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "clang/Tooling/CompilationDatabase.h" | ||
#include "clang/Tooling/Tooling.h" | ||
#include "llvm/Support/Path.h" | ||
#include "llvm/Support/Program.h" | ||
#include <memory> | ||
|
||
namespace clang { | ||
namespace tooling { | ||
|
||
namespace { | ||
class LocationAdderDatabase : public CompilationDatabase { | ||
public: | ||
LocationAdderDatabase(std::unique_ptr<CompilationDatabase> Base) | ||
: Base(std::move(Base)) { | ||
assert(this->Base != nullptr); | ||
} | ||
|
||
std::vector<std::string> getAllFiles() const override { | ||
return Base->getAllFiles(); | ||
} | ||
|
||
std::vector<CompileCommand> getAllCompileCommands() const override { | ||
return addLocation(Base->getAllCompileCommands()); | ||
} | ||
|
||
std::vector<CompileCommand> | ||
getCompileCommands(StringRef FilePath) const override { | ||
return addLocation(Base->getCompileCommands(FilePath)); | ||
} | ||
|
||
private: | ||
std::vector<CompileCommand> | ||
addLocation(std::vector<CompileCommand> Cmds) const { | ||
for (auto &Cmd : Cmds) { | ||
if (Cmd.CommandLine.empty()) | ||
continue; | ||
std::string &Driver = Cmd.CommandLine.front(); | ||
// If the driver name already is absolute, we don't need to do anything. | ||
if (llvm::sys::path::is_absolute(Driver)) | ||
continue; | ||
// If the name is a relative path, like bin/clang, we assume it's | ||
// possible to resolve it and don't do anything about it either. | ||
if (llvm::any_of(Driver, | ||
[](char C) { return llvm::sys::path::is_separator(C); })) | ||
continue; | ||
auto Absolute = llvm::sys::findProgramByName(Driver); | ||
// If we found it in path, update the entry in Cmd.CommandLine | ||
if (Absolute && llvm::sys::path::is_absolute(*Absolute)) | ||
Driver = std::move(*Absolute); | ||
} | ||
return Cmds; | ||
} | ||
std::unique_ptr<CompilationDatabase> Base; | ||
}; | ||
} // namespace | ||
|
||
std::unique_ptr<CompilationDatabase> | ||
inferToolLocation(std::unique_ptr<CompilationDatabase> Base) { | ||
return std::make_unique<LocationAdderDatabase>(std::move(Base)); | ||
} | ||
|
||
} // namespace tooling | ||
} // namespace clang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Check that we can detect an implicit target when clang is invoked as | ||
// <triple->clang. Using an implicit triple requires that the target actually | ||
// is available, too. | ||
// REQUIRES: x86-registered-target | ||
|
||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json | ||
|
||
// Check that we can deduce this both when using a compilation database, and when using | ||
// a literal command line. | ||
|
||
// RUN: clang-scan-deps -format experimental-full -compilation-database %t/cdb.json | FileCheck %s | ||
|
||
// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-clang %t/source.c -o %t/source.o | FileCheck %s | ||
|
||
// CHECK: "-triple", | ||
// CHECK-NEXT: "x86_64-w64-windows-gnu", | ||
|
||
|
||
//--- cdb.json.in | ||
[ | ||
{ | ||
"directory": "DIR" | ||
"command": "x86_64-w64-mingw32-clang -c DIR/source.c -o DIR/source.o" | ||
"file": "DIR/source.c" | ||
}, | ||
] | ||
|
||
//--- source.c | ||
void func(void) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.