ziqingluo-90 updated this revision to Diff 504896. ziqingluo-90 added a comment.
Address comments CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145993/new/ https://reviews.llvm.org/D145993 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp =================================================================== --- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp +++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp @@ -1,4 +1,3 @@ -// REQUIRES: !system-windows // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s typedef int * Int_ptr_t; typedef int Int_t; Index: clang/lib/Analysis/UnsafeBufferUsage.cpp =================================================================== --- clang/lib/Analysis/UnsafeBufferUsage.cpp +++ clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -660,8 +660,20 @@ return {std::move(CB.FixableGadgets), std::move(CB.WarningGadgets), std::move(CB.Tracker)}; } +// Compares AST nodes by source locations. +template <typename NodeTy> struct CompareNode { + bool operator()(const NodeTy *N1, const NodeTy *N2) const { + return N1->getBeginLoc().getRawEncoding() < + N2->getBeginLoc().getRawEncoding(); + } +}; + struct WarningGadgetSets { - std::map<const VarDecl *, std::set<std::unique_ptr<WarningGadget>>> byVar; + std::map<const VarDecl *, std::set<std::unique_ptr<WarningGadget>>, + // To keep keys sorted by their locations in the map so that the + // order is deterministic: + CompareNode<VarDecl>> + byVar; // These Gadgets are not related to pointer variables (e. g. temporaries). llvm::SmallVector<std::unique_ptr<WarningGadget>, 16> noVar; };
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp =================================================================== --- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp +++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp @@ -1,4 +1,3 @@ -// REQUIRES: !system-windows // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s typedef int * Int_ptr_t; typedef int Int_t; Index: clang/lib/Analysis/UnsafeBufferUsage.cpp =================================================================== --- clang/lib/Analysis/UnsafeBufferUsage.cpp +++ clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -660,8 +660,20 @@ return {std::move(CB.FixableGadgets), std::move(CB.WarningGadgets), std::move(CB.Tracker)}; } +// Compares AST nodes by source locations. +template <typename NodeTy> struct CompareNode { + bool operator()(const NodeTy *N1, const NodeTy *N2) const { + return N1->getBeginLoc().getRawEncoding() < + N2->getBeginLoc().getRawEncoding(); + } +}; + struct WarningGadgetSets { - std::map<const VarDecl *, std::set<std::unique_ptr<WarningGadget>>> byVar; + std::map<const VarDecl *, std::set<std::unique_ptr<WarningGadget>>, + // To keep keys sorted by their locations in the map so that the + // order is deterministic: + CompareNode<VarDecl>> + byVar; // These Gadgets are not related to pointer variables (e. g. temporaries). llvm::SmallVector<std::unique_ptr<WarningGadget>, 16> noVar; };
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits