summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/arcmt-test/arcmt-test.cpp7
-rw-r--r--tools/c-index-test/CMakeLists.txt2
-rw-r--r--tools/c-index-test/c-index-test.c45
-rw-r--r--tools/c-index-test/core_main.cpp7
-rw-r--r--tools/clang-check/ClangCheck.cpp10
-rw-r--r--tools/clang-diff/ClangDiff.cpp7
-rw-r--r--tools/clang-extdef-mapping/ClangExtDefMapGen.cpp70
-rw-r--r--tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs911
-rw-r--r--tools/clang-format-vs/ClangFormat/Guids.cs2
-rw-r--r--tools/clang-format-vs/ClangFormat/PkgCmdID.cs2
-rw-r--r--tools/clang-format-vs/ClangFormat/license.txt254
-rw-r--r--tools/clang-format-vs/source.extension.vsixmanifest.in2
-rw-r--r--tools/clang-format/ClangFormat.cpp9
-rwxr-xr-xtools/clang-format/clang-format-diff.py11
-rw-r--r--tools/clang-format/clang-format-test.el5
-rw-r--r--tools/clang-format/fuzzer/ClangFormatFuzzer.cpp7
-rwxr-xr-xtools/clang-format/git-clang-format7
-rw-r--r--tools/clang-fuzzer/ClangFuzzer.cpp7
-rw-r--r--tools/clang-fuzzer/Dockerfile7
-rw-r--r--tools/clang-fuzzer/DummyClangFuzzer.cpp7
-rw-r--r--tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp7
-rw-r--r--tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp7
-rw-r--r--tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp7
-rw-r--r--tools/clang-fuzzer/cxx_loop_proto.proto7
-rw-r--r--tools/clang-fuzzer/cxx_proto.proto7
-rw-r--r--tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp7
-rw-r--r--tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h7
-rw-r--r--tools/clang-fuzzer/handle-cxx/handle_cxx.cpp7
-rw-r--r--tools/clang-fuzzer/handle-cxx/handle_cxx.h7
-rw-r--r--tools/clang-fuzzer/handle-llvm/handle_llvm.cpp7
-rw-r--r--tools/clang-fuzzer/handle-llvm/handle_llvm.h7
-rw-r--r--tools/clang-fuzzer/handle-llvm/input_arrays.h7
-rw-r--r--tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp7
-rw-r--r--tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp7
-rw-r--r--tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp7
-rw-r--r--tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h7
-rw-r--r--tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp7
-rw-r--r--tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp7
-rw-r--r--tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h7
-rw-r--r--tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm_main.cpp7
-rw-r--r--tools/clang-import-test/clang-import-test.cpp12
-rw-r--r--tools/clang-offload-bundler/ClangOffloadBundler.cpp9
-rw-r--r--tools/clang-refactor/ClangRefactor.cpp7
-rw-r--r--tools/clang-refactor/TestSupport.cpp7
-rw-r--r--tools/clang-refactor/TestSupport.h7
-rw-r--r--tools/clang-refactor/ToolRefactoringResultConsumer.h7
-rw-r--r--tools/clang-rename/ClangRename.cpp7
-rw-r--r--tools/diagtool/CMakeLists.txt2
-rw-r--r--tools/diagtool/DiagTool.cpp7
-rw-r--r--tools/diagtool/DiagTool.h7
-rw-r--r--tools/diagtool/DiagnosticNames.cpp7
-rw-r--r--tools/diagtool/DiagnosticNames.h7
-rw-r--r--tools/diagtool/FindDiagnosticID.cpp7
-rw-r--r--tools/diagtool/ListWarnings.cpp7
-rw-r--r--tools/diagtool/ShowEnabledWarnings.cpp7
-rw-r--r--tools/diagtool/TreeView.cpp7
-rw-r--r--tools/diagtool/diagtool_main.cpp7
-rw-r--r--tools/driver/CMakeLists.txt2
-rw-r--r--tools/driver/cc1_main.cpp31
-rw-r--r--tools/driver/cc1as_main.cpp31
-rw-r--r--tools/driver/cc1gen_reproducer_main.cpp7
-rw-r--r--tools/driver/driver.cpp9
-rw-r--r--tools/libclang/ARCMigrate.cpp7
-rw-r--r--tools/libclang/BuildSystem.cpp7
-rw-r--r--tools/libclang/CIndex.cpp40
-rw-r--r--tools/libclang/CIndexCXX.cpp7
-rw-r--r--tools/libclang/CIndexCodeCompletion.cpp12
-rw-r--r--tools/libclang/CIndexDiagnostic.cpp24
-rw-r--r--tools/libclang/CIndexDiagnostic.h8
-rw-r--r--tools/libclang/CIndexHigh.cpp13
-rw-r--r--tools/libclang/CIndexInclusionStack.cpp7
-rw-r--r--tools/libclang/CIndexUSRs.cpp9
-rw-r--r--tools/libclang/CIndexer.cpp77
-rw-r--r--tools/libclang/CIndexer.h7
-rw-r--r--tools/libclang/CLog.h7
-rw-r--r--tools/libclang/CMakeLists.txt9
-rw-r--r--tools/libclang/CXComment.cpp7
-rw-r--r--tools/libclang/CXComment.h7
-rw-r--r--tools/libclang/CXCursor.cpp19
-rw-r--r--tools/libclang/CXCursor.h7
-rw-r--r--tools/libclang/CXIndexDataConsumer.cpp7
-rw-r--r--tools/libclang/CXIndexDataConsumer.h7
-rw-r--r--tools/libclang/CXLoadedDiagnostic.cpp7
-rw-r--r--tools/libclang/CXLoadedDiagnostic.h8
-rw-r--r--tools/libclang/CXSourceLocation.cpp7
-rw-r--r--tools/libclang/CXSourceLocation.h7
-rw-r--r--tools/libclang/CXStoredDiagnostic.cpp23
-rw-r--r--tools/libclang/CXString.cpp7
-rw-r--r--tools/libclang/CXString.h7
-rw-r--r--tools/libclang/CXTranslationUnit.h7
-rw-r--r--tools/libclang/CXType.cpp37
-rw-r--r--tools/libclang/CXType.h7
-rw-r--r--tools/libclang/CursorVisitor.h7
-rw-r--r--tools/libclang/Index_Internal.h7
-rw-r--r--tools/libclang/Indexing.cpp12
-rw-r--r--tools/libclang/libclang.exports1
-rw-r--r--tools/scan-build-py/README.md2
-rwxr-xr-xtools/scan-build-py/bin/analyze-build7
-rwxr-xr-xtools/scan-build-py/bin/analyze-c++7
-rwxr-xr-xtools/scan-build-py/bin/analyze-cc7
-rwxr-xr-xtools/scan-build-py/bin/intercept-build7
-rwxr-xr-xtools/scan-build-py/bin/intercept-c++7
-rwxr-xr-xtools/scan-build-py/bin/intercept-cc7
-rwxr-xr-xtools/scan-build-py/bin/scan-build7
-rw-r--r--tools/scan-build-py/libear/__init__.py7
-rw-r--r--tools/scan-build-py/libear/config.h.in7
-rw-r--r--tools/scan-build-py/libear/ear.c7
-rw-r--r--tools/scan-build-py/libscanbuild/__init__.py7
-rw-r--r--tools/scan-build-py/libscanbuild/analyze.py9
-rw-r--r--tools/scan-build-py/libscanbuild/arguments.py7
-rw-r--r--tools/scan-build-py/libscanbuild/clang.py7
-rw-r--r--tools/scan-build-py/libscanbuild/compilation.py7
-rw-r--r--tools/scan-build-py/libscanbuild/intercept.py7
-rw-r--r--tools/scan-build-py/libscanbuild/report.py7
-rw-r--r--tools/scan-build-py/libscanbuild/shell.py7
-rw-r--r--tools/scan-build-py/tests/__init__.py7
-rw-r--r--tools/scan-build-py/tests/functional/cases/__init__.py7
-rw-r--r--tools/scan-build-py/tests/functional/cases/test_create_cdb.py7
-rw-r--r--tools/scan-build-py/tests/functional/cases/test_exec_anatomy.py7
-rw-r--r--tools/scan-build-py/tests/functional/cases/test_from_cdb.py7
-rw-r--r--tools/scan-build-py/tests/functional/cases/test_from_cmd.py7
-rw-r--r--tools/scan-build-py/tests/functional/exec/config.h.in7
-rw-r--r--tools/scan-build-py/tests/functional/exec/main.c7
-rw-r--r--tools/scan-build-py/tests/unit/__init__.py7
-rw-r--r--tools/scan-build-py/tests/unit/test_analyze.py7
-rw-r--r--tools/scan-build-py/tests/unit/test_clang.py7
-rw-r--r--tools/scan-build-py/tests/unit/test_compilation.py7
-rw-r--r--tools/scan-build-py/tests/unit/test_intercept.py7
-rw-r--r--tools/scan-build-py/tests/unit/test_libear.py7
-rw-r--r--tools/scan-build-py/tests/unit/test_report.py7
-rw-r--r--tools/scan-build-py/tests/unit/test_shell.py7
-rwxr-xr-xtools/scan-build/bin/scan-build30
-rwxr-xr-xtools/scan-build/bin/set-xcode-analyzer2
-rwxr-xr-xtools/scan-build/libexec/ccc-analyzer7
-rw-r--r--tools/scan-build/man/scan-build.15
135 files changed, 1364 insertions, 1074 deletions
diff --git a/tools/arcmt-test/arcmt-test.cpp b/tools/arcmt-test/arcmt-test.cpp
index 80354788a3..5f075f860f 100644
--- a/tools/arcmt-test/arcmt-test.cpp
+++ b/tools/arcmt-test/arcmt-test.cpp
@@ -1,9 +1,8 @@
//===-- arcmt-test.cpp - ARC Migration Tool testbed -----------------------===//
//
-// 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/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt
index 53e3421f1b..ceef4b0863 100644
--- a/tools/c-index-test/CMakeLists.txt
+++ b/tools/c-index-test/CMakeLists.txt
@@ -61,7 +61,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
RUNTIME DESTINATION "${INSTALL_DESTINATION}"
COMPONENT c-index-test)
- if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+ if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-c-index-test
DEPENDS c-index-test
COMPONENT c-index-test)
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index fc6ba46fd6..17b773c636 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1665,34 +1665,55 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p,
}
}
+ /* Print if it is an anonymous record decl */
+ {
+ unsigned isAnonRecDecl = clang_Cursor_isAnonymousRecordDecl(cursor);
+ printf(" [isAnonRecDecl=%d]", isAnonRecDecl);
+ }
+
printf("\n");
}
return CXChildVisit_Recurse;
}
-static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
- CXClientData d) {
- CXType T;
- enum CXCursorKind K = clang_getCursorKind(cursor);
- if (clang_isInvalid(K))
- return CXChildVisit_Recurse;
- T = clang_getCursorType(cursor);
- PrintCursor(cursor, NULL);
- PrintTypeAndTypeKind(T, " [type=%s] [typekind=%s]");
+static void PrintSingleTypeSize(CXType T, const char *TypeKindFormat,
+ const char *SizeFormat,
+ const char *AlignFormat) {
+ PrintTypeAndTypeKind(T, TypeKindFormat);
/* Print the type sizeof if applicable. */
{
long long Size = clang_Type_getSizeOf(T);
if (Size >= 0 || Size < -1 ) {
- printf(" [sizeof=%lld]", Size);
+ printf(SizeFormat, Size);
}
}
/* Print the type alignof if applicable. */
{
long long Align = clang_Type_getAlignOf(T);
if (Align >= 0 || Align < -1) {
- printf(" [alignof=%lld]", Align);
+ printf(AlignFormat, Align);
}
}
+
+ /* Print the return type if it exists. */
+ {
+ CXType RT = clang_getResultType(T);
+ if (RT.kind != CXType_Invalid)
+ PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",
+ " [resultsizeof=%lld]", " [resultalignof=%lld]");
+ }
+}
+
+static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+ CXType T;
+ enum CXCursorKind K = clang_getCursorKind(cursor);
+ if (clang_isInvalid(K))
+ return CXChildVisit_Recurse;
+ T = clang_getCursorType(cursor);
+ PrintCursor(cursor, NULL);
+ PrintSingleTypeSize(T, " [type=%s] [typekind=%s]", " [sizeof=%lld]",
+ " [alignof=%lld]");
/* Print the record field offset if applicable. */
{
CXString FieldSpelling = clang_getCursorSpelling(cursor);
@@ -1730,7 +1751,9 @@ static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
if (IsBitfield)
printf(" [BitFieldSize=%d]", clang_getFieldDeclBitWidth(cursor));
}
+
printf("\n");
+
return CXChildVisit_Recurse;
}
diff --git a/tools/c-index-test/core_main.cpp b/tools/c-index-test/core_main.cpp
index b9c0f19a7f..90bfbd9ed6 100644
--- a/tools/c-index-test/core_main.cpp
+++ b/tools/c-index-test/core_main.cpp
@@ -1,9 +1,8 @@
//===-- core_main.cpp - Core Index Tool testbed ---------------------------===//
//
-// 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/tools/clang-check/ClangCheck.cpp b/tools/clang-check/ClangCheck.cpp
index 66d865b749..ce400b5c20 100644
--- a/tools/clang-check/ClangCheck.cpp
+++ b/tools/clang-check/ClangCheck.cpp
@@ -1,9 +1,8 @@
//===--- tools/clang-check/ClangCheck.cpp - Clang check tool --------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -91,9 +90,6 @@ public:
}
std::string RewriteFilename(const std::string& filename, int &fd) override {
- assert(llvm::sys::path::is_absolute(filename) &&
- "clang-fixit expects absolute paths only.");
-
// We don't need to do permission checking here since clang will diagnose
// any I/O errors itself.
diff --git a/tools/clang-diff/ClangDiff.cpp b/tools/clang-diff/ClangDiff.cpp
index 4e2150aa45..f0b3ace201 100644
--- a/tools/clang-diff/ClangDiff.cpp
+++ b/tools/clang-diff/ClangDiff.cpp
@@ -1,9 +1,8 @@
//===- ClangDiff.cpp - compare source files by AST nodes ------*- C++ -*- -===//
//
-// 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/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp b/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
index 7885f39018..7a374698f7 100644
--- a/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ b/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -1,9 +1,8 @@
-//===- ClangFnMapGen.cpp -----------------------------------------------===//
+//===- ClangExtDefMapGen.cpp -----------------------------------------------===//
//
-// 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
//
//===--------------------------------------------------------------------===//
//
@@ -35,20 +34,22 @@ static cl::OptionCategory ClangExtDefMapGenCategory("clang-extdefmapgen options"
class MapExtDefNamesConsumer : public ASTConsumer {
public:
MapExtDefNamesConsumer(ASTContext &Context)
- : SM(Context.getSourceManager()) {}
+ : Ctx(Context), SM(Context.getSourceManager()) {}
~MapExtDefNamesConsumer() {
// Flush results to standard output.
llvm::outs() << createCrossTUIndexString(Index);
}
- void HandleTranslationUnit(ASTContext &Ctx) override {
- handleDecl(Ctx.getTranslationUnitDecl());
+ void HandleTranslationUnit(ASTContext &Context) override {
+ handleDecl(Context.getTranslationUnitDecl());
}
private:
void handleDecl(const Decl *D);
+ void addIfInMain(const DeclaratorDecl *DD, SourceLocation defStart);
+ ASTContext &Ctx;
SourceManager &SM;
llvm::StringMap<std::string> Index;
std::string CurrentFileName;
@@ -59,30 +60,13 @@ void MapExtDefNamesConsumer::handleDecl(const Decl *D) {
return;
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
- if (FD->isThisDeclarationADefinition()) {
- if (const Stmt *Body = FD->getBody()) {
- if (CurrentFileName.empty()) {
- CurrentFileName =
- SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
- if (CurrentFileName.empty())
- CurrentFileName = "invalid_file";
- }
-
- switch (FD->getLinkageInternal()) {
- case ExternalLinkage:
- case VisibleNoLinkage:
- case UniqueExternalLinkage:
- if (SM.isInMainFile(Body->getBeginLoc())) {
- std::string LookupName =
- CrossTranslationUnitContext::getLookupName(FD);
- Index[LookupName] = CurrentFileName;
- }
- break;
- default:
- break;
- }
- }
- }
+ if (FD->isThisDeclarationADefinition())
+ if (const Stmt *Body = FD->getBody())
+ addIfInMain(FD, Body->getBeginLoc());
+ } else if (const auto *VD = dyn_cast<VarDecl>(D)) {
+ if (cross_tu::containsConst(VD, Ctx) && VD->hasInit())
+ if (const Expr *Init = VD->getInit())
+ addIfInMain(VD, Init->getBeginLoc());
}
if (const auto *DC = dyn_cast<DeclContext>(D))
@@ -90,6 +74,28 @@ void MapExtDefNamesConsumer::handleDecl(const Decl *D) {
handleDecl(D);
}
+void MapExtDefNamesConsumer::addIfInMain(const DeclaratorDecl *DD,
+ SourceLocation defStart) {
+ std::string LookupName = CrossTranslationUnitContext::getLookupName(DD);
+ if (CurrentFileName.empty()) {
+ CurrentFileName =
+ SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
+ if (CurrentFileName.empty())
+ CurrentFileName = "invalid_file";
+ }
+
+ switch (DD->getLinkageInternal()) {
+ case ExternalLinkage:
+ case VisibleNoLinkage:
+ case UniqueExternalLinkage:
+ if (SM.isInMainFile(defStart))
+ Index[LookupName] = CurrentFileName;
+ break;
+ default:
+ break;
+ }
+}
+
class MapExtDefNamesAction : public ASTFrontendAction {
protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
diff --git a/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs b/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
index 1071b680ae..7443405efa 100644
--- a/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ b/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -1,456 +1,455 @@
-//===-- ClangFormatPackages.cs - VSPackage for clang-format ------*- C# -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This class contains a VS extension package that runs clang-format over a
-// selection in a VS text editor.
-//
-//===----------------------------------------------------------------------===//
-
-using EnvDTE;
-using Microsoft.VisualStudio.Shell;
-using Microsoft.VisualStudio.Shell.Interop;
-using Microsoft.VisualStudio.Text;
-using Microsoft.VisualStudio.Text.Editor;
-using System;
-using System.Collections;
-using System.ComponentModel;
-using System.ComponentModel.Design;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Xml.Linq;
-using System.Linq;
-
-namespace LLVM.ClangFormat
-{
- [ClassInterface(ClassInterfaceType.AutoDual)]
- [CLSCompliant(false), ComVisible(true)]
- public class OptionPageGrid : DialogPage
- {
- private string assumeFilename = "";
- private string fallbackStyle = "LLVM";
- private bool sortIncludes = false;
- private string style = "file";
- private bool formatOnSave = false;
- private string formatOnSaveFileExtensions =
- ".c;.cpp;.cxx;.cc;.tli;.tlh;.h;.hh;.hpp;.hxx;.hh;.inl;" +
- ".java;.js;.ts;.m;.mm;.proto;.protodevel;.td";
-
- public OptionPageGrid Clone()
- {
- // Use MemberwiseClone to copy value types.
- var clone = (OptionPageGrid)MemberwiseClone();
- return clone;
- }
-
- public class StyleConverter : TypeConverter
- {
- protected ArrayList values;
- public StyleConverter()
- {
- // Initializes the standard values list with defaults.
- values = new ArrayList(new string[] { "file", "Chromium", "Google", "LLVM", "Mozilla", "WebKit" });
- }
-
- public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
- {
- return true;
- }
-
- public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
- {
- return new StandardValuesCollection(values);
- }
-
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- if (sourceType == typeof(string))
- return true;
-
- return base.CanConvertFrom(context, sourceType);
- }
-
- public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
- {
- string s = value as string;
- if (s == null)
- return base.ConvertFrom(context, culture, value);
-
- return value;
- }
- }
-
- [Category("Format Options")]
- [DisplayName("Style")]
- [Description("Coding style, currently supports:\n" +
- " - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" +
- " - 'file' to search for a YAML .clang-format or _clang-format\n" +
- " configuration file.\n" +
- " - A YAML configuration snippet.\n\n" +
- "'File':\n" +
- " Searches for a .clang-format or _clang-format configuration file\n" +
- " in the source file's directory and its parents.\n\n" +
- "YAML configuration snippet:\n" +
- " The content of a .clang-format configuration file, as string.\n" +
- " Example: '{BasedOnStyle: \"LLVM\", IndentWidth: 8}'\n\n" +
- "See also: http://clang.llvm.org/docs/ClangFormatStyleOptions.html.")]
- [TypeConverter(typeof(StyleConverter))]
- public string Style
- {
- get { return style; }
- set { style = value; }
- }
-
- public sealed class FilenameConverter : TypeConverter
- {
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- if (sourceType == typeof(string))
- return true;
-
- return base.CanConvertFrom(context, sourceType);
- }
-
- public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
- {
- string s = value as string;
- if (s == null)
- return base.ConvertFrom(context, culture, value);
-
- // Check if string contains quotes. On Windows, file names cannot contain quotes.
- // We do not accept them however to avoid hard-to-debug problems.
- // A quote in user input would end the parameter quote and so break the command invocation.
- if (s.IndexOf('\"') != -1)
- throw new NotSupportedException("Filename cannot contain quotes");
-
- return value;
- }
- }
-
- [Category("Format Options")]
- [DisplayName("Assume Filename")]
- [Description("When reading from stdin, clang-format assumes this " +
- "filename to look for a style config file (with 'file' style) " +
- "and to determine the language.")]
- [TypeConverter(typeof(FilenameConverter))]
- public string AssumeFilename
- {
- get { return assumeFilename; }
- set { assumeFilename = value; }
- }
-
- public sealed class FallbackStyleConverter : StyleConverter
- {
- public FallbackStyleConverter()
- {
- // Add "none" to the list of styles.
- values.Insert(0, "none");
- }
- }
-
- [Category("Format Options")]
- [DisplayName("Fallback Style")]
- [Description("The name of the predefined style used as a fallback in case clang-format " +
- "is invoked with 'file' style, but can not find the configuration file.\n" +
- "Use 'none' fallback style to skip formatting.")]
- [TypeConverter(typeof(FallbackStyleConverter))]
- public string FallbackStyle
- {
- get { return fallbackStyle; }
- set { fallbackStyle = value; }
- }
-
- [Category("Format Options")]
- [DisplayName("Sort includes")]
- [Description("Sort touched include lines.\n\n" +
- "See also: http://clang.llvm.org/docs/ClangFormat.html.")]
- public bool SortIncludes
- {
- get { return sortIncludes; }
- set { sortIncludes = value; }
- }
-
- [Category("Format On Save")]
- [DisplayName("Enable")]
- [Description("Enable running clang-format when modified files are saved. " +
- "Will only format if Style is found (ignores Fallback Style)."
- )]
- public bool FormatOnSave
- {
- get { return formatOnSave; }
- set { formatOnSave = value; }
- }
-
- [Category("Format On Save")]
- [DisplayName("File extensions")]
- [Description("When formatting on save, clang-format will be applied only to " +
- "files with these extensions.")]
- public string FormatOnSaveFileExtensions
- {
- get { return formatOnSaveFileExtensions; }
- set { formatOnSaveFileExtensions = value; }
- }
- }
-
- [PackageRegistration(UseManagedResourcesOnly = true)]
- [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
- [ProvideMenuResource("Menus.ctmenu", 1)]
- [ProvideAutoLoad(UIContextGuids80.SolutionExists)] // Load package on solution load
- [Guid(GuidList.guidClangFormatPkgString)]
- [ProvideOptionPage(typeof(OptionPageGrid), "LLVM/Clang", "ClangFormat", 0, 0, true)]
- public sealed class ClangFormatPackage : Package
- {
- #region Package Members
-
- RunningDocTableEventsDispatcher _runningDocTableEventsDispatcher;
-
- protected override void Initialize()
- {
- base.Initialize();
-
- _runningDocTableEventsDispatcher = new RunningDocTableEventsDispatcher(this);
- _runningDocTableEventsDispatcher.BeforeSave += OnBeforeSave;
-
- var commandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
- if (commandService != null)
- {
- {
- var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatSelection);
- var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
- commandService.AddCommand(menuItem);
- }
-
- {
- var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatDocument);
- var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
- commandService.AddCommand(menuItem);
- }
- }
- }
- #endregion
-
- OptionPageGrid GetUserOptions()
- {
- return (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
- }
-
- private void MenuItemCallback(object sender, EventArgs args)
- {
- var mc = sender as System.ComponentModel.Design.MenuCommand;
- if (mc == null)
- return;
-
- switch (mc.CommandID.ID)
- {
- case (int)PkgCmdIDList.cmdidClangFormatSelection:
- FormatSelection(GetUserOptions());
- break;
-
- case (int)PkgCmdIDList.cmdidClangFormatDocument:
- FormatDocument(GetUserOptions());
- break;
- }
- }
-
- private static bool FileHasExtension(string filePath, string fileExtensions)
- {
- var extensions = fileExtensions.ToLower().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
- return extensions.Contains(Path.GetExtension(filePath).ToLower());
- }
-
- private void OnBeforeSave(object sender, Document document)
- {
- var options = GetUserOptions();
-
- if (!options.FormatOnSave)
- return;
-
- if (!FileHasExtension(document.FullName, options.FormatOnSaveFileExtensions))
- return;
-
- if (!Vsix.IsDocumentDirty(document))
- return;
-
- var optionsWithNoFallbackStyle = GetUserOptions().Clone();
- optionsWithNoFallbackStyle.FallbackStyle = "none";
- FormatDocument(document, optionsWithNoFallbackStyle);
- }
-
- /// <summary>
- /// Runs clang-format on the current selection
- /// </summary>
- private void FormatSelection(OptionPageGrid options)
- {
- IWpfTextView view = Vsix.GetCurrentView();
- if (view == null)
- // We're not in a text view.
- return;
- string text = view.TextBuffer.CurrentSnapshot.GetText();
- int start = view.Selection.Start.Position.GetContainingLine().Start.Position;
- int end = view.Selection.End.Position.GetContainingLine().End.Position;
- int length = end - start;
-
- // clang-format doesn't support formatting a range that starts at the end
- // of the file.
- if (start >= text.Length && text.Length > 0)
- start = text.Length - 1;
- string path = Vsix.GetDocumentParent(view);
- string filePath = Vsix.GetDocumentPath(view);
-
- RunClangFormatAndApplyReplacements(text, start, length, path, filePath, options, view);
- }
-
- /// <summary>
- /// Runs clang-format on the current document
- /// </summary>
- private void FormatDocument(OptionPageGrid options)
- {
- FormatView(Vsix.GetCurrentView(), options);
- }
-
- private void FormatDocument(Document document, OptionPageGrid options)
- {
- FormatView(Vsix.GetDocumentView(document), options);
- }
-
- private void FormatView(IWpfTextView view, OptionPageGrid options)
- {
- if (view == null)
- // We're not in a text view.
- return;
-
- string filePath = Vsix.GetDocumentPath(view);
- var path = Path.GetDirectoryName(filePath);
-
- string text = view.TextBuffer.CurrentSnapshot.GetText();
- if (!text.EndsWith(Environment.NewLine))
- {
- view.TextBuffer.Insert(view.TextBuffer.CurrentSnapshot.Length, Environment.NewLine);
- text += Environment.NewLine;
- }
-
- RunClangFormatAndApplyReplacements(text, 0, text.Length, path, filePath, options, view);
- }
-
- private void RunClangFormatAndApplyReplacements(string text, int offset, int length, string path, string filePath, OptionPageGrid options, IWpfTextView view)
- {
- try
- {
- string replacements = RunClangFormat(text, offset, length, path, filePath, options);
- ApplyClangFormatReplacements(replacements, view);
- }
- catch (Exception e)
- {
- var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
- var id = Guid.Empty;
- int result;
- uiShell.ShowMessageBox(
- 0, ref id,
- "Error while running clang-format:",
- e.Message,
- string.Empty, 0,
- OLEMSGBUTTON.OLEMSGBUTTON_OK,
- OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
- OLEMSGICON.OLEMSGICON_INFO,
- 0, out result);
- }
- }
-
- /// <summary>
- /// Runs the given text through clang-format and returns the replacements as XML.
- ///
- /// Formats the text range starting at offset of the given length.
- /// </summary>
- private static string RunClangFormat(string text, int offset, int length, string path, string filePath, OptionPageGrid options)
- {
- string vsixPath = Path.GetDirectoryName(
- typeof(ClangFormatPackage).Assembly.Location);
-
- System.Diagnostics.Process process = new System.Diagnostics.Process();
- process.StartInfo.UseShellExecute = false;
- process.StartInfo.FileName = vsixPath + "\\clang-format.exe";
- // Poor man's escaping - this will not work when quotes are already escaped
- // in the input (but we don't need more).
- string style = options.Style.Replace("\"", "\\\"");
- string fallbackStyle = options.FallbackStyle.Replace("\"", "\\\"");
- process.StartInfo.Arguments = " -offset " + offset +
- " -length " + length +
- " -output-replacements-xml " +
- " -style \"" + style + "\"" +
- " -fallback-style \"" + fallbackStyle + "\"";
- if (options.SortIncludes)
- process.StartInfo.Arguments += " -sort-includes ";
- string assumeFilename = options.AssumeFilename;
- if (string.IsNullOrEmpty(assumeFilename))
- assumeFilename = filePath;
- if (!string.IsNullOrEmpty(assumeFilename))
- process.StartInfo.Arguments += " -assume-filename \"" + assumeFilename + "\"";
- process.StartInfo.CreateNoWindow = true;
- process.StartInfo.RedirectStandardInput = true;
- process.StartInfo.RedirectStandardOutput = true;
- process.StartInfo.RedirectStandardError = true;
- if (path != null)
- process.StartInfo.WorkingDirectory = path;
- // We have to be careful when communicating via standard input / output,
- // as writes to the buffers will block until they are read from the other side.
- // Thus, we:
- // 1. Start the process - clang-format.exe will start to read the input from the
- // standard input.
- try
- {
- process.Start();
- }
- catch (Exception e)
- {
- throw new Exception(
- "Cannot execute " + process.StartInfo.FileName + ".\n\"" +
- e.Message + "\".\nPlease make sure it is on the PATH.");
- }
- // 2. We write everything to the standard output - this cannot block, as clang-format
- // reads the full standard input before analyzing it without writing anything to the
- // standard output.
- process.StandardInput.Write(text);
- // 3. We notify clang-format that the input is done - after this point clang-format
- // will start analyzing the input and eventually write the output.
- process.StandardInput.Close();
- // 4. We must read clang-format's output before waiting for it to exit; clang-format
- // will close the channel by exiting.
- string output = process.StandardOutput.ReadToEnd();
- // 5. clang-format is done, wait until it is fully shut down.
- process.WaitForExit();
- if (process.ExitCode != 0)
- {
- // FIXME: If clang-format writes enough to the standard error stream to block,
- // we will never reach this point; instead, read the standard error asynchronously.
- throw new Exception(process.StandardError.ReadToEnd());
- }
- return output;
- }
-
- /// <summary>
- /// Applies the clang-format replacements (xml) to the current view
- /// </summary>
- private static void ApplyClangFormatReplacements(string replacements, IWpfTextView view)
- {
- // clang-format returns no replacements if input text is empty
- if (replacements.Length == 0)
- return;
-
- var root = XElement.Parse(replacements);
- var edit = view.TextBuffer.CreateEdit();
- foreach (XElement replacement in root.Descendants("replacement"))
- {
- var span = new Span(
- int.Parse(replacement.Attribute("offset").Value),
- int.Parse(replacement.Attribute("length").Value));
- edit.Replace(span, replacement.Value);
- }
- edit.Apply();
- }
- }
-}
+//===-- ClangFormatPackages.cs - VSPackage for clang-format ------*- C# -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This class contains a VS extension package that runs clang-format over a
+// selection in a VS text editor.
+//
+//===----------------------------------------------------------------------===//
+
+using EnvDTE;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Editor;
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Xml.Linq;
+using System.Linq;
+
+namespace LLVM.ClangFormat
+{
+ [ClassInterface(ClassInterfaceType.AutoDual)]
+ [CLSCompliant(false), ComVisible(true)]
+ public class OptionPageGrid : DialogPage
+ {
+ private string assumeFilename = "";
+ private string fallbackStyle = "LLVM";
+ private bool sortIncludes = false;
+ private string style = "file";
+ private bool formatOnSave = false;
+ private string formatOnSaveFileExtensions =
+ ".c;.cpp;.cxx;.cc;.tli;.tlh;.h;.hh;.hpp;.hxx;.hh;.inl;" +
+ ".java;.js;.ts;.m;.mm;.proto;.protodevel;.td";
+
+ public OptionPageGrid Clone()
+ {
+ // Use MemberwiseClone to copy value types.
+ var clone = (OptionPageGrid)MemberwiseClone();
+ return clone;
+ }
+
+ public class StyleConverter : TypeConverter
+ {
+ protected ArrayList values;
+ public StyleConverter()
+ {
+ // Initializes the standard values list with defaults.
+ values = new ArrayList(new string[] { "file", "Chromium", "Google", "LLVM", "Mozilla", "WebKit" });
+ }
+
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
+ {
+ return new StandardValuesCollection(values);
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ return true;
+
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom(context, culture, value);
+
+ return value;
+ }
+ }
+
+ [Category("Format Options")]
+ [DisplayName("Style")]
+ [Description("Coding style, currently supports:\n" +
+ " - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" +
+ " - 'file' to search for a YAML .clang-format or _clang-format\n" +
+ " configuration file.\n" +
+ " - A YAML configuration snippet.\n\n" +
+ "'File':\n" +
+ " Searches for a .clang-format or _clang-format configuration file\n" +
+ " in the source file's directory and its parents.\n\n" +
+ "YAML configuration snippet:\n" +
+ " The content of a .clang-format configuration file, as string.\n" +
+ " Example: '{BasedOnStyle: \"LLVM\", IndentWidth: 8}'\n\n" +
+ "See also: http://clang.llvm.org/docs/ClangFormatStyleOptions.html.")]
+ [TypeConverter(typeof(StyleConverter))]
+ public string Style
+ {
+ get { return style; }
+ set { style = value; }
+ }
+
+ public sealed class FilenameConverter : TypeConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ return true;
+
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom(context, culture, value);
+
+ // Check if string contains quotes. On Windows, file names cannot contain quotes.
+ // We do not accept them however to avoid hard-to-debug problems.
+ // A quote in user input would end the parameter quote and so break the command invocation.
+ if (s.IndexOf('\"') != -1)
+ throw new NotSupportedException("Filename cannot contain quotes");
+
+ return value;
+ }
+ }
+
+ [Category("Format Options")]
+ [DisplayName("Assume Filename")]
+ [Description("When reading from stdin, clang-format assumes this " +
+ "filename to look for a style config file (with 'file' style) " +
+ "and to determine the language.")]
+ [TypeConverter(typeof(FilenameConverter))]
+ public string AssumeFilename
+ {
+ get { return assumeFilename; }
+ set { assumeFilename = value; }
+ }
+
+ public sealed class FallbackStyleConverter : StyleConverter
+ {
+ public FallbackStyleConverter()
+ {
+ // Add "none" to the list of styles.
+ values.Insert(0, "none");
+ }
+ }
+
+ [Category("Format Options")]
+ [DisplayName("Fallback Style")]
+ [Description("The name of the predefined style used as a fallback in case clang-format " +
+ "is invoked with 'file' style, but can not find the configuration file.\n" +
+ "Use 'none' fallback style to skip formatting.")]
+ [TypeConverter(typeof(FallbackStyleConverter))]
+ public string FallbackStyle
+ {
+ get { return fallbackStyle; }
+ set { fallbackStyle = value; }
+ }
+
+ [Category("Format Options")]
+ [DisplayName("Sort includes")]
+ [Description("Sort touched include lines.\n\n" +
+ "See also: http://clang.llvm.org/docs/ClangFormat.html.")]
+ public bool SortIncludes
+ {
+ get { return sortIncludes; }
+ set { sortIncludes = value; }
+ }
+
+ [Category("Format On Save")]
+ [DisplayName("Enable")]
+ [Description("Enable running clang-format when modified files are saved. " +
+ "Will only format if Style is found (ignores Fallback Style)."
+ )]
+ public bool FormatOnSave
+ {
+ get { return formatOnSave; }
+ set { formatOnSave = value; }
+ }
+
+ [Category("Format On Save")]
+ [DisplayName("File extensions")]
+ [Description("When formatting on save, clang-format will be applied only to " +
+ "files with these extensions.")]
+ public string FormatOnSaveFileExtensions
+ {
+ get { return formatOnSaveFileExtensions; }
+ set { formatOnSaveFileExtensions = value; }
+ }
+ }
+
+ [PackageRegistration(UseManagedResourcesOnly = true)]
+ [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
+ [ProvideMenuResource("Menus.ctmenu", 1)]
+ [ProvideAutoLoad(UIContextGuids80.SolutionExists)] // Load package on solution load
+ [Guid(GuidList.guidClangFormatPkgString)]
+ [ProvideOptionPage(typeof(OptionPageGrid), "LLVM/Clang", "ClangFormat", 0, 0, true)]
+ public sealed class ClangFormatPackage : Package
+ {
+ #region Package Members
+
+ RunningDocTableEventsDispatcher _runningDocTableEventsDispatcher;
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ _runningDocTableEventsDispatcher = new RunningDocTableEventsDispatcher(this);
+ _runningDocTableEventsDispatcher.BeforeSave += OnBeforeSave;
+
+ var commandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
+ if (commandService != null)
+ {
+ {
+ var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatSelection);
+ var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+ commandService.AddCommand(menuItem);
+ }
+
+ {
+ var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatDocument);
+ var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+ commandService.AddCommand(menuItem);
+ }
+ }
+ }
+ #endregion
+
+ OptionPageGrid GetUserOptions()
+ {
+ return (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
+ }
+
+ private void MenuItemCallback(object sender, EventArgs args)
+ {
+ var mc = sender as System.ComponentModel.Design.MenuCommand;
+ if (mc == null)
+ return;
+
+ switch (mc.CommandID.ID)
+ {
+ case (int)PkgCmdIDList.cmdidClangFormatSelection:
+ FormatSelection(GetUserOptions());
+ break;
+
+ case (int)PkgCmdIDList.cmdidClangFormatDocument:
+ FormatDocument(GetUserOptions());
+ break;
+ }
+ }
+
+ private static bool FileHasExtension(string filePath, string fileExtensions)
+ {
+ var extensions = fileExtensions.ToLower().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
+ return extensions.Contains(Path.GetExtension(filePath).ToLower());
+ }
+
+ private void OnBeforeSave(object sender, Document document)
+ {
+ var options = GetUserOptions();
+
+ if (!options.FormatOnSave)
+ return;
+
+ if (!FileHasExtension(document.FullName, options.FormatOnSaveFileExtensions))
+ return;
+
+ if (!Vsix.IsDocumentDirty(document))
+ return;
+
+ var optionsWithNoFallbackStyle = GetUserOptions().Clone();
+ optionsWithNoFallbackStyle.FallbackStyle = "none";
+ FormatDocument(document, optionsWithNoFallbackStyle);
+ }
+
+ /// <summary>
+ /// Runs clang-format on the current selection
+ /// </summary>
+ private void FormatSelection(OptionPageGrid options)
+ {
+ IWpfTextView view = Vsix.GetCurrentView();
+ if (view == null)
+ // We're not in a text view.
+ return;
+ string text = view.TextBuffer.CurrentSnapshot.GetText();
+ int start = view.Selection.Start.Position.GetContainingLine().Start.Position;
+ int end = view.Selection.End.Position.GetContainingLine().End.Position;
+ int length = end - start;
+
+ // clang-format doesn't support formatting a range that starts at the end
+ // of the file.
+ if (start >= text.Length && text.Length > 0)
+ start = text.Length - 1;
+ string path = Vsix.GetDocumentParent(view);
+ string filePath = Vsix.GetDocumentPath(view);
+
+ RunClangFormatAndApplyReplacements(text, start, length, path, filePath, options, view);
+ }
+
+ /// <summary>
+ /// Runs clang-format on the current document
+ /// </summary>
+ private void FormatDocument(OptionPageGrid options)
+ {
+ FormatView(Vsix.GetCurrentView(), options);
+ }
+
+ private void FormatDocument(Document document, OptionPageGrid options)
+ {
+ FormatView(Vsix.GetDocumentView(document), options);
+ }
+
+ private void FormatView(IWpfTextView view, OptionPageGrid options)
+ {
+ if (view == null)
+ // We're not in a text view.
+ return;
+
+ string filePath = Vsix.GetDocumentPath(view);
+ var path = Path.GetDirectoryName(filePath);
+
+ string text = view.TextBuffer.CurrentSnapshot.GetText();
+ if (!text.EndsWith(Environment.NewLine))
+ {
+ view.TextBuffer.Insert(view.TextBuffer.CurrentSnapshot.Length, Environment.NewLine);
+ text += Environment.NewLine;
+ }
+
+ RunClangFormatAndApplyReplacements(text, 0, text.Length, path, filePath, options, view);
+ }
+
+ private void RunClangFormatAndApplyReplacements(string text, int offset, int length, string path, string filePath, OptionPageGrid options, IWpfTextView view)
+ {
+ try
+ {
+ string replacements = RunClangFormat(text, offset, length, path, filePath, options);
+ ApplyClangFormatReplacements(replacements, view);
+ }
+ catch (Exception e)
+ {
+ var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
+ var id = Guid.Empty;
+ int result;
+ uiShell.ShowMessageBox(
+ 0, ref id,
+ "Error while running clang-format:",
+ e.Message,
+ string.Empty, 0,
+ OLEMSGBUTTON.OLEMSGBUTTON_OK,
+ OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
+ OLEMSGICON.OLEMSGICON_INFO,
+ 0, out result);
+ }
+ }
+
+ /// <summary>
+ /// Runs the given text through clang-format and returns the replacements as XML.
+ ///
+ /// Formats the text range starting at offset of the given length.
+ /// </summary>
+ private static string RunClangFormat(string text, int offset, int length, string path, string filePath, OptionPageGrid options)
+ {
+ string vsixPath = Path.GetDirectoryName(
+ typeof(ClangFormatPackage).Assembly.Location);
+
+ System.Diagnostics.Process process = new System.Diagnostics.Process();
+ process.StartInfo.UseShellExecute = false;
+ process.StartInfo.FileName = vsixPath + "\\clang-format.exe";
+ // Poor man's escaping - this will not work when quotes are already escaped
+ // in the input (but we don't need more).
+ string style = options.Style.Replace("\"", "\\\"");
+ string fallbackStyle = options.FallbackStyle.Replace("\"", "\\\"");
+ process.StartInfo.Arguments = " -offset " + offset +
+ " -length " + length +
+ " -output-replacements-xml " +
+ " -style \"" + style + "\"" +
+ " -fallback-style \"" + fallbackStyle + "\"";
+ if (options.SortIncludes)
+ process.StartInfo.Arguments += " -sort-includes ";
+ string assumeFilename = options.AssumeFilename;
+ if (string.IsNullOrEmpty(assumeFilename))
+ assumeFilename = filePath;
+ if (!string.IsNullOrEmpty(assumeFilename))
+ process.StartInfo.Arguments += " -assume-filename \"" + assumeFilename + "\"";
+ process.StartInfo.CreateNoWindow = true;
+ process.StartInfo.RedirectStandardInput = true;
+ process.StartInfo.RedirectStandardOutput = true;
+ process.StartInfo.RedirectStandardError = true;
+ if (path != null)
+ process.StartInfo.WorkingDirectory = path;
+ // We have to be careful when communicating via standard input / output,
+ // as writes to the buffers will block until they are read from the other side.
+ // Thus, we:
+ // 1. Start the process - clang-format.exe will start to read the input from the
+ // standard input.
+ try
+ {
+ process.Start();
+ }
+ catch (Exception e)
+ {
+ throw new Exception(
+ "Cannot execute " + process.StartInfo.FileName + ".\n\"" +
+ e.Message + "\".\nPlease make sure it is on the PATH.");
+ }
+ // 2. We write everything to the standard output - this cannot block, as clang-format
+ // reads the full standard input before analyzing it without writing anything to the
+ // standard output.
+ process.StandardInput.Write(text);
+ // 3. We notify clang-format that the input is done - after this point clang-format
+ // will start analyzing the input and eventually write the output.
+ process.StandardInput.Close();
+ // 4. We must read clang-format's output before waiting for it to exit; clang-format
+ // will close the channel by exiting.
+ string output = process.StandardOutput.ReadToEnd();
+ // 5. clang-format is done, wait until it is fully shut down.
+ process.WaitForExit();
+ if (process.ExitCode != 0)
+ {
+ // FIXME: If clang-format writes enough to the standard error stream to block,
+ // we will never reach this point; instead, read the standard error asynchronously.
+ throw new Exception(process.StandardError.ReadToEnd());
+ }
+ return output;
+ }
+
+ /// <summary>
+ /// Applies the clang-format replacements (xml) to the current view
+ /// </summary>
+ private static void ApplyClangFormatReplacements(string replacements, IWpfTextView view)
+ {
+ // clang-format returns no replacements if input text is empty
+ if (replacements.Length == 0)
+ return;
+
+ var root = XElement.Parse(replacements);
+ var edit = view.TextBuffer.CreateEdit();
+ foreach (XElement replacement in root.Descendants("replacement"))
+ {
+ var span = new Span(
+ int.Parse(replacement.Attribute("offset").Value),
+ int.Parse(replacement.Attribute("length").Value));
+ edit.Replace(span, replacement.Value);
+ }
+ edit.Apply();
+ }
+ }
+}
diff --git a/tools/clang-format-vs/ClangFormat/Guids.cs b/tools/clang-format-vs/ClangFormat/Guids.cs
index c045224cd0..ed1c12d61e 100644
--- a/tools/clang-format-vs/ClangFormat/Guids.cs
+++ b/tools/clang-format-vs/ClangFormat/Guids.cs
@@ -9,4 +9,4 @@ namespace LLVM.ClangFormat
public static readonly Guid guidClangFormatCmdSet = new Guid(guidClangFormatCmdSetString);
};
-} \ No newline at end of file
+}
diff --git a/tools/clang-format-vs/ClangFormat/PkgCmdID.cs b/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
index fcc31ee95b..c274d1ca1b 100644
--- a/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
+++ b/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
@@ -5,4 +5,4 @@
public const uint cmdidClangFormatSelection = 0x100;
public const uint cmdidClangFormatDocument = 0x101;
};
-} \ No newline at end of file
+}
diff --git a/tools/clang-format-vs/ClangFormat/license.txt b/tools/clang-format-vs/ClangFormat/license.txt
index 76aa2afdf8..63c17f148e 100644
--- a/tools/clang-format-vs/ClangFormat/license.txt
+++ b/tools/clang-format-vs/ClangFormat/license.txt
@@ -1,6 +1,241 @@
-====================
-LLVM Release License
-====================
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+ `LICENSE` file at the top containing the specific license and restrictions
+ which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+ file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
+==============================================================================
University of Illinois/NCSA
Open Source License
@@ -24,16 +259,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
* Neither the names of the LLVM Team, University of Illinois at Urbana-Champaign, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
-
-====================
-The LLVM software contains code written by third parties. Such software will have its own individual LICENSE.TXT file in the directory in which it appears. This file will describe the copyrights, license, and restrictions which apply
-to that code.
-
-The disclaimer of warranty in the University of Illinois Open Source License applies to all code in the LLVM Distribution, and nothing in any of the other licenses gives permission to use the names of the LLVM Team or the University of Illinois to endorse or promote products derived from this Software.
-
-The following pieces of software have additional or alternate copyrights, licenses, and/or restrictions:
-
-Program Directory
-------- ---------
-<none yet>
-
diff --git a/tools/clang-format-vs/source.extension.vsixmanifest.in b/tools/clang-format-vs/source.extension.vsixmanifest.in
index cf7186f73a..8afd362c61 100644
--- a/tools/clang-format-vs/source.extension.vsixmanifest.in
+++ b/tools/clang-format-vs/source.extension.vsixmanifest.in
@@ -8,7 +8,7 @@
<License>license.txt</License>
</Metadata>
<Installation InstalledByMsi="false">
- <InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[11.0, 15.0]" />
+ <InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[11.0, 16.0]" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.VisualStudio.MPF" MinVersion="11.0" DisplayName="Visual Studio MPF" />
diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp
index 49162d0d91..655a8d8e87 100644
--- a/tools/clang-format/ClangFormat.cpp
+++ b/tools/clang-format/ClangFormat.cpp
@@ -1,9 +1,8 @@
//===-- clang-format/ClangFormat.cpp - Clang format tool ------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
///
@@ -346,7 +345,7 @@ int main(int argc, const char **argv) {
cl::SetVersionPrinter(PrintVersion);
cl::ParseCommandLineOptions(
argc, argv,
- "A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.\n\n"
+ "A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code.\n\n"
"If no arguments are specified, it formats the code from standard input\n"
"and writes the result to the standard output.\n"
"If <file>s are given, it reformats the files. If -i is specified\n"
diff --git a/tools/clang-format/clang-format-diff.py b/tools/clang-format/clang-format-diff.py
index d6d3510416..3ba0abefc9 100755
--- a/tools/clang-format/clang-format-diff.py
+++ b/tools/clang-format/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
#
#===------------------------------------------------------------------------===#
@@ -67,7 +66,7 @@ def main():
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:
@@ -80,7 +79,7 @@ def main():
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/tools/clang-format/clang-format-test.el b/tools/clang-format/clang-format-test.el
index 0e1f4dde40..0defe7452c 100644
--- a/tools/clang-format/clang-format-test.el
+++ b/tools/clang-format/clang-format-test.el
@@ -4,8 +4,9 @@
;; Author: Philipp Stephani <phst@google.com>
-;; 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
;;; Commentary:
diff --git a/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp b/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
index 0c9ae848d5..d39d8da0cc 100644
--- a/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
+++ b/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
@@ -1,9 +1,8 @@
//===-- ClangFormatFuzzer.cpp - Fuzz the Clang format tool ----------------===//
//
-// 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/tools/clang-format/git-clang-format b/tools/clang-format/git-clang-format
index 96e3b4e8a2..2696d099e4 100755
--- a/tools/clang-format/git-clang-format
+++ b/tools/clang-format/git-clang-format
@@ -2,10 +2,9 @@
#
#===- git-clang-format - ClangFormat Git Integration ---------*- 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/tools/clang-fuzzer/ClangFuzzer.cpp b/tools/clang-fuzzer/ClangFuzzer.cpp
index f169f58a39..3a14f4949c 100644
--- a/tools/clang-fuzzer/ClangFuzzer.cpp
+++ b/tools/clang-fuzzer/ClangFuzzer.cpp
@@ -1,9 +1,8 @@
//===-- ClangFuzzer.cpp - Fuzz Clang --------------------------------------===//
//
-// 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/tools/clang-fuzzer/Dockerfile b/tools/clang-fuzzer/Dockerfile
index 9f6336c479..a0c361dd96 100644
--- a/tools/clang-fuzzer/Dockerfile
+++ b/tools/clang-fuzzer/Dockerfile
@@ -1,9 +1,8 @@
#===- llvm/tools/clang/tools/clang-fuzzer ---------------------------------===//
#
-# 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
#
#===----------------------------------------------------------------------===//
# Produces an image that builds clang-proto-fuzzer
diff --git a/tools/clang-fuzzer/DummyClangFuzzer.cpp b/tools/clang-fuzzer/DummyClangFuzzer.cpp
index 382c161307..78fd801438 100644
--- a/tools/clang-fuzzer/DummyClangFuzzer.cpp
+++ b/tools/clang-fuzzer/DummyClangFuzzer.cpp
@@ -1,9 +1,8 @@
//===-- DummyClangFuzzer.cpp - Entry point to sanity check fuzzers --------===//
//
-// 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/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp b/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
index 347ba1c320..2401299be1 100644
--- a/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
+++ b/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
@@ -1,9 +1,8 @@
//===-- ExampleClangLLVMProtoFuzzer.cpp - Fuzz Clang ----------------------===//
//
-// 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/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp b/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
index 3640be13fa..a9a03f1f46 100644
--- a/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
+++ b/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
@@ -1,9 +1,8 @@
//===-- ExampleClangLoopProtoFuzzer.cpp - Fuzz Clang ----------------------===//
//
-// 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/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp b/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
index 159ded3ca1..651f5c99a8 100644
--- a/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ b/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -1,9 +1,8 @@
//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --------------------------===//
//
-// 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/tools/clang-fuzzer/cxx_loop_proto.proto b/tools/clang-fuzzer/cxx_loop_proto.proto
index 760904b579..360042d382 100644
--- a/tools/clang-fuzzer/cxx_loop_proto.proto
+++ b/tools/clang-fuzzer/cxx_loop_proto.proto
@@ -1,9 +1,8 @@
//===-- cxx_loop_proto.proto - Protobuf description of C++ with for loops -===//
//
-// 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/tools/clang-fuzzer/cxx_proto.proto b/tools/clang-fuzzer/cxx_proto.proto
index 499101fc0f..eaf69d1844 100644
--- a/tools/clang-fuzzer/cxx_proto.proto
+++ b/tools/clang-fuzzer/cxx_proto.proto
@@ -1,9 +1,8 @@
//===-- cxx_proto.proto - Protobuf description of C++ ---------------------===//
//
-// 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/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp b/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
index 75bf22803b..20cf98896e 100644
--- a/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
+++ b/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
@@ -1,9 +1,8 @@
//===-- fuzzer_initialize.cpp - Fuzz Clang --------------------------------===//
//
-// 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/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h b/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
index 83a5cf9dc5..9f32d6396b 100644
--- a/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
+++ b/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
@@ -1,9 +1,8 @@
//==-- fuzzer_initialize.h - Fuzz Clang ------------------------------------==//
//
-// 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/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp b/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
index 4985fedbe1..bc172f2373 100644
--- a/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
+++ b/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
@@ -1,9 +1,8 @@
//==-- handle_cxx.cpp - Helper function for Clang fuzzers ------------------==//
//
-// 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/tools/clang-fuzzer/handle-cxx/handle_cxx.h b/tools/clang-fuzzer/handle-cxx/handle_cxx.h
index e76311ff39..8359bea969 100644
--- a/tools/clang-fuzzer/handle-cxx/handle_cxx.h
+++ b/tools/clang-fuzzer/handle-cxx/handle_cxx.h
@@ -1,9 +1,8 @@
//==-- handle_cxx.h - Helper function for Clang fuzzers --------------------==//
//
-// 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/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
index 86df06ab8b..d0d35d51e8 100644
--- a/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ b/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -1,9 +1,8 @@
//==-- handle_llvm.cpp - Helper function for Clang fuzzers -----------------==//
//
-// 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/tools/clang-fuzzer/handle-llvm/handle_llvm.h b/tools/clang-fuzzer/handle-llvm/handle_llvm.h
index 1149c29cef..36e1a5f1aa 100644
--- a/tools/clang-fuzzer/handle-llvm/handle_llvm.h
+++ b/tools/clang-fuzzer/handle-llvm/handle_llvm.h
@@ -1,9 +1,8 @@
//==-- handle_llvm.h - Helper function for Clang fuzzers -------------------==//
//
-// 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/tools/clang-fuzzer/handle-llvm/input_arrays.h b/tools/clang-fuzzer/handle-llvm/input_arrays.h
index b60e3e1b2e..4b03d01bab 100644
--- a/tools/clang-fuzzer/handle-llvm/input_arrays.h
+++ b/tools/clang-fuzzer/handle-llvm/input_arrays.h
@@ -1,9 +1,8 @@
//==-- input_arrays.h - Helper function for LLVM fuzzer inputs -------------==//
//
-// 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/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp b/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
index 698e0fed8b..114f5fc40e 100644
--- a/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ b/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -1,9 +1,8 @@
//==-- loop_proto_to_cxx.cpp - Protobuf-C++ conversion ---------------------==//
//
-// 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/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp b/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
index a4b8e58c12..15f0ace9a1 100644
--- a/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
+++ b/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -1,9 +1,8 @@
//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -----==//
//
-// 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/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
index 4a86515f55..029b42ae0e 100644
--- a/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
+++ b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -1,9 +1,8 @@
//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --------------------------==//
//
-// 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/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
index 8d2e2e6f00..204f66de06 100644
--- a/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
+++ b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -1,9 +1,8 @@
//==-- proto_to_cxx.h - Protobuf-C++ conversion ----------------------------==//
//
-// 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/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
index 73ef14b755..67ff01a31d 100644
--- a/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
+++ b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -1,9 +1,8 @@
//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion ----------==//
//
-// 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/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp b/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
index ffbb1c9f0d..409570c3f0 100644
--- a/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ b/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -1,10 +1,9 @@
//==-- loop_proto_to_llvm.cpp - Protobuf-C++ conversion
//---------------------==//
//
-// 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/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h b/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
index 51660fcb71..173b937e52 100644
--- a/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
+++ b/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
@@ -1,9 +1,8 @@
//==-- loop_proto_to_llvm.h - Protobuf-C++ conversion ----------------------------==//
//
-// 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/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm_main.cpp b/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm_main.cpp
index 17ca15ec27..e8b19158f7 100644
--- a/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm_main.cpp
+++ b/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm_main.cpp
@@ -1,9 +1,8 @@
//==-- loop_proto_to_llvm_main.cpp - Driver for protobuf-LLVM conversion----==//
//
-// 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/tools/clang-import-test/clang-import-test.cpp b/tools/clang-import-test/clang-import-test.cpp
index a7e749c646..b1078acdda 100644
--- a/tools/clang-import-test/clang-import-test.cpp
+++ b/tools/clang-import-test/clang-import-test.cpp
@@ -1,9 +1,8 @@
-//===-- import-test.cpp - ASTImporter/ExternalASTSource testbed -----------===//
+//===-- clang-import-test.cpp - ASTImporter/ExternalASTSource testbed -----===//
//
-// 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
//
//===----------------------------------------------------------------------===//
@@ -103,7 +102,8 @@ private:
unsigned LocColumn =
SM.getSpellingColumnNumber(Loc, /*Invalid=*/nullptr) - 1;
FileID FID = SM.getFileID(Loc);
- llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
+ const llvm::MemoryBuffer *Buffer =
+ SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
assert(LocData >= Buffer->getBufferStart() &&
LocData < Buffer->getBufferEnd());
diff --git a/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 29cd9848d1..4e7cdd6c91 100644
--- a/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -1,9 +1,8 @@
//===-- clang-offload-bundler/ClangOffloadBundler.cpp ---------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
///
@@ -293,7 +292,7 @@ public:
ReadChars += TripleSize;
// Check if the offset and size make sense.
- if (!Size || !Offset || Offset + Size > FC.size())
+ if (!Offset || Offset + Size > FC.size())
return;
assert(BundlesInfo.find(Triple) == BundlesInfo.end() &&
diff --git a/tools/clang-refactor/ClangRefactor.cpp b/tools/clang-refactor/ClangRefactor.cpp
index e64f325be2..f7ca39fcfe 100644
--- a/tools/clang-refactor/ClangRefactor.cpp
+++ b/tools/clang-refactor/ClangRefactor.cpp
@@ -1,9 +1,8 @@
//===--- ClangRefactor.cpp - Clang-based refactoring tool -----------------===//
//
-// 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/tools/clang-refactor/TestSupport.cpp b/tools/clang-refactor/TestSupport.cpp
index f81f4a8bc8..bad640227f 100644
--- a/tools/clang-refactor/TestSupport.cpp
+++ b/tools/clang-refactor/TestSupport.cpp
@@ -1,9 +1,8 @@
//===--- TestSupport.cpp - Clang-based refactoring tool -------------------===//
//
-// 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/tools/clang-refactor/TestSupport.h b/tools/clang-refactor/TestSupport.h
index 779006b0c5..1282c3a90f 100644
--- a/tools/clang-refactor/TestSupport.h
+++ b/tools/clang-refactor/TestSupport.h
@@ -1,9 +1,8 @@
//===--- TestSupport.h - Clang-based refactoring tool -----------*- C++ -*-===//
//
-// 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/tools/clang-refactor/ToolRefactoringResultConsumer.h b/tools/clang-refactor/ToolRefactoringResultConsumer.h
index 64a994d88b..b69f9d673f 100644
--- a/tools/clang-refactor/ToolRefactoringResultConsumer.h
+++ b/tools/clang-refactor/ToolRefactoringResultConsumer.h
@@ -1,9 +1,8 @@
//===--- ToolRefactoringResultConsumer.h - ----------------------*- C++ -*-===//
//
-// 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/tools/clang-rename/ClangRename.cpp b/tools/clang-rename/ClangRename.cpp
index d58f44e4d4..071d3cb90f 100644
--- a/tools/clang-rename/ClangRename.cpp
+++ b/tools/clang-rename/ClangRename.cpp
@@ -1,9 +1,8 @@
//===--- tools/extra/clang-rename/ClangRename.cpp - Clang rename tool -----===//
//
-// 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/tools/diagtool/CMakeLists.txt b/tools/diagtool/CMakeLists.txt
index 96d1c39024..80d787b12f 100644
--- a/tools/diagtool/CMakeLists.txt
+++ b/tools/diagtool/CMakeLists.txt
@@ -23,7 +23,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
COMPONENT diagtool
RUNTIME DESTINATION bin)
- if (NOT CMAKE_CONFIGURATION_TYPES)
+ if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-diagtool
DEPENDS diagtool
COMPONENT diagtool)
diff --git a/tools/diagtool/DiagTool.cpp b/tools/diagtool/DiagTool.cpp
index 1690a4456c..6cd67cca39 100644
--- a/tools/diagtool/DiagTool.cpp
+++ b/tools/diagtool/DiagTool.cpp
@@ -1,9 +1,8 @@
//===- DiagTool.cpp - Classes for defining diagtool tools -------------------===//
//
-// 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/tools/diagtool/DiagTool.h b/tools/diagtool/DiagTool.h
index 04b926df3b..1d9da75bf3 100644
--- a/tools/diagtool/DiagTool.h
+++ b/tools/diagtool/DiagTool.h
@@ -1,9 +1,8 @@
//===- DiagTool.h - Classes for defining diagtool tools -------------------===//
//
-// 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/tools/diagtool/DiagnosticNames.cpp b/tools/diagtool/DiagnosticNames.cpp
index b0ca7f9806..cc7385a11a 100644
--- a/tools/diagtool/DiagnosticNames.cpp
+++ b/tools/diagtool/DiagnosticNames.cpp
@@ -1,9 +1,8 @@
//===- DiagnosticNames.cpp - Defines a table of all builtin diagnostics ----==//
//
-// 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/tools/diagtool/DiagnosticNames.h b/tools/diagtool/DiagnosticNames.h
index fba5909594..d8fd6401ef 100644
--- a/tools/diagtool/DiagnosticNames.h
+++ b/tools/diagtool/DiagnosticNames.h
@@ -1,9 +1,8 @@
//===- DiagnosticNames.h - Defines a table of all builtin diagnostics ------==//
//
-// 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/tools/diagtool/FindDiagnosticID.cpp b/tools/diagtool/FindDiagnosticID.cpp
index db6fe5e472..2a08814478 100644
--- a/tools/diagtool/FindDiagnosticID.cpp
+++ b/tools/diagtool/FindDiagnosticID.cpp
@@ -1,9 +1,8 @@
//===- FindDiagnosticID.cpp - diagtool tool for finding diagnostic id -----===//
//
-// 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/tools/diagtool/ListWarnings.cpp b/tools/diagtool/ListWarnings.cpp
index eae6301250..a71f6e3a66 100644
--- a/tools/diagtool/ListWarnings.cpp
+++ b/tools/diagtool/ListWarnings.cpp
@@ -1,9 +1,8 @@
//===- ListWarnings.h - diagtool tool for printing warning flags ----------===//
//
-// 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/tools/diagtool/ShowEnabledWarnings.cpp b/tools/diagtool/ShowEnabledWarnings.cpp
index 513abc15b2..ae2d3e37e8 100644
--- a/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/tools/diagtool/ShowEnabledWarnings.cpp
@@ -1,9 +1,8 @@
//===- ShowEnabledWarnings - diagtool tool for printing enabled flags -----===//
//
-// 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/tools/diagtool/TreeView.cpp b/tools/diagtool/TreeView.cpp
index 4919c17282..c3c4d5f6d2 100644
--- a/tools/diagtool/TreeView.cpp
+++ b/tools/diagtool/TreeView.cpp
@@ -1,9 +1,8 @@
//===- TreeView.cpp - diagtool tool for printing warning flags ------------===//
//
-// 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/tools/diagtool/diagtool_main.cpp b/tools/diagtool/diagtool_main.cpp
index 4eef54dbfe..7cbe93de9c 100644
--- a/tools/diagtool/diagtool_main.cpp
+++ b/tools/diagtool/diagtool_main.cpp
@@ -1,9 +1,8 @@
//===- diagtool_main.h - Entry point for invoking all diagnostic tools ----===//
//
-// 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/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt
index 89a3aa3ced..30ab163a6c 100644
--- a/tools/driver/CMakeLists.txt
+++ b/tools/driver/CMakeLists.txt
@@ -60,7 +60,7 @@ if(CLANG_PLUGIN_SUPPORT)
export_executable_symbols(clang)
endif()
-add_dependencies(clang clang-headers)
+add_dependencies(clang clang-resource-headers)
if(NOT CLANG_LINKS_TO_CREATE)
set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp
index 7d21c6a671..ae60fefdcf 100644
--- a/tools/driver/cc1_main.cpp
+++ b/tools/driver/cc1_main.cpp
@@ -1,9 +1,8 @@
//===-- cc1_main.cpp - Clang CC1 Compiler Frontend ------------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -35,8 +34,10 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdio>
@@ -195,6 +196,9 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
bool Success = CompilerInvocation::CreateFromArgs(
Clang->getInvocation(), Argv.begin(), Argv.end(), Diags);
+ if (Clang->getFrontendOpts().TimeTrace)
+ llvm::timeTraceProfilerInitialize();
+
// Infer the builtin include path if unspecified.
if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
Clang->getHeaderSearchOpts().ResourceDir.empty())
@@ -216,12 +220,29 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
return 1;
// Execute the frontend actions.
- Success = ExecuteCompilerInvocation(Clang.get());
+ {
+ llvm::TimeTraceScope TimeScope("ExecuteCompiler", StringRef(""));
+ Success = ExecuteCompilerInvocation(Clang.get());
+ }
// If any timers were active but haven't been destroyed yet, print their
// results now. This happens in -disable-free mode.
llvm::TimerGroup::printAll(llvm::errs());
+ if (llvm::timeTraceProfilerEnabled()) {
+ SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
+ llvm::sys::path::replace_extension(Path, "json");
+ auto profilerOutput =
+ Clang->createOutputFile(Path.str(),
+ /*Binary=*/false,
+ /*RemoveFileOnSignal=*/false, "",
+ /*Extension=*/"json",
+ /*useTemporary=*/false);
+
+ llvm::timeTraceProfilerWrite(*profilerOutput);
+ llvm::timeTraceProfilerCleanup();
+ }
+
// Our error handler depends on the Diagnostics object, which we're
// potentially about to delete. Uninstall the handler now so that any
// later errors use the default handling behavior instead.
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
index be4f174ed4..c0334609be 100644
--- a/tools/driver/cc1as_main.cpp
+++ b/tools/driver/cc1as_main.cpp
@@ -1,9 +1,8 @@
//===-- cc1as_main.cpp - Clang Assembler ---------------------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -138,6 +137,10 @@ struct AssemblerInvocation {
/// The name of the relocation model to use.
std::string RelocationModel;
+ /// The ABI targeted by the backend. Specified using -target-abi. Empty
+ /// otherwise.
+ std::string TargetABI;
+
/// @}
public:
@@ -283,6 +286,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
+ Opts.TargetABI = Args.getLastArgValue(OPT_target_abi);
Opts.IncrementalLinkerCompatible =
Args.hasArg(OPT_mincremental_linker_compatible);
Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
@@ -337,7 +341,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
SourceMgr SrcMgr;
// Tell SrcMgr about this buffer, which is what the parser will pick up.
- SrcMgr.AddNewSourceBuffer(std::move(*Buffer), SMLoc());
+ unsigned BufferIndex = SrcMgr.AddNewSourceBuffer(std::move(*Buffer), SMLoc());
// Record the location of the include directories so that the lexer can find
// it later.
@@ -394,12 +398,21 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
Ctx.setDwarfDebugProducer(StringRef(Opts.DwarfDebugProducer));
if (!Opts.DebugCompilationDir.empty())
Ctx.setCompilationDir(Opts.DebugCompilationDir);
+ else {
+ // If no compilation dir is set, try to use the current directory.
+ SmallString<128> CWD;
+ if (!sys::fs::current_path(CWD))
+ Ctx.setCompilationDir(CWD);
+ }
if (!Opts.DebugPrefixMap.empty())
for (const auto &KV : Opts.DebugPrefixMap)
Ctx.addDebugPrefixMapEntry(KV.first, KV.second);
if (!Opts.MainFileName.empty())
Ctx.setMainFileName(StringRef(Opts.MainFileName));
Ctx.setDwarfVersion(Opts.DwarfVersion);
+ if (Opts.GenDwarfForAssembly)
+ Ctx.setGenDwarfRootFile(Opts.InputFile,
+ SrcMgr.getMemoryBuffer(BufferIndex)->getBuffer());
// Build up the feature string from the target feature list.
std::string FS;
@@ -418,6 +431,9 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
raw_pwrite_stream *Out = FDOS.get();
std::unique_ptr<buffer_ostream> BOS;
+ MCTargetOptions MCOptions;
+ MCOptions.ABIName = Opts.TargetABI;
+
// FIXME: There is a bit of code duplication with addPassesToEmitFile.
if (Opts.OutputType == AssemblerInvocation::FT_Asm) {
MCInstPrinter *IP = TheTarget->createMCInstPrinter(
@@ -426,7 +442,6 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
std::unique_ptr<MCCodeEmitter> CE;
if (Opts.ShowEncoding)
CE.reset(TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
- MCTargetOptions MCOptions;
std::unique_ptr<MCAsmBackend> MAB(
TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
@@ -447,7 +462,6 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
std::unique_ptr<MCCodeEmitter> CE(
TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
- MCTargetOptions MCOptions;
std::unique_ptr<MCAsmBackend> MAB(
TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
std::unique_ptr<MCObjectWriter> OW =
@@ -481,9 +495,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
// FIXME: init MCTargetOptions from sanitizer flags here.
- MCTargetOptions Options;
std::unique_ptr<MCTargetAsmParser> TAP(
- TheTarget->createMCAsmParser(*STI, *Parser, *MCII, Options));
+ TheTarget->createMCAsmParser(*STI, *Parser, *MCII, MCOptions));
if (!TAP)
Failed = Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
diff --git a/tools/driver/cc1gen_reproducer_main.cpp b/tools/driver/cc1gen_reproducer_main.cpp
index 2d7ea86f74..4aadab7301 100644
--- a/tools/driver/cc1gen_reproducer_main.cpp
+++ b/tools/driver/cc1gen_reproducer_main.cpp
@@ -1,9 +1,8 @@
//===-- cc1gen_reproducer_main.cpp - Clang reproducer generator ----------===//
//
-// 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/tools/driver/driver.cpp b/tools/driver/driver.cpp
index 51143e3d8c..dfc96d308a 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -1,9 +1,8 @@
//===-- driver.cpp - Clang GCC-Compatible Driver --------------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -341,7 +340,7 @@ int main(int argc_, const char **argv_) {
// response files written by clang will tokenize the same way in either mode.
bool ClangCLMode = false;
if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
- std::find_if(argv.begin(), argv.end(), [](const char *F) {
+ llvm::find_if(argv, [](const char *F) {
return F && strcmp(F, "--driver-mode=cl") == 0;
}) != argv.end()) {
ClangCLMode = true;
diff --git a/tools/libclang/ARCMigrate.cpp b/tools/libclang/ARCMigrate.cpp
index ed2ecdb29e..da8a7e4b91 100644
--- a/tools/libclang/ARCMigrate.cpp
+++ b/tools/libclang/ARCMigrate.cpp
@@ -1,9 +1,8 @@
//===- ARCMigrate.cpp - Clang-C ARC Migration Library ---------------------===//
//
-// 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/tools/libclang/BuildSystem.cpp b/tools/libclang/BuildSystem.cpp
index 6c1f2c145b..0d69dcf172 100644
--- a/tools/libclang/BuildSystem.cpp
+++ b/tools/libclang/BuildSystem.cpp
@@ -1,9 +1,8 @@
//===- BuildSystem.cpp - Utilities for use by build systems ---------------===//
//
-// 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/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index a9c3077e5f..d7eee5e684 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1,9 +1,8 @@
//===- CIndex.cpp - Clang-C Source Indexing Library -----------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -172,7 +171,6 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
static SourceRange getRawCursorExtent(CXCursor C);
static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr);
-
RangeComparisonResult CursorVisitor::CompareRegionOfInterest(SourceRange R) {
return RangeCompare(AU->getSourceManager(), R, RegionOfInterest);
}
@@ -2169,6 +2167,10 @@ void OMPClauseEnqueue::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
Visitor->AddStmt(C->getSimdlen());
}
+void OMPClauseEnqueue::VisitOMPAllocatorClause(const OMPAllocatorClause *C) {
+ Visitor->AddStmt(C->getAllocator());
+}
+
void OMPClauseEnqueue::VisitOMPCollapseClause(const OMPCollapseClause *C) {
Visitor->AddStmt(C->getNumForLoops());
}
@@ -2260,6 +2262,10 @@ void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
}
}
+void OMPClauseEnqueue::VisitOMPAllocateClause(const OMPAllocateClause *C) {
+ VisitOMPClauseList(C);
+ Visitor->AddStmt(C->getAllocator());
+}
void OMPClauseEnqueue::VisitOMPPrivateClause(const OMPPrivateClause *C) {
VisitOMPClauseList(C);
for (const auto *E : C->private_copies()) {
@@ -2473,7 +2479,7 @@ void EnqueueVisitor::VisitCXXNewExpr(const CXXNewExpr *E) {
// Enqueue the initializer , if any.
AddStmt(E->getInitializer());
// Enqueue the array size, if any.
- AddStmt(E->getArraySize());
+ AddStmt(E->getArraySize().getValueOr(nullptr));
// Enqueue the allocated type.
AddTypeLoc(E->getAllocatedTypeSourceInfo());
// Enqueue the placement arguments.
@@ -3409,7 +3415,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
if (options & CXTranslationUnit_KeepGoing)
- Diags->setSuppressAfterFatalError(false);
+ Diags->setFatalsAsError(true);
// Recover resources if we crash before exiting this function.
llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,
@@ -4221,7 +4227,7 @@ const char *clang_getFileContents(CXTranslationUnit TU, CXFile file,
const SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
FileID fid = SM.translateFile(static_cast<FileEntry *>(file));
bool Invalid = true;
- llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid);
+ const llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid);
if (Invalid) {
if (size)
*size = 0;
@@ -5474,7 +5480,15 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
case CXCursor_StaticAssert:
return cxstring::createRef("StaticAssert");
case CXCursor_FriendDecl:
- return cxstring::createRef("FriendDecl");
+ return cxstring::createRef("FriendDecl");
+ case CXCursor_ConvergentAttr:
+ return cxstring::createRef("attribute(convergent)");
+ case CXCursor_WarnUnusedAttr:
+ return cxstring::createRef("attribute(warn_unused)");
+ case CXCursor_WarnUnusedResultAttr:
+ return cxstring::createRef("attribute(warn_unused_result)");
+ case CXCursor_AlignedAttr:
+ return cxstring::createRef("attribute(aligned)");
}
llvm_unreachable("Unhandled CXCursorKind");
@@ -6228,7 +6242,9 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
case Decl::CXXDeductionGuide:
case Decl::Import:
case Decl::OMPThreadPrivate:
+ case Decl::OMPAllocate:
case Decl::OMPDeclareReduction:
+ case Decl::OMPDeclareMapper:
case Decl::OMPRequires:
case Decl::ObjCTypeParam:
case Decl::BuiltinTemplate:
@@ -8361,7 +8377,7 @@ unsigned clang_CXXMethod_isConst(CXCursor C) {
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
- return (Method && Method->getTypeQualifiers().hasConst()) ? 1 : 0;
+ return (Method && Method->getMethodQualifiers().hasConst()) ? 1 : 0;
}
unsigned clang_CXXMethod_isDefaulted(CXCursor C) {
@@ -8706,8 +8722,8 @@ void clang::setThreadBackgroundPriority() {
if (getenv("LIBCLANG_BGPRIO_DISABLE"))
return;
-#ifdef USE_DARWIN_THREADS
- setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG);
+#if LLVM_ENABLE_THREADS
+ llvm::set_thread_priority(llvm::ThreadPriority::Background);
#endif
}
diff --git a/tools/libclang/CIndexCXX.cpp b/tools/libclang/CIndexCXX.cpp
index 028b64a2b2..a06fe7ba4a 100644
--- a/tools/libclang/CIndexCXX.cpp
+++ b/tools/libclang/CIndexCXX.cpp
@@ -1,9 +1,8 @@
//===- CIndexCXX.cpp - Clang-C Source Indexing Library --------------------===//
//
-// 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/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp
index c5cece52ac..1588812802 100644
--- a/tools/libclang/CIndexCodeCompletion.cpp
+++ b/tools/libclang/CIndexCodeCompletion.cpp
@@ -1,9 +1,8 @@
//===- CIndexCodeCompletion.cpp - Code Completion API hooks ---------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -569,9 +568,8 @@ namespace {
CaptureCompletionResults(const CodeCompleteOptions &Opts,
AllocatedCXCodeCompleteResults &Results,
CXTranslationUnit *TranslationUnit)
- : CodeCompleteConsumer(Opts, false),
- AllocatedResults(Results), CCTUInfo(Results.CodeCompletionAllocator),
- TU(TranslationUnit) { }
+ : CodeCompleteConsumer(Opts), AllocatedResults(Results),
+ CCTUInfo(Results.CodeCompletionAllocator), TU(TranslationUnit) {}
~CaptureCompletionResults() override { Finish(); }
void ProcessCodeCompleteResults(Sema &S,
diff --git a/tools/libclang/CIndexDiagnostic.cpp b/tools/libclang/CIndexDiagnostic.cpp
index a4e75e2aae..6dfdf2d2f9 100644
--- a/tools/libclang/CIndexDiagnostic.cpp
+++ b/tools/libclang/CIndexDiagnostic.cpp
@@ -1,15 +1,15 @@
-/*===-- CIndexDiagnostics.cpp - Diagnostics C Interface ---------*- C++ -*-===*\
-|* *|
-|* The LLVM Compiler Infrastructure *|
-|* *|
-|* This file is distributed under the University of Illinois Open Source *|
-|* License. See LICENSE.TXT for details. *|
-|* *|
-|*===----------------------------------------------------------------------===*|
-|* *|
-|* Implements the diagnostic functions of the Clang C interface. *|
-|* *|
-\*===----------------------------------------------------------------------===*/
+//===- CIndexDiagnostic.cpp - Diagnostics C Interface ---------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Implements the diagnostic functions of the Clang C interface.
+//
+//===----------------------------------------------------------------------===//
+
#include "CIndexDiagnostic.h"
#include "CIndexer.h"
#include "CXTranslationUnit.h"
diff --git a/tools/libclang/CIndexDiagnostic.h b/tools/libclang/CIndexDiagnostic.h
index e865df0894..25589bb574 100644
--- a/tools/libclang/CIndexDiagnostic.h
+++ b/tools/libclang/CIndexDiagnostic.h
@@ -1,9 +1,9 @@
/*===-- CIndexDiagnostic.h - Diagnostics C Interface ------------*- C++ -*-===*\
|* *|
-|* 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/tools/libclang/CIndexHigh.cpp b/tools/libclang/CIndexHigh.cpp
index a9cd2cac42..04699ccb01 100644
--- a/tools/libclang/CIndexHigh.cpp
+++ b/tools/libclang/CIndexHigh.cpp
@@ -1,9 +1,8 @@
//===- CIndexHigh.cpp - Higher level API functions ------------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
@@ -110,16 +109,14 @@ struct FindFileIdRefVisitData {
private:
bool isOverriddingMethod(const Decl *D) const {
- if (std::find(TopMethods.begin(), TopMethods.end(), D) !=
- TopMethods.end())
+ if (llvm::find(TopMethods, D) != TopMethods.end())
return true;
TopMethodsTy methods;
getTopOverriddenMethods(TU, D, methods);
for (TopMethodsTy::iterator
I = methods.begin(), E = methods.end(); I != E; ++I) {
- if (std::find(TopMethods.begin(), TopMethods.end(), *I) !=
- TopMethods.end())
+ if (llvm::find(TopMethods, *I) != TopMethods.end())
return true;
}
diff --git a/tools/libclang/CIndexInclusionStack.cpp b/tools/libclang/CIndexInclusionStack.cpp
index 4b021fc4cb..f1c5b53c5e 100644
--- a/tools/libclang/CIndexInclusionStack.cpp
+++ b/tools/libclang/CIndexInclusionStack.cpp
@@ -1,9 +1,8 @@
//===- CIndexInclusionStack.cpp - Clang-C Source Indexing Library ---------===//
//
-// 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/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp
index 7cd7b6f1cd..75bb3b0129 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -1,9 +1,8 @@
-//===- CIndexUSR.cpp - Clang-C Source Indexing Library --------------------===//
+//===- CIndexUSRs.cpp - Clang-C Source Indexing Library -------------------===//
//
-// 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/tools/libclang/CIndexer.cpp b/tools/libclang/CIndexer.cpp
index 3c6e1530f1..0054c15bc7 100644
--- a/tools/libclang/CIndexer.cpp
+++ b/tools/libclang/CIndexer.cpp
@@ -1,9 +1,8 @@
-//===- CIndex.cpp - Clang-C Source Indexing Library -----------------------===//
+//===- CIndexer.cpp - Clang-C Source Indexing Library ---------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -15,6 +14,7 @@
#include "CXString.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Version.h"
+#include "clang/Driver/Driver.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/MD5.h"
@@ -32,12 +32,69 @@
#ifdef _WIN32
#include <windows.h>
+#elif defined(_AIX)
+#include <errno.h>
+#include <sys/ldr.h>
#else
#include <dlfcn.h>
#endif
using namespace clang;
+#ifdef _AIX
+namespace clang {
+namespace {
+
+template <typename LibClangPathType>
+void getClangResourcesPathImplAIX(LibClangPathType &LibClangPath) {
+ int PrevErrno = errno;
+
+ size_t BufSize = 2048u;
+ std::unique_ptr<char[]> Buf;
+ while (true) {
+ Buf = llvm::make_unique<char []>(BufSize);
+ errno = 0;
+ int Ret = loadquery(L_GETXINFO, Buf.get(), (unsigned int)BufSize);
+ if (Ret != -1)
+ break; // loadquery() was successful.
+ if (errno != ENOMEM)
+ llvm_unreachable("Encountered an unexpected loadquery() failure");
+
+ // errno == ENOMEM; try to allocate more memory.
+ if ((BufSize & ~((-1u) >> 1u)) != 0u)
+ llvm::report_fatal_error("BufSize needed for loadquery() too large");
+
+ Buf.release();
+ BufSize <<= 1u;
+ }
+
+ // Extract the function entry point from the function descriptor.
+ uint64_t EntryAddr =
+ reinterpret_cast<uintptr_t &>(clang_createTranslationUnit);
+
+ // Loop to locate the function entry point in the loadquery() results.
+ ld_xinfo *CurInfo = reinterpret_cast<ld_xinfo *>(Buf.get());
+ while (true) {
+ uint64_t CurTextStart = (uint64_t)CurInfo->ldinfo_textorg;
+ uint64_t CurTextEnd = CurTextStart + CurInfo->ldinfo_textsize;
+ if (CurTextStart <= EntryAddr && EntryAddr < CurTextEnd)
+ break; // Successfully located.
+
+ if (CurInfo->ldinfo_next == 0u)
+ llvm::report_fatal_error("Cannot locate entry point in "
+ "the loadquery() results");
+ CurInfo = reinterpret_cast<ld_xinfo *>(reinterpret_cast<char *>(CurInfo) +
+ CurInfo->ldinfo_next);
+ }
+
+ LibClangPath += reinterpret_cast<char *>(CurInfo) + CurInfo->ldinfo_filename;
+ errno = PrevErrno;
+}
+
+} // end anonymous namespace
+} // end namespace clang
+#endif
+
const std::string &CIndexer::getClangResourcesPath() {
// Did we already compute the path?
if (!ResourcesPath.empty())
@@ -63,7 +120,9 @@ const std::string &CIndexer::getClangResourcesPath() {
#endif
#endif
- LibClangPath += llvm::sys::path::parent_path(path);
+ LibClangPath += path;
+#elif defined(_AIX)
+ getClangResourcesPathImplAIX(LibClangPath);
#else
// This silly cast below avoids a C++ warning.
Dl_info info;
@@ -71,13 +130,11 @@ const std::string &CIndexer::getClangResourcesPath() {
llvm_unreachable("Call to dladdr() failed");
// We now have the CIndex directory, locate clang relative to it.
- LibClangPath += llvm::sys::path::parent_path(info.dli_fname);
+ LibClangPath += info.dli_fname;
#endif
- llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
-
// Cache our result.
- ResourcesPath = LibClangPath.str();
+ ResourcesPath = driver::Driver::GetResourcesPath(LibClangPath);
return ResourcesPath;
}
diff --git a/tools/libclang/CIndexer.h b/tools/libclang/CIndexer.h
index 3ba35d6db6..b7dd5f8ace 100644
--- a/tools/libclang/CIndexer.h
+++ b/tools/libclang/CIndexer.h
@@ -1,9 +1,8 @@
//===- CIndexer.h - Clang-C Source Indexing Library -------------*- C++ -*-===//
//
-// 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/tools/libclang/CLog.h b/tools/libclang/CLog.h
index a935995a11..c25dbc03a5 100644
--- a/tools/libclang/CLog.h
+++ b/tools/libclang/CLog.h
@@ -1,9 +1,8 @@
//===- CLog.h - Logging Interface -------------------------------*- C++ -*-===//
//
-// 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/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
index 32333b011a..2de5b2956d 100644
--- a/tools/libclang/CMakeLists.txt
+++ b/tools/libclang/CMakeLists.txt
@@ -36,6 +36,7 @@ set(SOURCES
set(LIBS
clangAST
clangBasic
+ clangDriver
clangFrontend
clangIndex
clangLex
@@ -74,7 +75,7 @@ if(MSVC)
set(LLVM_EXPORTED_SYMBOL_FILE)
endif()
-if( LLVM_ENABLE_PIC )
+if(LLVM_ENABLE_PIC OR WIN32)
set(ENABLE_SHARED SHARED)
endif()
@@ -91,7 +92,7 @@ endif()
add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC}
OUTPUT_NAME ${output_name}
${SOURCES}
- DEPENDS clang-headers
+ DEPENDS clang-resource-headers
LINK_LIBS
${LIBS}
@@ -148,7 +149,7 @@ install(DIRECTORY ../../include/clang-c
add_custom_target(libclang-headers)
set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-libclang-headers
COMPONENT libclang-headers)
endif()
@@ -164,7 +165,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS})
DESTINATION
"lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
endforeach()
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
add_custom_target(libclang-python-bindings)
add_llvm_install_targets(install-libclang-python-bindings
COMPONENT
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index 028fdf1d3a..cb27b253fd 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -1,9 +1,8 @@
//===- CXComment.cpp - libclang APIs for manipulating CXComments ----------===//
//
-// 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/tools/libclang/CXComment.h b/tools/libclang/CXComment.h
index a937a80346..30be06419c 100644
--- a/tools/libclang/CXComment.h
+++ b/tools/libclang/CXComment.h
@@ -1,9 +1,8 @@
//===- CXComment.h - Routines for manipulating CXComments -----------------===//
//
-// 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/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index 99e4319fc1..f26d97f86b 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -1,9 +1,8 @@
//===- CXCursor.cpp - Routines for manipulating CXCursors -----------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
//
@@ -79,6 +78,10 @@ static CXCursorKind GetCursorKind(const Attr *A) {
case attr::ObjCRuntimeVisible: return CXCursor_ObjCRuntimeVisible;
case attr::ObjCBoxable: return CXCursor_ObjCBoxable;
case attr::FlagEnum: return CXCursor_FlagEnum;
+ case attr::Convergent: return CXCursor_ConvergentAttr;
+ case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
+ case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
+ case attr::Aligned: return CXCursor_AlignedAttr;
}
return CXCursor_UnexposedAttr;
@@ -106,8 +109,8 @@ CXCursor cxcursor::MakeCXCursor(const Decl *D, CXTranslationUnit TU,
RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) {
SmallVector<SourceLocation, 16> SelLocs;
cast<ObjCMethodDecl>(D)->getSelectorLocs(SelLocs);
- SmallVectorImpl<SourceLocation>::iterator
- I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin());
+ SmallVectorImpl<SourceLocation>::iterator I =
+ llvm::find(SelLocs, RegionOfInterest.getBegin());
if (I != SelLocs.end())
SelectorIdIndex = I - SelLocs.begin();
}
@@ -559,8 +562,8 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) {
SmallVector<SourceLocation, 16> SelLocs;
cast<ObjCMessageExpr>(S)->getSelectorLocs(SelLocs);
- SmallVectorImpl<SourceLocation>::iterator
- I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin());
+ SmallVectorImpl<SourceLocation>::iterator I =
+ llvm::find(SelLocs, RegionOfInterest.getBegin());
if (I != SelLocs.end())
SelectorIdIndex = I - SelLocs.begin();
}
diff --git a/tools/libclang/CXCursor.h b/tools/libclang/CXCursor.h
index 312fb3ff25..d17381ba0a 100644
--- a/tools/libclang/CXCursor.h
+++ b/tools/libclang/CXCursor.h
@@ -1,9 +1,8 @@
//===- CXCursor.h - Routines for manipulating CXCursors -------------------===//
//
-// 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/tools/libclang/CXIndexDataConsumer.cpp b/tools/libclang/CXIndexDataConsumer.cpp
index 3dec36a5da..d5de7df707 100644
--- a/tools/libclang/CXIndexDataConsumer.cpp
+++ b/tools/libclang/CXIndexDataConsumer.cpp
@@ -1,9 +1,8 @@
//===- CXIndexDataConsumer.cpp - Index data consumer for libclang----------===//
//
-// 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/tools/libclang/CXIndexDataConsumer.h b/tools/libclang/CXIndexDataConsumer.h
index 5c1ce80b2f..864d870a90 100644
--- a/tools/libclang/CXIndexDataConsumer.h
+++ b/tools/libclang/CXIndexDataConsumer.h
@@ -1,9 +1,8 @@
//===- CXIndexDataConsumer.h - Index data consumer for libclang--*- C++ -*-===//
//
-// 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/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp
index fd6881e03a..551d8343fc 100644
--- a/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/tools/libclang/CXLoadedDiagnostic.cpp
@@ -1,9 +1,8 @@
//===-- CXLoadedDiagnostic.cpp - Handling of persisent diags ----*- C++ -*-===//
//
-// 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/tools/libclang/CXLoadedDiagnostic.h b/tools/libclang/CXLoadedDiagnostic.h
index 521ebd84bf..93995d7bb7 100644
--- a/tools/libclang/CXLoadedDiagnostic.h
+++ b/tools/libclang/CXLoadedDiagnostic.h
@@ -1,9 +1,9 @@
/*===-- CXLoadedDiagnostic.h - Handling of persisent diags ------*- C++ -*-===*\
|* *|
-|* 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/tools/libclang/CXSourceLocation.cpp b/tools/libclang/CXSourceLocation.cpp
index 2e0ea4e440..a253dadb3b 100644
--- a/tools/libclang/CXSourceLocation.cpp
+++ b/tools/libclang/CXSourceLocation.cpp
@@ -1,9 +1,8 @@
//===- CXSourceLocation.cpp - CXSourceLocations APIs ------------*- C++ -*-===//
//
-// 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/tools/libclang/CXSourceLocation.h b/tools/libclang/CXSourceLocation.h
index dddc847590..6702d0cf97 100644
--- a/tools/libclang/CXSourceLocation.h
+++ b/tools/libclang/CXSourceLocation.h
@@ -1,9 +1,8 @@
//===- CXSourceLocation.h - CXSourceLocations Utilities ---------*- C++ -*-===//
//
-// 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/tools/libclang/CXStoredDiagnostic.cpp b/tools/libclang/CXStoredDiagnostic.cpp
index 6bd2f67466..c4c24876e7 100644
--- a/tools/libclang/CXStoredDiagnostic.cpp
+++ b/tools/libclang/CXStoredDiagnostic.cpp
@@ -1,15 +1,14 @@
-/*===-- CXStoreDiagnostic.cpp - Diagnostics C Interface ----------*- C++ -*-===*\
-|* *|
-|* The LLVM Compiler Infrastructure *|
-|* *|
-|* This file is distributed under the University of Illinois Open Source *|
-|* License. See LICENSE.TXT for details. *|
-|* *|
-|*===----------------------------------------------------------------------===*|
-|* *|
-|* Implements part of the diagnostic functions of the Clang C interface. *|
-|* *|
-\*===----------------------------------------------------------------------===*/
+//===- CXStoredDiagnostic.cpp - Diagnostics C Interface -------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Implements part of the diagnostic functions of the Clang C interface.
+//
+//===----------------------------------------------------------------------===//
#include "CIndexDiagnostic.h"
#include "CIndexer.h"
diff --git a/tools/libclang/CXString.cpp b/tools/libclang/CXString.cpp
index cef4e53a42..2754795f4a 100644
--- a/tools/libclang/CXString.cpp
+++ b/tools/libclang/CXString.cpp
@@ -1,9 +1,8 @@
//===- CXString.cpp - Routines for manipulating CXStrings -----------------===//
//
-// 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/tools/libclang/CXString.h b/tools/libclang/CXString.h
index ed19261187..809bdec3d6 100644
--- a/tools/libclang/CXString.h
+++ b/tools/libclang/CXString.h
@@ -1,9 +1,8 @@
//===- CXString.h - Routines for manipulating CXStrings -------------------===//
//
-// 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/tools/libclang/CXTranslationUnit.h b/tools/libclang/CXTranslationUnit.h
index 590142f30f..3424bf2997 100644
--- a/tools/libclang/CXTranslationUnit.h
+++ b/tools/libclang/CXTranslationUnit.h
@@ -1,9 +1,8 @@
//===- CXTranslationUnit.h - Routines for manipulating CXTranslationUnits -===//
//
-// 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/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index b8009ddc1c..6cb680a64d 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -1,9 +1,8 @@
-//===- CXTypes.cpp - Implements 'CXTypes' aspect of libclang ------------===//
+//===- CXType.cpp - Implements 'CXTypes' aspect of libclang ---------------===//
//
-// 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
//
//===--------------------------------------------------------------------===//
//
@@ -110,6 +109,7 @@ static CXTypeKind GetTypeKind(QualType T) {
TKCASE(VariableArray);
TKCASE(DependentSizedArray);
TKCASE(Vector);
+ TKCASE(ExtVector);
TKCASE(MemberPointer);
TKCASE(Auto);
TKCASE(Elaborated);
@@ -129,7 +129,9 @@ CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
// Handle attributed types as the original type
if (auto *ATT = T->getAs<AttributedType>()) {
if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes)) {
- return MakeCXType(ATT->getModifiedType(), TU);
+ // Return the equivalent type which represents the canonically
+ // equivalent type.
+ return MakeCXType(ATT->getEquivalentType(), TU);
}
}
// Handle paren types as the original type
@@ -599,6 +601,7 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) {
TKIND(VariableArray);
TKIND(DependentSizedArray);
TKIND(Vector);
+ TKIND(ExtVector);
TKIND(MemberPointer);
TKIND(Auto);
TKIND(Elaborated);
@@ -803,6 +806,9 @@ CXType clang_getElementType(CXType CT) {
case Type::Vector:
ET = cast<VectorType> (TP)->getElementType();
break;
+ case Type::ExtVector:
+ ET = cast<ExtVectorType>(TP)->getElementType();
+ break;
case Type::Complex:
ET = cast<ComplexType> (TP)->getElementType();
break;
@@ -826,6 +832,9 @@ long long clang_getNumElements(CXType CT) {
case Type::Vector:
result = cast<VectorType> (TP)->getNumElements();
break;
+ case Type::ExtVector:
+ result = cast<ExtVectorType>(TP)->getNumElements();
+ break;
default:
break;
}
@@ -890,6 +899,9 @@ long long clang_Type_getAlignOf(CXType T) {
return CXTypeLayoutError_Incomplete;
if (QT->isDependentType())
return CXTypeLayoutError_Dependent;
+ if (const auto *Deduced = dyn_cast<DeducedType>(QT))
+ if (Deduced->getDeducedType().isNull())
+ return CXTypeLayoutError_Undeduced;
// Exceptions by GCC extension - see ASTContext.cpp:1313 getTypeInfoImpl
// if (QT->isFunctionType()) return 4; // Bug #15511 - should be 1
// if (QT->isVoidType()) return 1;
@@ -927,6 +939,9 @@ long long clang_Type_getSizeOf(CXType T) {
return CXTypeLayoutError_Dependent;
if (!QT->isConstantSizeType())
return CXTypeLayoutError_NotConstantSize;
+ if (const auto *Deduced = dyn_cast<DeducedType>(QT))
+ if (Deduced->getDeducedType().isNull())
+ return CXTypeLayoutError_Undeduced;
// [gcc extension] lib/AST/ExprConstant.cpp:1372
// HandleSizeof : {voidtype,functype} == 1
// not handled by ASTContext.cpp:1313 getTypeInfoImpl
@@ -1238,6 +1253,16 @@ unsigned clang_Cursor_isAnonymous(CXCursor C){
return 0;
}
+
+unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C){
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+ const Decl *D = cxcursor::getCursorDecl(C);
+ if (const RecordDecl *FD = dyn_cast_or_null<RecordDecl>(D))
+ return FD->isAnonymousStructOrUnion();
+ return 0;
+}
+
CXType clang_Type_getNamedType(CXType CT){
QualType T = GetQualType(CT);
const Type *TP = T.getTypePtrOrNull();
diff --git a/tools/libclang/CXType.h b/tools/libclang/CXType.h
index 941cc0a9fd..1d458086c0 100644
--- a/tools/libclang/CXType.h
+++ b/tools/libclang/CXType.h
@@ -1,9 +1,8 @@
//===- CXTypes.h - Routines for manipulating CXTypes ----------------------===//
//
-// 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/tools/libclang/CursorVisitor.h b/tools/libclang/CursorVisitor.h
index f2fb68fab9..b0afa5a0b5 100644
--- a/tools/libclang/CursorVisitor.h
+++ b/tools/libclang/CursorVisitor.h
@@ -1,9 +1,8 @@
//===- CursorVisitor.h - CursorVisitor interface ----------------*- C++ -*-===//
//
-// 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/tools/libclang/Index_Internal.h b/tools/libclang/Index_Internal.h
index fbe3cabf04..d28438770e 100644
--- a/tools/libclang/Index_Internal.h
+++ b/tools/libclang/Index_Internal.h
@@ -1,9 +1,8 @@
//===- CXString.h - Routines for manipulating CXStrings -------------------===//
//
-// 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/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 4da046b282..ad3dc70ea3 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -1,9 +1,8 @@
-//===- CIndexHigh.cpp - Higher level API functions ------------------------===//
+//===- Indexing.cpp - Higher level API functions --------------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
@@ -94,9 +93,6 @@ typedef llvm::DenseSet<PPRegion> PPRegionSetTy;
} // end anonymous namespace
namespace llvm {
- template <> struct isPodLike<PPRegion> {
- static const bool value = true;
- };
template <>
struct DenseMapInfo<PPRegion> {
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index 2c4b083a59..1d3cd5cd14 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -39,6 +39,7 @@ clang_Cursor_getSpellingNameRange
clang_Cursor_getTranslationUnit
clang_Cursor_getReceiverType
clang_Cursor_isAnonymous
+clang_Cursor_isAnonymousRecordDecl
clang_Cursor_isBitField
clang_Cursor_isDynamicCall
clang_Cursor_isExternalSymbol
diff --git a/tools/scan-build-py/README.md b/tools/scan-build-py/README.md
index 01e3454bed..0f89b6fa43 100644
--- a/tools/scan-build-py/README.md
+++ b/tools/scan-build-py/README.md
@@ -138,7 +138,7 @@ how to fix it, include that as well. Patches are also welcome.
License
-------
-The project is licensed under University of Illinois/NCSA Open Source License.
+The project is licensed under Apache-2.0 with LLVM exceptions.
See LICENSE.TXT for details.
[1]: http://clang.llvm.org/docs/JSONCompilationDatabase.html
diff --git a/tools/scan-build-py/bin/analyze-build b/tools/scan-build-py/bin/analyze-build
index 991cff0658..6c285874a2 100755
--- a/tools/scan-build-py/bin/analyze-build
+++ b/tools/scan-build-py/bin/analyze-build
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# 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
import multiprocessing
multiprocessing.freeze_support()
diff --git a/tools/scan-build-py/bin/analyze-c++ b/tools/scan-build-py/bin/analyze-c++
index df1012dee5..564e2abf55 100755
--- a/tools/scan-build-py/bin/analyze-c++
+++ b/tools/scan-build-py/bin/analyze-c++
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# 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
import sys
import os.path
diff --git a/tools/scan-build-py/bin/analyze-cc b/tools/scan-build-py/bin/analyze-cc
index df1012dee5..564e2abf55 100755
--- a/tools/scan-build-py/bin/analyze-cc
+++ b/tools/scan-build-py/bin/analyze-cc
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# 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
import sys
import os.path
diff --git a/tools/scan-build-py/bin/intercept-build b/tools/scan-build-py/bin/intercept-build
index 2c3a26ecdd..23f5104782 100755
--- a/tools/scan-build-py/bin/intercept-build
+++ b/tools/scan-build-py/bin/intercept-build
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# 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
import multiprocessing
multiprocessing.freeze_support()
diff --git a/tools/scan-build-py/bin/intercept-c++ b/tools/scan-build-py/bin/intercept-c++
index 67e076f39e..4230c8035d 100755
--- a/tools/scan-build-py/bin/intercept-c++
+++ b/tools/scan-build-py/bin/intercept-c++
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# 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
import sys
import os.path
diff --git a/tools/scan-build-py/bin/intercept-cc b/tools/scan-build-py/bin/intercept-cc
index 67e076f39e..4230c8035d 100755
--- a/tools/scan-build-py/bin/intercept-cc
+++ b/tools/scan-build-py/bin/intercept-cc
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# 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
import sys
import os.path
diff --git a/tools/scan-build-py/bin/scan-build b/tools/scan-build-py/bin/scan-build
index f0f34695b0..156da064a2 100755
--- a/tools/scan-build-py/bin/scan-build
+++ b/tools/scan-build-py/bin/scan-build
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# 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
import multiprocessing
multiprocessing.freeze_support()
diff --git a/tools/scan-build-py/libear/__init__.py b/tools/scan-build-py/libear/__init__.py
index 421e2e74f0..0dfe8c11eb 100644
--- a/tools/scan-build-py/libear/__init__.py
+++ b/tools/scan-build-py/libear/__init__.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module compiles the intercept library. """
import sys
diff --git a/tools/scan-build-py/libear/config.h.in b/tools/scan-build-py/libear/config.h.in
index 6643d8995c..6ca1b9580b 100644
--- a/tools/scan-build-py/libear/config.h.in
+++ b/tools/scan-build-py/libear/config.h.in
@@ -1,8 +1,7 @@
/* -*- coding: utf-8 -*-
-// 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
*/
#pragma once
diff --git a/tools/scan-build-py/libear/ear.c b/tools/scan-build-py/libear/ear.c
index 0e7093af75..21c5768474 100644
--- a/tools/scan-build-py/libear/ear.c
+++ b/tools/scan-build-py/libear/ear.c
@@ -1,8 +1,7 @@
/* -*- coding: utf-8 -*-
-// 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/tools/scan-build-py/libscanbuild/__init__.py b/tools/scan-build-py/libscanbuild/__init__.py
index 903207c6be..2e43281650 100644
--- a/tools/scan-build-py/libscanbuild/__init__.py
+++ b/tools/scan-build-py/libscanbuild/__init__.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module is a collection of methods commonly used in this project. """
import collections
import functools
diff --git a/tools/scan-build-py/libscanbuild/analyze.py b/tools/scan-build-py/libscanbuild/analyze.py
index ab8ea62f46..49de387c70 100644
--- a/tools/scan-build-py/libscanbuild/analyze.py
+++ b/tools/scan-build-py/libscanbuild/analyze.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module implements the 'scan-build' command API.
To run the static analyzer against a build is done in multiple steps:
@@ -98,7 +97,7 @@ def need_analyzer(args):
when compiler wrappers are used. That's the moment when build setup
check the compiler and capture the location for the build process. """
- return len(args) and not re.search('configure|autogen', args[0])
+ return len(args) and not re.search(r'configure|autogen', args[0])
def prefix_with(constant, pieces):
diff --git a/tools/scan-build-py/libscanbuild/arguments.py b/tools/scan-build-py/libscanbuild/arguments.py
index 58c56d2b6d..e258a41003 100644
--- a/tools/scan-build-py/libscanbuild/arguments.py
+++ b/tools/scan-build-py/libscanbuild/arguments.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module parses and validates arguments for command-line interfaces.
It uses argparse module to create the command line parser. (This library is
diff --git a/tools/scan-build-py/libscanbuild/clang.py b/tools/scan-build-py/libscanbuild/clang.py
index 0cbfdb648f..3451b98dbd 100644
--- a/tools/scan-build-py/libscanbuild/clang.py
+++ b/tools/scan-build-py/libscanbuild/clang.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module is responsible for the Clang executable.
Since Clang command line interface is so rich, but this project is using only
diff --git a/tools/scan-build-py/libscanbuild/compilation.py b/tools/scan-build-py/libscanbuild/compilation.py
index ef906fa60b..38ce634fbe 100644
--- a/tools/scan-build-py/libscanbuild/compilation.py
+++ b/tools/scan-build-py/libscanbuild/compilation.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module is responsible for to parse a compiler invocation. """
import re
diff --git a/tools/scan-build-py/libscanbuild/intercept.py b/tools/scan-build-py/libscanbuild/intercept.py
index b9bf9e9175..70f3233f5e 100644
--- a/tools/scan-build-py/libscanbuild/intercept.py
+++ b/tools/scan-build-py/libscanbuild/intercept.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module is responsible to capture the compiler invocation of any
build process. The result of that should be a compilation database.
diff --git a/tools/scan-build-py/libscanbuild/report.py b/tools/scan-build-py/libscanbuild/report.py
index b3753c1d9d..8bd6385fce 100644
--- a/tools/scan-build-py/libscanbuild/report.py
+++ b/tools/scan-build-py/libscanbuild/report.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module is responsible to generate 'index.html' for the report.
The input for this step is the output directory, where individual reports
diff --git a/tools/scan-build-py/libscanbuild/shell.py b/tools/scan-build-py/libscanbuild/shell.py
index a575946a95..f9c08dfef2 100644
--- a/tools/scan-build-py/libscanbuild/shell.py
+++ b/tools/scan-build-py/libscanbuild/shell.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
""" This module implements basic shell escaping/unescaping methods. """
import re
diff --git a/tools/scan-build-py/tests/__init__.py b/tools/scan-build-py/tests/__init__.py
index bde2376a67..9efd160226 100644
--- a/tools/scan-build-py/tests/__init__.py
+++ b/tools/scan-build-py/tests/__init__.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import unittest
diff --git a/tools/scan-build-py/tests/functional/cases/__init__.py b/tools/scan-build-py/tests/functional/cases/__init__.py
index 8fb8465702..7ac3456f98 100644
--- a/tools/scan-build-py/tests/functional/cases/__init__.py
+++ b/tools/scan-build-py/tests/functional/cases/__init__.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import re
import os.path
diff --git a/tools/scan-build-py/tests/functional/cases/test_create_cdb.py b/tools/scan-build-py/tests/functional/cases/test_create_cdb.py
index c26fce0bbf..692a489b61 100644
--- a/tools/scan-build-py/tests/functional/cases/test_create_cdb.py
+++ b/tools/scan-build-py/tests/functional/cases/test_create_cdb.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear
from . import make_args, silent_check_call, silent_call, create_empty_file
diff --git a/tools/scan-build-py/tests/functional/cases/test_exec_anatomy.py b/tools/scan-build-py/tests/functional/cases/test_exec_anatomy.py
index d58a61217b..b0fec3db0c 100644
--- a/tools/scan-build-py/tests/functional/cases/test_exec_anatomy.py
+++ b/tools/scan-build-py/tests/functional/cases/test_exec_anatomy.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear
import unittest
diff --git a/tools/scan-build-py/tests/functional/cases/test_from_cdb.py b/tools/scan-build-py/tests/functional/cases/test_from_cdb.py
index 50264005c8..7af3eea4dd 100644
--- a/tools/scan-build-py/tests/functional/cases/test_from_cdb.py
+++ b/tools/scan-build-py/tests/functional/cases/test_from_cdb.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear
from . import call_and_report
diff --git a/tools/scan-build-py/tests/functional/cases/test_from_cmd.py b/tools/scan-build-py/tests/functional/cases/test_from_cmd.py
index 0eee4bb928..62e369c7c6 100644
--- a/tools/scan-build-py/tests/functional/cases/test_from_cmd.py
+++ b/tools/scan-build-py/tests/functional/cases/test_from_cmd.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear
from . import make_args, check_call_and_report, create_empty_file
diff --git a/tools/scan-build-py/tests/functional/exec/config.h.in b/tools/scan-build-py/tests/functional/exec/config.h.in
index 6221083fd2..2f07d0cbea 100644
--- a/tools/scan-build-py/tests/functional/exec/config.h.in
+++ b/tools/scan-build-py/tests/functional/exec/config.h.in
@@ -1,8 +1,7 @@
/* -*- coding: utf-8 -*-
-// 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
*/
#pragma once
diff --git a/tools/scan-build-py/tests/functional/exec/main.c b/tools/scan-build-py/tests/functional/exec/main.c
index 830cf3749c..0f5e01fb35 100644
--- a/tools/scan-build-py/tests/functional/exec/main.c
+++ b/tools/scan-build-py/tests/functional/exec/main.c
@@ -1,8 +1,7 @@
/* -*- coding: utf-8 -*-
-// 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
*/
#include "config.h"
diff --git a/tools/scan-build-py/tests/unit/__init__.py b/tools/scan-build-py/tests/unit/__init__.py
index 6b7fd9fa0d..83a04743e6 100644
--- a/tools/scan-build-py/tests/unit/__init__.py
+++ b/tools/scan-build-py/tests/unit/__init__.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
from . import test_libear
from . import test_compilation
diff --git a/tools/scan-build-py/tests/unit/test_analyze.py b/tools/scan-build-py/tests/unit/test_analyze.py
index 768a3b6910..4b6f5d0521 100644
--- a/tools/scan-build-py/tests/unit/test_analyze.py
+++ b/tools/scan-build-py/tests/unit/test_analyze.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import unittest
import re
diff --git a/tools/scan-build-py/tests/unit/test_clang.py b/tools/scan-build-py/tests/unit/test_clang.py
index 7d625c6c5b..80ce61a1fa 100644
--- a/tools/scan-build-py/tests/unit/test_clang.py
+++ b/tools/scan-build-py/tests/unit/test_clang.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear
import libscanbuild.clang as sut
diff --git a/tools/scan-build-py/tests/unit/test_compilation.py b/tools/scan-build-py/tests/unit/test_compilation.py
index 124febaf01..e8ad3d8c99 100644
--- a/tools/scan-build-py/tests/unit/test_compilation.py
+++ b/tools/scan-build-py/tests/unit/test_compilation.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libscanbuild.compilation as sut
import unittest
diff --git a/tools/scan-build-py/tests/unit/test_intercept.py b/tools/scan-build-py/tests/unit/test_intercept.py
index 583d1c3da9..5473b88d83 100644
--- a/tools/scan-build-py/tests/unit/test_intercept.py
+++ b/tools/scan-build-py/tests/unit/test_intercept.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear
import libscanbuild.intercept as sut
diff --git a/tools/scan-build-py/tests/unit/test_libear.py b/tools/scan-build-py/tests/unit/test_libear.py
index f5b9280289..933da50242 100644
--- a/tools/scan-build-py/tests/unit/test_libear.py
+++ b/tools/scan-build-py/tests/unit/test_libear.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear as sut
import unittest
diff --git a/tools/scan-build-py/tests/unit/test_report.py b/tools/scan-build-py/tests/unit/test_report.py
index c943699156..60ec0d855f 100644
--- a/tools/scan-build-py/tests/unit/test_report.py
+++ b/tools/scan-build-py/tests/unit/test_report.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libear
import libscanbuild.report as sut
diff --git a/tools/scan-build-py/tests/unit/test_shell.py b/tools/scan-build-py/tests/unit/test_shell.py
index a2904b07f5..6ffbb8782a 100644
--- a/tools/scan-build-py/tests/unit/test_shell.py
+++ b/tools/scan-build-py/tests/unit/test_shell.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-# 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
import libscanbuild.shell as sut
import unittest
diff --git a/tools/scan-build/bin/scan-build b/tools/scan-build/bin/scan-build
index fd0dd66b2d..903e19a290 100755
--- a/tools/scan-build/bin/scan-build
+++ b/tools/scan-build/bin/scan-build
@@ -1,9 +1,8 @@
#!/usr/bin/env perl
#
-# 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
#
##===----------------------------------------------------------------------===##
#
@@ -1461,6 +1460,16 @@ sub ShellEscape {
}
##----------------------------------------------------------------------------##
+# FindXcrun - searches for the 'xcrun' executable. Returns "" if not found.
+##----------------------------------------------------------------------------##
+
+sub FindXcrun {
+ my $xcrun = `which xcrun`;
+ chomp $xcrun;
+ return $xcrun;
+}
+
+##----------------------------------------------------------------------------##
# FindClang - searches for 'clang' executable.
##----------------------------------------------------------------------------##
@@ -1469,6 +1478,16 @@ sub FindClang {
$Clang = Cwd::realpath("$RealBin/bin/clang") if (-f "$RealBin/bin/clang");
if (!defined $Clang || ! -x $Clang) {
$Clang = Cwd::realpath("$RealBin/clang") if (-f "$RealBin/clang");
+ if (!defined $Clang || ! -x $Clang) {
+ # When an Xcode toolchain is present, look for a clang in the sibling bin
+ # of the parent of the bin directory. So if scan-build is at
+ # $TOOLCHAIN/usr/local/bin/scan-build look for clang at
+ # $TOOLCHAIN/usr/bin/clang.
+ my $has_xcode_toolchain = FindXcrun() ne "";
+ if ($has_xcode_toolchain && -f "$RealBin/../../bin/clang") {
+ $Clang = Cwd::realpath("$RealBin/../../bin/clang");
+ }
+ }
}
if (!defined $Clang || ! -x $Clang) {
return "error: Cannot find an executable 'clang' relative to" .
@@ -1478,8 +1497,7 @@ sub FindClang {
}
else {
if ($Options{AnalyzerDiscoveryMethod} =~ /^[Xx]code$/) {
- my $xcrun = `which xcrun`;
- chomp $xcrun;
+ my $xcrun = FindXcrun();
if ($xcrun eq "") {
return "Cannot find 'xcrun' to find 'clang' for analysis.\n";
}
diff --git a/tools/scan-build/bin/set-xcode-analyzer b/tools/scan-build/bin/set-xcode-analyzer
index 8e674823ba..c2a65c9085 100755
--- a/tools/scan-build/bin/set-xcode-analyzer
+++ b/tools/scan-build/bin/set-xcode-analyzer
@@ -42,7 +42,7 @@ def ModifySpec(path, isBuiltinAnalyzer, pathToChecker):
if line.find("Static Analyzer") >= 0:
foundAnalyzer = True
else:
- m = re.search('^(\s*ExecPath\s*=\s*")', line)
+ m = re.search(r'^(\s*ExecPath\s*=\s*")', line)
if m:
line = "".join([m.group(0), pathToChecker, '";\n'])
# Do not modify further ExecPath's later in the xcspec.
diff --git a/tools/scan-build/libexec/ccc-analyzer b/tools/scan-build/libexec/ccc-analyzer
index 70afb5bcbb..9a4548f167 100755
--- a/tools/scan-build/libexec/ccc-analyzer
+++ b/tools/scan-build/libexec/ccc-analyzer
@@ -1,9 +1,8 @@
#!/usr/bin/env perl
#
-# 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/tools/scan-build/man/scan-build.1 b/tools/scan-build/man/scan-build.1
index cf7e7b15c3..4f3cd8d103 100644
--- a/tools/scan-build/man/scan-build.1
+++ b/tools/scan-build/man/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