diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:19:40 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:01:50 +0000 |
commit | 51f6c2793adab2d864b3d2b360000ef8db1d3e92 (patch) | |
tree | 835b3b4446b012c75e80177cef9fbe6972cc7dbe /chromium/tools/clang | |
parent | 6036726eb981b6c4b42047513b9d3f4ac865daac (diff) | |
download | qtwebengine-chromium-51f6c2793adab2d864b3d2b360000ef8db1d3e92.tar.gz |
BASELINE: Update Chromium to 71.0.3578.93
Change-Id: I6a32086c33670e1b033f8b10e6bf1fd4da1d105d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/tools/clang')
16 files changed, 202 insertions, 99 deletions
diff --git a/chromium/tools/clang/base_bind_rewriters/BaseBindRewriters.cpp b/chromium/tools/clang/base_bind_rewriters/BaseBindRewriters.cpp index 4f6c068e54b..45964a676eb 100644 --- a/chromium/tools/clang/base_bind_rewriters/BaseBindRewriters.cpp +++ b/chromium/tools/clang/base_bind_rewriters/BaseBindRewriters.cpp @@ -92,7 +92,7 @@ class PassedToMoveRewriter : public MatchFinder::MatchCallback, // base::Passed(std::move(bar)); // In these cases, we can just remove base::Passed. auto left = clang::CharSourceRange::getTokenRange( - result.SourceManager->getSpellingLoc(target->getLocStart()), + result.SourceManager->getSpellingLoc(target->getBeginLoc()), result.SourceManager->getSpellingLoc(target->getArg(0)->getExprLoc()) .getLocWithOffset(-1)); auto r_paren = clang::CharSourceRange::getTokenRange( @@ -111,7 +111,7 @@ class PassedToMoveRewriter : public MatchFinder::MatchCallback, if (unary->getOpcode() == clang::UO_AddrOf) { // base::Passed(&xxx) -> std::move(xxx). auto left = clang::CharSourceRange::getTokenRange( - result.SourceManager->getSpellingLoc(target->getLocStart()), + result.SourceManager->getSpellingLoc(target->getBeginLoc()), result.SourceManager->getSpellingLoc( target->getArg(0)->getExprLoc())); replacements_->emplace_back(*result.SourceManager, left, "std::move("); @@ -121,7 +121,7 @@ class PassedToMoveRewriter : public MatchFinder::MatchCallback, // base::Passed(xxx) -> std::move(*xxx) auto left = clang::CharSourceRange::getTokenRange( - result.SourceManager->getSpellingLoc(target->getLocStart()), + result.SourceManager->getSpellingLoc(target->getBeginLoc()), result.SourceManager->getSpellingLoc(target->getArg(0)->getExprLoc()) .getLocWithOffset(-1)); replacements_->emplace_back(*result.SourceManager, left, "std::move(*"); @@ -169,8 +169,8 @@ class BindOnceRewriter : public MatchFinder::MatchCallback, public Rewriter { auto* target = result.Nodes.getNodeAs<clang::CallExpr>("target"); auto* callee = target->getCallee(); auto range = clang::CharSourceRange::getTokenRange( - result.SourceManager->getSpellingLoc(callee->getLocEnd()), - result.SourceManager->getSpellingLoc(callee->getLocEnd())); + result.SourceManager->getSpellingLoc(callee->getEndLoc()), + result.SourceManager->getSpellingLoc(callee->getEndLoc())); replacements_->emplace_back(*result.SourceManager, range, "BindOnce"); } @@ -213,11 +213,11 @@ class PassByValueRewriter : public MatchFinder::MatchCallback, public Rewriter { // Remove the leading `const` and the following `&`. auto type_loc = target->getTypeSourceInfo()->getTypeLoc(); auto const_keyword = clang::CharSourceRange::getTokenRange( - result.SourceManager->getSpellingLoc(target->getLocStart()), - result.SourceManager->getSpellingLoc(target->getLocStart())); + result.SourceManager->getSpellingLoc(target->getBeginLoc()), + result.SourceManager->getSpellingLoc(target->getBeginLoc())); auto lvalue_ref = clang::CharSourceRange::getTokenRange( - result.SourceManager->getSpellingLoc(type_loc.getLocEnd()), - result.SourceManager->getSpellingLoc(type_loc.getLocEnd())); + result.SourceManager->getSpellingLoc(type_loc.getEndLoc()), + result.SourceManager->getSpellingLoc(type_loc.getEndLoc())); replacements_->emplace_back(*result.SourceManager, const_keyword, " "); replacements_->emplace_back(*result.SourceManager, lvalue_ref, " "); } @@ -481,11 +481,11 @@ class AddStdMoveRewriter : public MatchFinder::MatchCallback, public Rewriter { replacements_->emplace_back( *result.SourceManager, - result.SourceManager->getSpellingLoc(target->getLocStart()), 0, + result.SourceManager->getSpellingLoc(target->getBeginLoc()), 0, "std::move("); replacements_->emplace_back( *result.SourceManager, - clang::Lexer::getLocForEndOfToken(target->getLocEnd(), 0, + clang::Lexer::getLocForEndOfToken(target->getEndLoc(), 0, *result.SourceManager, result.Context->getLangOpts()), 0, ")"); @@ -620,7 +620,7 @@ class AdaptCallbackForRepeatingRewriter : public MatchFinder::MatchCallback, auto* target = result.Nodes.getNodeAs<clang::CallExpr>("target"); auto left = clang::CharSourceRange::getTokenRange( - result.SourceManager->getSpellingLoc(target->getLocStart()), + result.SourceManager->getSpellingLoc(target->getBeginLoc()), result.SourceManager->getSpellingLoc(target->getArg(0)->getExprLoc()) .getLocWithOffset(-1)); diff --git a/chromium/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp b/chromium/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp index 7768fe355f3..3df46a3c413 100644 --- a/chromium/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp +++ b/chromium/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp @@ -570,7 +570,7 @@ void BlinkGCPluginConsumer::DumpClass(RecordInfo* info) { json_->OpenObject(); json_->Write("name", info->record()->getQualifiedNameAsString()); - json_->Write("loc", GetLocString(info->record()->getLocStart())); + json_->Write("loc", GetLocString(info->record()->getBeginLoc())); json_->CloseObject(); class DumpEdgeVisitor : public RecursiveEdgeVisitor { @@ -637,16 +637,12 @@ void BlinkGCPluginConsumer::DumpClass(RecordInfo* info) { DumpEdgeVisitor visitor(json_); for (auto& base : info->GetBases()) - visitor.DumpEdge(info, - base.second.info(), - "<super>", - Edge::kStrong, - GetLocString(base.second.spec().getLocStart())); + visitor.DumpEdge(info, base.second.info(), "<super>", Edge::kStrong, + GetLocString(base.second.spec().getBeginLoc())); for (auto& field : info->GetFields()) - visitor.DumpField(info, - &field.second, - GetLocString(field.second.field()->getLocStart())); + visitor.DumpField(info, &field.second, + GetLocString(field.second.field()->getBeginLoc())); } std::string BlinkGCPluginConsumer::GetLocString(SourceLocation loc) { @@ -681,7 +677,7 @@ bool BlinkGCPluginConsumer::IsIgnoredClass(RecordInfo* info) { bool BlinkGCPluginConsumer::InIgnoredDirectory(RecordInfo* info) { std::string filename; - if (!GetFilename(info->record()->getLocStart(), &filename)) + if (!GetFilename(info->record()->getBeginLoc(), &filename)) return false; // TODO: should we ignore non-existing file locations? #if defined(_WIN32) std::replace(filename.begin(), filename.end(), '\\', '/'); diff --git a/chromium/tools/clang/blink_gc_plugin/CheckFinalizerVisitor.cpp b/chromium/tools/clang/blink_gc_plugin/CheckFinalizerVisitor.cpp index f0a9bf3dba0..699b740e247 100644 --- a/chromium/tools/clang/blink_gc_plugin/CheckFinalizerVisitor.cpp +++ b/chromium/tools/clang/blink_gc_plugin/CheckFinalizerVisitor.cpp @@ -56,7 +56,7 @@ void MightBeCollectedVisitor::VisitMember(Member* edge) { void MightBeCollectedVisitor::VisitCollection(Collection* edge) { if (edge->on_heap() && !is_eagerly_finalized_) { - might_be_collected_ = !edge->is_root(); + might_be_collected_ = true; } else { edge->AcceptMembers(this); } diff --git a/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp b/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp index ab2d2601bc3..92cfa97615d 100644 --- a/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp +++ b/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp @@ -46,8 +46,3 @@ void CheckGCRootsVisitor::VisitValue(Value* edge) { void CheckGCRootsVisitor::VisitPersistent(Persistent* edge) { gc_roots_.push_back(current_); } - -void CheckGCRootsVisitor::AtCollection(Collection* edge) { - if (edge->is_root()) - gc_roots_.push_back(current_); -} diff --git a/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.h b/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.h index b3cede16f91..6257d4e33cb 100644 --- a/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.h +++ b/chromium/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.h @@ -27,7 +27,6 @@ class CheckGCRootsVisitor : public RecursiveEdgeVisitor { void VisitValue(Value* edge) override; void VisitPersistent(Persistent* edge) override; - void AtCollection(Collection* edge) override; private: RootPath current_; diff --git a/chromium/tools/clang/blink_gc_plugin/Config.h b/chromium/tools/clang/blink_gc_plugin/Config.h index bd347b89243..a4573ebaccf 100644 --- a/chromium/tools/clang/blink_gc_plugin/Config.h +++ b/chromium/tools/clang/blink_gc_plugin/Config.h @@ -79,24 +79,10 @@ class Config { } static bool IsGCCollection(const std::string& name) { - return name == "HeapVector" || - name == "HeapDeque" || - name == "HeapHashSet" || - name == "HeapListHashSet" || - name == "HeapLinkedHashSet" || - name == "HeapHashCountedSet" || - name == "HeapHashMap" || - IsPersistentGCCollection(name); - } - - static bool IsPersistentGCCollection(const std::string& name) { - return name == "PersistentHeapVector" || - name == "PersistentHeapDeque" || - name == "PersistentHeapHashSet" || - name == "PersistentHeapListHashSet" || - name == "PersistentHeapLinkedHashSet" || - name == "PersistentHeapHashCountedSet" || - name == "PersistentHeapHashMap"; + return name == "HeapVector" || name == "HeapDeque" || + name == "HeapHashSet" || name == "HeapListHashSet" || + name == "HeapLinkedHashSet" || name == "HeapHashCountedSet" || + name == "HeapHashMap"; } static bool IsGCCollectionWithUnsafeIterator(const std::string& name) { diff --git a/chromium/tools/clang/blink_gc_plugin/DiagnosticsReporter.cpp b/chromium/tools/clang/blink_gc_plugin/DiagnosticsReporter.cpp index 82175817e6e..032f3ffe7a3 100644 --- a/chromium/tools/clang/blink_gc_plugin/DiagnosticsReporter.cpp +++ b/chromium/tools/clang/blink_gc_plugin/DiagnosticsReporter.cpp @@ -312,7 +312,7 @@ void DiagnosticsReporter::BaseRequiresTracing( RecordInfo* derived, CXXMethodDecl* trace, CXXRecordDecl* base) { - ReportDiagnostic(trace->getLocStart(), diag_base_requires_tracing_) + ReportDiagnostic(trace->getBeginLoc(), diag_base_requires_tracing_) << base << derived->record(); } @@ -327,8 +327,7 @@ void DiagnosticsReporter::FieldsImproperlyTraced( break; } } - ReportDiagnostic(trace->getLocStart(), diag) - << info->record(); + ReportDiagnostic(trace->getBeginLoc(), diag) << info->record(); for (auto& field : info->GetFields()) { if (!field.second.IsProperlyTraced()) NoteFieldRequiresTracing(info, field.first); @@ -340,8 +339,7 @@ void DiagnosticsReporter::FieldsImproperlyTraced( void DiagnosticsReporter::ClassContainsInvalidFields( RecordInfo* info, const CheckFieldsVisitor::Errors& errors) { - - ReportDiagnostic(info->record()->getLocStart(), + ReportDiagnostic(info->record()->getBeginLoc(), diag_class_contains_invalid_fields_) << info->record(); @@ -380,7 +378,7 @@ void DiagnosticsReporter::ClassContainsGCRoots( for (FieldPoint* path : error) { if (!point) { point = path; - ReportDiagnostic(info->record()->getLocStart(), + ReportDiagnostic(info->record()->getBeginLoc(), diag_class_contains_gc_root_) << info->record() << point->field(); continue; @@ -403,7 +401,7 @@ void DiagnosticsReporter::FinalizerAccessesFinalizedFields( unsigned diag_note = as_eagerly_finalized ? diag_eagerly_finalized_field_note_ : diag_finalized_field_note_; - ReportDiagnostic(error.member->getLocStart(), diag_error) + ReportDiagnostic(error.member->getBeginLoc(), diag_error) << dtor << error.field->field(); NoteField(error.field, diag_note); } @@ -426,7 +424,7 @@ void DiagnosticsReporter::OverriddenNonVirtualTrace( RecordInfo* info, CXXMethodDecl* trace, CXXMethodDecl* overridden) { - ReportDiagnostic(trace->getLocStart(), diag_overridden_non_virtual_trace_) + ReportDiagnostic(trace->getBeginLoc(), diag_overridden_non_virtual_trace_) << info->record() << overridden->getParent(); NoteOverriddenNonVirtualTrace(overridden); } @@ -472,28 +470,27 @@ void DiagnosticsReporter::ReportMissingDispatch( const FunctionDecl* dispatch, RecordInfo* receiver, unsigned error) { - ReportDiagnostic(dispatch->getLocStart(), error) << receiver->record(); + ReportDiagnostic(dispatch->getBeginLoc(), error) << receiver->record(); } void DiagnosticsReporter::StackAllocatedDerivesGarbageCollected( RecordInfo* info, BasePoint* base) { - ReportDiagnostic(base->spec().getLocStart(), - diag_stack_allocated_derives_gc_) + ReportDiagnostic(base->spec().getBeginLoc(), diag_stack_allocated_derives_gc_) << info->record() << base->info()->record(); } void DiagnosticsReporter::ClassOverridesNew( RecordInfo* info, CXXMethodDecl* newop) { - ReportDiagnostic(newop->getLocStart(), diag_class_overrides_new_) + ReportDiagnostic(newop->getBeginLoc(), diag_class_overrides_new_) << info->record(); } void DiagnosticsReporter::ClassDeclaresPureVirtualTrace( RecordInfo* info, CXXMethodDecl* trace) { - ReportDiagnostic(trace->getLocStart(), + ReportDiagnostic(trace->getBeginLoc(), diag_class_declares_pure_virtual_trace_) << info->record(); } @@ -501,7 +498,7 @@ void DiagnosticsReporter::ClassDeclaresPureVirtualTrace( void DiagnosticsReporter::LeftMostBaseMustBePolymorphic( RecordInfo* derived, CXXRecordDecl* base) { - ReportDiagnostic(base->getLocStart(), + ReportDiagnostic(base->getBeginLoc(), diag_left_most_base_must_be_polymorphic_) << base << derived->record(); } @@ -509,7 +506,7 @@ void DiagnosticsReporter::LeftMostBaseMustBePolymorphic( void DiagnosticsReporter::BaseClassMustDeclareVirtualTrace( RecordInfo* derived, CXXRecordDecl* base) { - ReportDiagnostic(base->getLocStart(), + ReportDiagnostic(base->getBeginLoc(), diag_base_class_must_declare_virtual_trace_) << base << derived->record(); } @@ -517,20 +514,18 @@ void DiagnosticsReporter::BaseClassMustDeclareVirtualTrace( void DiagnosticsReporter::TraceMethodForStackAllocatedClass( RecordInfo* info, CXXMethodDecl* trace) { - ReportDiagnostic(trace->getLocStart(), + ReportDiagnostic(trace->getBeginLoc(), diag_trace_method_of_stack_allocated_parent_) << info->record(); } void DiagnosticsReporter::NoteManualDispatchMethod(CXXMethodDecl* dispatch) { - ReportDiagnostic(dispatch->getLocStart(), - diag_manual_dispatch_method_note_) + ReportDiagnostic(dispatch->getBeginLoc(), diag_manual_dispatch_method_note_) << dispatch; } void DiagnosticsReporter::NoteBaseRequiresTracing(BasePoint* base) { - ReportDiagnostic(base->spec().getLocStart(), - diag_base_requires_tracing_note_) + ReportDiagnostic(base->spec().getBeginLoc(), diag_base_requires_tracing_note_) << base->info()->record(); } @@ -548,7 +543,7 @@ void DiagnosticsReporter::NoteFieldShouldNotBeTraced( void DiagnosticsReporter::NotePartObjectContainsGCRoot(FieldPoint* point) { FieldDecl* field = point->field(); - ReportDiagnostic(field->getLocStart(), + ReportDiagnostic(field->getBeginLoc(), diag_part_object_contains_gc_root_note_) << field << field->getParent(); } @@ -558,15 +553,15 @@ void DiagnosticsReporter::NoteFieldContainsGCRoot(FieldPoint* point) { } void DiagnosticsReporter::NoteUserDeclaredDestructor(CXXMethodDecl* dtor) { - ReportDiagnostic(dtor->getLocStart(), diag_user_declared_destructor_note_); + ReportDiagnostic(dtor->getBeginLoc(), diag_user_declared_destructor_note_); } void DiagnosticsReporter::NoteUserDeclaredFinalizer(CXXMethodDecl* dtor) { - ReportDiagnostic(dtor->getLocStart(), diag_user_declared_finalizer_note_); + ReportDiagnostic(dtor->getBeginLoc(), diag_user_declared_finalizer_note_); } void DiagnosticsReporter::NoteBaseRequiresFinalization(BasePoint* base) { - ReportDiagnostic(base->spec().getLocStart(), + ReportDiagnostic(base->spec().getBeginLoc(), diag_base_requires_finalization_note_) << base->info()->record(); } @@ -580,12 +575,12 @@ void DiagnosticsReporter::NoteField(FieldPoint* point, unsigned note) { } void DiagnosticsReporter::NoteField(FieldDecl* field, unsigned note) { - ReportDiagnostic(field->getLocStart(), note) << field; + ReportDiagnostic(field->getBeginLoc(), note) << field; } void DiagnosticsReporter::NoteOverriddenNonVirtualTrace( CXXMethodDecl* overridden) { - ReportDiagnostic(overridden->getLocStart(), + ReportDiagnostic(overridden->getBeginLoc(), diag_overridden_non_virtual_trace_note_) << overridden; } @@ -594,7 +589,7 @@ void DiagnosticsReporter::UniquePtrUsedWithGC( const clang::Expr* expr, const clang::FunctionDecl* bad_function, const clang::CXXRecordDecl* gc_type) { - ReportDiagnostic(expr->getLocStart(), diag_unique_ptr_used_with_gc_) + ReportDiagnostic(expr->getBeginLoc(), diag_unique_ptr_used_with_gc_) << bad_function << gc_type << expr->getSourceRange(); } @@ -602,6 +597,6 @@ void DiagnosticsReporter::OptionalUsedWithGC( const clang::Expr* expr, const clang::CXXRecordDecl* optional, const clang::CXXRecordDecl* gc_type) { - ReportDiagnostic(expr->getLocStart(), diag_optional_used_with_gc_) + ReportDiagnostic(expr->getBeginLoc(), diag_optional_used_with_gc_) << optional << gc_type << expr->getSourceRange(); } diff --git a/chromium/tools/clang/blink_gc_plugin/Edge.h b/chromium/tools/clang/blink_gc_plugin/Edge.h index 5549e6a77c7..74ccd4db202 100644 --- a/chromium/tools/clang/blink_gc_plugin/Edge.h +++ b/chromium/tools/clang/blink_gc_plugin/Edge.h @@ -226,10 +226,7 @@ class CrossThreadPersistent : public PtrEdge { class Collection : public Edge { public: typedef std::vector<Edge*> Members; - Collection(RecordInfo* info, bool on_heap, bool is_root) - : info_(info), - on_heap_(on_heap), - is_root_(is_root) {} + Collection(RecordInfo* info, bool on_heap) : info_(info), on_heap_(on_heap) {} ~Collection() { for (Members::iterator it = members_.begin(); it != members_.end(); ++it) { assert(*it && "Collection-edge members must be non-null"); @@ -237,9 +234,8 @@ class Collection : public Edge { } } bool IsCollection() override { return true; } - LivenessKind Kind() override { return is_root_ ? kRoot : kStrong; } + LivenessKind Kind() override { return kStrong; } bool on_heap() { return on_heap_; } - bool is_root() { return is_root_; } Members& members() { return members_; } void Accept(EdgeVisitor* visitor) override { visitor->VisitCollection(this); } void AcceptMembers(EdgeVisitor* visitor) { @@ -248,8 +244,6 @@ class Collection : public Edge { } bool NeedsFinalization() override; TracingStatus NeedsTracing(NeedsTracingOption) override { - if (is_root_) - return TracingStatus::Unneeded(); if (on_heap_) return TracingStatus::Needed(); // For off-heap collections, determine tracing status of members. @@ -265,7 +259,6 @@ class Collection : public Edge { RecordInfo* info_; Members members_; bool on_heap_; - bool is_root_; }; // An iterator edge is a direct edge to some iterator type. diff --git a/chromium/tools/clang/blink_gc_plugin/RecordInfo.cpp b/chromium/tools/clang/blink_gc_plugin/RecordInfo.cpp index 30a5c745d29..6af11e820a6 100644 --- a/chromium/tools/clang/blink_gc_plugin/RecordInfo.cpp +++ b/chromium/tools/clang/blink_gc_plugin/RecordInfo.cpp @@ -703,12 +703,11 @@ Edge* RecordInfo::CreateEdge(const Type* type) { if (Config::IsGCCollection(info->name()) || Config::IsWTFCollection(info->name())) { - bool is_root = Config::IsPersistentGCCollection(info->name()); - bool on_heap = is_root || info->IsHeapAllocatedCollection(); + bool on_heap = info->IsHeapAllocatedCollection(); size_t count = Config::CollectionDimension(info->name()); if (!info->GetTemplateArgs(count, &args)) return 0; - Collection* edge = new Collection(info, on_heap, is_root); + Collection* edge = new Collection(info, on_heap); for (TemplateArgs::iterator it = args.begin(); it != args.end(); ++it) { if (Edge* member = CreateEdge(*it)) { edge->members().push_back(member); diff --git a/chromium/tools/clang/blink_gc_plugin/RecordInfo.h b/chromium/tools/clang/blink_gc_plugin/RecordInfo.h index 3ac082fb5c0..ec510f38680 100644 --- a/chromium/tools/clang/blink_gc_plugin/RecordInfo.h +++ b/chromium/tools/clang/blink_gc_plugin/RecordInfo.h @@ -75,7 +75,7 @@ class RecordInfo { struct FieldDeclCmp { bool operator()(clang::FieldDecl* a, clang::FieldDecl *b) const { - return a->getLocStart() < b->getLocStart(); + return a->getBeginLoc() < b->getBeginLoc(); } }; typedef std::map<clang::FieldDecl*, FieldPoint, FieldDeclCmp> Fields; diff --git a/chromium/tools/clang/plugins/CheckIPCVisitor.cpp b/chromium/tools/clang/plugins/CheckIPCVisitor.cpp index b123b0130ed..5e8113d0f07 100644 --- a/chromium/tools/clang/plugins/CheckIPCVisitor.cpp +++ b/chromium/tools/clang/plugins/CheckIPCVisitor.cpp @@ -149,8 +149,7 @@ bool CheckIPCVisitor::ValidateCheckedTuple( auto* parent_decl = GetParentDecl<Decl>(); ReportCheckError( - details, - parent_decl ? parent_decl->getLocStart() : SourceLocation(), + details, parent_decl ? parent_decl->getBeginLoc() : SourceLocation(), error_tuple_bad_type_); } diff --git a/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp b/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp index 5d430c384f0..d5a18d3144b 100644 --- a/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp +++ b/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp @@ -573,7 +573,7 @@ void FindBadConstructsConsumer::CheckVirtualSpecifiers( // Deletion of virtual and insertion of override are tricky. The AST does not // expose the location of `virtual` or `=`: the former is useful when trying // to remove `virtual, while the latter is useful when trying to insert - // `override`. Iterate over the tokens from |method->getLocStart()| until: + // `override`. Iterate over the tokens from |method->getBeginLoc()| until: // 1. A `{` not nested inside parentheses is found or // 2. A `=` not nested inside parentheses is found or // 3. A `;` not nested inside parentheses is found or @@ -582,7 +582,7 @@ void FindBadConstructsConsumer::CheckVirtualSpecifiers( SourceLocation override_insertion_loc; // Attempt to set up the lexer in raw mode. std::pair<FileID, unsigned> decomposed_start = - manager.getDecomposedLoc(method->getLocStart()); + manager.getDecomposedLoc(method->getBeginLoc()); bool invalid = false; StringRef buffer = manager.getBufferData(decomposed_start.first, &invalid); if (!invalid) { @@ -816,7 +816,7 @@ bool FindBadConstructsConsumer::HasPublicDtorCallback( // Outputs a C++ inheritance chain as a diagnostic aid. void FindBadConstructsConsumer::PrintInheritanceChain(const CXXBasePath& path) { for (CXXBasePath::const_iterator it = path.begin(); it != path.end(); ++it) { - diagnostic().Report(it->Base->getLocStart(), diag_note_inheritance_) + diagnostic().Report(it->Base->getBeginLoc(), diag_note_inheritance_) << it->Class << it->Base->getType(); } } @@ -1041,7 +1041,7 @@ void FindBadConstructsConsumer::CheckVarDecl(clang::VarDecl* var_decl) { // should be fewer auto types than banned namespace/directory types, // so check this last. LocationType location_type = - ClassifyLocation(var_decl->getLocStart()); + ClassifyLocation(var_decl->getBeginLoc()); if (location_type != LocationType::kThirdParty) { // The range starts from |var_decl|'s loc start, which is the // beginning of the full expression defining this |var_decl|. It @@ -1051,8 +1051,8 @@ void FindBadConstructsConsumer::CheckVarDecl(clang::VarDecl* var_decl) { // qualifiers, which is why it's not a good candidate to use for the // start of the range. clang::SourceRange range( - var_decl->getLocStart(), - var_decl->getTypeSourceInfo()->getTypeLoc().getLocEnd()); + var_decl->getBeginLoc(), + var_decl->getTypeSourceInfo()->getTypeLoc().getEndLoc()); ReportIfSpellingLocNotIgnored(range.getBegin(), diag_auto_deduced_to_a_pointer_type_) << FixItHint::CreateReplacement( diff --git a/chromium/tools/clang/scripts/download_strip.py b/chromium/tools/clang/scripts/download_strip.py new file mode 100755 index 00000000000..9daab0afdcd --- /dev/null +++ b/chromium/tools/clang/scripts/download_strip.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# Copyright 2018 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Script to download llvm-strip from google storage.""" + +import os +import sys + +import update + +LLVM_BUILD_DIR = update.LLVM_BUILD_DIR +STRIP_PATH = os.path.join(LLVM_BUILD_DIR, 'bin', 'llvm-strip') +STAMP_FILE = os.path.normpath( + os.path.join(LLVM_BUILD_DIR, 'llvmstrip_build_revision')) + + +def AlreadyUpToDate(): + if not os.path.exists(STRIP_PATH): + return False + stamp = update.ReadStampFile(STAMP_FILE) + return stamp.rstrip() == update.PACKAGE_VERSION + + +def main(): + if not AlreadyUpToDate(): + cds_file = 'llvmstrip-%s.tgz' % update.PACKAGE_VERSION + cds_full_url = update.GetPlatformUrlPrefix(sys.platform) + cds_file + update.DownloadAndUnpack(cds_full_url, update.LLVM_BUILD_DIR) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/chromium/tools/clang/scripts/package.py b/chromium/tools/clang/scripts/package.py index 7f799192af3..745362c73e7 100755 --- a/chromium/tools/clang/scripts/package.py +++ b/chromium/tools/clang/scripts/package.py @@ -253,7 +253,7 @@ def main(): # runtime libraries: 'lib/clang/*/lib/darwin/*asan_osx*', 'lib/clang/*/lib/darwin/*asan_iossim*', - 'lib/clang/*/lib/darwin/*fuzzer*', + 'lib/clang/*/lib/darwin/*fuzzer_no_main*', 'lib/clang/*/lib/darwin/*profile_osx*', 'lib/clang/*/lib/darwin/*profile_iossim*', # And the OSX and ios builtin libraries (iossim is lipo'd into @@ -270,7 +270,7 @@ def main(): # but not dfsan. want.extend(['lib/clang/*/lib/linux/*[atm]san*', 'lib/clang/*/lib/linux/*ubsan*', - 'lib/clang/*/lib/linux/*libclang_rt.fuzzer*', + 'lib/clang/*/lib/linux/*libclang_rt.fuzzer_no_main*', 'lib/clang/*/lib/linux/*libclang_rt.san*', 'lib/clang/*/lib/linux/*profile*', 'lib/clang/*/share/msan_blacklist.txt', @@ -278,10 +278,17 @@ def main(): elif sys.platform == 'win32': want.extend(['lib/clang/*/lib/windows/clang_rt.asan*.dll', 'lib/clang/*/lib/windows/clang_rt.asan*.lib', + 'lib/clang/*/lib/windows/clang_rt.fuzzer_no_main*.lib', 'lib/clang/*/lib/windows/clang_rt.profile*.lib', 'lib/clang/*/lib/windows/clang_rt.ubsan*.lib', ]) + if sys.platform in ('linux2', 'darwin'): + # Include libclang_rt.builtins.a for Fuchsia targets. + want.extend(['lib/clang/*/aarch64-fuchsia/lib/libclang_rt.builtins.a', + 'lib/clang/*/x86_64-fuchsia/lib/libclang_rt.builtins.a', + ]) + for root, dirs, files in os.walk(LLVM_RELEASE_DIR): # root: third_party/llvm-build/Release+Asserts/lib/..., rel_root: lib/... rel_root = root[len(LLVM_RELEASE_DIR)+1:] @@ -415,6 +422,8 @@ def main(): os.makedirs(os.path.join(llddir, 'bin')) shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'lld'), os.path.join(llddir, 'bin')) + shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'llvm-ar'), + os.path.join(llddir, 'bin')) os.symlink('lld', os.path.join(llddir, 'bin', 'lld-link')) os.symlink('lld', os.path.join(llddir, 'bin', 'ld.lld')) with tarfile.open(llddir + '.tgz', 'w:gz') as tar: @@ -422,6 +431,26 @@ def main(): filter=PrintTarProgress) MaybeUpload(args, llddir, platform) + # On Linux and Mac, package and upload llvm-strip in a separate zip. + # This is used for the Fuchsia build. + if sys.platform == 'darwin' or sys.platform.startswith('linux'): + stripdir = 'llvmstrip-' + stamp + shutil.rmtree(stripdir, ignore_errors=True) + os.makedirs(os.path.join(stripdir, 'bin')) + shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'llvm-strip'), + os.path.join(stripdir, 'bin')) + llvmstrip_stamp_file_base = 'llvmstrip_build_revision' + llvmstrip_stamp_file = os.path.join(stripdir, llvmstrip_stamp_file_base) + with open(llvmstrip_stamp_file, 'w') as f: + f.write(expected_stamp) + f.write('\n') + with tarfile.open(stripdir + '.tgz', 'w:gz') as tar: + tar.add(os.path.join(stripdir, 'bin'), arcname='bin', + filter=PrintTarProgress) + tar.add(llvmstrip_stamp_file, arcname=llvmstrip_stamp_file_base, + filter=PrintTarProgress) + MaybeUpload(args, stripdir, platform) + # Zip up the translation_unit tool. translation_unit_dir = 'translation_unit-' + stamp shutil.rmtree(translation_unit_dir, ignore_errors=True) diff --git a/chromium/tools/clang/scripts/run_tool.py b/chromium/tools/clang/scripts/run_tool.py index 82ae64def61..6d8a0dfac2e 100755 --- a/chromium/tools/clang/scripts/run_tool.py +++ b/chromium/tools/clang/scripts/run_tool.py @@ -220,8 +220,16 @@ def _ExecuteTool(toolname, tool_args, build_directory, compdb_entry): # Windows. We don't need to do this here, and it results in lots of spam # and a massive log file, so we strip it. and a != '/showIncludes' + # -MMD has the same purpose on non-Windows. It may have a corresponding + # '-MF <filename>', which we strip below. + and a != '-MMD' ]) + for i, arg in enumerate(args): + if arg == '-MF': + del args[i:i+2] + break + # shlex.split escapes double qoutes in non-Posix mode, so we need to strip # them back. if sys.platform == 'win32': diff --git a/chromium/tools/clang/scripts/update.py b/chromium/tools/clang/scripts/update.py index 63434e38dd4..6cd0319de4f 100755 --- a/chromium/tools/clang/scripts/update.py +++ b/chromium/tools/clang/scripts/update.py @@ -27,7 +27,7 @@ import zipfile # Do NOT CHANGE this if you don't know what you're doing -- see # https://chromium.googlesource.com/chromium/src/+/master/docs/updating_clang.md # Reverting problematic clang rolls is safe, though. -CLANG_REVISION = '340925' +CLANG_REVISION = '344066' use_head_revision = bool(os.environ.get('LLVM_FORCE_HEAD_REVISION', '0') in ('1', 'YES')) @@ -71,6 +71,8 @@ STAMP_FILE = os.path.normpath( VERSION = '8.0.0' ANDROID_NDK_DIR = os.path.join( CHROMIUM_DIR, 'third_party', 'android_ndk') +FUCHSIA_SDK_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'fuchsia-sdk', + 'sdk') # URL for pre-built binaries. CDS_URL = os.environ.get('CDS_CLANG_BUCKET_OVERRIDE', @@ -483,6 +485,16 @@ def UpdateClang(args): print 'for how to install the NDK, or pass --without-android.' return 1 + if args.with_fuchsia and not os.path.exists(FUCHSIA_SDK_DIR): + print 'Fuchsia SDK not found at ' + FUCHSIA_SDK_DIR + print 'The Fuchsia SDK is needed to build libclang_rt for Fuchsia.' + print 'Install the Fuchsia SDK by adding fuchsia to the ' + print 'target_os section in your .gclient and running hooks, ' + print 'or pass --without-fuchsia.' + print 'https://chromium.googlesource.com/chromium/src/+/master/docs/fuchsia_build_instructions.md' + print 'for general Fuchsia build instructions.' + return 1 + print 'Locally building Clang %s...' % PACKAGE_VERSION AddCMakeToPath(args) @@ -816,6 +828,57 @@ def UpdateClang(args): if os.path.exists(lib_path): shutil.copy(lib_path, rt_lib_dst_dir) + if args.with_fuchsia: + # Fuchsia links against libclang_rt.builtins-<arch>.a instead of libgcc.a. + for target_arch in ['aarch64', 'x86_64']: + fuchsia_arch_name = {'aarch64': 'arm64', 'x86_64': 'x64'}[target_arch] + toolchain_dir = os.path.join( + FUCHSIA_SDK_DIR, 'arch', fuchsia_arch_name, 'sysroot') + # Build clang_rt runtime for Fuchsia in a separate build tree. + build_dir = os.path.join(LLVM_BUILD_DIR, 'fuchsia-' + target_arch) + if not os.path.exists(build_dir): + os.mkdir(os.path.join(build_dir)) + os.chdir(build_dir) + target_spec = target_arch + '-fuchsia' + # TODO(thakis): Might have to pass -B here once sysroot contains + # binaries (e.g. gas for arm64?) + fuchsia_args = base_cmake_args + [ + '-DLLVM_ENABLE_THREADS=OFF', + '-DCMAKE_C_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'), + '-DCMAKE_CXX_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang++'), + '-DCMAKE_LINKER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'), + '-DCMAKE_AR=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-ar'), + '-DLLVM_CONFIG_PATH=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-config'), + '-DCMAKE_SYSTEM_NAME=Fuchsia', + '-DCMAKE_C_COMPILER_TARGET=%s-fuchsia' % target_arch, + '-DCMAKE_ASM_COMPILER_TARGET=%s-fuchsia' % target_arch, + '-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON', + '-DCMAKE_SYSROOT=%s' % toolchain_dir, + # TODO(thakis|scottmg): Use PER_TARGET_RUNTIME_DIR for all platforms. + # https://crbug.com/882485. + '-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON', + + # These are necessary because otherwise CMake tries to build an + # executable to test to see if the compiler is working, but in doing so, + # it links against the builtins.a that we're about to build. + '-DCMAKE_C_COMPILER_WORKS=ON', + '-DCMAKE_ASM_COMPILER_WORKS=ON', + ] + RmCmakeCache('.') + RunCommand(['cmake'] + + fuchsia_args + + [os.path.join(COMPILER_RT_DIR, 'lib', 'builtins')]) + builtins_a = 'libclang_rt.builtins.a' + RunCommand(['ninja', builtins_a]) + + # And copy it into the main build tree. + fuchsia_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', + VERSION, target_spec, 'lib') + if not os.path.exists(fuchsia_lib_dst_dir): + os.makedirs(fuchsia_lib_dst_dir) + CopyFile(os.path.join(build_dir, target_spec, 'lib', builtins_a), + fuchsia_lib_dst_dir) + # Run tests. if args.run_tests or use_head_revision: os.chdir(LLVM_BUILD_DIR) @@ -869,6 +932,10 @@ def main(): help='don\'t build Android ASan runtime (linux only)', dest='with_android', default=sys.platform.startswith('linux')) + parser.add_argument('--without-fuchsia', action='store_false', + help='don\'t build Fuchsia clang_rt runtime (linux/mac)', + dest='with_fuchsia', + default=sys.platform in ('linux2', 'darwin')) args = parser.parse_args() if args.lto_lld and not args.bootstrap: @@ -921,6 +988,8 @@ def main(): if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): # Only build the Android ASan rt on ToT bots when targetting Android. args.with_android = False + # Don't build fuchsia runtime on ToT bots at all. + args.with_fuchsia = False return UpdateClang(args) |