diff options
author | Sylvestre Ledru <sylvestre@debian.org> | 2021-02-03 09:17:26 +0100 |
---|---|---|
committer | Sylvestre Ledru <sylvestre@debian.org> | 2021-02-03 09:17:26 +0100 |
commit | 5c8ed5873e462f740c85c06a3e0afabeaaaad302 (patch) | |
tree | e8901447dfcc37e2725c074273884ebec10226d6 | |
parent | 3328924cc33b76ed9650bcd942514f2db8505c9f (diff) | |
parent | 0580cabec4f10b5c56af96551aa8a8b728fee962 (diff) |
clang_8.0, it is now 0.14; Called this version 8.14 as we cannot
go back to 0.14. Update watch
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | debian/patches/GlobalSourceManager.patch | 210 | ||||
-rw-r--r-- | debian/patches/PrintableStmt.patch | 54 |
3 files changed, 267 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog index edc4a27..3ab7f07 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,12 +8,11 @@ iwyu (8.15-1) unstable; urgency=medium * Move to clang-11 (Closes: #974814) * Add clang-{11,12} in the depends * Upstream updated their versioning on github. it was called - clang_8.0, it is now 0.15; Called this version 8.15 as we cannot - go back to 0.15. Update watch - - remove stringref.patch, PrintableStmt.patch & GlobalSourceManager.patch + clang_8.0, it is now 0.14; Called this version 8.14 as we cannot + go back to 0.14. Update watch * Update watch file format version to 4. - -- Sylvestre Ledru <sylvestre@debian.org> Thu, 26 Nov 2020 15:40:13 +0100 + -- Sylvestre Ledru <sylvestre@debian.org> Thu, 26 Nov 2020 15:39:04 +0100 iwyu (8.0-3) unstable; urgency=medium diff --git a/debian/patches/GlobalSourceManager.patch b/debian/patches/GlobalSourceManager.patch new file mode 100644 index 0000000..b865b55 --- /dev/null +++ b/debian/patches/GlobalSourceManager.patch @@ -0,0 +1,210 @@ +From fbffd6e3be4c409109b06f858368bcee1ea2f99d Mon Sep 17 00:00:00 2001 +From: Kim Grasman <kim.grasman@gmail.com> +Date: Tue, 22 Sep 2020 19:28:24 +0200 +Subject: [PATCH] Remove source manager from ASTNode constructor + +ASTNode was consistently instantiated using GlobalSourceManager(). The +passed-in source manager was only used in ASTNode::GetLocation(). + +Use GlobalSourceManager() there directly instead to keep the constructor +interface simpler. + +No functional change. +--- + iwyu.cc | 20 ++++++++++---------- + iwyu_ast_util.cc | 9 ++++----- + iwyu_ast_util.h | 42 ++++++++++++++++++------------------------ + 3 files changed, 32 insertions(+), 39 deletions(-) + +Index: iwyu/iwyu.cc +=================================================================== +--- iwyu.orig/iwyu.cc ++++ iwyu/iwyu.cc +@@ -329,7 +329,7 @@ class BaseAstVisitor : public RecursiveA + bool TraverseDecl(Decl* decl) { + if (current_ast_node_->StackContainsContent(decl)) + return true; // avoid recursion +- ASTNode node(decl, *GlobalSourceManager()); ++ ASTNode node(decl); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + return Base::TraverseDecl(decl); + } +@@ -337,7 +337,7 @@ class BaseAstVisitor : public RecursiveA + bool TraverseStmt(Stmt* stmt) { + if (current_ast_node_->StackContainsContent(stmt)) + return true; // avoid recursion +- ASTNode node(stmt, *GlobalSourceManager()); ++ ASTNode node(stmt); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + return Base::TraverseStmt(stmt); + } +@@ -348,7 +348,7 @@ class BaseAstVisitor : public RecursiveA + const Type* type = qualtype.getTypePtr(); + if (current_ast_node_->StackContainsContent(type)) + return true; // avoid recursion +- ASTNode node(type, *GlobalSourceManager()); ++ ASTNode node(type); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + return Base::TraverseType(qualtype); + } +@@ -372,7 +372,7 @@ class BaseAstVisitor : public RecursiveA + } + if (current_ast_node_->StackContainsContent(&typeloc)) + return true; // avoid recursion +- ASTNode node(&typeloc, *GlobalSourceManager()); ++ ASTNode node(&typeloc); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + return Base::TraverseTypeLoc(typeloc); + } +@@ -380,7 +380,7 @@ class BaseAstVisitor : public RecursiveA + bool TraverseNestedNameSpecifier(NestedNameSpecifier* nns) { + if (nns == nullptr) + return true; +- ASTNode node(nns, *GlobalSourceManager()); ++ ASTNode node(nns); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + if (!this->getDerived().VisitNestedNameSpecifier(nns)) + return false; +@@ -390,7 +390,7 @@ class BaseAstVisitor : public RecursiveA + bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc nns_loc) { + if (!nns_loc) // using NNSLoc::operator bool() + return true; +- ASTNode node(&nns_loc, *GlobalSourceManager()); ++ ASTNode node(&nns_loc); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + // TODO(csilvers): have VisitNestedNameSpecifierLoc instead. + if (!this->getDerived().VisitNestedNameSpecifier( +@@ -400,7 +400,7 @@ class BaseAstVisitor : public RecursiveA + } + + bool TraverseTemplateName(TemplateName template_name) { +- ASTNode node(&template_name, *GlobalSourceManager()); ++ ASTNode node(&template_name); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + if (!this->getDerived().VisitTemplateName(template_name)) + return false; +@@ -408,7 +408,7 @@ class BaseAstVisitor : public RecursiveA + } + + bool TraverseTemplateArgument(const TemplateArgument& arg) { +- ASTNode node(&arg, *GlobalSourceManager()); ++ ASTNode node(&arg); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + if (!this->getDerived().VisitTemplateArgument(arg)) + return false; +@@ -416,7 +416,7 @@ class BaseAstVisitor : public RecursiveA + } + + bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc& argloc) { +- ASTNode node(&argloc, *GlobalSourceManager()); ++ ASTNode node(&argloc); + CurrentASTNodeUpdater canu(¤t_ast_node_, &node); + if (!this->getDerived().VisitTemplateArgumentLoc(argloc)) + return false; +@@ -3940,7 +3940,7 @@ class IwyuAstConsumer + if (const TemplateSpecializationType* arg_tmpl = DynCastFrom(arg_type)) { + // Special case: We are instantiating the type in the context of an + // expression. Need to push the type to the AST stack explicitly. +- ASTNode node(arg_tmpl, *GlobalSourceManager()); ++ ASTNode node(arg_tmpl); + node.SetParent(current_ast_node()); + + instantiated_template_visitor_.ScanInstantiatedType( +Index: iwyu/iwyu_ast_util.cc +=================================================================== +--- iwyu.orig/iwyu_ast_util.cc ++++ iwyu/iwyu_ast_util.cc +@@ -183,13 +183,12 @@ SourceLocation ASTNode::GetLocation() co + // locations are in a different file, then we're uncertain of our + // own location. Return an invalid location. + if (retval.isValid()) { +- FullSourceLoc full_loc(retval, source_manager_); ++ clang::SourceManager& sm = *GlobalSourceManager(); ++ FullSourceLoc full_loc(retval, sm); + const FileEntry* spelling_file = +- source_manager_.getFileEntryForID( +- source_manager_.getFileID(full_loc.getSpellingLoc())); ++ sm.getFileEntryForID(sm.getFileID(full_loc.getSpellingLoc())); + const FileEntry* instantiation_file = +- source_manager_.getFileEntryForID( +- source_manager_.getFileID(full_loc.getExpansionLoc())); ++ sm.getFileEntryForID(sm.getFileID(full_loc.getExpansionLoc())); + if (spelling_file != instantiation_file) + return SourceLocation(); + } +Index: iwyu/iwyu_ast_util.h +=================================================================== +--- iwyu.orig/iwyu_ast_util.h ++++ iwyu/iwyu_ast_util.h +@@ -40,7 +40,6 @@ class ClassTemplateDecl; + class Expr; + class FunctionDecl; + class NamedDecl; +-class SourceManager; + class TagDecl; + class TemplateDecl; + class TemplateName; +@@ -72,37 +71,33 @@ class ASTNode { + public: + // In each case, the caller owns the object, and must guarantee it + // lives for at least as long as the ASTNode object does. +- ASTNode(const clang::Decl* decl, const clang::SourceManager& sm) ++ ASTNode(const clang::Decl* decl) + : kind_(kDeclKind), as_decl_(decl), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::Stmt* stmt, const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::Stmt* stmt) + : kind_(kStmtKind), as_stmt_(stmt), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::Type* type, const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::Type* type) + : kind_(kTypeKind), as_type_(type), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::TypeLoc* typeloc, const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::TypeLoc* typeloc) + : kind_(kTypelocKind), as_typeloc_(typeloc), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::NestedNameSpecifier* nns, const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::NestedNameSpecifier* nns) + : kind_(kNNSKind), as_nns_(nns), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::NestedNameSpecifierLoc* nnsloc, +- const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::NestedNameSpecifierLoc* nnsloc) + : kind_(kNNSLocKind), as_nnsloc_(nnsloc), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::TemplateName* template_name, +- const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::TemplateName* template_name) + : kind_(kTemplateNameKind), as_template_name_(template_name), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::TemplateArgument* template_arg, +- const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::TemplateArgument* template_arg) + : kind_(kTemplateArgumentKind), as_template_arg_(template_arg), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } +- ASTNode(const clang::TemplateArgumentLoc* template_argloc, +- const clang::SourceManager& sm) ++ parent_(nullptr), in_fwd_decl_context_(false) { } ++ ASTNode(const clang::TemplateArgumentLoc* template_argloc) + : kind_(kTemplateArgumentLocKind), as_template_argloc_(template_argloc), +- parent_(nullptr), in_fwd_decl_context_(false), source_manager_(sm) { } ++ parent_(nullptr), in_fwd_decl_context_(false) { } + + // A 'forward-declare' context means some parent of us can be + // forward-declared, which means we can be too. e.g. in +@@ -327,7 +322,6 @@ class ASTNode { + }; + const ASTNode* parent_; + bool in_fwd_decl_context_; +- const clang::SourceManager& source_manager_; + }; + + // --- Helper classes for ASTNode. diff --git a/debian/patches/PrintableStmt.patch b/debian/patches/PrintableStmt.patch new file mode 100644 index 0000000..52bc05f --- /dev/null +++ b/debian/patches/PrintableStmt.patch @@ -0,0 +1,54 @@ +From 30549c6931972456d1e09ff5dbeecd258a8df72b Mon Sep 17 00:00:00 2001 +From: Kim Grasman <kim.grasman@gmail.com> +Date: Thu, 9 Jul 2020 18:47:56 +0200 +Subject: [PATCH] Implement Stmt printing with ASTDumper + +The Clang API changed in commit 473fbc90d1fbf17e so that Stmt::dump +takes an ASTContext instead of a SourceManager. + +Rather than wire a global ASTContext, reimplement PrintableStmt and +PrintStmt to duplicate the most trivial implementations not requiring +ASTContext. + +No functional change. +--- + iwyu_ast_util.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +Index: iwyu/iwyu_ast_util.cc +=================================================================== +--- iwyu.orig/iwyu_ast_util.cc ++++ iwyu/iwyu_ast_util.cc +@@ -26,6 +26,7 @@ + #include "llvm/Support/Casting.h" + #include "llvm/Support/raw_ostream.h" + #include "clang/AST/ASTContext.h" ++#include "clang/AST/ASTDumper.h" + #include "clang/AST/CanonicalType.h" + #include "clang/AST/Decl.h" + #include "clang/AST/DeclBase.h" +@@ -47,6 +48,7 @@ namespace clang { + class FileEntry; + } // namespace clang + ++using clang::ASTDumper; + using clang::BlockPointerType; + using clang::CXXConstructExpr; + using clang::CXXConstructorDecl; +@@ -440,12 +442,14 @@ string PrintableDecl(const Decl* decl, b + string PrintableStmt(const Stmt* stmt) { + std::string buffer; + raw_string_ostream ostream(buffer); +- stmt->dump(ostream, *GlobalSourceManager()); ++ ASTDumper dumper(ostream, /*ShowColors=*/false); ++ dumper.Visit(stmt); + return ostream.str(); + } + + void PrintStmt(const Stmt* stmt) { +- stmt->dump(*GlobalSourceManager()); // This prints to errs(). ++ ASTDumper dumper(llvm::errs(), /*ShowColors=*/false); ++ dumper.Visit(stmt); + } + + string PrintableType(const Type* type) { |