[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/94717 >From eeb334620df72c395a5ad27f44a864a6a0c194a5 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 6 Jun 2024 23:18:12 -0400 Subject: [PATCH 1/2] [clang][clang-doc] add asset path --- .../clang-doc/tool/ClangDocMain.cpp | 73 ++- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 21b581fa6df2e..df53c46b4a76e 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -81,6 +81,12 @@ static llvm::cl::list UserStylesheets( llvm::cl::desc("CSS stylesheets to extend the default styles."), llvm::cl::cat(ClangDocCategory)); +static llvm::cl::opt +UserAssetPath("asset", + llvm::cl::desc("User supplied asset path for html output to " + "override the default css and js files"), + llvm::cl::cat(ClangDocCategory)); + static llvm::cl::opt SourceRoot("source-root", llvm::cl::desc(R"( Directory where processed files are stored. Links to definition locations will only be @@ -131,12 +137,54 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } +void GetAssetFiles(clang::doc::ClangDocContext CDCtx) { + std::error_code Code; + for (auto DirIt = llvm::sys::fs::directory_iterator( +std::string(UserAssetPath), Code), +dir_end = llvm::sys::fs::directory_iterator(); + !Code && DirIt != dir_end; DirIt.increment(Code)) { +llvm::SmallString<128> filePath = llvm::SmallString<128>(DirIt->path()); +if (llvm::sys::fs::is_regular_file(filePath)) { + if (filePath.ends_with(".css")) { +CDCtx.UserStylesheets.push_back(std::string(filePath)); + } else if (filePath.ends_with(".js")) { +CDCtx.FilesToCopy.push_back(std::string(filePath)); + } +} + } +} + +void GetDefaultAssetFiles(const char *Argv0, + clang::doc::ClangDocContext CDCtx) { + void *MainAddr = (void *)(intptr_t)GetExecutablePath; + std::string ClangDocPath = GetExecutablePath(Argv0, MainAddr); + llvm::SmallString<128> NativeClangDocPath; + llvm::sys::path::native(ClangDocPath, NativeClangDocPath); + + llvm::SmallString<128> AssetsPath; + AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); + llvm::sys::path::append(AssetsPath, "..", "share", "clang"); + llvm::SmallString<128> DefaultStylesheet; + llvm::sys::path::native(AssetsPath, DefaultStylesheet); + llvm::sys::path::append(DefaultStylesheet, + "clang-doc-default-stylesheet.css"); + llvm::SmallString<128> IndexJS; + llvm::sys::path::native(AssetsPath, IndexJS); + llvm::sys::path::append(IndexJS, "index.js"); + CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), + std::string(DefaultStylesheet)); + CDCtx.FilesToCopy.emplace_back(IndexJS.str()); + + llvm::outs() << "No default asset path found using default asset path: " + << AssetsPath << "\n"; +} + int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); std::error_code OK; const char *Overview = -R"(Generates documentation from source code and comments. + R"(Generates documentation from source code and comments. Example usage for files without flags (default): @@ -182,23 +230,12 @@ Example usage for a project using a compile commands database: {"index.js", "index_json.js"}}; if (Format == "html") { -void *MainAddr = (void *)(intptr_t)GetExecutablePath; -std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr); -llvm::SmallString<128> NativeClangDocPath; -llvm::sys::path::native(ClangDocPath, NativeClangDocPath); -llvm::SmallString<128> AssetsPath; -AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); -llvm::sys::path::append(AssetsPath, "..", "share", "clang"); -llvm::SmallString<128> DefaultStylesheet; -llvm::sys::path::native(AssetsPath, DefaultStylesheet); -llvm::sys::path::append(DefaultStylesheet, -"clang-doc-default-stylesheet.css"); -llvm::SmallString<128> IndexJS; -llvm::sys::path::native(AssetsPath, IndexJS); -llvm::sys::path::append(IndexJS, "index.js"); -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); -CDCtx.FilesToCopy.emplace_back(IndexJS.str()); +if (!UserAssetPath.empty() && +llvm::sys::fs::is_directory(std::string(UserAssetPath))) { + GetAssetFiles(CDCtx); +} else { + GetDefaultAssetFiles(argv[0], CDCtx); +} } // Mapping phase >From 85581ed2f05974eac5697f43ab95a34ce17742a0 Mon Sep 17 00:00:00 2001 From:
[clang-tools-extra] [clang-doc] Add basic e2e test (PR #93928)
PeterChou1 wrote: I split the PR into 2 this PR relies on https://github.com/llvm/llvm-project/pull/94717 https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add basic e2e test (PR #93928)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/93928 >From 219df1820de43696dd51268f1aa22c397846c0a6 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Fri, 7 Jun 2024 01:47:15 -0400 Subject: [PATCH] [clang-doc] add basic e2e test --- .../Inputs/clang-doc-default-stylesheet.css | 969 ++ .../Inputs/clang-doc-project1/Calculator.cpp | 21 + .../Inputs/clang-doc-project1/Calculator.h| 46 + .../Inputs/clang-doc-project1/Circle.cpp | 11 + .../Inputs/clang-doc-project1/Circle.h| 35 + .../Inputs/clang-doc-project1/Rectangle.cpp | 12 + .../Inputs/clang-doc-project1/Rectangle.h | 37 + .../Inputs/clang-doc-project1/Shape.h | 30 + .../clang-doc-project1/database_template.json | 17 + .../test/clang-doc/Inputs/index.js| 87 ++ .../test/clang-doc/clang-doc-project1.cpp | 361 +++ 11 files changed, 1626 insertions(+) create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.cpp create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.h create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.cpp create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.h create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.cpp create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.h create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Shape.h create mode 100644 clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/database_template.json create mode 100644 clang-tools-extra/test/clang-doc/Inputs/index.js create mode 100644 clang-tools-extra/test/clang-doc/clang-doc-project1.cpp diff --git a/clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css b/clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css new file mode 100644 index 0..8b335232b8048 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css @@ -0,0 +1,969 @@ +.dark-primary-color{ background: #1976D2; } +.default-primary-color { background: #2196F3; } +.light-primary-color { background: #BBDEFB; } +.text-primary-color{ color: #FF; } +.accent-color { background: #00BCD4; } +.primary-text-color{ color: #212121; } +.secondary-text-color { color: #727272; } +.divider-color { border-color: #B6B6B6; } + +/* for layout */ +html, +body { + margin: 0; + padding: 0; + height: 100%; + width: 100%; + overflow: hidden; + box-sizing: border-box; +} + +*, *:before, *:after { + box-sizing: inherit; +} + +body { + display: flex; + flex-direction: column; + min-height: 100vh; +} + +header { + flex: 0 0 50px; + display: flex; + flex-direction: row; + align-items: center; + padding-left: 30px; +} + +header ol { + list-style: none; + margin: 0; + padding: 0; +} + +header ol li { + display: inline; +} + +header form { + display: flex; + flex: 1; + justify-content: flex-end; + padding-right: 30px; +} + +header#header-search-sidebar { + height: 50px; + margin-bottom: 25px; +} + +footer { + flex: 0 0 16px; + text-align: center; + padding: 16px 20px; +} + +main { + flex: 1; + display: flex; + flex-direction: row; + padding: 20px; + min-height: 0; +} + +.sidebar-offcanvas-left { + flex: 0 1 230px; + overflow-y: scroll; + padding: 20px 0 15px 30px; + margin: 5px 20px 0 0; + visibility: visible; /* shown by Javascript after scroll position restore */ +} + +::-webkit-scrollbar-button{ display: none; height: 13px; border-radius: 0px; background-color: #AAA; } +::-webkit-scrollbar-button:hover{ background-color: #AAA; } +::-webkit-scrollbar-thumb{ background-color: #CCC; } +::-webkit-scrollbar-thumb:hover{ background-color: #CCC; } +::-webkit-scrollbar{ width: 4px; } +/* ::-webkit-overflow-scrolling: touch; */ + +.main-content::-webkit-scrollbar{ width: 8px; } + +.main-content { + flex: 1; + overflow-y: scroll; + padding: 10px 20px 0 20px; + visibility: visible; /* shown by Javascript after scroll position restore */ +} + +.sidebar-offcanvas-right { + flex: 0 1 12em; + overflow-y: scroll; + padding: 20px 15px 15px 15px; + margin-top: 5px; + margin-right: 20px; + visibility: visible; /* shown by Javascript after scroll position restore */ +} +/* end for layout */ + +body { + -webkit-text-size-adjust: 100%; + overflow-x: hidden; + font-family: Roboto, sans-serif; + font-size: 16px; + line-height: 1.42857143; + color: #11; + background-color: #fff; +} + +/* some of this is to reset bootstrap */ +nav.navbar { + background-color: inherit; + min-height: 50px; + border: 0; +} + +@media (max-width: 768px) { + .hidden-xs { +display: none !important; + } +} + +@media (min-width: 769px) { +
[clang] Fix spurious non-strict availability warning (PR #94377)
https://github.com/Xazax-hun closed https://github.com/llvm/llvm-project/pull/94377 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 670fa2b - Fix spurious non-strict availability warning (#94377)
Author: Gábor Horváth Date: 2024-06-07T06:47:57+01:00 New Revision: 670fa2bd7a4d50c33bc24d4e3e1fa4079592b730 URL: https://github.com/llvm/llvm-project/commit/670fa2bd7a4d50c33bc24d4e3e1fa4079592b730 DIFF: https://github.com/llvm/llvm-project/commit/670fa2bd7a4d50c33bc24d4e3e1fa4079592b730.diff LOG: Fix spurious non-strict availability warning (#94377) The availability attributes are stored on the function declarations. The code was looking for them in the function template declarations. This resulted in spuriously diagnosing (non-strict) availablity issues in contexts that are not available. Co-authored-by: Gabor Horvath Added: clang/test/Sema/attr-availability-macosx.cpp Modified: clang/include/clang/Sema/Initialization.h clang/lib/Sema/SemaAvailability.cpp Removed: diff --git a/clang/include/clang/Sema/Initialization.h b/clang/include/clang/Sema/Initialization.h index 2072cd8d1c3ef..f443e327eaf32 100644 --- a/clang/include/clang/Sema/Initialization.h +++ b/clang/include/clang/Sema/Initialization.h @@ -212,7 +212,7 @@ class alignas(8) InitializedEntity { struct C Capture; }; - InitializedEntity() {}; + InitializedEntity() {} /// Create the initialization entity for a variable. InitializedEntity(VarDecl *Var, EntityKind EK = EK_Variable) diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp index 330cd602297d4..3e5f90b450367 100644 --- a/clang/lib/Sema/SemaAvailability.cpp +++ b/clang/lib/Sema/SemaAvailability.cpp @@ -12,6 +12,7 @@ #include "clang/AST/Attr.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Basic/DiagnosticSema.h" #include "clang/Basic/IdentifierTable.h" @@ -46,6 +47,10 @@ static const AvailabilityAttr *getAttrForPlatform(ASTContext , // Check each AvailabilityAttr to find the one for this platform. // For multiple attributes with the same platform try to find one for this // environment. + // The attribute is always on the FunctionDecl, not on the + // FunctionTemplateDecl. + if (const auto *FTD = dyn_cast(D)) +D = FTD->getTemplatedDecl(); for (const auto *A : D->attrs()) { if (const auto *Avail = dyn_cast(A)) { // FIXME: this is copied from CheckAvailability. We should try to diff --git a/clang/test/Sema/attr-availability-macosx.cpp b/clang/test/Sema/attr-availability-macosx.cpp new file mode 100644 index 0..52f320d409281 --- /dev/null +++ b/clang/test/Sema/attr-availability-macosx.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 "-triple" "arm64-apple-macosx10.15" -fsyntax-only -verify %s + +__attribute__((availability(macos,introduced=11))) +inline bool try_acquire() { + return true; +} + +template +__attribute__((availability(macos,introduced=11))) +bool try_acquire_for(T duration) { // expected-note{{'try_acquire_for' has been marked as being introduced in macOS 11 here, but the deployment target is macOS 10.15}} + return try_acquire(); +} + +int main() { + try_acquire_for(1); // expected-warning{{'try_acquire_for' is only available on macOS 11 or newer}} + // expected-note@-1{{enclose 'try_acquire_for' in a __builtin_available check to silence this warning}} +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 98714866830f505d7bb87de6b92a28f280a34b9b d535cb7b7c92a22931b276a8c9fe97a2f04c2258 -- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp `` View the diff from clang-format here. ``diff diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index ab6f6198aa..b72767d201 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -54,38 +54,38 @@ static llvm::cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); static llvm::cl::OptionCategory ClangDocCategory("clang-doc options"); static llvm::cl::opt -ProjectName("project-name", llvm::cl::desc("Name of project."), -llvm::cl::cat(ClangDocCategory)); +ProjectName("project-name", llvm::cl::desc("Name of project."), +llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt IgnoreMappingFailures( -"ignore-map-errors", -llvm::cl::desc("Continue if files are not mapped correctly."), -llvm::cl::init(true), llvm::cl::cat(ClangDocCategory)); +"ignore-map-errors", +llvm::cl::desc("Continue if files are not mapped correctly."), +llvm::cl::init(true), llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt -OutDirectory("output", - llvm::cl::desc("Directory for outputting generated files."), - llvm::cl::init("docs"), llvm::cl::cat(ClangDocCategory)); +OutDirectory("output", + llvm::cl::desc("Directory for outputting generated files."), + llvm::cl::init("docs"), llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt -PublicOnly("public", llvm::cl::desc("Document only public declarations."), - llvm::cl::init(false), llvm::cl::cat(ClangDocCategory)); +PublicOnly("public", llvm::cl::desc("Document only public declarations."), + llvm::cl::init(false), llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt DoxygenOnly( -"doxygen", -llvm::cl::desc("Use only doxygen-style comments to generate docs."), -llvm::cl::init(false), llvm::cl::cat(ClangDocCategory)); +"doxygen", +llvm::cl::desc("Use only doxygen-style comments to generate docs."), +llvm::cl::init(false), llvm::cl::cat(ClangDocCategory)); static llvm::cl::list UserStylesheets( -"stylesheets", llvm::cl::CommaSeparated, -llvm::cl::desc("CSS stylesheets to extend the default styles."), -llvm::cl::cat(ClangDocCategory)); +"stylesheets", llvm::cl::CommaSeparated, +llvm::cl::desc("CSS stylesheets to extend the default styles."), +llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt -UserAssetPath("asset", - llvm::cl::desc("User supplied asset path for html output to " - "override the default css and js files"), - llvm::cl::cat(ClangDocCategory)); +UserAssetPath("asset", + llvm::cl::desc("User supplied asset path for html output to " + "override the default css and js files"), + llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt SourceRoot("source-root", llvm::cl::desc(R"( Directory where processed files are stored. @@ -94,38 +94,38 @@ generated if the file is in this dir.)"), llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt -RepositoryUrl("repository", llvm::cl::desc(R"( +RepositoryUrl("repository", llvm::cl::desc(R"( URL of repository that hosts code. Used for links to definition locations.)"), - llvm::cl::cat(ClangDocCategory)); + llvm::cl::cat(ClangDocCategory)); enum OutputFormatTy { -md, -yaml, -html, + md, + yaml, + html, }; static llvm::cl::opt -FormatEnum("format", llvm::cl::desc("Format for outputted docs."), - llvm::cl::values(clEnumValN(OutputFormatTy::yaml, "yaml", - "Documentation in YAML format."), -clEnumValN(OutputFormatTy::md, "md", - "Documentation in MD format."), -clEnumValN(OutputFormatTy::html, "html", - "Documentation in HTML format.")), - llvm::cl::init(OutputFormatTy::yaml), - llvm::cl::cat(ClangDocCategory)); +FormatEnum("format", llvm::cl::desc("Format for outputted docs."), + llvm::cl::values(clEnumValN(OutputFormatTy::yaml, "yaml", +
[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/94717 >From eeb334620df72c395a5ad27f44a864a6a0c194a5 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 6 Jun 2024 23:18:12 -0400 Subject: [PATCH 1/2] [clang][clang-doc] add asset path --- .../clang-doc/tool/ClangDocMain.cpp | 73 ++- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 21b581fa6df2e..df53c46b4a76e 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -81,6 +81,12 @@ static llvm::cl::list UserStylesheets( llvm::cl::desc("CSS stylesheets to extend the default styles."), llvm::cl::cat(ClangDocCategory)); +static llvm::cl::opt +UserAssetPath("asset", + llvm::cl::desc("User supplied asset path for html output to " + "override the default css and js files"), + llvm::cl::cat(ClangDocCategory)); + static llvm::cl::opt SourceRoot("source-root", llvm::cl::desc(R"( Directory where processed files are stored. Links to definition locations will only be @@ -131,12 +137,54 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } +void GetAssetFiles(clang::doc::ClangDocContext CDCtx) { + std::error_code Code; + for (auto DirIt = llvm::sys::fs::directory_iterator( +std::string(UserAssetPath), Code), +dir_end = llvm::sys::fs::directory_iterator(); + !Code && DirIt != dir_end; DirIt.increment(Code)) { +llvm::SmallString<128> filePath = llvm::SmallString<128>(DirIt->path()); +if (llvm::sys::fs::is_regular_file(filePath)) { + if (filePath.ends_with(".css")) { +CDCtx.UserStylesheets.push_back(std::string(filePath)); + } else if (filePath.ends_with(".js")) { +CDCtx.FilesToCopy.push_back(std::string(filePath)); + } +} + } +} + +void GetDefaultAssetFiles(const char *Argv0, + clang::doc::ClangDocContext CDCtx) { + void *MainAddr = (void *)(intptr_t)GetExecutablePath; + std::string ClangDocPath = GetExecutablePath(Argv0, MainAddr); + llvm::SmallString<128> NativeClangDocPath; + llvm::sys::path::native(ClangDocPath, NativeClangDocPath); + + llvm::SmallString<128> AssetsPath; + AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); + llvm::sys::path::append(AssetsPath, "..", "share", "clang"); + llvm::SmallString<128> DefaultStylesheet; + llvm::sys::path::native(AssetsPath, DefaultStylesheet); + llvm::sys::path::append(DefaultStylesheet, + "clang-doc-default-stylesheet.css"); + llvm::SmallString<128> IndexJS; + llvm::sys::path::native(AssetsPath, IndexJS); + llvm::sys::path::append(IndexJS, "index.js"); + CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), + std::string(DefaultStylesheet)); + CDCtx.FilesToCopy.emplace_back(IndexJS.str()); + + llvm::outs() << "No default asset path found using default asset path: " + << AssetsPath << "\n"; +} + int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); std::error_code OK; const char *Overview = -R"(Generates documentation from source code and comments. + R"(Generates documentation from source code and comments. Example usage for files without flags (default): @@ -182,23 +230,12 @@ Example usage for a project using a compile commands database: {"index.js", "index_json.js"}}; if (Format == "html") { -void *MainAddr = (void *)(intptr_t)GetExecutablePath; -std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr); -llvm::SmallString<128> NativeClangDocPath; -llvm::sys::path::native(ClangDocPath, NativeClangDocPath); -llvm::SmallString<128> AssetsPath; -AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); -llvm::sys::path::append(AssetsPath, "..", "share", "clang"); -llvm::SmallString<128> DefaultStylesheet; -llvm::sys::path::native(AssetsPath, DefaultStylesheet); -llvm::sys::path::append(DefaultStylesheet, -"clang-doc-default-stylesheet.css"); -llvm::SmallString<128> IndexJS; -llvm::sys::path::native(AssetsPath, IndexJS); -llvm::sys::path::append(IndexJS, "index.js"); -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); -CDCtx.FilesToCopy.emplace_back(IndexJS.str()); +if (!UserAssetPath.empty() && +llvm::sys::fs::is_directory(std::string(UserAssetPath))) { + GetAssetFiles(CDCtx); +} else { + GetDefaultAssetFiles(argv[0], CDCtx); +} } // Mapping phase >From d535cb7b7c92a22931b276a8c9fe97a2f04c2258 Mon Sep 17 00:00:00 2001 From:
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -1830,6 +1830,9 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables , if (VTable->hasInitializer()) return; + if (RD->shouldEmitInExternalSource()) +return; ChuanqiXu9 wrote: Got it. If it is primarily for optimizations, I guess it might not be a blocker. I'll add a FIXME later. https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -1830,6 +1830,9 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables , if (VTable->hasInitializer()) return; + if (RD->shouldEmitInExternalSource()) +return; dwblaikie wrote: Yes, and we do emit them in normal builds above -O0 if the vtable is homed elsewhere due to a key function for instance - they can be used to allow for devirtualization https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] refactor misc-header-include-cycle (PR #94697)
https://github.com/HerrCai0907 closed https://github.com/llvm/llvm-project/pull/94697 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] c5ff983 - [clang-tidy] refactor misc-header-include-cycle (#94697)
Author: Congcong Cai Date: 2024-06-07T13:32:18+08:00 New Revision: c5ff983fe4a3180e13c7244a6ce9f5994b4379b4 URL: https://github.com/llvm/llvm-project/commit/c5ff983fe4a3180e13c7244a6ce9f5994b4379b4 DIFF: https://github.com/llvm/llvm-project/commit/c5ff983fe4a3180e13c7244a6ce9f5994b4379b4.diff LOG: [clang-tidy] refactor misc-header-include-cycle (#94697) 1. merge valid check 2. use range base loop Added: Modified: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp index 37bc577c646ab..cdb5e6b16069b 100644 --- a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp @@ -130,20 +130,15 @@ class CyclicDependencyCallbacks : public PPCallbacks { << FileName; const bool IsIncludePathValid = -std::all_of(Files.rbegin(), It, [](const Include ) { +std::all_of(Files.rbegin(), It + 1, [](const Include ) { return !Elem.Name.empty() && Elem.Loc.isValid(); }); - if (!IsIncludePathValid) return; -auto CurrentIt = Files.rbegin(); -do { - if (CurrentIt->Loc.isValid()) -Check.diag(CurrentIt->Loc, "'%0' included from here", - DiagnosticIDs::Note) -<< CurrentIt->Name; -} while (CurrentIt++ != It); +for (const Include : llvm::make_range(Files.rbegin(), It + 1)) + Check.diag(I.Loc, "'%0' included from here", DiagnosticIDs::Note) + << I.Name; } bool isFileIgnored(StringRef FileName) const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
xry111 wrote: I'm really not a fan of enabling frame pointer by default. And enabling -fasynchronous-unwind-table is at least consistent with GCC. https://github.com/llvm/llvm-project/pull/94711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] refactor misc-header-include-cycle (PR #94697)
https://github.com/PiotrZSL approved this pull request. https://github.com/llvm/llvm-project/pull/94697 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PowerPC] Support -mno-red-zone option (PR #94581)
https://github.com/chenzheng1030 approved this pull request. The small LIT cases seem all good. Based on that, the patch LGTM. If possible, can you run some big applications with `-mno-redzone` to double confirm the functionality? I am not so sure about its quality since the option seems not be tested on PPC at all... https://github.com/llvm/llvm-project/pull/94581 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake][Release] Use the TXZ cpack generator for binaries (PR #90138)
https://github.com/tru approved this pull request. https://github.com/llvm/llvm-project/pull/90138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)
wangpc-pp wrote: The description needs to be revised. https://github.com/llvm/llvm-project/pull/94564 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)
https://github.com/wangpc-pp edited https://github.com/llvm/llvm-project/pull/94578 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/94578 >From 57c914eaefa7e59aa51a2b1e730fe1b7d6d10e57 Mon Sep 17 00:00:00 2001 From: Wang Pengcheng Date: Thu, 6 Jun 2024 13:48:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.6-beta.1 --- clang/include/clang/Basic/BuiltinsRISCV.td| 18 ++ clang/lib/CodeGen/CGBuiltin.cpp | 22 ++ clang/lib/Headers/CMakeLists.txt | 1 + clang/lib/Headers/riscv_atomics.h | 36 +++ clang/lib/Sema/SemaRISCV.cpp | 10 +- .../RISCV/atomics-intrinsics/zalrsc-error.c | 13 + .../CodeGen/RISCV/atomics-intrinsics/zalrsc.c | 222 ++ .../CodeGen/RISCV/atomics-intrinsics/zawrs.c | 42 llvm/include/llvm/IR/IntrinsicsRISCV.td | 32 +++ llvm/lib/Target/RISCV/RISCVInstrInfoA.td | 25 ++ llvm/lib/Target/RISCV/RISCVInstrInfoZa.td | 5 +- llvm/test/CodeGen/RISCV/zalrsc-rv32.ll| 74 ++ llvm/test/CodeGen/RISCV/zalrsc-rv64.ll| 74 ++ llvm/test/CodeGen/RISCV/zawrs.ll | 33 +++ 14 files changed, 605 insertions(+), 2 deletions(-) create mode 100644 clang/lib/Headers/riscv_atomics.h create mode 100644 clang/test/CodeGen/RISCV/atomics-intrinsics/zalrsc-error.c create mode 100644 clang/test/CodeGen/RISCV/atomics-intrinsics/zalrsc.c create mode 100644 clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c create mode 100644 llvm/test/CodeGen/RISCV/zalrsc-rv32.ll create mode 100644 llvm/test/CodeGen/RISCV/zalrsc-rv64.ll create mode 100644 llvm/test/CodeGen/RISCV/zawrs.ll diff --git a/clang/include/clang/Basic/BuiltinsRISCV.td b/clang/include/clang/Basic/BuiltinsRISCV.td index 4cc89a8a9d8af..458c755179417 100644 --- a/clang/include/clang/Basic/BuiltinsRISCV.td +++ b/clang/include/clang/Basic/BuiltinsRISCV.td @@ -146,3 +146,21 @@ let Features = "zihintntl", Attributes = [CustomTypeChecking] in { def ntl_load : RISCVBuiltin<"void(...)">; def ntl_store : RISCVBuiltin<"void(...)">; } // Features = "zihintntl", Attributes = [CustomTypeChecking] + +//===--===// +// Zawrs extension. +//===--===// +let Features = "zawrs" in { +def wrs_nto : RISCVBuiltin<"void()">; +def wrs_sto : RISCVBuiltin<"void()">; +} // Features = "zawrs" + +//===--===// +// Zalrsc extension. +//===--===// +let Features = "zalrsc" in { +def lr_w : RISCVBuiltin<"int(int *, _Constant unsigned int)">; +def lr_d : RISCVBuiltin<"int64_t(int64_t *, _Constant unsigned int)">; +def sc_w : RISCVBuiltin<"int(int, int *, _Constant unsigned int)">; +def sc_d : RISCVBuiltin<"int64_t(int64_t, int64_t *, _Constant unsigned int)">; +} // Features = "zalrsc" diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 37d0c478e0330..db48c69e10c86 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -21769,6 +21769,28 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID, ID = Intrinsic::riscv_sm3p1; break; + // Zawrs + case RISCV::BI__builtin_riscv_wrs_nto: +ID = Intrinsic::riscv_wrs_nto; +break; + case RISCV::BI__builtin_riscv_wrs_sto: +ID = Intrinsic::riscv_wrs_sto; +break; + + // Zalrsc + case RISCV::BI__builtin_riscv_lr_w: +ID = Intrinsic::riscv_lr_w; +break; + case RISCV::BI__builtin_riscv_lr_d: +ID = Intrinsic::riscv_lr_d; +break; + case RISCV::BI__builtin_riscv_sc_w: +ID = Intrinsic::riscv_sc_w; +break; + case RISCV::BI__builtin_riscv_sc_d: +ID = Intrinsic::riscv_sc_d; +break; + // Zihintntl case RISCV::BI__builtin_riscv_ntl_load: { llvm::Type *ResTy = ConvertType(E->getType()); diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index d3090e488306f..cf2fbf1893772 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -118,6 +118,7 @@ set(ppc_htm_files ) set(riscv_files + riscv_atomics.h riscv_bitmanip.h riscv_crypto.h riscv_ntlh.h diff --git a/clang/lib/Headers/riscv_atomics.h b/clang/lib/Headers/riscv_atomics.h new file mode 100644 index 0..35db57fe36131 --- /dev/null +++ b/clang/lib/Headers/riscv_atomics.h @@ -0,0 +1,36 @@ +/*=== riscv_atomics.h - RISC-V atomics intrinsics --=== + * + * 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 + * +
[clang] Testing32 bit for https://github.com/llvm/llvm-project/pull/92083 (PR #94603)
ChuanqiXu9 wrote: @DavidSpickett oh, sorry. I didn't expect the refined patch will break 32 bit again. Can you try the new patch? https://github.com/llvm/llvm-project/pull/94603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
ChuanqiXu9 wrote: Sadly it looks like the (refined) patch still breaks the alignment on 32 bit machine. https://lab.llvm.org/buildbot/#/builders/174/builds/34307 I've reverted the patch and updated https://github.com/llvm/llvm-project/pull/94603 to test it again. https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Testing32 bit for https://github.com/llvm/llvm-project/pull/92083 (PR #94603)
https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/94603 >From 264041a5819f7842ad5883e76b74de64615ddea1 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 6 Jun 2024 11:51:05 +0800 Subject: [PATCH 1/2] [serialization] no transitive decl change (#92083) Following of https://github.com/llvm/llvm-project/pull/86912 The motivation of the patch series is that, for a module interface unit `X`, when the dependent modules of `X` changes, if the changes is not relevant with `X`, we hope the BMI of `X` won't change. For the specific patch, we hope if the changes was about irrelevant declaration changes, we hope the BMI of `X` won't change. **However**, I found the patch itself is not very useful in practice, since the adding or removing declarations, will change the state of identifiers and types in most cases. That said, for the most simple example, ``` // partA.cppm export module m:partA; // partA.v1.cppm export module m:partA; export void a() {} // partB.cppm export module m:partB; export void b() {} // m.cppm export module m; export import :partA; export import :partB; // onlyUseB; export module onlyUseB; import m; export inline void onluUseB() { b(); } ``` the BMI of `onlyUseB` will change after we change the implementation of `partA.cppm` to `partA.v1.cppm`. Since `partA.v1.cppm` introduces new identifiers and types (the function prototype). So in this patch, we have to write the tests as: ``` // partA.cppm export module m:partA; export int getA() { ... } export int getA2(int) { ... } // partA.v1.cppm export module m:partA; export int getA() { ... } export int getA(int) { ... } export int getA2(int) { ... } // partB.cppm export module m:partB; export void b() {} // m.cppm export module m; export import :partA; export import :partB; // onlyUseB; export module onlyUseB; import m; export inline void onluUseB() { b(); } ``` so that the new introduced declaration `int getA(int)` doesn't introduce new identifiers and types, then the BMI of `onlyUseB` can keep unchanged. While it looks not so great, the patch should be the base of the patch to erase the transitive change for identifiers and types since I don't know how can we introduce new types and identifiers without introducing new declarations. Given how tightly the relationship between declarations, types and identifiers, I think we can only reach the ideal state after we made the series for all of the three entties. The design of the patch is similar to https://github.com/llvm/llvm-project/pull/86912, which extends the 32-bit DeclID to 64-bit and use the higher bits to store the module file index and the lower bits to store the Local Decl ID. A slight difference is that we only use 48 bits to store the new DeclID since we try to use the higher 16 bits to store the module ID in the prefix of Decl class. Previously, we use 32 bits to store the module ID and 32 bits to store the DeclID. I don't want to allocate additional space so I tried to make the additional space the same as 64 bits. An potential interesting thing here is about the relationship between the module ID and the module file index. I feel we can get the module file index by the module ID. But I didn't prove it or implement it. Since I want to make the patch itself as small as possible. We can make it in the future if we want. Another change in the patch is the new concept Decl Index, which means the index of the very big array `DeclsLoaded` in ASTReader. Previously, the index of a loaded declaration is simply the Decl ID minus PREDEFINED_DECL_NUMs. So there are some places they got used ambiguously. But this patch tried to split these two concepts. As https://github.com/llvm/llvm-project/pull/86912 did, the change will increase the on-disk PCM file sizes. As the declaration ID may be the most IDs in the PCM file, this can have the biggest impact on the size. In my experiments, this change will bring 6.6% increase of the on-disk PCM size. No compile-time performance regression observed. Given the benefits in the motivation example, I think the cost is worthwhile. --- clang/include/clang/AST/ASTUnresolvedSet.h| 9 +- clang/include/clang/AST/DeclAccessPair.h | 30 +++- clang/include/clang/AST/DeclBase.h| 17 +- clang/include/clang/AST/DeclID.h | 18 +- clang/include/clang/AST/UnresolvedSet.h | 1 + .../include/clang/Serialization/ASTBitCodes.h | 29 +++- clang/include/clang/Serialization/ASTReader.h | 36 ++-- .../include/clang/Serialization/ModuleFile.h | 18 +- .../clang/Serialization/ModuleManager.h | 2 +- clang/lib/AST/DeclBase.cpp| 40 - clang/lib/AST/DeclCXX.cpp | 4 +- clang/lib/Serialization/ASTReader.cpp | 163 ++ clang/lib/Serialization/ASTReaderDecl.cpp | 16 +- clang/lib/Serialization/ASTWriter.cpp | 7 +- clang/lib/Serialization/ModuleFile.cpp| 3 +-
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
MaskRay wrote: `.eh_frame` for non-C++-exception unwinding is pretty bad... As a new architecture, you can avoid doing it... https://ubuntu.com/blog/ubuntu-performance-engineering-with-frame-pointers-by-default https://www.brendangregg.com/blog/2024-03-17/the-return-of-the-frame-pointers.html https://github.com/llvm/llvm-project/pull/94711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/94717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/94717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/94717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang][clang-doc] Add Assets (PR #94717)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: None (PeterChou1) Changes Adds a new option --asset which allows users to specified the asset folder for the html output of clang-doc --- Full diff: https://github.com/llvm/llvm-project/pull/94717.diff 1 Files Affected: - (modified) clang-tools-extra/clang-doc/tool/ClangDocMain.cpp (+55-18) ``diff diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 21b581fa6df2e..df53c46b4a76e 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -81,6 +81,12 @@ static llvm::cl::list UserStylesheets( llvm::cl::desc("CSS stylesheets to extend the default styles."), llvm::cl::cat(ClangDocCategory)); +static llvm::cl::opt +UserAssetPath("asset", + llvm::cl::desc("User supplied asset path for html output to " + "override the default css and js files"), + llvm::cl::cat(ClangDocCategory)); + static llvm::cl::opt SourceRoot("source-root", llvm::cl::desc(R"( Directory where processed files are stored. Links to definition locations will only be @@ -131,12 +137,54 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } +void GetAssetFiles(clang::doc::ClangDocContext CDCtx) { + std::error_code Code; + for (auto DirIt = llvm::sys::fs::directory_iterator( +std::string(UserAssetPath), Code), +dir_end = llvm::sys::fs::directory_iterator(); + !Code && DirIt != dir_end; DirIt.increment(Code)) { +llvm::SmallString<128> filePath = llvm::SmallString<128>(DirIt->path()); +if (llvm::sys::fs::is_regular_file(filePath)) { + if (filePath.ends_with(".css")) { +CDCtx.UserStylesheets.push_back(std::string(filePath)); + } else if (filePath.ends_with(".js")) { +CDCtx.FilesToCopy.push_back(std::string(filePath)); + } +} + } +} + +void GetDefaultAssetFiles(const char *Argv0, + clang::doc::ClangDocContext CDCtx) { + void *MainAddr = (void *)(intptr_t)GetExecutablePath; + std::string ClangDocPath = GetExecutablePath(Argv0, MainAddr); + llvm::SmallString<128> NativeClangDocPath; + llvm::sys::path::native(ClangDocPath, NativeClangDocPath); + + llvm::SmallString<128> AssetsPath; + AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); + llvm::sys::path::append(AssetsPath, "..", "share", "clang"); + llvm::SmallString<128> DefaultStylesheet; + llvm::sys::path::native(AssetsPath, DefaultStylesheet); + llvm::sys::path::append(DefaultStylesheet, + "clang-doc-default-stylesheet.css"); + llvm::SmallString<128> IndexJS; + llvm::sys::path::native(AssetsPath, IndexJS); + llvm::sys::path::append(IndexJS, "index.js"); + CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), + std::string(DefaultStylesheet)); + CDCtx.FilesToCopy.emplace_back(IndexJS.str()); + + llvm::outs() << "No default asset path found using default asset path: " + << AssetsPath << "\n"; +} + int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); std::error_code OK; const char *Overview = -R"(Generates documentation from source code and comments. + R"(Generates documentation from source code and comments. Example usage for files without flags (default): @@ -182,23 +230,12 @@ Example usage for a project using a compile commands database: {"index.js", "index_json.js"}}; if (Format == "html") { -void *MainAddr = (void *)(intptr_t)GetExecutablePath; -std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr); -llvm::SmallString<128> NativeClangDocPath; -llvm::sys::path::native(ClangDocPath, NativeClangDocPath); -llvm::SmallString<128> AssetsPath; -AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); -llvm::sys::path::append(AssetsPath, "..", "share", "clang"); -llvm::SmallString<128> DefaultStylesheet; -llvm::sys::path::native(AssetsPath, DefaultStylesheet); -llvm::sys::path::append(DefaultStylesheet, -"clang-doc-default-stylesheet.css"); -llvm::SmallString<128> IndexJS; -llvm::sys::path::native(AssetsPath, IndexJS); -llvm::sys::path::append(IndexJS, "index.js"); -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); -CDCtx.FilesToCopy.emplace_back(IndexJS.str()); +if (!UserAssetPath.empty() && +llvm::sys::fs::is_directory(std::string(UserAssetPath))) { + GetAssetFiles(CDCtx); +} else { + GetDefaultAssetFiles(argv[0], CDCtx); +} } // Mapping phase `` https://github.com/llvm/llvm-project/pull/94717
[clang] 4f70c5e - Revert "[serialization] no transitive decl change (#92083)"
Author: Chuanqi Xu Date: 2024-06-07T11:29:09+08:00 New Revision: 4f70c5ec4a57e84642fa0772536f120cd9c75edb URL: https://github.com/llvm/llvm-project/commit/4f70c5ec4a57e84642fa0772536f120cd9c75edb DIFF: https://github.com/llvm/llvm-project/commit/4f70c5ec4a57e84642fa0772536f120cd9c75edb.diff LOG: Revert "[serialization] no transitive decl change (#92083)" This reverts commit 5c104879c1a98eeb845c03e7c45206bd48e88f0c. The ArmV7 bot is complaining the change breaks the alignment. Added: Modified: clang/include/clang/AST/ASTUnresolvedSet.h clang/include/clang/AST/DeclAccessPair.h clang/include/clang/AST/DeclBase.h clang/include/clang/AST/DeclID.h clang/include/clang/AST/UnresolvedSet.h clang/include/clang/Serialization/ASTBitCodes.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ModuleFile.h clang/include/clang/Serialization/ModuleManager.h clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclCXX.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ModuleFile.cpp Removed: clang/test/Modules/no-transitive-decls-change.cppm diff --git a/clang/include/clang/AST/ASTUnresolvedSet.h b/clang/include/clang/AST/ASTUnresolvedSet.h index dcce3bc63df25..398ffb188c95b 100644 --- a/clang/include/clang/AST/ASTUnresolvedSet.h +++ b/clang/include/clang/AST/ASTUnresolvedSet.h @@ -16,7 +16,6 @@ #include "clang/AST/ASTVector.h" #include "clang/AST/DeclAccessPair.h" -#include "clang/AST/DeclID.h" #include "clang/AST/UnresolvedSet.h" #include "clang/Basic/Specifiers.h" #include @@ -57,10 +56,6 @@ class ASTUnresolvedSet { Decls.push_back(DeclAccessPair::make(D, AS), C); } - void addLazyDecl(ASTContext , GlobalDeclID ID, AccessSpecifier AS) { -Decls.push_back(DeclAccessPair::makeLazy(ID.get(), AS), C); - } - /// Replaces the given declaration with the new one, once. /// /// \return true if the set changed @@ -114,10 +109,10 @@ class LazyASTUnresolvedSet { void reserve(ASTContext , unsigned N) { Impl.reserve(C, N); } - void addLazyDecl(ASTContext , GlobalDeclID ID, AccessSpecifier AS) { + void addLazyDecl(ASTContext , uintptr_t ID, AccessSpecifier AS) { assert(Impl.empty() || Impl.Decls.isLazy()); Impl.Decls.setLazy(true); -Impl.addLazyDecl(C, ID, AS); +Impl.addDecl(C, reinterpret_cast(ID << 2), AS); } }; diff --git a/clang/include/clang/AST/DeclAccessPair.h b/clang/include/clang/AST/DeclAccessPair.h index 17f29c3e97cea..805342c2910a7 100644 --- a/clang/include/clang/AST/DeclAccessPair.h +++ b/clang/include/clang/AST/DeclAccessPair.h @@ -27,17 +27,9 @@ class NamedDecl; /// A POD class for pairing a NamedDecl* with an access specifier. /// Can be put into unions. class DeclAccessPair { - /// Use the lower 2 bit to store AccessSpecifier. Use the higher - /// 61 bit to store the pointer to a NamedDecl or the DeclID to - /// a NamedDecl. If the 3rd bit is set, storing the DeclID, otherwise - /// storing the pointer. - // - // we'd use llvm::PointerUnion, but it isn't trivial - uint64_t Ptr; + uintptr_t Ptr; // we'd use llvm::PointerUnion, but it isn't trivial - enum { ASMask = 0x3, Mask = 0x7 }; - - bool isDeclID() const { return (Ptr >> 2) & 0x1; } + enum { Mask = 0x3 }; public: static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS) { @@ -46,22 +38,12 @@ class DeclAccessPair { return p; } - static DeclAccessPair makeLazy(uint64_t ID, AccessSpecifier AS) { -DeclAccessPair p; -p.Ptr = (ID << 3) | (0x1 << 2) | uint64_t(AS); -return p; - } - - uint64_t getDeclID() const { -assert(isDeclID()); -return (~Mask & Ptr) >> 3; - } - NamedDecl *getDecl() const { -assert(!isDeclID()); return reinterpret_cast(~Mask & Ptr); } - AccessSpecifier getAccess() const { return AccessSpecifier(ASMask & Ptr); } + AccessSpecifier getAccess() const { +return AccessSpecifier(Mask & Ptr); + } void setDecl(NamedDecl *D) { set(D, getAccess()); @@ -70,7 +52,7 @@ class DeclAccessPair { set(getDecl(), AS); } void set(NamedDecl *D, AccessSpecifier AS) { -Ptr = uint64_t(AS) | reinterpret_cast(D); +Ptr = uintptr_t(AS) | reinterpret_cast(D); } operator NamedDecl*() const { return getDecl(); } diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 5f19af1891b74..600ce73c7f019 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -708,7 +708,10 @@ class alignas(8) Decl { /// Set the owning module ID. This may only be called for /// deserialized Decls. - void setOwningModuleID(unsigned ID); + void setOwningModuleID(unsigned ID) { +assert(isFromASTFile() && "Only works on a deserialized declaration"); +
[clang-tools-extra] [clang][clang-doc] Add Assets (PR #94717)
https://github.com/PeterChou1 created https://github.com/llvm/llvm-project/pull/94717 Adds a new option --asset which allows users to specified the asset folder for the html output of clang-doc >From eeb334620df72c395a5ad27f44a864a6a0c194a5 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 6 Jun 2024 23:18:12 -0400 Subject: [PATCH] [clang][clang-doc] add asset path --- .../clang-doc/tool/ClangDocMain.cpp | 73 ++- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 21b581fa6df2e..df53c46b4a76e 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -81,6 +81,12 @@ static llvm::cl::list UserStylesheets( llvm::cl::desc("CSS stylesheets to extend the default styles."), llvm::cl::cat(ClangDocCategory)); +static llvm::cl::opt +UserAssetPath("asset", + llvm::cl::desc("User supplied asset path for html output to " + "override the default css and js files"), + llvm::cl::cat(ClangDocCategory)); + static llvm::cl::opt SourceRoot("source-root", llvm::cl::desc(R"( Directory where processed files are stored. Links to definition locations will only be @@ -131,12 +137,54 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } +void GetAssetFiles(clang::doc::ClangDocContext CDCtx) { + std::error_code Code; + for (auto DirIt = llvm::sys::fs::directory_iterator( +std::string(UserAssetPath), Code), +dir_end = llvm::sys::fs::directory_iterator(); + !Code && DirIt != dir_end; DirIt.increment(Code)) { +llvm::SmallString<128> filePath = llvm::SmallString<128>(DirIt->path()); +if (llvm::sys::fs::is_regular_file(filePath)) { + if (filePath.ends_with(".css")) { +CDCtx.UserStylesheets.push_back(std::string(filePath)); + } else if (filePath.ends_with(".js")) { +CDCtx.FilesToCopy.push_back(std::string(filePath)); + } +} + } +} + +void GetDefaultAssetFiles(const char *Argv0, + clang::doc::ClangDocContext CDCtx) { + void *MainAddr = (void *)(intptr_t)GetExecutablePath; + std::string ClangDocPath = GetExecutablePath(Argv0, MainAddr); + llvm::SmallString<128> NativeClangDocPath; + llvm::sys::path::native(ClangDocPath, NativeClangDocPath); + + llvm::SmallString<128> AssetsPath; + AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); + llvm::sys::path::append(AssetsPath, "..", "share", "clang"); + llvm::SmallString<128> DefaultStylesheet; + llvm::sys::path::native(AssetsPath, DefaultStylesheet); + llvm::sys::path::append(DefaultStylesheet, + "clang-doc-default-stylesheet.css"); + llvm::SmallString<128> IndexJS; + llvm::sys::path::native(AssetsPath, IndexJS); + llvm::sys::path::append(IndexJS, "index.js"); + CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), + std::string(DefaultStylesheet)); + CDCtx.FilesToCopy.emplace_back(IndexJS.str()); + + llvm::outs() << "No default asset path found using default asset path: " + << AssetsPath << "\n"; +} + int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); std::error_code OK; const char *Overview = -R"(Generates documentation from source code and comments. + R"(Generates documentation from source code and comments. Example usage for files without flags (default): @@ -182,23 +230,12 @@ Example usage for a project using a compile commands database: {"index.js", "index_json.js"}}; if (Format == "html") { -void *MainAddr = (void *)(intptr_t)GetExecutablePath; -std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr); -llvm::SmallString<128> NativeClangDocPath; -llvm::sys::path::native(ClangDocPath, NativeClangDocPath); -llvm::SmallString<128> AssetsPath; -AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); -llvm::sys::path::append(AssetsPath, "..", "share", "clang"); -llvm::SmallString<128> DefaultStylesheet; -llvm::sys::path::native(AssetsPath, DefaultStylesheet); -llvm::sys::path::append(DefaultStylesheet, -"clang-doc-default-stylesheet.css"); -llvm::SmallString<128> IndexJS; -llvm::sys::path::native(AssetsPath, IndexJS); -llvm::sys::path::append(IndexJS, "index.js"); -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); -CDCtx.FilesToCopy.emplace_back(IndexJS.str()); +if (!UserAssetPath.empty() && +llvm::sys::fs::is_directory(std::string(UserAssetPath))) { + GetAssetFiles(CDCtx); +} else { + GetDefaultAssetFiles(argv[0], CDCtx); +}
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -1830,6 +1830,9 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables , if (VTable->hasInitializer()) return; + if (RD->shouldEmitInExternalSource()) +return; ChuanqiXu9 wrote: > This check seems like it's at the wrong level; if we don't want a vtable, why > are we calling this in the first place? Done in the newest update. https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/75912 >From cf8be3c418dde67b74d4a5a4ea98a33f0e2fbd72 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Tue, 19 Dec 2023 17:00:59 +0800 Subject: [PATCH 1/3] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes Close https://github.com/llvm/llvm-project/issues/70585 and reflect https://github.com/itanium-cxx-abi/cxx-abi/issues/170. The significant change of the patch is: for dynamic classes attached to module units, we generate the vtable to the attached module units directly and the key functions for such classes is meaningless. --- clang/include/clang/AST/DeclBase.h| 3 ++ clang/lib/AST/DeclBase.cpp| 9 + clang/lib/CodeGen/CGVTables.cpp | 28 ++ clang/lib/CodeGen/CodeGenModule.cpp | 7 clang/lib/CodeGen/ItaniumCXXABI.cpp | 3 ++ clang/lib/Sema/SemaDecl.cpp | 9 + clang/lib/Sema/SemaDeclCXX.cpp| 12 -- clang/lib/Serialization/ASTReaderDecl.cpp | 6 +++ clang/lib/Serialization/ASTWriterDecl.cpp | 6 +++ clang/test/CodeGenCXX/modules-vtable.cppm | 31 +-- clang/test/CodeGenCXX/pr70585.cppm| 47 +++ 11 files changed, 138 insertions(+), 23 deletions(-) create mode 100644 clang/test/CodeGenCXX/pr70585.cppm diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 600ce73c7f019..f38386381853b 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -670,6 +670,9 @@ class alignas(8) Decl { /// Whether this declaration comes from another module unit. bool isInAnotherModuleUnit() const; + /// Whether this declaration comes from the same module unit being compiled. + bool isInCurrentModuleUnit() const; + /// Whether the definition of the declaration should be emitted in external /// sources. bool shouldEmitInExternalSource() const; diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 1e9c879e371bc..153dc3351dae5 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1106,6 +1106,15 @@ bool Decl::isInAnotherModuleUnit() const { return M != getASTContext().getCurrentNamedModule(); } +bool Decl::isInCurrentModuleUnit() const { + auto *M = getOwningModule(); + + if (!M || !M->isNamedModule()) +return false; + + return M == getASTContext().getCurrentNamedModule(); +} + bool Decl::shouldEmitInExternalSource() const { ExternalASTSource *Source = getASTContext().getExternalSource(); if (!Source) diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 001633453f242..55c3032dc9332 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -1051,6 +1051,11 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { if (!RD->isExternallyVisible()) return llvm::GlobalVariable::InternalLinkage; + // V-tables for non-template classes with an owning module are always + // uniquely emitted in that module. + if (RD->isInNamedModule()) +return llvm::GlobalVariable::ExternalLinkage; + // We're at the end of the translation unit, so the current key // function is fully correct. const CXXMethodDecl *keyFunction = Context.getCurrentKeyFunction(RD); @@ -1185,6 +1190,21 @@ bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) { TSK == TSK_ExplicitInstantiationDefinition) return false; + // Itanium C++ ABI [5.2.3]: + // Virtual tables for dynamic classes are emitted as follows: + // + // - If the class is templated, the tables are emitted in every object that + // references any of them. + // - Otherwise, if the class is attached to a module, the tables are uniquely + // emitted in the object for the module unit in which it is defined. + // - Otherwise, if the class has a key function (see below), the tables are + // emitted in the object for the translation unit containing the definition of + // the key function. This is unique if the key function is not inline. + // - Otherwise, the tables are emitted in every object that references any of + // them. + if (RD->isInNamedModule()) +return RD->shouldEmitInExternalSource(); + // Otherwise, if the class doesn't have a key function (possibly // anymore), the vtable must be defined here. const CXXMethodDecl *keyFunction = CGM.getContext().getCurrentKeyFunction(RD); @@ -1194,13 +1214,7 @@ bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) { const FunctionDecl *Def; // Otherwise, if we don't have a definition of the key function, the // vtable must be defined somewhere else. - if (!keyFunction->hasBody(Def)) -return true; - - assert(Def && "The body of the key function is not assigned to Def?"); - // If the non-inline key function comes from another module unit, the vtable - // must be defined there. - return
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
wangleiat wrote: Thanks, updated test. https://github.com/llvm/llvm-project/pull/94711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
https://github.com/wangleiat updated https://github.com/llvm/llvm-project/pull/94711 >From 819f126473b34014bb3ad946f78b4e86b7fca09d Mon Sep 17 00:00:00 2001 From: wanglei Date: Fri, 7 Jun 2024 09:08:57 +0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- clang/lib/Driver/ToolChains/Gnu.cpp| 2 ++ clang/test/Driver/loongarch-features.c | 7 +++ 2 files changed, 9 insertions(+) create mode 100644 clang/test/Driver/loongarch-features.c diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b141e5f2adfab..e8c81ca966801 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -3087,6 +3087,8 @@ Generic_GCC::getDefaultUnwindTableLevel(const ArgList ) const { switch (getArch()) { case llvm::Triple::aarch64: case llvm::Triple::aarch64_be: + case llvm::Triple::loongarch32: + case llvm::Triple::loongarch64: case llvm::Triple::ppc: case llvm::Triple::ppcle: case llvm::Triple::ppc64: diff --git a/clang/test/Driver/loongarch-features.c b/clang/test/Driver/loongarch-features.c new file mode 100644 index 0..6d0db0f3ac6a9 --- /dev/null +++ b/clang/test/Driver/loongarch-features.c @@ -0,0 +1,7 @@ +// RUN: %clang --target=loongarch64-linux -### %s -fsyntax-only 2>&1 \ +// RUN: | FileCheck %s -check-prefix=DEFAULT-LINUX + +// DEFAULT-LINUX: "-funwind-tables=2" +// DEFAULT-LINUX-SAME: "-target-feature" "+f" +// DEFAULT-LINUX-SAME: "-target-feature" "+d" +// DEFAULT-LINUX-SAME: "-target-feature" "+ual" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
ChuanqiXu9 wrote: Resent https://github.com/llvm/llvm-project/commit/5c104879c1a98eeb845c03e7c45206bd48e88f0c Thanks for testing it ! https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5c10487 - [serialization] no transitive decl change (#92083)
Author: Chuanqi Xu Date: 2024-06-07T10:47:53+08:00 New Revision: 5c104879c1a98eeb845c03e7c45206bd48e88f0c URL: https://github.com/llvm/llvm-project/commit/5c104879c1a98eeb845c03e7c45206bd48e88f0c DIFF: https://github.com/llvm/llvm-project/commit/5c104879c1a98eeb845c03e7c45206bd48e88f0c.diff LOG: [serialization] no transitive decl change (#92083) Following of https://github.com/llvm/llvm-project/pull/86912 The motivation of the patch series is that, for a module interface unit `X`, when the dependent modules of `X` changes, if the changes is not relevant with `X`, we hope the BMI of `X` won't change. For the specific patch, we hope if the changes was about irrelevant declaration changes, we hope the BMI of `X` won't change. **However**, I found the patch itself is not very useful in practice, since the adding or removing declarations, will change the state of identifiers and types in most cases. That said, for the most simple example, ``` // partA.cppm export module m:partA; // partA.v1.cppm export module m:partA; export void a() {} // partB.cppm export module m:partB; export void b() {} // m.cppm export module m; export import :partA; export import :partB; // onlyUseB; export module onlyUseB; import m; export inline void onluUseB() { b(); } ``` the BMI of `onlyUseB` will change after we change the implementation of `partA.cppm` to `partA.v1.cppm`. Since `partA.v1.cppm` introduces new identifiers and types (the function prototype). So in this patch, we have to write the tests as: ``` // partA.cppm export module m:partA; export int getA() { ... } export int getA2(int) { ... } // partA.v1.cppm export module m:partA; export int getA() { ... } export int getA(int) { ... } export int getA2(int) { ... } // partB.cppm export module m:partB; export void b() {} // m.cppm export module m; export import :partA; export import :partB; // onlyUseB; export module onlyUseB; import m; export inline void onluUseB() { b(); } ``` so that the new introduced declaration `int getA(int)` doesn't introduce new identifiers and types, then the BMI of `onlyUseB` can keep unchanged. While it looks not so great, the patch should be the base of the patch to erase the transitive change for identifiers and types since I don't know how can we introduce new types and identifiers without introducing new declarations. Given how tightly the relationship between declarations, types and identifiers, I think we can only reach the ideal state after we made the series for all of the three entties. The design of the patch is similar to https://github.com/llvm/llvm-project/pull/86912, which extends the 32-bit DeclID to 64-bit and use the higher bits to store the module file index and the lower bits to store the Local Decl ID. A slight difference is that we only use 48 bits to store the new DeclID since we try to use the higher 16 bits to store the module ID in the prefix of Decl class. Previously, we use 32 bits to store the module ID and 32 bits to store the DeclID. I don't want to allocate additional space so I tried to make the additional space the same as 64 bits. An potential interesting thing here is about the relationship between the module ID and the module file index. I feel we can get the module file index by the module ID. But I didn't prove it or implement it. Since I want to make the patch itself as small as possible. We can make it in the future if we want. Another change in the patch is the new concept Decl Index, which means the index of the very big array `DeclsLoaded` in ASTReader. Previously, the index of a loaded declaration is simply the Decl ID minus PREDEFINED_DECL_NUMs. So there are some places they got used ambiguously. But this patch tried to split these two concepts. As https://github.com/llvm/llvm-project/pull/86912 did, the change will increase the on-disk PCM file sizes. As the declaration ID may be the most IDs in the PCM file, this can have the biggest impact on the size. In my experiments, this change will bring 6.6% increase of the on-disk PCM size. No compile-time performance regression observed. Given the benefits in the motivation example, I think the cost is worthwhile. Added: clang/test/Modules/no-transitive-decls-change.cppm Modified: clang/include/clang/AST/ASTUnresolvedSet.h clang/include/clang/AST/DeclAccessPair.h clang/include/clang/AST/DeclBase.h clang/include/clang/AST/DeclID.h clang/include/clang/AST/UnresolvedSet.h clang/include/clang/Serialization/ASTBitCodes.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ModuleFile.h clang/include/clang/Serialization/ModuleManager.h clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclCXX.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ModuleFile.cpp Removed:
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -1185,6 +1190,21 @@ bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) { TSK == TSK_ExplicitInstantiationDefinition) return false; + // Itanium C++ ABI [5.2.3]: + // Virtual tables for dynamic classes are emitted as follows: + // + // - If the class is templated, the tables are emitted in every object that + // references any of them. + // - Otherwise, if the class is attached to a module, the tables are uniquely + // emitted in the object for the module unit in which it is defined. + // - Otherwise, if the class has a key function (see below), the tables are + // emitted in the object for the translation unit containing the definition of + // the key function. This is unique if the key function is not inline. + // - Otherwise, the tables are emitted in every object that references any of + // them. + if (RD->isInNamedModule()) +return RD->shouldEmitInExternalSource(); ChuanqiXu9 wrote: I think we would have to maintain both the one phase compilation and two phase compilation path. Maybe we can make it better by refining the API. https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
SixWeining wrote: I just rename it in f2441b0297501610b59527f93e3174c814d63941. https://github.com/llvm/llvm-project/pull/94711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f2441b0 - [Driver][test] Rename loongarch-{default-, }features.c
Author: Weining Lu Date: 2024-06-07T09:52:43+08:00 New Revision: f2441b0297501610b59527f93e3174c814d63941 URL: https://github.com/llvm/llvm-project/commit/f2441b0297501610b59527f93e3174c814d63941 DIFF: https://github.com/llvm/llvm-project/commit/f2441b0297501610b59527f93e3174c814d63941.diff LOG: [Driver][test] Rename loongarch-{default-,}features.c Added: clang/test/Driver/loongarch-features.c Modified: Removed: clang/test/Driver/loongarch-default-features.c diff --git a/clang/test/Driver/loongarch-default-features.c b/clang/test/Driver/loongarch-features.c similarity index 100% rename from clang/test/Driver/loongarch-default-features.c rename to clang/test/Driver/loongarch-features.c ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)
https://github.com/hdoc updated https://github.com/llvm/llvm-project/pull/88367 >From a98d117c68b33d2e6632a832ff77b0e8258469e6 Mon Sep 17 00:00:00 2001 From: hdoc Date: Thu, 11 Apr 2024 01:54:18 -0700 Subject: [PATCH 1/3] Attach comments to decl even if preproc directives are in between --- clang/lib/AST/ASTContext.cpp | 7 +- clang/lib/Headers/amxcomplexintrin.h | 4 + clang/lib/Headers/ia32intrin.h | 2 + clang/test/Index/annotate-comments.cpp | 5 +- clang/unittests/AST/DeclTest.cpp | 310 + 5 files changed, 323 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index bf74e56a14799..3e9131ecf12d0 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -282,9 +282,10 @@ RawComment *ASTContext::getRawCommentForDeclNoCacheImpl( StringRef Text(Buffer + CommentEndOffset, DeclLocDecomp.second - CommentEndOffset); - // There should be no other declarations or preprocessor directives between - // comment and declaration. - if (Text.find_last_of(";{}#@") != StringRef::npos) + // There should be no other declarations between comment and declaration. + // Preprocessor directives are implicitly allowed to be between a comment and + // its associated decl. + if (Text.find_last_of(";{}@") != StringRef::npos) return nullptr; return CommentBeforeDecl; diff --git a/clang/lib/Headers/amxcomplexintrin.h b/clang/lib/Headers/amxcomplexintrin.h index 84ef972fcadf0..19eaee10ede65 100644 --- a/clang/lib/Headers/amxcomplexintrin.h +++ b/clang/lib/Headers/amxcomplexintrin.h @@ -62,6 +62,8 @@ ///The 2nd source tile. Max size is 1024 Bytes. #define _tile_cmmimfp16ps(dst, a, b) __builtin_ia32_tcmmimfp16ps(dst, a, b) +; + /// Perform matrix multiplication of two tiles containing complex elements and ///accumulate the results into a packed single precision tile. Each dword ///element in input tiles \a a and \a b is interpreted as a complex number @@ -107,6 +109,8 @@ ///The 2nd source tile. Max size is 1024 Bytes. #define _tile_cmmrlfp16ps(dst, a, b) __builtin_ia32_tcmmrlfp16ps(dst, a, b) +; + static __inline__ _tile1024i __DEFAULT_FN_ATTRS_COMPLEX _tile_cmmimfp16ps_internal(unsigned short m, unsigned short n, unsigned short k, _tile1024i dst, _tile1024i src1, _tile1024i src2) { diff --git a/clang/lib/Headers/ia32intrin.h b/clang/lib/Headers/ia32intrin.h index 8e65f232a0def..c9c92b9ee0f99 100644 --- a/clang/lib/Headers/ia32intrin.h +++ b/clang/lib/Headers/ia32intrin.h @@ -533,6 +533,8 @@ __rdtscp(unsigned int *__A) { /// \see __rdpmc #define _rdpmc(A) __rdpmc(A) +; + static __inline__ void __DEFAULT_FN_ATTRS _wbinvd(void) { __builtin_ia32_wbinvd(); diff --git a/clang/test/Index/annotate-comments.cpp b/clang/test/Index/annotate-comments.cpp index 6f9f8f0bbbc9e..bff25d46cf80e 100644 --- a/clang/test/Index/annotate-comments.cpp +++ b/clang/test/Index/annotate-comments.cpp @@ -204,9 +204,9 @@ void isdoxy45(void); /// Ggg. IS_DOXYGEN_END void isdoxy46(void); -/// IS_DOXYGEN_NOT_ATTACHED +/// isdoxy47 IS_DOXYGEN_SINGLE #define FOO -void notdoxy47(void); +void isdoxy47(void); /// IS_DOXYGEN_START Aaa bbb /// \param ccc @@ -330,6 +330,7 @@ void isdoxy54(int); // CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb ccc.] // CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[Ddd eee. Fff.] // CHECK: annotate-comments.cpp:205:6: FunctionDecl=isdoxy46:{{.*}} BriefComment=[Ddd eee. Fff.] +// CHECK: annotate-comments.cpp:209:6: FunctionDecl=isdoxy47:{{.*}} isdoxy47 IS_DOXYGEN_SINGLE // CHECK: annotate-comments.cpp:214:6: FunctionDecl=isdoxy48:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb] // CHECK: annotate-comments.cpp:218:6: FunctionDecl=isdoxy49:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa] // CHECK: annotate-comments.cpp:222:6: FunctionDecl=isdoxy50:{{.*}} BriefComment=[Returns ddd IS_DOXYGEN_END] diff --git a/clang/unittests/AST/DeclTest.cpp b/clang/unittests/AST/DeclTest.cpp index 16aa2b50b7a06..8dca011ba8779 100644 --- a/clang/unittests/AST/DeclTest.cpp +++ b/clang/unittests/AST/DeclTest.cpp @@ -576,3 +576,313 @@ void instantiate_template() { EXPECT_EQ(GetNameInfoRange(Matches[1]), ""); EXPECT_EQ(GetNameInfoRange(Matches[2]), ""); } + +TEST(Decl, CommentsAttachedToDecl1) { + const SmallVector Sources{ + R"( +/// Test comment +void f(); + )", + + R"( +/// Test comment + +void f(); + )", + + R"( +/// Test comment +#if 0 +// tralala +#endif +void f(); + )", + + R"( +/// Test comment + +#if 0 +// tralala +#endif + +void f(); + )", + + R"( +/// Test comment +#ifdef DOCS +template +#endif +void f(); +
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -1830,6 +1830,9 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables , if (VTable->hasInitializer()) return; + if (RD->shouldEmitInExternalSource()) +return; ChuanqiXu9 wrote: > Also, even if the vtable is getting emitted somewhere else, we might want an > available_externally vtable. Out of curiosity, is it helpful to have an available_externally vtable? https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format]: Annotate colons found in inline assembly (PR #92617)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/92617 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a10135f - [clang-format]: Annotate colons found in inline assembly (#92617)
Author: Gedare Bloom Date: 2024-06-06T18:38:21-07:00 New Revision: a10135f4922624f92c3a108d23ab64adc09dd285 URL: https://github.com/llvm/llvm-project/commit/a10135f4922624f92c3a108d23ab64adc09dd285 DIFF: https://github.com/llvm/llvm-project/commit/a10135f4922624f92c3a108d23ab64adc09dd285.diff LOG: [clang-format]: Annotate colons found in inline assembly (#92617) Short-circuit the parsing of tok::colon to label colons found within lines starting with asm as InlineASMColon. Fixes #92616. - Co-authored-by: Owen Pan Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 26c0aa36bdcb6..1fe3b61a5a81f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1358,6 +1358,8 @@ class AnnotatingParser { Line.First->startsSequence(tok::kw_export, Keywords.kw_module) || Line.First->startsSequence(tok::kw_export, Keywords.kw_import)) { Tok->setType(TT_ModulePartitionColon); + } else if (Line.First->is(tok::kw_asm)) { +Tok->setType(TT_InlineASMColon); } else if (Contexts.back().ColonIsDictLiteral || Style.isProto()) { Tok->setType(TT_DictLiteral); if (Style.Language == FormatStyle::LK_TextProto) { @@ -1425,13 +1427,6 @@ class AnnotatingParser { // This handles a special macro in ObjC code where selectors including // the colon are passed as macro arguments. Tok->setType(TT_ObjCMethodExpr); - } else if (Contexts.back().ContextKind == tok::l_paren && - !Line.InPragmaDirective) { -if (Style.isTableGen() && Contexts.back().IsTableGenDAGArg) { - Tok->setType(TT_TableGenDAGArgListColon); - break; -} -Tok->setType(TT_InlineASMColon); } break; case tok::pipe: diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 3d609a1f041bc..8cc5c239d30a1 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -1496,12 +1496,82 @@ TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) { TEST_F(TokenAnnotatorTest, UnderstandsAsm) { auto Tokens = annotate("__asm{\n" - "a:\n" - "};"); - ASSERT_EQ(Tokens.size(), 7u) << Tokens; + "\"a\":\n" + ": x\n" + ":};"); + ASSERT_EQ(Tokens.size(), 10u) << Tokens; EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown); EXPECT_TOKEN(Tokens[1], tok::l_brace, TT_InlineASMBrace); - EXPECT_TOKEN(Tokens[4], tok::r_brace, TT_InlineASMBrace); + EXPECT_TOKEN(Tokens[3], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[4], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[7], tok::r_brace, TT_InlineASMBrace); + + Tokens = annotate("__asm(\n" +"\"a\":\n" +": x\n" +":);"); + ASSERT_EQ(Tokens.size(), 10u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown); + EXPECT_TOKEN(Tokens[3], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[4], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon); + + Tokens = annotate("asm volatile (\n" +"\"a_label:\"\n" +":\n" +": x\n" +":);"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown); + EXPECT_TOKEN(Tokens[4], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[5], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[7], tok::colon, TT_InlineASMColon); + + Tokens = annotate("__asm__(\n" +"\"a_label:\"\n" +": x\n" +":\n" +": y);"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown); + EXPECT_TOKEN(Tokens[3], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[5], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon); + + Tokens = annotate("__asm volatile (\n" +"\"a_label:\"\n" +"\"a b c(%%x)\"\n" +":\n" +": x\n" +":);"); + ASSERT_EQ(Tokens.size(), 12u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown); + EXPECT_TOKEN(Tokens[5], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon); + EXPECT_TOKEN(Tokens[8], tok::colon, TT_InlineASMColon); + + Tokens = annotate("asm(\n" +"\"insn\"\n" +
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -6853,6 +6853,13 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never) DI->completeUnusedClass(*CRD); } +// If we're emitting a dynamic class from the importable module we're +// emitting, we always need to emit the virtual table according to the ABI +// requirement. +if (CRD->getDefinition() && CRD->isDynamicClass() && +CRD->isInCurrentModuleUnit()) + EmitVTable(CRD); ChuanqiXu9 wrote: Yes, this can happen with the two phase compilation of modules (https://clang.llvm.org/docs/StandardCPlusPlusModules.html#how-to-produce-a-bmi). Which will compile a `.cppm` file to a `.pcm` file, and we will compile the `.pcm` file the `.o` file. The one phase compilation can also happen for modules. https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
SixWeining wrote: We already have `loongarch-default-features.c`. https://github.com/llvm/llvm-project/pull/94711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Remove an else after a return statement (PR #94548)
github-actions[bot] wrote: @khufu1 Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/94548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Remove an else after a return statement (PR #94548)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/94548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c967c7e - [clang-format][NFC] Remove an else after a return statement (#94548)
Author: Nour Date: 2024-06-06T18:36:33-07:00 New Revision: c967c7e0223845b54a5220e2d4211fee50c5fb30 URL: https://github.com/llvm/llvm-project/commit/c967c7e0223845b54a5220e2d4211fee50c5fb30 DIFF: https://github.com/llvm/llvm-project/commit/c967c7e0223845b54a5220e2d4211fee50c5fb30.diff LOG: [clang-format][NFC] Remove an else after a return statement (#94548) Added: Modified: clang/tools/clang-format/ClangFormat.cpp Removed: diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 50dd073c41255..6cba1267f3b0d 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -509,8 +509,7 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) { if (OutputXML || DryRun) { if (DryRun) return emitReplacementWarnings(Replaces, AssumedFileName, Code); -else - outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition); +outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition); } else { IntrusiveRefCntPtr InMemoryFileSystem( new llvm::vfs::InMemoryFileSystem); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)
zqb-all wrote: LGTM. x60 also supports `svnapot`, and although it seems to have no impact on compiler behavior, I see that it is defined in llvm and is part of RVA23, so it might be worth adding it as well. https://github.com/llvm/llvm-project/pull/94564 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Testing32 bit for https://github.com/llvm/llvm-project/pull/92083 (PR #94603)
ChuanqiXu9 wrote: Thanks! https://github.com/llvm/llvm-project/pull/94603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
wangleiat wrote: @xen0n @xry111 https://github.com/llvm/llvm-project/pull/94711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)
@@ -1457,6 +1457,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState ) { !Current.isOneOf(tok::colon, tok::comment)) { return ContinuationIndent; } + if (Style.isCpp() && Current.is(tok::arrow) && c8ef wrote: Exactly, thanks for your suggestions! https://github.com/llvm/llvm-project/pull/94560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)
@@ -22858,6 +22858,31 @@ TEST_F(FormatTest, FormatsLambdas) { " //\n" "});"); + verifyFormat("int main() {\n" c8ef wrote: Done. https://github.com/llvm/llvm-project/pull/94560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)
https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/94560 >From 624e74b3066930a5a2bb15d6c0b2ddb4f94d3b79 Mon Sep 17 00:00:00 2001 From: c8ef Date: Thu, 6 Jun 2024 10:44:57 +0800 Subject: [PATCH 1/2] fix incorrectly indents lambda trailing return --- clang/lib/Format/ContinuationIndenter.cpp | 5 + clang/unittests/Format/FormatTest.cpp | 25 +++ 2 files changed, 30 insertions(+) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 6b9fbfe0ebf53..630a4ebff9843 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -1457,6 +1457,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState ) { !Current.isOneOf(tok::colon, tok::comment)) { return ContinuationIndent; } + if (Style.isCpp() && Current.is(tok::arrow) && + Previous.isOneOf(tok::kw_noexcept, tok::kw_mutable, tok::kw_constexpr, + tok::kw_consteval, tok::kw_static)) { +return ContinuationIndent; + } if (Current.is(TT_ProtoExtensionLSquare)) return CurrentState.Indent; if (Current.isBinaryOperator() && CurrentState.UnindentOperator) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 4e427268fb82a..d117efc06c2a7 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -22858,6 +22858,31 @@ TEST_F(FormatTest, FormatsLambdas) { " //\n" "});"); + verifyFormat("int main() {\n" + " very_long_function_name_yes_it_is_really_long(\n" + " [](auto n)\n" + " -> std::unordered_map {\n" + "really_do_something();\n" + " });\n" + "}"); + verifyFormat("int main() {\n" + " very_long_function_name_yes_it_is_really_long(\n" + " [](auto n) noexcept\n" + " -> std::unordered_map {\n" + "really_do_something();\n" + " });\n" + "}"); + verifyFormat("int main() {\n" + " very_long_function_name_yes_it_is_really_long(\n" + " [](auto n) constexpr\n" + " -> std::unordered_map {\n" + "really_do_something();\n" + " });\n" + "}"); + FormatStyle DoNotMerge = getLLVMStyle(); DoNotMerge.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None; verifyFormat("auto c = []() {\n" >From ec319435d82f1a815206eeb51a8e6e09c5d811fe Mon Sep 17 00:00:00 2001 From: c8ef Date: Fri, 7 Jun 2024 09:18:26 +0800 Subject: [PATCH 2/2] address CR issue --- clang/lib/Format/ContinuationIndenter.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 21 - 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 630a4ebff9843..9206344490b53 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -1457,7 +1457,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState ) { !Current.isOneOf(tok::colon, tok::comment)) { return ContinuationIndent; } - if (Style.isCpp() && Current.is(tok::arrow) && + if (Style.isCpp() && Current.is(TT_TrailingReturnArrow) && Previous.isOneOf(tok::kw_noexcept, tok::kw_mutable, tok::kw_constexpr, tok::kw_consteval, tok::kw_static)) { return ContinuationIndent; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d117efc06c2a7..9759d58c718b5 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -22861,27 +22861,30 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("int main() {\n" " very_long_function_name_yes_it_is_really_long(\n" " [](auto n)\n" - " -> std::unordered_map {\n" + " -> std::unordered_map {\n" "really_do_something();\n" " });\n" - "}"); + "}", + getLLVMStyleWithColumns(60)); verifyFormat("int main() {\n" " very_long_function_name_yes_it_is_really_long(\n" " [](auto n) noexcept\n" - " -> std::unordered_map {\n" + " -> std::unordered_map {\n" "really_do_something();\n" " });\n" - "}"); + "}", + getLLVMStyleWithColumns(60)); verifyFormat("int main() {\n" " very_long_function_name_yes_it_is_really_long(\n" " [](auto n) constexpr\n" - " -> std::unordered_map {\n" +
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
ilovepi wrote: Also, the current PR only has tests for the HTML output. Please file separate bugs for the other formats, and be sure to follow up with more tests for those formats. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV] Unify all the code that adds unaligned-scalar/vector-mem to Features vector. (PR #94660)
https://github.com/topperc closed https://github.com/llvm/llvm-project/pull/94660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2d65097 - [RISCV] Unify all the code that adds unaligned-scalar/vector-mem to Features vector. (#94660)
Author: Craig Topper Date: 2024-06-06T18:12:07-07:00 New Revision: 2d65097b4ff18f99e4baf18e2e0b155ecf478b0a URL: https://github.com/llvm/llvm-project/commit/2d65097b4ff18f99e4baf18e2e0b155ecf478b0a DIFF: https://github.com/llvm/llvm-project/commit/2d65097b4ff18f99e4baf18e2e0b155ecf478b0a.diff LOG: [RISCV] Unify all the code that adds unaligned-scalar/vector-mem to Features vector. (#94660) Instead of having multiple places insert into the Features vector independently, check all the conditions in one place. This avoids a subtle ordering requirement that -mstrict-align processing had to be done after the others. Added: Modified: clang/lib/Driver/ToolChains/Arch/RISCV.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp index 2e2bce8494672..26789b0ba6e09 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -67,11 +67,6 @@ static void getRISCFeaturesFromMcpu(const Driver , const Arg *A, D.Diag(clang::diag::err_drv_unsupported_option_argument) << A->getSpelling() << Mcpu; } - - if (llvm::RISCV::hasFastUnalignedAccess(Mcpu)) { -Features.push_back("+unaligned-scalar-mem"); -Features.push_back("+unaligned-vector-mem"); - } } void riscv::getRISCVTargetFeatures(const Driver , const llvm::Triple , @@ -82,6 +77,8 @@ void riscv::getRISCVTargetFeatures(const Driver , const llvm::Triple , if (!getArchFeatures(D, MArch, Features, Args)) return; + bool CPUFastUnaligned = false; + // If users give march and mcpu, get std extension feature from MArch // and other features (ex. mirco architecture feature) from mcpu if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { @@ -90,6 +87,9 @@ void riscv::getRISCVTargetFeatures(const Driver , const llvm::Triple , CPU = llvm::sys::getHostCPUName(); getRISCFeaturesFromMcpu(D, A, Triple, CPU, Features); + +if (llvm::RISCV::hasFastUnalignedAccess(CPU)) + CPUFastUnaligned = true; } // Handle features corresponding to "-ffixed-X" options @@ -169,18 +169,23 @@ void riscv::getRISCVTargetFeatures(const Driver , const llvm::Triple , Features.push_back("-relax"); } - // Android requires fast unaligned access on RISCV64. - if (Triple.isAndroid()) { + // If -mstrict-align or -mno-strict-align is passed, use it. Otherwise, the + // unaligned-*-mem is enabled if the CPU supports it or the target is + // Android. + if (const Arg *A = Args.getLastArg(options::OPT_mno_strict_align, + options::OPT_mstrict_align)) { +if (A->getOption().matches(options::OPT_mno_strict_align)) { + Features.push_back("+unaligned-scalar-mem"); + Features.push_back("+unaligned-vector-mem"); +} else { + Features.push_back("-unaligned-scalar-mem"); + Features.push_back("-unaligned-vector-mem"); +} + } else if (CPUFastUnaligned || Triple.isAndroid()) { Features.push_back("+unaligned-scalar-mem"); Features.push_back("+unaligned-vector-mem"); } - // -mstrict-align is default, unless -mno-strict-align is specified. - AddTargetFeature(Args, Features, options::OPT_mno_strict_align, - options::OPT_mstrict_align, "unaligned-scalar-mem"); - AddTargetFeature(Args, Features, options::OPT_mno_strict_align, - options::OPT_mstrict_align, "unaligned-vector-mem"); - // Now add any that the user explicitly requested on the command line, // which may override the defaults. handleTargetFeaturesGroup(D, Triple, Args, Features, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
@@ -186,19 +196,36 @@ Example usage for a project using a compile commands database: std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr); llvm::SmallString<128> NativeClangDocPath; llvm::sys::path::native(ClangDocPath, NativeClangDocPath); -llvm::SmallString<128> AssetsPath; -AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); -llvm::sys::path::append(AssetsPath, "..", "share", "clang"); -llvm::SmallString<128> DefaultStylesheet; -llvm::sys::path::native(AssetsPath, DefaultStylesheet); -llvm::sys::path::append(DefaultStylesheet, -"clang-doc-default-stylesheet.css"); -llvm::SmallString<128> IndexJS; -llvm::sys::path::native(AssetsPath, IndexJS); -llvm::sys::path::append(IndexJS, "index.js"); -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); -CDCtx.FilesToCopy.emplace_back(IndexJS.str()); +if (!UserAssetPath.empty()) { +std::error_code code; +llvm::sys::fs::directory_iterator dirIt(std::string(UserAssetPath), code); +while (!code && dirIt != llvm::sys::fs::directory_iterator()) { ilovepi wrote: I'm not sure the logic here is correct. You check the error code, but what happens if that directory doesn't exist? To me it looks like the AssetsPath is never configured. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
@@ -186,19 +196,36 @@ Example usage for a project using a compile commands database: std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr); llvm::SmallString<128> NativeClangDocPath; llvm::sys::path::native(ClangDocPath, NativeClangDocPath); -llvm::SmallString<128> AssetsPath; -AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); -llvm::sys::path::append(AssetsPath, "..", "share", "clang"); -llvm::SmallString<128> DefaultStylesheet; -llvm::sys::path::native(AssetsPath, DefaultStylesheet); -llvm::sys::path::append(DefaultStylesheet, -"clang-doc-default-stylesheet.css"); -llvm::SmallString<128> IndexJS; -llvm::sys::path::native(AssetsPath, IndexJS); -llvm::sys::path::append(IndexJS, "index.js"); -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); -CDCtx.FilesToCopy.emplace_back(IndexJS.str()); +if (!UserAssetPath.empty()) { +std::error_code code; +llvm::sys::fs::directory_iterator dirIt(std::string(UserAssetPath), code); +while (!code && dirIt != llvm::sys::fs::directory_iterator()) { +std::basic_string filePath = dirIt->path(); +if (llvm::sys::fs::is_regular_file(filePath)) { +if (ends_with(filePath, ".css")) { +CDCtx.UserStylesheets.push_back(filePath); +} +else if (ends_with(filePath, ".js")) { +CDCtx.UserStylesheets.push_back(filePath); +} +} +} +} +else { +llvm::SmallString<128> AssetsPath; +AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); +llvm::sys::path::append(AssetsPath, "..", "share", "clang"); +llvm::SmallString<128> DefaultStylesheet; +llvm::sys::path::native(AssetsPath, DefaultStylesheet); +llvm::sys::path::append(DefaultStylesheet, +"clang-doc-default-stylesheet.css"); +llvm::SmallString<128> IndexJS; +llvm::sys::path::native(AssetsPath, IndexJS); +llvm::sys::path::append(IndexJS, "index.js"); +CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), + std::string(DefaultStylesheet)); +CDCtx.FilesToCopy.emplace_back(IndexJS.str()); ilovepi wrote: probably each of these branches could be extracted into a helper function to make this a bit easier to follow, but you do want to be careful to ensure the user path can fall back to the default behavior, or give very clear errors about missing assets/paths. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
@@ -131,6 +135,12 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } +inline bool ends_with(std::string const & value, std::string const & ending) +{ +if (ending.size() > value.size()) return false; +return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); +} + ilovepi wrote: `ends_with` is a c++20 feature. I believe LLVM is still on C++17 (https://www.llvm.org/docs/CodingStandards.html#c-standard-versions), you can't use the one from the STL, but `SmallString` does, https://llvm.org/doxygen/classllvm_1_1SmallString.html#a6f1b0c312b24ebd6db62d9612a466f46. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
llvmbot wrote: @llvm/pr-subscribers-clang Author: wanglei (wangleiat) Changes This could improve user experience for stack unwinding, and also this is enabled by default by LoongArch GCC. Similar to commit be437f3bb8b657f4d2de4603734f24daa624d204 --- Full diff: https://github.com/llvm/llvm-project/pull/94711.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+2) - (added) clang/test/Driver/loongarch-features.c (+7) ``diff diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b141e5f2adfab..e8c81ca966801 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -3087,6 +3087,8 @@ Generic_GCC::getDefaultUnwindTableLevel(const ArgList ) const { switch (getArch()) { case llvm::Triple::aarch64: case llvm::Triple::aarch64_be: + case llvm::Triple::loongarch32: + case llvm::Triple::loongarch64: case llvm::Triple::ppc: case llvm::Triple::ppcle: case llvm::Triple::ppc64: diff --git a/clang/test/Driver/loongarch-features.c b/clang/test/Driver/loongarch-features.c new file mode 100644 index 0..6d0db0f3ac6a9 --- /dev/null +++ b/clang/test/Driver/loongarch-features.c @@ -0,0 +1,7 @@ +// RUN: %clang --target=loongarch64-linux -### %s -fsyntax-only 2>&1 \ +// RUN: | FileCheck %s -check-prefix=DEFAULT-LINUX + +// DEFAULT-LINUX: "-funwind-tables=2" +// DEFAULT-LINUX-SAME: "-target-feature" "+f" +// DEFAULT-LINUX-SAME: "-target-feature" "+d" +// DEFAULT-LINUX-SAME: "-target-feature" "+ual" `` https://github.com/llvm/llvm-project/pull/94711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Enable -fasynchronous-unwind-tables by default on Linux (PR #94711)
https://github.com/wangleiat created https://github.com/llvm/llvm-project/pull/94711 This could improve user experience for stack unwinding, and also this is enabled by default by LoongArch GCC. Similar to commit be437f3bb8b657f4d2de4603734f24daa624d204 >From 819f126473b34014bb3ad946f78b4e86b7fca09d Mon Sep 17 00:00:00 2001 From: wanglei Date: Fri, 7 Jun 2024 09:08:57 +0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- clang/lib/Driver/ToolChains/Gnu.cpp| 2 ++ clang/test/Driver/loongarch-features.c | 7 +++ 2 files changed, 9 insertions(+) create mode 100644 clang/test/Driver/loongarch-features.c diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b141e5f2adfab..e8c81ca966801 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -3087,6 +3087,8 @@ Generic_GCC::getDefaultUnwindTableLevel(const ArgList ) const { switch (getArch()) { case llvm::Triple::aarch64: case llvm::Triple::aarch64_be: + case llvm::Triple::loongarch32: + case llvm::Triple::loongarch64: case llvm::Triple::ppc: case llvm::Triple::ppcle: case llvm::Triple::ppc64: diff --git a/clang/test/Driver/loongarch-features.c b/clang/test/Driver/loongarch-features.c new file mode 100644 index 0..6d0db0f3ac6a9 --- /dev/null +++ b/clang/test/Driver/loongarch-features.c @@ -0,0 +1,7 @@ +// RUN: %clang --target=loongarch64-linux -### %s -fsyntax-only 2>&1 \ +// RUN: | FileCheck %s -check-prefix=DEFAULT-LINUX + +// DEFAULT-LINUX: "-funwind-tables=2" +// DEFAULT-LINUX-SAME: "-target-feature" "+f" +// DEFAULT-LINUX-SAME: "-target-feature" "+d" +// DEFAULT-LINUX-SAME: "-target-feature" "+ual" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Skip auto-init on scalar vars that have a non-constant Init and no self-ref (PR #94642)
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/94642 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)
temyurchenko wrote: This is a relanding of #93131. The first commit is the same, the second commit presents and fixes the issue from the linked discussion. cc @erichkeane, @AaronBallman, @gulfemsavrun. (I can't set the reviewers myself) https://github.com/llvm/llvm-project/pull/93913 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)
https://github.com/temyurchenko updated https://github.com/llvm/llvm-project/pull/93913 >From fac45476736cd04f044f046fd0df9e59450a926b Mon Sep 17 00:00:00 2001 From: Artem Yurchenko Date: Wed, 22 May 2024 23:41:35 -0400 Subject: [PATCH 1/2] [clang][AST] fix ast-print of `extern ` with >=2 declarators Problem: the printer used to ignore all but the first declarator for unbraced language linkage declarators. Furthemore, that one would be printed without the final semicolon. Solution: for unbraced case we traverse all declarators via `VisitDeclContext`. Furthermore, in appropriate visitors we query for whether they are a part of the unbraced extern language linkage spec, and if so, print appropriately. --- clang/lib/AST/DeclPrinter.cpp | 55 ++- clang/test/AST/ast-print-language-linkage.cpp | 31 +++ 2 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 clang/test/AST/ast-print-language-linkage.cpp diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 0cf4e64f83b8d..9250a7f6eceb2 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream , Out << Proto; } -static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy , +static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy , QualType T, llvm::raw_ostream ) { StringRef prefix = T->isClassType() ? "class " @@ -643,6 +643,22 @@ static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy , Out << prefix; } +/// Return the language of the linkage spec of `D`, if applicable. +/// +/// \Return - "C" if `D` has been declared with unbraced `extern "C"` +/// - "C++" if `D` has been declared with unbraced `extern "C++"` +/// - nullptr in any other case +static const char *tryGetUnbracedLinkageLanguage(const Decl *D) { + const auto *SD = dyn_cast(D->getDeclContext()); + if (!SD || SD->hasBraces()) +return nullptr; + if (SD->getLanguage() == LinkageSpecLanguageIDs::C) +return "C"; + assert(SD->getLanguage() == LinkageSpecLanguageIDs::CXX && + "unknown language in linkage specification"); + return "C++"; +} + void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { if (!D->getDescribedFunctionTemplate() && !D->isFunctionTemplateSpecialization()) { @@ -662,6 +678,11 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { CXXConversionDecl *ConversionDecl = dyn_cast(D); CXXDeductionGuideDecl *GuideDecl = dyn_cast(D); if (!Policy.SuppressSpecifiers) { +if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) { + // the "extern" specifier is implicit + assert(D->getStorageClass() == SC_None); + Out << "extern \"" << Lang << "\" "; +} switch (D->getStorageClass()) { case SC_None: break; case SC_Extern: Out << "extern "; break; @@ -807,7 +828,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } if (!Policy.SuppressTagKeyword && Policy.SuppressScope && !Policy.SuppressUnwrittenScope) -MaybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(), +maybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(), Out); AFT->getReturnType().print(Out, Policy, Proto); Proto.clear(); @@ -932,6 +953,11 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { : D->getASTContext().getUnqualifiedObjCPointerType(D->getType()); if (!Policy.SuppressSpecifiers) { +if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) { + // the "extern" specifier is implicit + assert(D->getStorageClass() == SC_None); + Out << "extern \"" << Lang << "\" "; +} StorageClass SC = D->getStorageClass(); if (SC != SC_None) Out << VarDecl::getStorageClassSpecifierString(SC) << " "; @@ -961,7 +987,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { if (!Policy.SuppressTagKeyword && Policy.SuppressScope && !Policy.SuppressUnwrittenScope) -MaybePrintTagKeywordIfSupressingScopes(Policy, T, Out); +maybePrintTagKeywordIfSupressingScopes(Policy, T, Out); printDeclType(T, (isa(D) && Policy.CleanUglifiedParameters && D->getIdentifier()) @@ -1064,6 +1090,8 @@ void DeclPrinter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { void DeclPrinter::VisitEmptyDecl(EmptyDecl *D) { prettyPrintAttributes(D); + if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) +Out << "extern \"" << Lang << "\";"; } void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) { @@ -1136,22 +1164,21 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) { } void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { - const char *l; + if (!D->hasBraces()) { +
[clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 5f243b3fffca42ed320529a54aefd86087aa85f8 db1eb9b69f2ed961a586d15d165acd000bb728c4 -- clang/test/AST/ast-print-language-linkage.cpp clang/lib/AST/Decl.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/Sema/SemaDecl.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp index 468e2b186c..e02b418b1e 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp @@ -77,7 +77,8 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType , clang::FunctionDecl *func_decl = FunctionDecl::Create( ast, context, SourceLocation(), SourceLocation(), decl_name, qual_type, - nullptr, SC_None, /*UsesFPIntrin=*/false, isInlineSpecified, hasWrittenPrototype, + nullptr, SC_None, /*UsesFPIntrin=*/false, isInlineSpecified, + hasWrittenPrototype, isConstexprSpecified ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified); `` https://github.com/llvm/llvm-project/pull/93913 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 98714866830f505d7bb87de6b92a28f280a34b9b 5a647f015051a572a36af6418fadb424db470cec -- clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.cpp clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.h clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.cpp clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.h clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.cpp clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.h clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Shape.h clang-tools-extra/test/clang-doc/clang-doc-project1.cpp clang-tools-extra/clang-doc/tool/ClangDocMain.cpp `` View the diff from clang-format here. ``diff diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 2e566db27b..15ad0b2404 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -81,9 +81,11 @@ static llvm::cl::list UserStylesheets( llvm::cl::desc("CSS stylesheets to extend the default styles."), llvm::cl::cat(ClangDocCategory)); -static llvm::cl::opt UserAssetPath( - "asset", llvm::cl::desc("User supplied asset path for html output to override the default css and js files"), - llvm::cl::cat(ClangDocCategory)); +static llvm::cl::opt +UserAssetPath("asset", + llvm::cl::desc("User supplied asset path for html output to " + "override the default css and js files"), + llvm::cl::cat(ClangDocCategory)); static llvm::cl::opt SourceRoot("source-root", llvm::cl::desc(R"( Directory where processed files are stored. @@ -135,10 +137,10 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } -inline bool ends_with(std::string const & value, std::string const & ending) -{ -if (ending.size() > value.size()) return false; -return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); +inline bool ends_with(std::string const , std::string const ) { + if (ending.size() > value.size()) +return false; + return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); } int main(int argc, const char **argv) { @@ -197,34 +199,32 @@ Example usage for a project using a compile commands database: llvm::SmallString<128> NativeClangDocPath; llvm::sys::path::native(ClangDocPath, NativeClangDocPath); if (!UserAssetPath.empty()) { -std::error_code code; -llvm::sys::fs::directory_iterator dirIt(std::string(UserAssetPath), code); -while (!code && dirIt != llvm::sys::fs::directory_iterator()) { -std::basic_string filePath = dirIt->path(); -if (llvm::sys::fs::is_regular_file(filePath)) { -if (ends_with(filePath, ".css")) { -CDCtx.UserStylesheets.push_back(filePath); -} -else if (ends_with(filePath, ".js")) { -CDCtx.UserStylesheets.push_back(filePath); -} -} + std::error_code code; + llvm::sys::fs::directory_iterator dirIt(std::string(UserAssetPath), code); + while (!code && dirIt != llvm::sys::fs::directory_iterator()) { +std::basic_string filePath = dirIt->path(); +if (llvm::sys::fs::is_regular_file(filePath)) { + if (ends_with(filePath, ".css")) { +CDCtx.UserStylesheets.push_back(filePath); + } else if (ends_with(filePath, ".js")) { +CDCtx.UserStylesheets.push_back(filePath); + } } -} -else { -llvm::SmallString<128> AssetsPath; -AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); -llvm::sys::path::append(AssetsPath, "..", "share", "clang"); -llvm::SmallString<128> DefaultStylesheet; -llvm::sys::path::native(AssetsPath, DefaultStylesheet); -llvm::sys::path::append(DefaultStylesheet, -"clang-doc-default-stylesheet.css"); -llvm::SmallString<128> IndexJS; -llvm::sys::path::native(AssetsPath, IndexJS); -llvm::sys::path::append(IndexJS, "index.js"); -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); -CDCtx.FilesToCopy.emplace_back(IndexJS.str()); + } +} else { + llvm::SmallString<128> AssetsPath; + AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); + llvm::sys::path::append(AssetsPath, "..", "share", "clang"); + llvm::SmallString<128> DefaultStylesheet; +
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
https://github.com/ilovepi edited https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
https://github.com/ilovepi commented: All of the changes related to allowing a different path belong in their own PR, or if they're invasive, perhaps multiple PRs. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)
https://github.com/temyurchenko updated https://github.com/llvm/llvm-project/pull/93913 >From fac45476736cd04f044f046fd0df9e59450a926b Mon Sep 17 00:00:00 2001 From: Artem Yurchenko Date: Wed, 22 May 2024 23:41:35 -0400 Subject: [PATCH 1/2] [clang][AST] fix ast-print of `extern ` with >=2 declarators Problem: the printer used to ignore all but the first declarator for unbraced language linkage declarators. Furthemore, that one would be printed without the final semicolon. Solution: for unbraced case we traverse all declarators via `VisitDeclContext`. Furthermore, in appropriate visitors we query for whether they are a part of the unbraced extern language linkage spec, and if so, print appropriately. --- clang/lib/AST/DeclPrinter.cpp | 55 ++- clang/test/AST/ast-print-language-linkage.cpp | 31 +++ 2 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 clang/test/AST/ast-print-language-linkage.cpp diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 0cf4e64f83b8d..9250a7f6eceb2 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream , Out << Proto; } -static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy , +static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy , QualType T, llvm::raw_ostream ) { StringRef prefix = T->isClassType() ? "class " @@ -643,6 +643,22 @@ static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy , Out << prefix; } +/// Return the language of the linkage spec of `D`, if applicable. +/// +/// \Return - "C" if `D` has been declared with unbraced `extern "C"` +/// - "C++" if `D` has been declared with unbraced `extern "C++"` +/// - nullptr in any other case +static const char *tryGetUnbracedLinkageLanguage(const Decl *D) { + const auto *SD = dyn_cast(D->getDeclContext()); + if (!SD || SD->hasBraces()) +return nullptr; + if (SD->getLanguage() == LinkageSpecLanguageIDs::C) +return "C"; + assert(SD->getLanguage() == LinkageSpecLanguageIDs::CXX && + "unknown language in linkage specification"); + return "C++"; +} + void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { if (!D->getDescribedFunctionTemplate() && !D->isFunctionTemplateSpecialization()) { @@ -662,6 +678,11 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { CXXConversionDecl *ConversionDecl = dyn_cast(D); CXXDeductionGuideDecl *GuideDecl = dyn_cast(D); if (!Policy.SuppressSpecifiers) { +if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) { + // the "extern" specifier is implicit + assert(D->getStorageClass() == SC_None); + Out << "extern \"" << Lang << "\" "; +} switch (D->getStorageClass()) { case SC_None: break; case SC_Extern: Out << "extern "; break; @@ -807,7 +828,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } if (!Policy.SuppressTagKeyword && Policy.SuppressScope && !Policy.SuppressUnwrittenScope) -MaybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(), +maybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(), Out); AFT->getReturnType().print(Out, Policy, Proto); Proto.clear(); @@ -932,6 +953,11 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { : D->getASTContext().getUnqualifiedObjCPointerType(D->getType()); if (!Policy.SuppressSpecifiers) { +if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) { + // the "extern" specifier is implicit + assert(D->getStorageClass() == SC_None); + Out << "extern \"" << Lang << "\" "; +} StorageClass SC = D->getStorageClass(); if (SC != SC_None) Out << VarDecl::getStorageClassSpecifierString(SC) << " "; @@ -961,7 +987,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { if (!Policy.SuppressTagKeyword && Policy.SuppressScope && !Policy.SuppressUnwrittenScope) -MaybePrintTagKeywordIfSupressingScopes(Policy, T, Out); +maybePrintTagKeywordIfSupressingScopes(Policy, T, Out); printDeclType(T, (isa(D) && Policy.CleanUglifiedParameters && D->getIdentifier()) @@ -1064,6 +1090,8 @@ void DeclPrinter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { void DeclPrinter::VisitEmptyDecl(EmptyDecl *D) { prettyPrintAttributes(D); + if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) +Out << "extern \"" << Lang << "\";"; } void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) { @@ -1136,22 +1164,21 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) { } void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { - const char *l; + if (!D->hasBraces()) { +
[clang] 5e0fc93 - [clang-format] Fix a bug in `AlignAfterOpenBracket: DontAlign` (#94561)
Author: Owen Pan Date: 2024-06-06T17:25:46-07:00 New Revision: 5e0fc93d01c216544c12b60c30fe8ac6c9931eb9 URL: https://github.com/llvm/llvm-project/commit/5e0fc93d01c216544c12b60c30fe8ac6c9931eb9 DIFF: https://github.com/llvm/llvm-project/commit/5e0fc93d01c216544c12b60c30fe8ac6c9931eb9.diff LOG: [clang-format] Fix a bug in `AlignAfterOpenBracket: DontAlign` (#94561) Fixes #94555. Added: Modified: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTest.cpp Removed: diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 6b9fbfe0ebf53..be684ac71cd61 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -1712,7 +1712,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState , (!Previous || Previous->isNot(tok::kw_return) || (Style.Language != FormatStyle::LK_Java && PrecedenceLevel > 0)) && (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign || - PrecedenceLevel != prec::Comma || Current.NestingLevel == 0) && + PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) && (!Style.isTableGen() || (Previous && Previous->isOneOf(TT_TableGenDAGArgListComma, TT_TableGenDAGArgListCommaToBreak { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 4e427268fb82a..dbc1916825f33 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -9241,6 +9241,14 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) { "b));", Style); + Style.ColumnLimit = 30; + verifyFormat("for (int foo = 0; foo < FOO;\n" + "++foo) {\n" + " bar(foo);\n" + "}", + Style); + Style.ColumnLimit = 80; + Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; Style.BinPackArguments = false; Style.BinPackParameters = false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in `AlignAfterOpenBracket: DontAlign` (PR #94561)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/94561 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Skip auto-init on scalar vars that have a non-constant Init and no self-ref (PR #94642)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Jan Voung (jvoung) Changes In that scalar case, the Init should initialize the auto var before use. The Init might use uninitialized memory from other sources (e.g., heap) but auto-init did not help us in that case because the auto-init would have been overwritten by the Init before use. For non-scalars e.g., classes, the Init expr might be a ctor call that leaves uninitialized members, so we leave the auto-init there. The motivation is to have less IR for the optimizer to later remove, which may not be until a fairly late pass (DSE) or may not get optimized in lower optimization levels like O1 (no DSE) or sometimes due to derefinement. This is ~10% less left-over auto-init in O1 in a few examples checked --- Full diff: https://github.com/llvm/llvm-project/pull/94642.diff 5 Files Affected: - (modified) clang/lib/CodeGen/CGDecl.cpp (+14-1) - (modified) clang/test/CodeGenCXX/auto-var-init-max-size.cpp (+1-1) - (modified) clang/test/CodeGenCXX/auto-var-init-stop-after.cpp (+1-1) - (modified) clang/test/CodeGenCXX/auto-var-init.cpp (-8) - (added) clang/test/CodeGenCXX/trivial-auto-var-init-skip-scalar-with-nonconst-init.cpp (+110) ``diff diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 4a213990d1e36..49e97a23cb0a9 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1972,7 +1972,20 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission ) { } if (!constant) { -initializeWhatIsTechnicallyUninitialized(Loc); +if (trivialAutoVarInit != +LangOptions::TrivialAutoVarInitKind::Uninitialized) { + // At this point, we know D has an Init expression, but isn't a constant. + // - If D is not a scalar, auto-var-init conservatively (members may be + // left uninitialized by constructor Init expressions for example). + // - If D is a scalar, we only need to auto-var-init if there is a + // self-reference. Otherwise, the Init expression should be sufficient. + // It may be that the Init expression uses other uninitialized memory, + // but auto-var-init here would not help, as auto-init would get + // overwritten by Init. + if (!D.getType()->isScalarType() || isAccessedBy(D, Init)) { +initializeWhatIsTechnicallyUninitialized(Loc); + } +} LValue lv = MakeAddrLValue(Loc, type); lv.setNonGC(true); return EmitExprAsInit(Init, , lv, capturedByInit); diff --git a/clang/test/CodeGenCXX/auto-var-init-max-size.cpp b/clang/test/CodeGenCXX/auto-var-init-max-size.cpp index ef38b8227a9a1..f4db297a07be8 100644 --- a/clang/test/CodeGenCXX/auto-var-init-max-size.cpp +++ b/clang/test/CodeGenCXX/auto-var-init-max-size.cpp @@ -15,7 +15,7 @@ struct Foo { int foo(unsigned n) { bool var_size_1; - long var_size_8 = 123; + long var_size_8; void *var_size_8p; int var_size_1024[256]; Foo var_size_1028; diff --git a/clang/test/CodeGenCXX/auto-var-init-stop-after.cpp b/clang/test/CodeGenCXX/auto-var-init-stop-after.cpp index a782692d0127e..f1dc0e3a068e7 100644 --- a/clang/test/CodeGenCXX/auto-var-init-stop-after.cpp +++ b/clang/test/CodeGenCXX/auto-var-init-stop-after.cpp @@ -18,7 +18,7 @@ typedef struct { int foo(unsigned n) { // scalar variable - long a = 888; + long a; // array S arr[ARRLEN]; // VLA diff --git a/clang/test/CodeGenCXX/auto-var-init.cpp b/clang/test/CodeGenCXX/auto-var-init.cpp index e1568bee136e5..e697731b0cdf1 100644 --- a/clang/test/CodeGenCXX/auto-var-init.cpp +++ b/clang/test/CodeGenCXX/auto-var-init.cpp @@ -146,16 +146,8 @@ struct notlockfree { long long a[4]; }; // PATTERN-O1-NOT: @__const.test_atomictailpad_uninit.uninit // PATTERN-O0: @__const.test_complexfloat_uninit.uninit = private unnamed_addr constant { float, float } { float 0xE000, float 0xE000 }, align 4 // PATTERN-O1-NOT: @__const.test_complexfloat_uninit.uninit -// PATTERN-O0: @__const.test_complexfloat_braces.braces = private unnamed_addr constant { float, float } { float 0xE000, float 0xE000 }, align 4 -// PATTERN-O1-NOT: @__const.test_complexfloat_braces.braces -// PATTERN-O0: @__const.test_complexfloat_custom.custom = private unnamed_addr constant { float, float } { float 0xE000, float 0xE000 }, align 4 -// PATTERN-O1-NOT: @__const.test_complexfloat_custom.custom // PATTERN-O0: @__const.test_complexdouble_uninit.uninit = private unnamed_addr constant { double, double } { double 0x, double 0x }, align 8 // PATTERN-O1-NOT: @__const.test_complexdouble_uninit.uninit -// PATTERN-O0: @__const.test_complexdouble_braces.braces = private unnamed_addr constant { double, double } { double 0x, double 0x }, align 8 -// PATTERN-O1-NOT: @__const.test_complexdouble_braces.braces -// PATTERN-O0:
[clang] Skip auto-init on scalar vars that have a non-constant Init and no self-ref (PR #94642)
https://github.com/jvoung ready_for_review https://github.com/llvm/llvm-project/pull/94642 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake][Release] Use the TXZ cpack generator for binaries (PR #90138)
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/90138 >From 0d0484ac99affdc8ccb9bc3a1eff827cf996c51c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 24 Apr 2024 07:54:41 -0700 Subject: [PATCH 1/3] [CMake][Release] Use the TGZ cpack generator for binaries --- clang/cmake/caches/Release.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index c164d5497275f..aa7e6f99e94d5 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -90,4 +90,5 @@ endif() # Final Stage Config (stage2) set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING) set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING) +set_final_stage_var(CPACK_GENERATOR "TGZ" STRING) >From 2bbc2c97a91ec98a57fdd12c373c0d17bd9eb023 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 17 May 2024 16:39:50 -0700 Subject: [PATCH 2/3] Switch to xz compression --- .github/workflows/release-binaries.yml | 2 +- clang/cmake/caches/Release.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index fc497a7de94f7..540675cc62d6a 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -214,7 +214,7 @@ jobs: - id: package-info run: | -filename="LLVM-${{ needs.prepare.outputs.release-version }}-Linux.tar.gz" +filename="LLVM-${{ needs.prepare.outputs.release-version }}-Linux.tar.xz" echo "filename=$filename" >> $GITHUB_OUTPUT echo "path=/mnt/build/tools/clang/stage2-bins/$filename" >> $GITHUB_OUTPUT diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index c6bcbdfebf999..24a45039c9dab 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -91,5 +91,5 @@ endif() # Final Stage Config (stage2) set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING) set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING) -set_final_stage_var(CPACK_GENERATOR "TGZ" STRING) +set_final_stage_var(CPACK_GENERATOR "TXZ" STRING) >From c8587febd7b7a318b9d5566ff540ca6881404bd7 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 6 Jun 2024 17:13:48 -0700 Subject: [PATCH 3/3] Use CPACK_ARCHIVE_THREADS --- clang/cmake/caches/Release.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index 24a45039c9dab..1dfb1bc535bf1 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -92,4 +92,5 @@ endif() set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING) set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING) set_final_stage_var(CPACK_GENERATOR "TXZ" STRING) +set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
@@ -69,8 +70,15 @@ clang_tidy_headers = os.path.join( config.test_source_root, "clang-tidy", "checkers", "Inputs", "Headers" ) + config.substitutions.append(("%clang_tidy_headers", clang_tidy_headers)) +clang_doc_install = os.path.join( +os.path.dirname(shutil.which("clang-doc")), "..", "share", "clang" +) ilovepi wrote: That's also likely true, but TBH I don't have a problem running clang-doc from the build directory, so maybe something else is wrong? https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler , + bool EmitSuggestions) { +#ifndef NDEBUG + Handler.clearDebugNotes(); +#endif + + assert(D); + + SmallVector Stmts; + + // We do not want to visit a Lambda expression defined inside a method + // independently. Instead, it should be visited along with the outer method. + // FIXME: do we want to do the same thing for `BlockDecl`s? + if (const auto *fd = dyn_cast(D)) { +if (fd->getParent()->isLambda() && fd->getParent()->isLocalClass()) + return; + } + + // Do not emit fixit suggestions for functions declared in an + // extern "C" block. + if (const auto *FD = dyn_cast(D)) { +for (FunctionDecl *FReDecl : FD->redecls()) { + if (FReDecl->isExternC()) { +EmitSuggestions = false; +break; + } +} + +Stmts.push_back(FD->getBody()); + +if (const auto *ID = dyn_cast(D)) { + for (const CXXCtorInitializer *CI : ID->inits()) { +Stmts.push_back(CI->getInit()); + } +} + } + + if (const auto *FD = dyn_cast(D)) { haoNoQ wrote: Ok I debugged this a little bit and it looks like you're blaming the wrong visitor. The `CXXCtorInitializer` is there and it gets correctly visited. However, `MatchDescendantVisitor` gets stuck because it considers `CXXDefaultInitExpr` implicit code. Enabling `MatchDescendantVisitor::shouldVisitImplicitCode()` takes care of your issue! Not sure it's a good solution though, might be a good idea to add an explicit `TraverseCXXDefaultInitExpr()` because I'm not sure we want to visit other kinds of implicit code. (Probably deserves a FIXME.) https://github.com/llvm/llvm-project/pull/91991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix spurious non-strict availability warning (PR #94377)
https://github.com/ahatanak approved this pull request. https://github.com/llvm/llvm-project/pull/94377 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #86923)
@@ -201,14 +211,26 @@ template <> struct DominatingValue { class saved_type { enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral, AggregateAddress, ComplexAddress }; - -llvm::Value *Value; -llvm::Type *ElementType; +union { + struct { +DominatingLLVMValue::saved_type first, second; + } Vals; + DominatingValue::saved_type AggregateAddr; +}; LLVM_PREFERRED_TYPE(Kind) unsigned K : 3; -unsigned Align : 29; -saved_type(llvm::Value *v, llvm::Type *e, Kind k, unsigned a = 0) - : Value(v), ElementType(e), K(k), Align(a) {} +unsigned IsVolatile : 1; mikerice1969 wrote: Hi @ahatanak, static verifier is concerned that IsVolatile is not initialized in the constructor. Can we add an initializer here? Also one of the constructors below has a IsVolatile parameter but isn't using it to initialize the field. Do you know what we should be doing here? https://github.com/llvm/llvm-project/pull/86923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang][CodeGen] `used` globals are fake (PR #93601)
https://github.com/yxsamliu approved this pull request. https://github.com/llvm/llvm-project/pull/93601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] refactor misc-header-include-cycle (PR #94697)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: Congcong Cai (HerrCai0907) Changes 1. merge valid check 2. use range base loop --- Full diff: https://github.com/llvm/llvm-project/pull/94697.diff 1 Files Affected: - (modified) clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp (+4-9) ``diff diff --git a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp index 37bc577c646ab..cdb5e6b16069b 100644 --- a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp @@ -130,20 +130,15 @@ class CyclicDependencyCallbacks : public PPCallbacks { << FileName; const bool IsIncludePathValid = -std::all_of(Files.rbegin(), It, [](const Include ) { +std::all_of(Files.rbegin(), It + 1, [](const Include ) { return !Elem.Name.empty() && Elem.Loc.isValid(); }); - if (!IsIncludePathValid) return; -auto CurrentIt = Files.rbegin(); -do { - if (CurrentIt->Loc.isValid()) -Check.diag(CurrentIt->Loc, "'%0' included from here", - DiagnosticIDs::Note) -<< CurrentIt->Name; -} while (CurrentIt++ != It); +for (const Include : llvm::make_range(Files.rbegin(), It + 1)) + Check.diag(I.Loc, "'%0' included from here", DiagnosticIDs::Note) + << I.Name; } bool isFileIgnored(StringRef FileName) const { `` https://github.com/llvm/llvm-project/pull/94697 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Fix error handling of the adjust_args clause (PR #94696)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Mike Rice (mikerice1969) Changes Static verifier noticed the current code has logically dead code parsing the clause where IsComma is assigned. Fix this and improve the error message received when a bad adjust-op is specified. This will now be handled like 'map' where a nice diagnostic is given with the correct values, then parsing continues on the next clause reducing unhelpful diagnostics. --- Full diff: https://github.com/llvm/llvm-project/pull/94696.diff 3 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2) - (modified) clang/lib/Parse/ParseOpenMP.cpp (+3-3) - (modified) clang/test/OpenMP/declare_variant_clauses_messages.cpp (+10) ``diff diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index d8c3fee7841f4..1160b0f7a7a5a 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1508,6 +1508,8 @@ def err_omp_unexpected_append_op : Error< "unexpected operation specified in 'append_args' clause, expected 'interop'">; def err_omp_unexpected_execution_modifier : Error< "unexpected 'execution' modifier in non-executable context">; +def err_omp_unknown_adjust_args_op : Error< + "incorrect adjust_args type, expected 'need_device_ptr' or 'nothing'">; def err_omp_declare_variant_wrong_clause : Error< "expected %select{'match'|'match', 'adjust_args', or 'append_args'}0 clause " "on 'omp declare variant' directive">; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 50a872fedebf7..76d1854520382 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -4785,8 +4785,8 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind, getLangOpts()); Data.ExtraModifierLoc = Tok.getLocation(); if (Data.ExtraModifier == OMPC_ADJUST_ARGS_unknown) { - SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end, -StopBeforeMatch); + Diag(Tok, diag::err_omp_unknown_adjust_args_op); + SkipUntil(tok::r_paren, tok::annot_pragma_openmp_end, StopBeforeMatch); } else { ConsumeToken(); if (Tok.is(tok::colon)) @@ -4799,7 +4799,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind, bool IsComma = (Kind != OMPC_reduction && Kind != OMPC_task_reduction && Kind != OMPC_in_reduction && Kind != OMPC_depend && - Kind != OMPC_doacross && Kind != OMPC_map) || + Kind != OMPC_doacross && Kind != OMPC_map && Kind != OMPC_adjust_args) || (Kind == OMPC_reduction && !InvalidReductionId) || (Kind == OMPC_map && Data.ExtraModifier != OMPC_MAP_unknown) || (Kind == OMPC_depend && Data.ExtraModifier != OMPC_DEPEND_unknown) || diff --git a/clang/test/OpenMP/declare_variant_clauses_messages.cpp b/clang/test/OpenMP/declare_variant_clauses_messages.cpp index 2a9e5385c9ca6..284e49bbd21b4 100644 --- a/clang/test/OpenMP/declare_variant_clauses_messages.cpp +++ b/clang/test/OpenMP/declare_variant_clauses_messages.cpp @@ -186,6 +186,16 @@ void vararg_bar2(const char *fmt) { return; } // expected-error@+1 {{variant in '#pragma omp declare variant' with type 'void (float *, float *, int *, omp_interop_t)' (aka 'void (float *, float *, int *, void *)') is incompatible with type 'void (float *, float *, int *)'}} #pragma omp declare variant(foo_v4) match(construct={dispatch}) +// expected-error@+3 {{incorrect adjust_args type, expected 'need_device_ptr' or 'nothing'}} +#pragma omp declare variant(foo_v1)\ + match(construct={dispatch}, device={arch(arm)}) \ + adjust_args(badaaop:AAA,BBB) + +// expected-error@+3 {{incorrect adjust_args type, expected 'need_device_ptr' or 'nothing'}} +#pragma omp declare variant(foo_v1)\ + match(construct={dispatch}, device={arch(arm)}) \ + adjust_args(badaaop AAA,BBB) + #endif // _OPENMP >= 202011 #if _OPENMP < 202011 // OpenMP 5.0 or lower // expected-error@+2 {{expected 'match' clause on 'omp declare variant' directive}} `` https://github.com/llvm/llvm-project/pull/94696 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] refactor misc-header-include-cycle (PR #94697)
https://github.com/HerrCai0907 created https://github.com/llvm/llvm-project/pull/94697 1. merge valid check 2. use range base loop >From 8104085685772f93bcc595858821f839636ada9e Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Fri, 7 Jun 2024 07:06:37 +0800 Subject: [PATCH] [clang-tidy] refactor misc-header-include-cycle 1. merge valid check 2. use range base loop --- .../clang-tidy/misc/HeaderIncludeCycleCheck.cpp | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp index 37bc577c646ab..cdb5e6b16069b 100644 --- a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp @@ -130,20 +130,15 @@ class CyclicDependencyCallbacks : public PPCallbacks { << FileName; const bool IsIncludePathValid = -std::all_of(Files.rbegin(), It, [](const Include ) { +std::all_of(Files.rbegin(), It + 1, [](const Include ) { return !Elem.Name.empty() && Elem.Loc.isValid(); }); - if (!IsIncludePathValid) return; -auto CurrentIt = Files.rbegin(); -do { - if (CurrentIt->Loc.isValid()) -Check.diag(CurrentIt->Loc, "'%0' included from here", - DiagnosticIDs::Note) -<< CurrentIt->Name; -} while (CurrentIt++ != It); +for (const Include : llvm::make_range(Files.rbegin(), It + 1)) + Check.diag(I.Loc, "'%0' included from here", DiagnosticIDs::Note) + << I.Name; } bool isFileIgnored(StringRef FileName) const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Fix error handling of the adjust_args clause (PR #94696)
https://github.com/mikerice1969 created https://github.com/llvm/llvm-project/pull/94696 Static verifier noticed the current code has logically dead code parsing the clause where IsComma is assigned. Fix this and improve the error message received when a bad adjust-op is specified. This will now be handled like 'map' where a nice diagnostic is given with the correct values, then parsing continues on the next clause reducing unhelpful diagnostics. >From 26ece1d7f046e81d095b7da609d34d19eebfed89 Mon Sep 17 00:00:00 2001 From: Mike Rice Date: Thu, 6 Jun 2024 15:57:27 -0700 Subject: [PATCH] [clang][OpenMP] Fix error handling of the adjust_args clause Static verifier noticed the current code has logically dead code parsing the clause where IsComma is assigned. Fix this and improve the error message received when a bad adjust-op is specified. This will now be handled like 'map' where a nice diagnostic is given with the correct values, then parsing continues on the next clause reducing unhelpful diagnostics. --- clang/include/clang/Basic/DiagnosticParseKinds.td | 2 ++ clang/lib/Parse/ParseOpenMP.cpp| 6 +++--- clang/test/OpenMP/declare_variant_clauses_messages.cpp | 10 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index d8c3fee7841f4..1160b0f7a7a5a 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1508,6 +1508,8 @@ def err_omp_unexpected_append_op : Error< "unexpected operation specified in 'append_args' clause, expected 'interop'">; def err_omp_unexpected_execution_modifier : Error< "unexpected 'execution' modifier in non-executable context">; +def err_omp_unknown_adjust_args_op : Error< + "incorrect adjust_args type, expected 'need_device_ptr' or 'nothing'">; def err_omp_declare_variant_wrong_clause : Error< "expected %select{'match'|'match', 'adjust_args', or 'append_args'}0 clause " "on 'omp declare variant' directive">; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 50a872fedebf7..76d1854520382 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -4785,8 +4785,8 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind, getLangOpts()); Data.ExtraModifierLoc = Tok.getLocation(); if (Data.ExtraModifier == OMPC_ADJUST_ARGS_unknown) { - SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end, -StopBeforeMatch); + Diag(Tok, diag::err_omp_unknown_adjust_args_op); + SkipUntil(tok::r_paren, tok::annot_pragma_openmp_end, StopBeforeMatch); } else { ConsumeToken(); if (Tok.is(tok::colon)) @@ -4799,7 +4799,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind, bool IsComma = (Kind != OMPC_reduction && Kind != OMPC_task_reduction && Kind != OMPC_in_reduction && Kind != OMPC_depend && - Kind != OMPC_doacross && Kind != OMPC_map) || + Kind != OMPC_doacross && Kind != OMPC_map && Kind != OMPC_adjust_args) || (Kind == OMPC_reduction && !InvalidReductionId) || (Kind == OMPC_map && Data.ExtraModifier != OMPC_MAP_unknown) || (Kind == OMPC_depend && Data.ExtraModifier != OMPC_DEPEND_unknown) || diff --git a/clang/test/OpenMP/declare_variant_clauses_messages.cpp b/clang/test/OpenMP/declare_variant_clauses_messages.cpp index 2a9e5385c9ca6..284e49bbd21b4 100644 --- a/clang/test/OpenMP/declare_variant_clauses_messages.cpp +++ b/clang/test/OpenMP/declare_variant_clauses_messages.cpp @@ -186,6 +186,16 @@ void vararg_bar2(const char *fmt) { return; } // expected-error@+1 {{variant in '#pragma omp declare variant' with type 'void (float *, float *, int *, omp_interop_t)' (aka 'void (float *, float *, int *, void *)') is incompatible with type 'void (float *, float *, int *)'}} #pragma omp declare variant(foo_v4) match(construct={dispatch}) +// expected-error@+3 {{incorrect adjust_args type, expected 'need_device_ptr' or 'nothing'}} +#pragma omp declare variant(foo_v1)\ + match(construct={dispatch}, device={arch(arm)}) \ + adjust_args(badaaop:AAA,BBB) + +// expected-error@+3 {{incorrect adjust_args type, expected 'need_device_ptr' or 'nothing'}} +#pragma omp declare variant(foo_v1)\ + match(construct={dispatch}, device={arch(arm)}) \ + adjust_args(badaaop AAA,BBB) + #endif // _OPENMP >= 202011 #if _OPENMP < 202011 // OpenMP 5.0 or lower // expected-error@+2 {{expected 'match' clause on 'omp declare variant' directive}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy]fix crashing when self include cycles for misc-header-include-cycle (PR #94636)
https://github.com/HerrCai0907 closed https://github.com/llvm/llvm-project/pull/94636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 21f5ee0 - [clang-tidy]fix crashing when self include cycles for misc-header-include-cycle (#94636)
Author: Congcong Cai Date: 2024-06-07T07:02:45+08:00 New Revision: 21f5ee014db5df4fcf3dfe4350fe9c6627f799ad URL: https://github.com/llvm/llvm-project/commit/21f5ee014db5df4fcf3dfe4350fe9c6627f799ad DIFF: https://github.com/llvm/llvm-project/commit/21f5ee014db5df4fcf3dfe4350fe9c6627f799ad.diff LOG: [clang-tidy]fix crashing when self include cycles for misc-header-include-cycle (#94636) Fixes: #94634 Added: clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.self.cpp Modified: clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp clang-tools-extra/docs/ReleaseNotes.rst Removed: diff --git a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp index fadfdc869d37b..37bc577c646ab 100644 --- a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp @@ -139,8 +139,10 @@ class CyclicDependencyCallbacks : public PPCallbacks { auto CurrentIt = Files.rbegin(); do { - Check.diag(CurrentIt->Loc, "'%0' included from here", DiagnosticIDs::Note) - << CurrentIt->Name; + if (CurrentIt->Loc.isValid()) +Check.diag(CurrentIt->Loc, "'%0' included from here", + DiagnosticIDs::Note) +<< CurrentIt->Name; } while (CurrentIt++ != It); } diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 661b2b1620d0b..da30aceb8d49d 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -317,6 +317,10 @@ Changes in existing checks Additionally, the option `UseHeaderFileExtensions` is removed, so that the check uses the `HeaderFileExtensions` option unconditionally. +- Improved :doc:`misc-header-include-cycle + ` check by avoiding crash for self + include cycles. + - Improved :doc:`misc-unused-using-decls ` check by replacing the local option `HeaderFileExtensions` by the global option of the same name. diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.self.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.self.cpp new file mode 100644 index 0..245dd0a65a8b4 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/header-include-cycle.self.cpp @@ -0,0 +1,3 @@ +// RUN: not clang-tidy %s -checks='-*,misc-header-include-cycle' + +#include "header-include-cycle.self.cpp" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
@@ -69,8 +70,15 @@ clang_tidy_headers = os.path.join( config.test_source_root, "clang-tidy", "checkers", "Inputs", "Headers" ) + config.substitutions.append(("%clang_tidy_headers", clang_tidy_headers)) +clang_doc_install = os.path.join( +os.path.dirname(shutil.which("clang-doc")), "..", "share", "clang" +) PeterChou1 wrote: I will note that currently there isn't a mechanism to pass another default stylesheet to the clang-doc the option --stylesheets= in clang-doc only extends the css stylesheet but still requires default stylesheet to be present. I was trying to find a ways to copy the asset via the lit command line but i can't seem to do it https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
@@ -69,8 +70,15 @@ clang_tidy_headers = os.path.join( config.test_source_root, "clang-tidy", "checkers", "Inputs", "Headers" ) + config.substitutions.append(("%clang_tidy_headers", clang_tidy_headers)) +clang_doc_install = os.path.join( +os.path.dirname(shutil.which("clang-doc")), "..", "share", "clang" +) ilovepi wrote: so the CMAKE_INSTALL_DATADIR variable is used when you build the install target w/ `ninja install` or equivalent. The install target isn't the build of clang/llvm or even clang-doc. Instead it copies the artifacts you want to install into their final location. Essentially, imagine if you wanted to install clang to`/usr/bin/`, and all its headers to `/usr/include/`, and all its libs to `/usr/lib/`. That's basically what the install step is for, and you can point the base install directory to be anywhere. For instance I have a `$HOME/clang-install/` folder that I install the toolchain into when I need to use it in production type situations. For daily development, I just run things out of my `build` folder. The build folder is also where tests run. This may be hidden by your IDE, but esentialy, you point CMake at the project, and tell it to build everything in some folder, usually called `build`. After CMake runs and sets up all the build files for a build system, like `ninja` or `make`, you can build the project by using the right build command. For clang-doc, that would be something like `ninja clang-doc` or `ninja check-clang-extra-clang-doc` to run its tests. But that won't install anything, it just builds things in the `build` directory. To install you'd run `ninja install` and then only the things that were important to ship would be installed to the location you specified, or to `/usr/local/` on Linux if you didn't specify anything. The default style sheet (and any other fixed resources) should be easy for you to either copy to the right place, or to pass into the `clang-doc` command line, since its path relative to the source directory is fixed. @petrhosek may know of some other mechanism to force an asset to be copied into the build directory, but I'm not sure that is required in this case. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV] Unify all the code that adds unaligned-scalar/vector-mem to Features vector. (PR #94660)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/94660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang][clang-doc] Add basic e2e test to clang-doc (PR #93928)
ilovepi wrote: A few meta comments on the particulars of the commit title and message: 1. Please change the title to only have the [clang-doc] tag. This doesn't impact `clang` at all. We use the`[tag] Title` convention to make it easy to understand where the changes are, and what they affect. Here something appropriate is either `[clang-doc] Add basic e2e test` or `[clang-doc][test] Add basic e2e test`. 2. The first comment on GitHub is special in a PR, as its the commit body. Ideally, it would have a description of what your change is doing and why. For tests, its often beneficial to put some rationale or explanation in the commit message, if there isn't a place to document it in the source. 3. If you only reference an issue, it just creates a cross ref. If your commit should fix or close the issue, there are special keywords you can put in the commit body for that (see [this reference](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)). https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 12ccc24 - [clang] Fix flag typo in comment
Author: Dave Lee Date: 2024-06-06T14:22:12-07:00 New Revision: 12ccc245f195695c8bac9156c75e5b70044882fa URL: https://github.com/llvm/llvm-project/commit/12ccc245f195695c8bac9156c75e5b70044882fa DIFF: https://github.com/llvm/llvm-project/commit/12ccc245f195695c8bac9156c75e5b70044882fa.diff LOG: [clang] Fix flag typo in comment Fixed for more accurate searches of the flag `-Wsystem-headers-in-module=`. Added: Modified: clang/include/clang/Basic/DiagnosticOptions.h Removed: diff --git a/clang/include/clang/Basic/DiagnosticOptions.h b/clang/include/clang/Basic/DiagnosticOptions.h index 099982c3bdd5a..30141c2b8f447 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.h +++ b/clang/include/clang/Basic/DiagnosticOptions.h @@ -124,7 +124,7 @@ class DiagnosticOptions : public RefCountedBase{ /// default). std::vector VerifyPrefixes; - /// The list of -Wsystem-header-in-module=... options used to override + /// The list of -Wsystem-headers-in-module=... options used to override /// whether -Wsystem-headers is enabled on a per-module basis. std::vector SystemHeaderWarningsModules; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang][clang-doc] Add basic e2e test to clang-doc (PR #93928)
ilovepi wrote: Also, I just noticed that the first comment has an `@` in it. The first comment in Github is special, as its really the body of the commit message, and will become that when you hit `Squash and merge`. Your question for @petrhosek may not even have been sent, as I don't know how github handles that. Please update the first message to be appropriate for the commit body, and copy any questions/context you have to another comment. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang][clang-doc] Add basic e2e test to clang-doc (PR #93928)
https://github.com/ilovepi edited https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA][HIP] warn incompatible redeclare (PR #77359)
@@ -9013,6 +9013,12 @@ def err_cuda_ovl_target : Error< "cannot overload %select{__device__|__global__|__host__|__host__ __device__}2 function %3">; def note_cuda_ovl_candidate_target_mismatch : Note< "candidate template ignored: target attributes do not match">; +def warn_offload_incompatible_redeclare : Warning< + "incompatible host/device attribute with redeclaration: " + "new declaration is %select{__device__|__global__|__host__|__host__ __device__}0 function, " + "old declaration is %select{__device__|__global__|__host__|__host__ __device__}1 function. " + "It will cause warning with nvcc">, Artem-B wrote: It will potentially be a more serious issue, than a mere warning. the source code has both functions, it's possible that the implementation lives in different TUs. With clang, they will be treated as function overloads and things will work. With NVCC, they will end up being treated as GPU functions and that will result in potential ORD violation becaue the user will end up with two different GPU-side functions. It will be a problem during RDC compilation which may link both instances into a single GPU executable. I'd rephrase it in more general terms. Maybe something along the lines of "Target-attribute based function overloads are not supported by NVCC and will be treated as a function redeclaration". We should tell what we're diagnosing, but make no opinion on whether it will be a problem in any specific case. https://github.com/llvm/llvm-project/pull/77359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA][HIP] warn incompatible redeclare (PR #77359)
@@ -9013,6 +9013,12 @@ def err_cuda_ovl_target : Error< "cannot overload %select{__device__|__global__|__host__|__host__ __device__}2 function %3">; def note_cuda_ovl_candidate_target_mismatch : Note< "candidate template ignored: target attributes do not match">; +def warn_offload_incompatible_redeclare : Warning< Artem-B wrote: We should have some sort of umbrella warning option for nvcc compatibility. Function overloads are the primary source of the differences, but we have other differences that the users may want to know about. E.g. some of the compiler builtins would be different. There are probably other things. This option is fine, for now. Also, we should document it. https://github.com/llvm/llvm-project/pull/77359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA][HIP] warn incompatible redeclare (PR #77359)
https://github.com/Artem-B approved this pull request. LGTM with some wording/namiung nits. https://github.com/llvm/llvm-project/pull/77359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA][HIP] warn incompatible redeclare (PR #77359)
https://github.com/Artem-B edited https://github.com/llvm/llvm-project/pull/77359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang][clang-doc] Add basic e2e test to clang-doc (PR #93928)
https://github.com/ilovepi requested changes to this pull request. Screen shots don't belong in the commit message. Public URLs are often OK for reference to LLVM source or a standards doc, but do make sure those are permalinks, and not pointed to somein on say the `main` brnach, which will change over time. In general, prefer including text and format it using markdown. This will show up in terminals and the GitHub UI equally well. https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)
vitalybuka wrote: Actually I will try myself, as I have access to the bot. https://github.com/llvm/llvm-project/pull/89811 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)
vitalybuka wrote: Try `// UNSUPPORTED: hwasan` https://github.com/llvm/llvm-project/pull/89811 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits