commit clang-extract for openSUSE:Factory
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-07-29 21:52:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/clang-extract (Old) and /work/SRC/openSUSE:Factory/.clang-extract.new.1882 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "clang-extract" Mon Jul 29 21:52:47 2024 rev:8 rq:1190165 version:0~20240726.4309abc Changes: -------- --- /work/SRC/openSUSE:Factory/clang-extract/clang-extract.changes 2024-07-25 11:47:12.717487643 +0200 +++ /work/SRC/openSUSE:Factory/.clang-extract.new.1882/clang-extract.changes 2024-07-29 21:53:46.048071742 +0200 @@ -1,0 +2,6 @@ +Mon Jul 29 07:08:20 UTC 2024 - mvetter@suse.com + +- Update to version 0~20240726.4309abc: + * Fix closure missing TypedefDecl because not being referenced by type + +------------------------------------------------------------------- Old: ---- clang-extract-0~20240722.a998e91.tar.xz New: ---- clang-extract-0~20240726.4309abc.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ clang-extract.spec ++++++ --- /var/tmp/diff_new_pack.s2eTZQ/_old 2024-07-29 21:53:46.568092801 +0200 +++ /var/tmp/diff_new_pack.s2eTZQ/_new 2024-07-29 21:53:46.572092962 +0200 @@ -17,7 +17,7 @@ Name: clang-extract -Version: 0~20240722.a998e91 +Version: 0~20240726.4309abc 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.s2eTZQ/_old 2024-07-29 21:53:46.600094096 +0200 +++ /var/tmp/diff_new_pack.s2eTZQ/_new 2024-07-29 21:53:46.604094258 +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">a998e91ea98a06179bb39f0fa6e39427ad29774b</param> + <param name="revision">4309abcfa899db4ada43550620bdfb226a9393f6</param> <param name="versionformat">0~%cd.%h</param> <param name="changesgenerate">enable</param> <param name="changesauthor">mvetter@suse.com</param> ++++++ clang-extract-0~20240722.a998e91.tar.xz -> clang-extract-0~20240726.4309abc.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240722.a998e91/libcextract/Closure.hh new/clang-extract-0~20240726.4309abc/libcextract/Closure.hh --- old/clang-extract-0~20240722.a998e91/libcextract/Closure.hh 2024-07-23 01:27:55.000000000 +0200 +++ new/clang-extract-0~20240726.4309abc/libcextract/Closure.hh 2024-07-26 20:29:36.000000000 +0200 @@ -22,6 +22,7 @@ #include <unordered_set> #include "LLVMMisc.hh" +#include "PrettyPrint.hh" using namespace clang; @@ -241,6 +242,66 @@ } return VISITOR_CONTINUE; + } + + bool VisitDeclaratorDecl(DeclaratorDecl *decl) + { + /* There are some types in which we lose the the typedef reference, for + * example: + * + * typedef void (*XtErrorHandler)(char *); + * extern void XtSetErrorHandler(XtErrorHandler __attribute((noreturn))); + * + * The type dump for this is: + * + * FunctionProtoType 0x5210000720e0 'void (void (*)(char *) __attribute__((noreturn)))' cdecl + * |-BuiltinType 0x521000014170 'void' + * `-PointerType 0x521000071fd0 'void (*)(char *) __attribute__((noreturn))' + * `-ParenType 0x521000071f70 'void (char *) __attribute__((noreturn))' sugar + * `-FunctionProtoType 0x521000071f30 'void (char *) __attribute__((noreturn))' noreturn cdecl + * |-BuiltinType 0x521000014170 'void' + * `-PointerType 0x521000014d10 'char *' + * `-BuiltinType 0x5210000141b0 'char' + * + * Notice that there is no reference for XtErrorHandler. Somehow clang was + * not able to identify that XtErrorHandler __attribute((noreturn)) is a + * XtErrorHandler. OTOH, if we drop __attribute((noreturn)) we get: + * + * FunctionProtoType 0x521000071ff0 'void (XtErrorHandler)' cdecl + * |-BuiltinType 0x521000014170 'void' + * `-ElaboratedType 0x521000071f00 'XtErrorHandler' sugar + * `-TypedefType 0x521000071ed0 'XtErrorHandler' sugar + * |-Typedef 0x521000071e78 'XtErrorHandler' + * `-PointerType 0x521000071e10 'void (*)(char *)' + * `-ParenType 0x521000071db0 'void (char *)' sugar + * `-FunctionProtoType 0x521000071d70 'void (char *)' cdecl + * |-BuiltinType 0x521000014170 'void' + * `-PointerType 0x521000014d10 'char *' + * `-BuiltinType 0x5210000141b0 'char' + * + * which is correct. Hence we get the SourceText and try to match to any + * decl that is in the symbol table with that name. + */ + + SourceManager &sm = AST->getSourceManager(); + const LangOptions &lo = AST->getLangOpts(); + + const TypeSourceInfo *typeinfo = decl->getTypeSourceInfo(); + const TypeLoc &tl = typeinfo->getTypeLoc(); + + /* Get the range of the token which we expect is the type of it. */ + SourceLocation tok_begin = Lexer::GetBeginningOfToken(tl.getBeginLoc(), sm, lo); + SourceLocation tok_end = Lexer::getLocForEndOfToken(tl.getBeginLoc(), 0, sm, lo); + + StringRef text = PrettyPrint::Get_Source_Text({tok_begin, tok_end}); + + /* Lookup in the symbol table for any Decl matching it. */ + DeclContextLookupResult decls = Get_Decl_From_Symtab(AST, text); + for (auto decl_it : decls) { + TRY_TO(TraverseDecl(decl_it)); + } + + return VISITOR_CONTINUE; } bool VisitValueDecl(ValueDecl *decl) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240722.a998e91/libcextract/LLVMMisc.cpp new/clang-extract-0~20240726.4309abc/libcextract/LLVMMisc.cpp --- old/clang-extract-0~20240722.a998e91/libcextract/LLVMMisc.cpp 2024-07-23 01:27:55.000000000 +0200 +++ new/clang-extract-0~20240726.4309abc/libcextract/LLVMMisc.cpp 2024-07-26 20:29:36.000000000 +0200 @@ -205,3 +205,18 @@ } return false; } + +/** Lookup in the symbol table for a declaration with given name passed by info. */ +DeclContextLookupResult Get_Decl_From_Symtab(ASTUnit *ast, const IdentifierInfo *info) +{ + TranslationUnitDecl *tu = ast->getASTContext().getTranslationUnitDecl(); + return tu->lookup(DeclarationName(info)); +} + +/** Lookup in the symbol table for a declaration with given name passed by name. */ +DeclContextLookupResult Get_Decl_From_Symtab(ASTUnit *ast, const StringRef &name) +{ + IdentifierTable &symtab = ast->getPreprocessor().getIdentifierTable(); + IdentifierInfo &info = symtab.get(name); + return Get_Decl_From_Symtab(ast, &info); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240722.a998e91/libcextract/LLVMMisc.hh new/clang-extract-0~20240726.4309abc/libcextract/LLVMMisc.hh --- old/clang-extract-0~20240722.a998e91/libcextract/LLVMMisc.hh 2024-07-23 01:27:55.000000000 +0200 +++ new/clang-extract-0~20240726.4309abc/libcextract/LLVMMisc.hh 2024-07-26 20:29:36.000000000 +0200 @@ -89,3 +89,9 @@ /** Check if Decl have a Location comment. */ bool Have_Location_Comment(const SourceManager &sm, RawComment *comment); + +/** Lookup in the symbol table for a declaration with given name passed by info. */ +DeclContextLookupResult Get_Decl_From_Symtab(ASTUnit *ast, const IdentifierInfo *info); + +/** Lookup in the symbol table for a declaration with given name passed by name. */ +DeclContextLookupResult Get_Decl_From_Symtab(ASTUnit *ast, const StringRef &name); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240722.a998e91/testsuite/small/attr-13.c new/clang-extract-0~20240726.4309abc/testsuite/small/attr-13.c --- old/clang-extract-0~20240722.a998e91/testsuite/small/attr-13.c 1970-01-01 01:00:00.000000000 +0100 +++ new/clang-extract-0~20240726.4309abc/testsuite/small/attr-13.c 2024-07-26 20:29:36.000000000 +0200 @@ -0,0 +1,14 @@ +/* { dg-options "-DCE_EXTRACT_FUNCTIONS=f -DCE_NO_EXTERNALIZATION" }*/ +/* { dg-xfail } */ + +enum MHD_Result { + MHD_NO = 0, + MHD_YES = 1 +}__attribute__((enum_extensibility(closed))); + +enum MHD_Result f() { + return MHD_NO; +} + + +/* { dg-final { scan-tree-dump "__attribute__\(\(enum_externsibility\(closed\)\)\)" } } */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240722.a998e91/testsuite/small/typedef-14.c new/clang-extract-0~20240726.4309abc/testsuite/small/typedef-14.c --- old/clang-extract-0~20240722.a998e91/testsuite/small/typedef-14.c 1970-01-01 01:00:00.000000000 +0100 +++ new/clang-extract-0~20240726.4309abc/testsuite/small/typedef-14.c 2024-07-26 20:29:36.000000000 +0200 @@ -0,0 +1,11 @@ +/* { dg-options "-DCE_EXTRACT_FUNCTIONS=f -DCE_NO_EXTERNALIZATION" }*/ + +typedef void (*XtErrorHandler)(char *); +extern void XtSetErrorHandler(XtErrorHandler __attribute((noreturn))); + +void f() { + XtSetErrorHandler(((void*)0)); +} + +/* { dg-final { scan-tree-dump "typedef void \(\*XtErrorHandler\)\(char \*\);" } } */ + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240722.a998e91/testsuite/small/typedef-15.c new/clang-extract-0~20240726.4309abc/testsuite/small/typedef-15.c --- old/clang-extract-0~20240722.a998e91/testsuite/small/typedef-15.c 1970-01-01 01:00:00.000000000 +0100 +++ new/clang-extract-0~20240726.4309abc/testsuite/small/typedef-15.c 2024-07-26 20:29:36.000000000 +0200 @@ -0,0 +1,23 @@ +/* { dg-options "-DCE_EXTRACT_FUNCTIONS=f -DCE_NO_EXTERNALIZATION" }*/ +/* { dg-xfail } */ + +typedef long unsigned int size_t; +typedef void + *(*AcquireMemoryHandler)(size_t), + (*DestroyMemoryHandler)(void *), + *(*ResizeMemoryHandler)(void *,size_t), + *(*AcquireAlignedMemoryHandler)(const size_t,const size_t), + (*RelinquishAlignedMemoryHandler)(void *); + +extern void + GetMagickMemoryMethods(AcquireMemoryHandler *,ResizeMemoryHandler *, DestroyMemoryHandler *), + *ResetMagickMemory(void *,int,const size_t); + +void f() +{ + (void) ResetMagickMemory((void*)0,0,0); +} + +/* { dg-final { scan-tree-dump "\*\(\*AcquireMemoryHandler\)\(size_t\)," } } */ +/* { dg-final { scan-tree-dump "\*\(\*DestroyMemoryHandler\)\(void *\*\)," } } */ +/* { dg-final { scan-tree-dump "\*\(\*ResizeMemoryHandler\)\(void *\*, *size_t\)," } } */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/clang-extract-0~20240722.a998e91/testsuite/small/typedef-16.c new/clang-extract-0~20240726.4309abc/testsuite/small/typedef-16.c --- old/clang-extract-0~20240722.a998e91/testsuite/small/typedef-16.c 1970-01-01 01:00:00.000000000 +0100 +++ new/clang-extract-0~20240726.4309abc/testsuite/small/typedef-16.c 2024-07-26 20:29:36.000000000 +0200 @@ -0,0 +1,34 @@ +/* { dg-options "-DCE_EXTRACT_FUNCTIONS=f -DCE_NO_EXTERNALIZATION" }*/ +/* { dg-xfail } */ + +typedef long unsigned int size_t; + +typedef struct _MagickWand + MagickWand; + +typedef enum +{ + MagickFalse = 0, + MagickTrue = 1 +} MagickBooleanType; + +typedef enum +{ + UndefinedChannel = 0x0000, + RedChannel = 0x0001, + GrayChannel = 0x0001, +} ChannelType; + +extern __attribute__ ((visibility ("default"))) MagickBooleanType + MagickAdaptiveBlurImage(MagickWand *,const double,const double), + MagickAdaptiveResizeImage(MagickWand *,const size_t,const size_t), + MagickAdaptiveSharpenImage(MagickWand *,const double,const double); + +MagickBooleanType f(MagickWand *wand, const ChannelType channel, const double radius, const double sigma) { + MagickBooleanType status; + status = MagickAdaptiveSharpenImage(wand, radius, sigma); + return status; +} + +/* { dg-final { scan-tree-dump "typedef long unsigned int size_t;" } } */ +/* { dg-final { scan-tree-dump "MagickAdaptiveSharpenImage\(MagickWand *\*,const double, *\*const double\);" } } */
participants (1)
-
Source-Sync