[PATCH] D68099: [MS ABI]: Fix mangling function arguments for template types to be compatible with MSVC
adamf created this revision. adamf added reviewers: rnk, thakis. adamf added a project: clang. Herald added a subscriber: cfe-commits. MS name mangling supports cache for first 10 distinct function arguments. The error was when non cached template type occurred twice (e.g. 11th and 12th). For such case there is another cache table TemplateArgStrings. Then one '@' character at the end of the mangled name taken from this table was missing. For other cases the missing '@' character was added in mangleSourceName function. Repository: rC Clang https://reviews.llvm.org/D68099 Files: clang/lib/AST/MicrosoftMangle.cpp clang/test/CodeGenCXX/mangle-ms-back-references.cpp Index: clang/test/CodeGenCXX/mangle-ms-back-references.cpp === --- clang/test/CodeGenCXX/mangle-ms-back-references.cpp +++ clang/test/CodeGenCXX/mangle-ms-back-references.cpp @@ -66,3 +66,20 @@ void foo() { } // CHECK: "?foo@0@YAXXZ" } + +class T01; +class T02; +class T03; +class T04; +class T05; +class T06; +class T07; +class T08; +class T09; +class T10; +class T11; +template +class H; + +void ManyParams(T01 &, T02 &, T03 &, T04 &, T05 &, T06 &, T07 &, T08 &, T09 &, T10 &, H &, H &) {} +// CHECK: "?ManyParams@@YAXAAVT01@@AAVT02@@AAVT03@@AAVT04@@AAVT05@@AAVT06@@AAVT07@@AAVT08@@AAVT09@@AAVT10@@AAV?$H@VT11AAV?$H@VT11@Z" Index: clang/lib/AST/MicrosoftMangle.cpp === --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -846,7 +846,7 @@ TemplateArgStringStorage.save(TemplateMangling.str()); } } else { -Out << Found->second; // Outputs a StringRef. +Out << Found->second << '@'; // Outputs a StringRef. } } else { Out << Found->second; // Outputs a back reference (an int). Index: clang/test/CodeGenCXX/mangle-ms-back-references.cpp === --- clang/test/CodeGenCXX/mangle-ms-back-references.cpp +++ clang/test/CodeGenCXX/mangle-ms-back-references.cpp @@ -66,3 +66,20 @@ void foo() { } // CHECK: "?foo@0@YAXXZ" } + +class T01; +class T02; +class T03; +class T04; +class T05; +class T06; +class T07; +class T08; +class T09; +class T10; +class T11; +template +class H; + +void ManyParams(T01 &, T02 &, T03 &, T04 &, T05 &, T06 &, T07 &, T08 &, T09 &, T10 &, H &, H &) {} +// CHECK: "?ManyParams@@YAXAAVT01@@AAVT02@@AAVT03@@AAVT04@@AAVT05@@AAVT06@@AAVT07@@AAVT08@@AAVT09@@AAVT10@@AAV?$H@VT11AAV?$H@VT11@Z" Index: clang/lib/AST/MicrosoftMangle.cpp === --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -846,7 +846,7 @@ TemplateArgStringStorage.save(TemplateMangling.str()); } } else { -Out << Found->second; // Outputs a StringRef. +Out << Found->second << '@'; // Outputs a StringRef. } } else { Out << Found->second; // Outputs a back reference (an int). ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D68099: [MS ABI]: Fix mangling function arguments for template types to be compatible with MSVC
adamf added a comment. @thakis Yes please, I cannot commit this patch by myself, because I don't have commit access. Surely, next time I will add more context in diff. Thanks a lot for the effort. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D68099/new/ https://reviews.llvm.org/D68099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32144: [Coverage] Don't emit mappings for functions in dependent contexts (fixes PR32679)
adamf added a comment. !MD->getParent()->getDescribedClassTemplate() looks like redundant now. This check is already done in isDependentContext. https://reviews.llvm.org/D32144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32406: [Coverage][Windows] Null pointer dereference in CodeGenPGO::skipRegionMappingForDecl (fixes PR32761)
adamf created this revision. In function CodeGenPGO::skipRegionMappingForDecl there is possible NULL pointer dereference on line: auto Loc = D->getBody()->getLocStart(); Value returned by getBody may be NULL. In corresponding test it happens during processing the virtual destructor ~A. (minor) The variable SkipCoverageMapping in the same function is always false. We can remove it. https://reviews.llvm.org/D32406 Files: lib/CodeGen/CodeGenPGO.cpp lib/CodeGen/CodeGenPGO.h test/CoverageMapping/empty-destructor.cpp Index: test/CoverageMapping/empty-destructor.cpp === --- test/CoverageMapping/empty-destructor.cpp +++ test/CoverageMapping/empty-destructor.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj -fprofile-instrument=clang -std=c++14 -fdelayed-template-parsing -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name empty-destructor.cpp -o - %s + +class A +{ +public: + A(); + virtual ~A(); +}; + +class B : public A +{ +public: + B(const A& base) +: A(base) + {} +}; + +void Test() +{ + A a; + B b(a); +} + Index: lib/CodeGen/CodeGenPGO.h === --- lib/CodeGen/CodeGenPGO.h +++ lib/CodeGen/CodeGenPGO.h @@ -40,14 +40,11 @@ std::unique_ptr ProfRecord; std::vector RegionCounts; uint64_t CurrentRegionCount; - /// \brief A flag that is set to true when this function doesn't need - /// to have coverage mapping data. - bool SkipCoverageMapping; public: CodeGenPGO(CodeGenModule &CGM) : CGM(CGM), NumValueSites({{0}}), NumRegionCounters(0), -FunctionHash(0), CurrentRegionCount(0), SkipCoverageMapping(false) {} +FunctionHash(0), CurrentRegionCount(0) {} /// Whether or not we have PGO region data for the current function. This is /// false both when we have no data at all and when our data has been Index: lib/CodeGen/CodeGenPGO.cpp === --- lib/CodeGen/CodeGenPGO.cpp +++ lib/CodeGen/CodeGenPGO.cpp @@ -666,7 +666,7 @@ } bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) { - if (SkipCoverageMapping) + if (!D->hasBody()) return true; // Don't map the functions in system headers. Index: test/CoverageMapping/empty-destructor.cpp === --- test/CoverageMapping/empty-destructor.cpp +++ test/CoverageMapping/empty-destructor.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj -fprofile-instrument=clang -std=c++14 -fdelayed-template-parsing -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name empty-destructor.cpp -o - %s + +class A +{ +public: + A(); + virtual ~A(); +}; + +class B : public A +{ +public: + B(const A& base) +: A(base) + {} +}; + +void Test() +{ + A a; + B b(a); +} + Index: lib/CodeGen/CodeGenPGO.h === --- lib/CodeGen/CodeGenPGO.h +++ lib/CodeGen/CodeGenPGO.h @@ -40,14 +40,11 @@ std::unique_ptr ProfRecord; std::vector RegionCounts; uint64_t CurrentRegionCount; - /// \brief A flag that is set to true when this function doesn't need - /// to have coverage mapping data. - bool SkipCoverageMapping; public: CodeGenPGO(CodeGenModule &CGM) : CGM(CGM), NumValueSites({{0}}), NumRegionCounters(0), -FunctionHash(0), CurrentRegionCount(0), SkipCoverageMapping(false) {} +FunctionHash(0), CurrentRegionCount(0) {} /// Whether or not we have PGO region data for the current function. This is /// false both when we have no data at all and when our data has been Index: lib/CodeGen/CodeGenPGO.cpp === --- lib/CodeGen/CodeGenPGO.cpp +++ lib/CodeGen/CodeGenPGO.cpp @@ -666,7 +666,7 @@ } bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) { - if (SkipCoverageMapping) + if (!D->hasBody()) return true; // Don't map the functions in system headers. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32406: [Coverage][Windows] Null pointer dereference in CodeGenPGO::skipRegionMappingForDecl (fixes PR32761)
adamf updated this revision to Diff 96454. adamf added a comment. Thanks for your comments! Updated test case according to @vsk comment about test case reduction. @rnk, your compilation command probably exposes another issue (with your compilation command the test still failure). I don't have time to analyze it now. I don't have write access to svn so if you think this change is ok please commit it. https://reviews.llvm.org/D32406 Files: lib/CodeGen/CodeGenPGO.cpp lib/CodeGen/CodeGenPGO.h test/CoverageMapping/empty-destructor.cpp Index: test/CoverageMapping/empty-destructor.cpp === --- test/CoverageMapping/empty-destructor.cpp +++ test/CoverageMapping/empty-destructor.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj -fprofile-instrument=clang -fdelayed-template-parsing -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name empty-destructor.cpp -o - %s + +struct A { + virtual ~A(); +}; + +void PR32761() { + A a; +} Index: lib/CodeGen/CodeGenPGO.h === --- lib/CodeGen/CodeGenPGO.h +++ lib/CodeGen/CodeGenPGO.h @@ -40,14 +40,11 @@ std::unique_ptr ProfRecord; std::vector RegionCounts; uint64_t CurrentRegionCount; - /// \brief A flag that is set to true when this function doesn't need - /// to have coverage mapping data. - bool SkipCoverageMapping; public: CodeGenPGO(CodeGenModule &CGM) : CGM(CGM), NumValueSites({{0}}), NumRegionCounters(0), -FunctionHash(0), CurrentRegionCount(0), SkipCoverageMapping(false) {} +FunctionHash(0), CurrentRegionCount(0) {} /// Whether or not we have PGO region data for the current function. This is /// false both when we have no data at all and when our data has been Index: lib/CodeGen/CodeGenPGO.cpp === --- lib/CodeGen/CodeGenPGO.cpp +++ lib/CodeGen/CodeGenPGO.cpp @@ -666,7 +666,7 @@ } bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) { - if (SkipCoverageMapping) + if (!D->hasBody()) return true; // Don't map the functions in system headers. Index: test/CoverageMapping/empty-destructor.cpp === --- test/CoverageMapping/empty-destructor.cpp +++ test/CoverageMapping/empty-destructor.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj -fprofile-instrument=clang -fdelayed-template-parsing -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name empty-destructor.cpp -o - %s + +struct A { + virtual ~A(); +}; + +void PR32761() { + A a; +} Index: lib/CodeGen/CodeGenPGO.h === --- lib/CodeGen/CodeGenPGO.h +++ lib/CodeGen/CodeGenPGO.h @@ -40,14 +40,11 @@ std::unique_ptr ProfRecord; std::vector RegionCounts; uint64_t CurrentRegionCount; - /// \brief A flag that is set to true when this function doesn't need - /// to have coverage mapping data. - bool SkipCoverageMapping; public: CodeGenPGO(CodeGenModule &CGM) : CGM(CGM), NumValueSites({{0}}), NumRegionCounters(0), -FunctionHash(0), CurrentRegionCount(0), SkipCoverageMapping(false) {} +FunctionHash(0), CurrentRegionCount(0) {} /// Whether or not we have PGO region data for the current function. This is /// false both when we have no data at all and when our data has been Index: lib/CodeGen/CodeGenPGO.cpp === --- lib/CodeGen/CodeGenPGO.cpp +++ lib/CodeGen/CodeGenPGO.cpp @@ -666,7 +666,7 @@ } bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) { - if (SkipCoverageMapping) + if (!D->hasBody()) return true; // Don't map the functions in system headers. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits