|
41 | 41 | #include "clang/Basic/CharInfo.h" |
42 | 42 | #include "clang/Basic/CodeGenOptions.h" |
43 | 43 | #include "clang/Basic/Diagnostic.h" |
| 44 | +#include "clang/Basic/DiagnosticFrontend.h" |
44 | 45 | #include "clang/Basic/FileManager.h" |
| 46 | +#include "clang/Basic/LangOptions.h" |
45 | 47 | #include "clang/Basic/Module.h" |
46 | 48 | #include "clang/Basic/SourceManager.h" |
47 | 49 | #include "clang/Basic/TargetInfo.h" |
|
54 | 56 | #include "llvm/ADT/StringSwitch.h" |
55 | 57 | #include "llvm/Analysis/TargetLibraryInfo.h" |
56 | 58 | #include "llvm/BinaryFormat/ELF.h" |
| 59 | +#include "llvm/Demangle/Demangle.h" |
57 | 60 | #include "llvm/Frontend/OpenMP/OMPIRBuilder.h" |
58 | 61 | #include "llvm/IR/AttributeMask.h" |
59 | 62 | #include "llvm/IR/CallingConv.h" |
|
75 | 78 | #include "llvm/TargetParser/Triple.h" |
76 | 79 | #include "llvm/TargetParser/X86TargetParser.h" |
77 | 80 | #include "llvm/Transforms/Utils/BuildLibCalls.h" |
| 81 | +#include <cassert> |
78 | 82 | #include <optional> |
79 | 83 |
|
80 | 84 | using namespace clang; |
@@ -2044,6 +2048,15 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) { |
2044 | 2048 | GD.getWithKernelReferenceKind(KernelReferenceKind::Kernel), |
2045 | 2049 | ND)); |
2046 | 2050 |
|
| 2051 | + if (getCodeGenOpts().DemanglingFailures && |
| 2052 | + getContext().getLangOpts().getClangABICompat() > |
| 2053 | + LangOptions::ClangABI::Ver19) { |
| 2054 | + if (llvm::isMangledName(MangledName) && |
| 2055 | + llvm::demangle(MangledName) == MangledName) |
| 2056 | + Diags.Report(ND->getLocation(), diag::warn_name_cannot_be_demangled) |
| 2057 | + << MangledName; |
| 2058 | + } |
| 2059 | + |
2047 | 2060 | auto Result = Manglings.insert(std::make_pair(MangledName, GD)); |
2048 | 2061 | return MangledDeclNames[CanonicalGD] = Result.first->first(); |
2049 | 2062 | } |
|
0 commit comments