Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package clang-extract for openSUSE:Factory checked in at 2024-08-16 12:23:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/clang-extract (Old) and /work/SRC/openSUSE:Factory/.clang-extract.new.2698 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "clang-extract" Fri Aug 16 12:23:33 2024 rev:12 rq:1194033 version:0~20240814.272ac2e Changes: -------- --- /work/SRC/openSUSE:Factory/clang-extract/clang-extract.changes 2024-08-14 14:16:49.189477427 +0200 +++ /work/SRC/openSUSE:Factory/.clang-extract.new.2698/clang-extract.changes 2024-08-16 12:24:03.992070818 +0200 @@ -1,0 +2,10 @@ +Thu Aug 15 04:21:56 UTC 2024 - mvet...@suse.com + +- Update to version 0~20240814.272ac2e: + * Drop VectorRef in favor of ArrayRef + * Fix copyright headers + * Drop use of `dynamic_cast` in favor of `dyn_cast` + * ElfCXX: Convert decompress_gz to use DecompressedObj attribute + * ElfCXX: Make decompress methods access ElfFd directly + +------------------------------------------------------------------- Old: ---- clang-extract-0~20240813.82f77f7.tar.xz New: ---- clang-extract-0~20240814.272ac2e.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ clang-extract.spec ++++++ --- /var/tmp/diff_new_pack.8tWyQ2/_old 2024-08-16 12:24:04.472090766 +0200 +++ /var/tmp/diff_new_pack.8tWyQ2/_new 2024-08-16 12:24:04.476090933 +0200 @@ -17,7 +17,7 @@ Name: clang-extract -Version: 0~20240813.82f77f7 +Version: 0~20240814.272ac2e Release: 0 Summary: A tool to extract code content from source files License: Apache-2.0 WITH LLVM-exception AND NCSA ++++++ _service ++++++ --- /var/tmp/diff_new_pack.8tWyQ2/_old 2024-08-16 12:24:04.512092429 +0200 +++ /var/tmp/diff_new_pack.8tWyQ2/_new 2024-08-16 12:24:04.516092595 +0200 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="manual"> <param name="scm">git</param> <param name="url">https://github.com/SUSE/clang-extract</param> - <param name="revision">82f77f742869693880658b2159b71e0b82e2a0ac</param> + <param name="revision">272ac2e328a2e15dab5b97bf77b35a2cefc59ef5</param> <param name="versionformat">0~%cd.%h</param> <param name="changesgenerate">enable</param> <param name="changesauthor">mvet...@suse.com</param> ++++++ clang-extract-0~20240813.82f77f7.tar.xz -> clang-extract-0~20240814.272ac2e.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/ClangCompat.hh new/clang-extract-0~20240814.272ac2e/libcextract/ClangCompat.hh --- old/clang-extract-0~20240813.82f77f7/libcextract/ClangCompat.hh 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/ClangCompat.hh 2024-08-14 19:15:03.000000000 +0200 @@ -1,34 +1,16 @@ -/* - * clang-extract - Extract functions from projects and its dependencies using - * libclang and LLVM infrastructure. - * - * Copyright (C) 2024 SUSE Software Solutions GmbH - * - * This file is part of clang-extract. - * - * clang-extract is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * clang-extract is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with clang-extract. If not, see <http://www.gnu.org/licenses/>. - */ - - -/** Header providing compatibility with older versions of clang. - * - * Clang API often have minor changes across versions. For this tool to be - * compatible with multiple versions, we have to provide a minimal interface - * between them. - * - * Author: Giuliano Belinassi - */ +//===- ClangCompat.hh - Compatibility layer for multiple clang versions *- C++ -*-===// +// +// This project is licensed 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 +// +//===----------------------------------------------------------------------===// +// +/// \file +/// This file provides a compatibility layer to clang-extract for it to compile +/// with multiple versions of clang and LLVM. +// +//===----------------------------------------------------------------------===// #pragma once diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/Closure.cpp new/clang-extract-0~20240814.272ac2e/libcextract/Closure.cpp --- old/clang-extract-0~20240813.82f77f7/libcextract/Closure.cpp 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/Closure.cpp 2024-08-14 19:15:03.000000000 +0200 @@ -523,12 +523,11 @@ bool DeclClosureVisitor::AnalyzeDeclsWithSameBeginlocHelper(Decl *decl) { SourceManager &SM = AST->getSourceManager(); - VectorRef<Decl *> decls = Get_Toplev_Decls_With_Same_Beginloc(AST, - SM.getExpansionLoc(decl->getBeginLoc())); - unsigned n = decls.getSize(); - Decl **array = decls.getPointer(); - for (unsigned i = 0; i < n; i++) { - TRY_TO(TraverseDecl(array[i])); + ArrayRef<Decl *> decls = Get_Toplev_Decls_With_Same_Beginloc(AST, + SM.getExpansionLoc(decl->getBeginLoc())); + + for (auto it = decls.begin(); it != decls.end(); ++it) { + TRY_TO(TraverseDecl(*it)); } return VISITOR_CONTINUE; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/ElfCXX.cpp new/clang-extract-0~20240814.272ac2e/libcextract/ElfCXX.cpp --- old/clang-extract-0~20240813.82f77f7/libcextract/ElfCXX.cpp 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/ElfCXX.cpp 2024-08-14 19:15:03.000000000 +0200 @@ -112,7 +112,7 @@ /* gzip magic number (zlib) */ case FileHandling::FILE_TYPE_GZ: { try { - ElfObj = decompress_gz(ElfFd); + ElfObj = decompress_gz(); close(ElfFd); ElfFd = -1; } catch (const std::runtime_error &error) { @@ -125,7 +125,7 @@ /* zstd magic number */ case FileHandling::FILE_TYPE_ZSTD: { try { - ElfObj = decompress_zstd(ElfFd); + ElfObj = decompress_zstd(); close(ElfFd); ElfFd = -1; } catch (const std::runtime_error &error) { @@ -159,7 +159,7 @@ } } -Elf *ElfObject::decompress_gz(int fd) +Elf *ElfObject::decompress_gz(void) { const size_t CHUNK = 16384; @@ -168,9 +168,9 @@ unsigned char out[CHUNK]; unsigned long dest_size = CHUNK; - unsigned char *dest = (unsigned char *)malloc(CHUNK); - if (!dest) - throw std::runtime_error("zlib dest malloc failed\n"); + DecompressedObj = (unsigned char *)malloc(CHUNK); + if (!DecompressedObj) + throw std::runtime_error("zlib malloc failed\n"); unsigned long dest_current = 0; @@ -184,7 +184,7 @@ /* decompress until deflate stream ends or end of file */ do { - strm.avail_in = read(fd, in, CHUNK); + strm.avail_in = read(ElfFd, in, CHUNK); if (strm.avail_in < 0) throw std::runtime_error("zlib read failed: " + std::to_string(strm.avail_in) + "\n"); @@ -212,10 +212,10 @@ /* double the buffer when needed */ if (have > dest_size - dest_current) { dest_size = dest_size * 2; - dest = (unsigned char *)realloc(dest, dest_size); + DecompressedObj = (unsigned char *)realloc(DecompressedObj, dest_size); } - memcpy(dest + dest_current, out, have); + memcpy(DecompressedObj + dest_current, out, have); dest_current += have; } while (strm.avail_out == 0); @@ -227,18 +227,14 @@ if (ret != Z_STREAM_END) throw std::runtime_error("zlib inflateEnd error: " + std::to_string(ret) + "\n"); - Elf *elf = elf_memory((char *)dest, ret); - if (elf == nullptr) { - free(dest); + Elf *elf = elf_memory((char *)DecompressedObj, ret); + if (elf == nullptr) throw std::runtime_error("libelf elf_memory error: " + std::string(elf_errmsg(elf_errno()))); - } - - free(dest); return elf; } -Elf *ElfObject::decompress_zstd(int fd) +Elf *ElfObject::decompress_zstd() { size_t buffInSize = ZSTD_DStreamInSize(); unsigned char buffIn[buffInSize]; @@ -258,7 +254,7 @@ throw std::runtime_error("zstd createDCtx failed\n"); size_t bytes_read; - while ((bytes_read = read(fd, buffIn, buffInSize)) ) { + while ((bytes_read = read(ElfFd, buffIn, buffInSize)) ) { if (bytes_read < 0) { ZSTD_freeDCtx(dctx); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/ElfCXX.hh new/clang-extract-0~20240814.272ac2e/libcextract/ElfCXX.hh --- old/clang-extract-0~20240813.82f77f7/libcextract/ElfCXX.hh 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/ElfCXX.hh 2024-08-14 19:15:03.000000000 +0200 @@ -239,8 +239,8 @@ return ElfObj; } - static Elf *decompress_gz(int fd); - Elf *decompress_zstd(int fd); + Elf *decompress_gz(void); + Elf *decompress_zstd(void); /** Iterator class for ELF sections. With this one can use C++ iterators * to iterate through all sections of the ELF file. Like this: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/ExpansionPolicy.cpp new/clang-extract-0~20240814.272ac2e/libcextract/ExpansionPolicy.cpp --- old/clang-extract-0~20240813.82f77f7/libcextract/ExpansionPolicy.cpp 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/ExpansionPolicy.cpp 2024-08-14 19:15:03.000000000 +0200 @@ -11,28 +11,6 @@ // //===----------------------------------------------------------------------===// -/* - * clang-extract - Extract functions from projects and its dependencies using - * libclang and LLVM infrastructure. - * - * Copyright (C) 2024 SUSE Software Solutions GmbH - * - * This file is part of clang-extract. - * - * clang-extract is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * clang-extract is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with clang-extract. If not, see <http://www.gnu.org/licenses/>. - */ - /* Author: Giuliano Belinassi, Marcos Paulo de Souza. */ #include "ExpansionPolicy.hh" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/FunctionDepsFinder.cpp new/clang-extract-0~20240814.272ac2e/libcextract/FunctionDepsFinder.cpp --- old/clang-extract-0~20240813.82f77f7/libcextract/FunctionDepsFinder.cpp 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/FunctionDepsFinder.cpp 2024-08-14 19:15:03.000000000 +0200 @@ -90,7 +90,7 @@ which is a redeclaration of enum Hand. Hence we have to remove the first `enum Hand` from the closure. See typedef-7.c testcase. */ - if (TypedefDecl *decl = dynamic_cast<TypedefDecl *>(*it)) { + if (TypedefDecl *decl = dyn_cast<TypedefDecl>(*it)) { SourceRange range = decl->getSourceRange(); const clang::Type *type = decl->getTypeForDecl(); @@ -150,7 +150,7 @@ this will remove the first enum declaration because the location tracking will correctly include the enum system_states. */ - else if (DeclaratorDecl *decl = dynamic_cast<DeclaratorDecl *>(*it)) { + else if (DeclaratorDecl *decl = dyn_cast<DeclaratorDecl>(*it)) { SourceRange range = decl->getSourceRange(); const clang::Type *type = ClangCompat::getTypePtr(decl->getType()); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/FunctionExternalizeFinder.cpp new/clang-extract-0~20240814.272ac2e/libcextract/FunctionExternalizeFinder.cpp --- old/clang-extract-0~20240813.82f77f7/libcextract/FunctionExternalizeFinder.cpp 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/FunctionExternalizeFinder.cpp 2024-08-14 19:15:03.000000000 +0200 @@ -44,7 +44,12 @@ bool FunctionExternalizeFinder::Should_Externalize(CallGraphNode *node) { - return Should_Externalize(dynamic_cast<FunctionDecl *>(node->getDecl())); + Decl *decl = node->getDecl(); + if (decl) { + return Should_Externalize(dyn_cast<FunctionDecl>(decl)); + } + + return false; } bool FunctionExternalizeFinder::Should_Externalize(const DeclaratorDecl *decl) @@ -125,7 +130,8 @@ bool FunctionExternalizeFinder::Analyze_Node(CallGraphNode *node) { - FunctionDecl *decl = dynamic_cast<FunctionDecl *>(node->getDecl()); + Decl *ndecl = node->getDecl(); + FunctionDecl *decl = ndecl ? dyn_cast<FunctionDecl>(ndecl) : nullptr; if (Is_Already_Analyzed(node)) { return false; @@ -170,7 +176,7 @@ if (DeclRefExpr::classof(stmt)) { DeclRefExpr *expr = (DeclRefExpr *) stmt; - DeclaratorDecl *decl = dynamic_cast<DeclaratorDecl *>(expr->getDecl()); + DeclaratorDecl *decl = dyn_cast<DeclaratorDecl>(expr->getDecl()); if (Should_Externalize(decl)) { externalized = Mark_For_Externalization(decl->getNameAsString()); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/FunctionExternalizeFinder.hh new/clang-extract-0~20240814.272ac2e/libcextract/FunctionExternalizeFinder.hh --- old/clang-extract-0~20240813.82f77f7/libcextract/FunctionExternalizeFinder.hh 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/FunctionExternalizeFinder.hh 2024-08-14 19:15:03.000000000 +0200 @@ -1,24 +1,15 @@ -/* - * clang-extract - Extract functions from projects and its dependencies using - * libclang and LLVM infrastructure. - * - * Copyright (C) 2024 SUSE Software Solutions GmbH - * - * This file is part of clang-extract. - * - * clang-extract is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * clang-extract is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with clang-extract. If not, see <http://www.gnu.org/licenses/>. - */ +//===- FunctionExternalizeFinder.hh - Find symbols to be externalized *- C++ -*-===// +// +// This project is licensed 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 +// +//===----------------------------------------------------------------------===// +// +/// \file +/// Finds which symbols must be externalized when extracting functions. +// +//===----------------------------------------------------------------------===// /* Author: Giuliano Belinassi */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/LLVMMisc.cpp new/clang-extract-0~20240814.272ac2e/libcextract/LLVMMisc.cpp --- old/clang-extract-0~20240813.82f77f7/libcextract/LLVMMisc.cpp 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/LLVMMisc.cpp 2024-08-14 19:15:03.000000000 +0200 @@ -160,7 +160,7 @@ return nullptr; } -VectorRef<Decl *> Get_Toplev_Decls_With_Same_Beginloc(ASTUnit *ast, const SourceLocation &loc) +ArrayRef<Decl *> Get_Toplev_Decls_With_Same_Beginloc(ASTUnit *ast, const SourceLocation &loc) { SourceManager &SM = ast->getSourceManager(); /* We don't have a way of accessing the TopLevel vector directly, hence we @@ -204,7 +204,7 @@ } } - return VectorRef(&array[last_l], &array[last_h]); + return ArrayRef(&array[last_l], &array[last_h+1]); } if (SM.isBeforeInTranslationUnit(begin, loc)) { @@ -214,7 +214,7 @@ } } - return VectorRef<Decl *>(nullptr, 0U); + return ArrayRef<Decl *>(nullptr, 0UL); } std::string Build_CE_Location_Comment(SourceManager &sm, const SourceLocation &loc) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/LLVMMisc.hh new/clang-extract-0~20240814.272ac2e/libcextract/LLVMMisc.hh --- old/clang-extract-0~20240813.82f77f7/libcextract/LLVMMisc.hh 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/LLVMMisc.hh 2024-08-14 19:15:03.000000000 +0200 @@ -81,7 +81,7 @@ Decl *Get_Toplevel_Decl_At_Location(ASTUnit *ast, const SourceLocation &loc); /* Get Toplevel decls with same beginloc. */ -VectorRef<Decl *> Get_Toplev_Decls_With_Same_Beginloc(ASTUnit *ast, const SourceLocation &loc); +ArrayRef<Decl *> Get_Toplev_Decls_With_Same_Beginloc(ASTUnit *ast, const SourceLocation &loc); /** Build a clang-extract location comment. */ std::string Build_CE_Location_Comment(SourceManager &sm, const SourceLocation &loc); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/NonLLVMMisc.hh new/clang-extract-0~20240814.272ac2e/libcextract/NonLLVMMisc.hh --- old/clang-extract-0~20240813.82f77f7/libcextract/NonLLVMMisc.hh 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/NonLLVMMisc.hh 2024-08-14 19:15:03.000000000 +0200 @@ -79,43 +79,6 @@ /** Check if output supports colors. */ bool check_color_available(void); -/** Vector reference. */ -template <typename T> -class VectorRef -{ - public: - VectorRef(T *reference, unsigned size) - : Ref(reference), - Size(size) - { - } - - VectorRef(T *base, T *top) - { - if (base == nullptr) { - Ref = nullptr, Size = 0; - return; - } - - Ref = base; - Size = ((ptrdiff_t)top - (ptrdiff_t)base)/sizeof(T) + 1; - } - - inline T *getPointer(void) - { - return Ref; - } - - inline unsigned getSize(void) - { - return Size; - } - - private: - T *Ref; - unsigned Size; -}; - class FileHandling { public: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240813.82f77f7/libcextract/PrettyPrint.cpp new/clang-extract-0~20240814.272ac2e/libcextract/PrettyPrint.cpp --- old/clang-extract-0~20240813.82f77f7/libcextract/PrettyPrint.cpp 2024-08-13 16:33:53.000000000 +0200 +++ new/clang-extract-0~20240814.272ac2e/libcextract/PrettyPrint.cpp 2024-08-14 19:15:03.000000000 +0200 @@ -31,9 +31,9 @@ with body. If yes, we can simply print the declaration, but otherwise we need to manually insert the end of statement ';' token. */ - FunctionDecl *f = dynamic_cast<FunctionDecl*>(decl); - TagDecl *t = dynamic_cast<TagDecl*>(decl); - EnumDecl *e = dynamic_cast<EnumDecl*>(decl); + FunctionDecl *f = dyn_cast<FunctionDecl>(decl); + TagDecl *t = dyn_cast<TagDecl>(decl); + EnumDecl *e = dyn_cast<EnumDecl>(decl); if (f && f->hasBody() && f->isThisDeclarationADefinition()) { Print_Decl_Raw(f); @@ -573,7 +573,7 @@ /* Handle namespaces. Namespace declaration can contain many functions that can be unused in the program. Hence we need to handle it carefully to remove what we don't need. */ - if (NamespaceDecl *namespacedecl = dynamic_cast<NamespaceDecl*>(decl)) { + if (NamespaceDecl *namespacedecl = dyn_cast<NamespaceDecl>(decl)) { if (namespacedecl->isInline()) { (*PrettyPrint::Out) << "inline "; }