clang  15.0.0git
Mangle.cpp
Go to the documentation of this file.
1 //===--- Mangle.cpp - Mangle C++ Names --------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implements generic name mangling support for blocks and Objective-C.
10 //
11 //===----------------------------------------------------------------------===//
12 #include "clang/AST/Attr.h"
13 #include "clang/AST/ASTContext.h"
14 #include "clang/AST/Decl.h"
15 #include "clang/AST/DeclCXX.h"
16 #include "clang/AST/DeclObjC.h"
17 #include "clang/AST/DeclTemplate.h"
18 #include "clang/AST/ExprCXX.h"
19 #include "clang/AST/Mangle.h"
21 #include "clang/Basic/ABI.h"
23 #include "clang/Basic/TargetInfo.h"
24 #include "llvm/ADT/StringExtras.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/IR/Mangler.h"
27 #include "llvm/Support/ErrorHandling.h"
28 #include "llvm/Support/Format.h"
29 #include "llvm/Support/raw_ostream.h"
30 
31 using namespace clang;
32 
33 // FIXME: For blocks we currently mimic GCC's mangling scheme, which leaves
34 // much to be desired. Come up with a better mangling scheme.
35 
36 static void mangleFunctionBlock(MangleContext &Context,
37  StringRef Outer,
38  const BlockDecl *BD,
39  raw_ostream &Out) {
40  unsigned discriminator = Context.getBlockId(BD, true);
41  if (discriminator == 0)
42  Out << "__" << Outer << "_block_invoke";
43  else
44  Out << "__" << Outer << "_block_invoke_" << discriminator+1;
45 }
46 
47 void MangleContext::anchor() { }
48 
49 enum CCMangling {
56 };
57 
58 static bool isExternC(const NamedDecl *ND) {
59  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND))
60  return FD->isExternC();
61  if (const VarDecl *VD = dyn_cast<VarDecl>(ND))
62  return VD->isExternC();
63  return false;
64 }
65 
67  const NamedDecl *ND) {
68  const TargetInfo &TI = Context.getTargetInfo();
69  const llvm::Triple &Triple = TI.getTriple();
70 
71  // On wasm, the argc/argv form of "main" is renamed so that the startup code
72  // can call it with the correct function signature.
73  // On Emscripten, users may be exporting "main" and expecting to call it
74  // themselves, so we can't mangle it.
75  if (Triple.isWasm() && !Triple.isOSEmscripten())
76  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND))
77  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
78  return CCM_WasmMainArgcArgv;
79 
80  if (!Triple.isOSWindows() || !Triple.isX86())
81  return CCM_Other;
82 
83  if (Context.getLangOpts().CPlusPlus && !isExternC(ND) &&
84  TI.getCXXABI() == TargetCXXABI::Microsoft)
85  return CCM_Other;
86 
87  const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
88  if (!FD)
89  return CCM_Other;
90  QualType T = FD->getType();
91 
92  const FunctionType *FT = T->castAs<FunctionType>();
93 
94  CallingConv CC = FT->getCallConv();
95  switch (CC) {
96  default:
97  return CCM_Other;
98  case CC_X86FastCall:
99  return CCM_Fast;
100  case CC_X86StdCall:
101  return CCM_Std;
102  case CC_X86VectorCall:
103  return CCM_Vector;
104  }
105 }
106 
109 
111  if (CC != CCM_Other)
112  return true;
113 
114  // If the declaration has an owning module for linkage purposes that needs to
115  // be mangled, we must mangle its name.
117  return true;
118 
119  // C functions with internal linkage have to be mangled with option
120  // -funique-internal-linkage-names.
121  if (!getASTContext().getLangOpts().CPlusPlus &&
123  return true;
124 
125  // In C, functions with no attributes never need to be mangled. Fastpath them.
126  if (!getASTContext().getLangOpts().CPlusPlus && !D->hasAttrs())
127  return false;
128 
129  // Any decl can be declared with __asm("foo") on it, and this takes precedence
130  // over all other naming in the .o file.
131  if (D->hasAttr<AsmLabelAttr>())
132  return true;
133 
134  // Declarations that don't have identifier names always need to be mangled.
135  if (isa<MSGuidDecl>(D))
136  return true;
137 
138  return shouldMangleCXXName(D);
139 }
140 
141 void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
143  const NamedDecl *D = cast<NamedDecl>(GD.getDecl());
144 
145  // Any decl can be declared with __asm("foo") on it, and this takes precedence
146  // over all other naming in the .o file.
147  if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
148  // If we have an asm name, then we use it as the mangling.
149 
150  // If the label isn't literal, or if this is an alias for an LLVM intrinsic,
151  // do not add a "\01" prefix.
152  if (!ALA->getIsLiteralLabel() || ALA->getLabel().startswith("llvm.")) {
153  Out << ALA->getLabel();
154  return;
155  }
156 
157  // Adding the prefix can cause problems when one file has a "foo" and
158  // another has a "\01foo". That is known to happen on ELF with the
159  // tricks normally used for producing aliases (PR9177). Fortunately the
160  // llvm mangler on ELF is a nop, so we can just avoid adding the \01
161  // marker.
162  StringRef UserLabelPrefix =
164 #ifndef NDEBUG
165  char GlobalPrefix =
166  llvm::DataLayout(getASTContext().getTargetInfo().getDataLayoutString())
167  .getGlobalPrefix();
168  assert((UserLabelPrefix.empty() && !GlobalPrefix) ||
169  (UserLabelPrefix.size() == 1 && UserLabelPrefix[0] == GlobalPrefix));
170 #endif
171  if (!UserLabelPrefix.empty())
172  Out << '\01'; // LLVM IR Marker for __asm("foo")
173 
174  Out << ALA->getLabel();
175  return;
176  }
177 
178  if (auto *GD = dyn_cast<MSGuidDecl>(D))
179  return mangleMSGuidDecl(GD, Out);
180 
182 
183  if (CC == CCM_WasmMainArgcArgv) {
184  Out << "__main_argc_argv";
185  return;
186  }
187 
188  bool MCXX = shouldMangleCXXName(D);
189  const TargetInfo &TI = Context.getTargetInfo();
190  if (CC == CCM_Other || (MCXX && TI.getCXXABI() == TargetCXXABI::Microsoft)) {
191  if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D))
193  else
194  mangleCXXName(GD, Out);
195  return;
196  }
197 
198  Out << '\01';
199  if (CC == CCM_Std)
200  Out << '_';
201  else if (CC == CCM_Fast)
202  Out << '@';
203  else if (CC == CCM_RegCall)
204  Out << "__regcall3__";
205 
206  if (!MCXX)
207  Out << D->getIdentifier()->getName();
208  else if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D))
210  else
211  mangleCXXName(GD, Out);
212 
213  const FunctionDecl *FD = cast<FunctionDecl>(D);
214  const FunctionType *FT = FD->getType()->castAs<FunctionType>();
215  const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT);
216  if (CC == CCM_Vector)
217  Out << '@';
218  Out << '@';
219  if (!Proto) {
220  Out << '0';
221  return;
222  }
223  assert(!Proto->isVariadic());
224  unsigned ArgWords = 0;
225  if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
226  if (!MD->isStatic())
227  ++ArgWords;
228  for (const auto &AT : Proto->param_types()) {
229  // If an argument type is incomplete there is no way to get its size to
230  // correctly encode into the mangling scheme.
231  // Follow GCCs behaviour by simply breaking out of the loop.
232  if (AT->isIncompleteType())
233  break;
234  // Size should be aligned to pointer size.
235  ArgWords +=
236  llvm::alignTo(ASTContext.getTypeSize(AT), TI.getPointerWidth(0)) /
237  TI.getPointerWidth(0);
238  }
239  Out << ((TI.getPointerWidth(0) / 8) * ArgWords);
240 }
241 
242 void MangleContext::mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &Out) {
243  // For now, follow the MSVC naming convention for GUID objects on all
244  // targets.
245  MSGuidDecl::Parts P = GD->getParts();
246  Out << llvm::format("_GUID_%08" PRIx32 "_%04" PRIx32 "_%04" PRIx32 "_",
247  P.Part1, P.Part2, P.Part3);
248  unsigned I = 0;
249  for (uint8_t C : P.Part4And5) {
250  Out << llvm::format("%02" PRIx8, C);
251  if (++I == 2)
252  Out << "_";
253  }
254 }
255 
257  const NamedDecl *ID,
258  raw_ostream &Out) {
259  unsigned discriminator = getBlockId(BD, false);
260  if (ID) {
262  mangleName(ID, Out);
263  else {
264  Out << ID->getIdentifier()->getName();
265  }
266  }
267  if (discriminator == 0)
268  Out << "_block_invoke";
269  else
270  Out << "_block_invoke_" << discriminator+1;
271 }
272 
274  CXXCtorType CT, const BlockDecl *BD,
275  raw_ostream &ResStream) {
276  SmallString<64> Buffer;
277  llvm::raw_svector_ostream Out(Buffer);
278  mangleName(GlobalDecl(CD, CT), Out);
279  mangleFunctionBlock(*this, Buffer, BD, ResStream);
280 }
281 
283  CXXDtorType DT, const BlockDecl *BD,
284  raw_ostream &ResStream) {
285  SmallString<64> Buffer;
286  llvm::raw_svector_ostream Out(Buffer);
287  mangleName(GlobalDecl(DD, DT), Out);
288  mangleFunctionBlock(*this, Buffer, BD, ResStream);
289 }
290 
292  raw_ostream &Out) {
293  assert(!isa<CXXConstructorDecl>(DC) && !isa<CXXDestructorDecl>(DC));
294 
295  SmallString<64> Buffer;
296  llvm::raw_svector_ostream Stream(Buffer);
297  if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
298  mangleObjCMethodNameAsSourceName(Method, Stream);
299  } else {
300  assert((isa<NamedDecl>(DC) || isa<BlockDecl>(DC)) &&
301  "expected a NamedDecl or BlockDecl");
302  if (isa<BlockDecl>(DC))
303  for (; DC && isa<BlockDecl>(DC); DC = DC->getParent())
304  (void) getBlockId(cast<BlockDecl>(DC), true);
305  assert((isa<TranslationUnitDecl>(DC) || isa<NamedDecl>(DC)) &&
306  "expected a TranslationUnitDecl or a NamedDecl");
307  if (const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
308  mangleCtorBlock(CD, /*CT*/ Ctor_Complete, BD, Out);
309  else if (const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
310  mangleDtorBlock(DD, /*DT*/ Dtor_Complete, BD, Out);
311  else if (auto ND = dyn_cast<NamedDecl>(DC)) {
312  if (!shouldMangleDeclName(ND) && ND->getIdentifier())
313  Stream << ND->getIdentifier()->getName();
314  else {
315  // FIXME: We were doing a mangleUnqualifiedName() before, but that's
316  // a private member of a class that will soon itself be private to the
317  // Itanium C++ ABI object. What should we do now? Right now, I'm just
318  // calling the mangleName() method on the MangleContext; is there a
319  // better way?
320  mangleName(ND, Stream);
321  }
322  }
323  }
324  mangleFunctionBlock(*this, Buffer, BD, Out);
325 }
326 
328  raw_ostream &OS,
329  bool includePrefixByte,
330  bool includeCategoryNamespace) {
331  if (getASTContext().getLangOpts().ObjCRuntime.isGNUFamily()) {
332  // This is the mangling we've always used on the GNU runtimes, but it
333  // has obvious collisions in the face of underscores within class
334  // names, category names, and selectors; maybe we should improve it.
335 
336  OS << (MD->isClassMethod() ? "_c_" : "_i_")
337  << MD->getClassInterface()->getName() << '_';
338 
339  if (includeCategoryNamespace) {
340  if (auto category = MD->getCategory())
341  OS << category->getName();
342  }
343  OS << '_';
344 
345  auto selector = MD->getSelector();
346  for (unsigned slotIndex = 0,
347  numArgs = selector.getNumArgs(),
348  slotEnd = std::max(numArgs, 1U);
349  slotIndex != slotEnd; ++slotIndex) {
350  if (auto name = selector.getIdentifierInfoForSlot(slotIndex))
351  OS << name->getName();
352 
353  // Replace all the positions that would've been ':' with '_'.
354  // That's after each slot except that a unary selector doesn't
355  // end in ':'.
356  if (numArgs)
357  OS << '_';
358  }
359 
360  return;
361  }
362 
363  // \01+[ContainerName(CategoryName) SelectorName]
364  if (includePrefixByte) {
365  OS << '\01';
366  }
367  OS << (MD->isInstanceMethod() ? '-' : '+') << '[';
368  if (const auto *CID = MD->getCategory()) {
369  OS << CID->getClassInterface()->getName();
370  if (includeCategoryNamespace) {
371  OS << '(' << *CID << ')';
372  }
373  } else if (const auto *CD =
374  dyn_cast<ObjCContainerDecl>(MD->getDeclContext())) {
375  OS << CD->getName();
376  } else {
377  llvm_unreachable("Unexpected ObjC method decl context");
378  }
379  OS << ' ';
380  MD->getSelector().print(OS);
381  OS << ']';
382 }
383 
385  raw_ostream &Out) {
386  SmallString<64> Name;
387  llvm::raw_svector_ostream OS(Name);
388 
389  mangleObjCMethodName(MD, OS, /*includePrefixByte=*/false,
390  /*includeCategoryNamespace=*/true);
391  Out << OS.str().size() << OS.str();
392 }
393 
395  std::unique_ptr<MangleContext> MC;
396  llvm::DataLayout DL;
397 
398 public:
399  explicit Implementation(ASTContext &Ctx)
400  : MC(Ctx.createMangleContext()),
401  DL(Ctx.getTargetInfo().getDataLayoutString()) {}
402 
403  bool writeName(const Decl *D, raw_ostream &OS) {
404  // First apply frontend mangling.
405  SmallString<128> FrontendBuf;
406  llvm::raw_svector_ostream FrontendBufOS(FrontendBuf);
407  if (auto *FD = dyn_cast<FunctionDecl>(D)) {
408  if (FD->isDependentContext())
409  return true;
410  if (writeFuncOrVarName(FD, FrontendBufOS))
411  return true;
412  } else if (auto *VD = dyn_cast<VarDecl>(D)) {
413  if (writeFuncOrVarName(VD, FrontendBufOS))
414  return true;
415  } else if (auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
416  MC->mangleObjCMethodName(MD, OS, /*includePrefixByte=*/false,
417  /*includeCategoryNamespace=*/true);
418  return false;
419  } else if (auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
420  writeObjCClassName(ID, FrontendBufOS);
421  } else {
422  return true;
423  }
424 
425  // Now apply backend mangling.
426  llvm::Mangler::getNameWithPrefix(OS, FrontendBufOS.str(), DL);
427  return false;
428  }
429 
431  std::string Name;
432  {
433  llvm::raw_string_ostream OS(Name);
434  writeName(D, OS);
435  }
436  return Name;
437  }
438 
439  enum ObjCKind {
442  };
443 
445  const ASTContext &Context) {
446  if (Context.getLangOpts().ObjCRuntime.isGNUFamily())
447  return Kind == ObjCMetaclass ? "_OBJC_METACLASS_" : "_OBJC_CLASS_";
448  return Kind == ObjCMetaclass ? "OBJC_METACLASS_$_" : "OBJC_CLASS_$_";
449  }
450 
451  std::vector<std::string> getAllManglings(const ObjCContainerDecl *OCD) {
452  StringRef ClassName;
453  if (const auto *OID = dyn_cast<ObjCInterfaceDecl>(OCD))
454  ClassName = OID->getObjCRuntimeNameAsString();
455  else if (const auto *OID = dyn_cast<ObjCImplementationDecl>(OCD))
456  ClassName = OID->getObjCRuntimeNameAsString();
457 
458  if (ClassName.empty())
459  return {};
460 
461  auto Mangle = [&](ObjCKind Kind, StringRef ClassName) -> std::string {
462  SmallString<40> Mangled;
463  auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext());
464  llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
465  return std::string(Mangled.str());
466  };
467 
468  return {
469  Mangle(ObjCClass, ClassName),
470  Mangle(ObjCMetaclass, ClassName),
471  };
472  }
473 
474  std::vector<std::string> getAllManglings(const Decl *D) {
475  if (const auto *OCD = dyn_cast<ObjCContainerDecl>(D))
476  return getAllManglings(OCD);
477 
478  if (!(isa<CXXRecordDecl>(D) || isa<CXXMethodDecl>(D)))
479  return {};
480 
481  const NamedDecl *ND = cast<NamedDecl>(D);
482 
483  ASTContext &Ctx = ND->getASTContext();
484  std::unique_ptr<MangleContext> M(Ctx.createMangleContext());
485 
486  std::vector<std::string> Manglings;
487 
488  auto hasDefaultCXXMethodCC = [](ASTContext &C, const CXXMethodDecl *MD) {
489  auto DefaultCC = C.getDefaultCallingConvention(/*IsVariadic=*/false,
490  /*IsCXXMethod=*/true);
491  auto CC = MD->getType()->castAs<FunctionProtoType>()->getCallConv();
492  return CC == DefaultCC;
493  };
494 
495  if (const auto *CD = dyn_cast_or_null<CXXConstructorDecl>(ND)) {
496  Manglings.emplace_back(getMangledStructor(CD, Ctor_Base));
497 
499  if (!CD->getParent()->isAbstract())
500  Manglings.emplace_back(getMangledStructor(CD, Ctor_Complete));
501 
502  if (Ctx.getTargetInfo().getCXXABI().isMicrosoft())
503  if (CD->hasAttr<DLLExportAttr>() && CD->isDefaultConstructor())
504  if (!(hasDefaultCXXMethodCC(Ctx, CD) && CD->getNumParams() == 0))
505  Manglings.emplace_back(getMangledStructor(CD, Ctor_DefaultClosure));
506  } else if (const auto *DD = dyn_cast_or_null<CXXDestructorDecl>(ND)) {
507  Manglings.emplace_back(getMangledStructor(DD, Dtor_Base));
508  if (Ctx.getTargetInfo().getCXXABI().isItaniumFamily()) {
509  Manglings.emplace_back(getMangledStructor(DD, Dtor_Complete));
510  if (DD->isVirtual())
511  Manglings.emplace_back(getMangledStructor(DD, Dtor_Deleting));
512  }
513  } else if (const auto *MD = dyn_cast_or_null<CXXMethodDecl>(ND)) {
514  Manglings.emplace_back(getName(ND));
515  if (MD->isVirtual())
516  if (const auto *TIV = Ctx.getVTableContext()->getThunkInfo(MD))
517  for (const auto &T : *TIV)
518  Manglings.emplace_back(getMangledThunk(MD, T));
519  }
520 
521  return Manglings;
522  }
523 
524 private:
525  bool writeFuncOrVarName(const NamedDecl *D, raw_ostream &OS) {
526  if (MC->shouldMangleDeclName(D)) {
527  GlobalDecl GD;
528  if (const auto *CtorD = dyn_cast<CXXConstructorDecl>(D))
529  GD = GlobalDecl(CtorD, Ctor_Complete);
530  else if (const auto *DtorD = dyn_cast<CXXDestructorDecl>(D))
531  GD = GlobalDecl(DtorD, Dtor_Complete);
532  else if (D->hasAttr<CUDAGlobalAttr>())
533  GD = GlobalDecl(cast<FunctionDecl>(D));
534  else
535  GD = GlobalDecl(D);
536  MC->mangleName(GD, OS);
537  return false;
538  } else {
539  IdentifierInfo *II = D->getIdentifier();
540  if (!II)
541  return true;
542  OS << II->getName();
543  return false;
544  }
545  }
546 
547  void writeObjCClassName(const ObjCInterfaceDecl *D, raw_ostream &OS) {
550  }
551 
552  std::string getMangledStructor(const NamedDecl *ND, unsigned StructorType) {
553  std::string FrontendBuf;
554  llvm::raw_string_ostream FOS(FrontendBuf);
555 
556  GlobalDecl GD;
557  if (const auto *CD = dyn_cast_or_null<CXXConstructorDecl>(ND))
558  GD = GlobalDecl(CD, static_cast<CXXCtorType>(StructorType));
559  else if (const auto *DD = dyn_cast_or_null<CXXDestructorDecl>(ND))
560  GD = GlobalDecl(DD, static_cast<CXXDtorType>(StructorType));
561  MC->mangleName(GD, FOS);
562 
563  std::string BackendBuf;
564  llvm::raw_string_ostream BOS(BackendBuf);
565 
566  llvm::Mangler::getNameWithPrefix(BOS, FOS.str(), DL);
567 
568  return BOS.str();
569  }
570 
571  std::string getMangledThunk(const CXXMethodDecl *MD, const ThunkInfo &T) {
572  std::string FrontendBuf;
573  llvm::raw_string_ostream FOS(FrontendBuf);
574 
575  MC->mangleThunk(MD, T, FOS);
576 
577  std::string BackendBuf;
578  llvm::raw_string_ostream BOS(BackendBuf);
579 
580  llvm::Mangler::getNameWithPrefix(BOS, FOS.str(), DL);
581 
582  return BOS.str();
583  }
584 };
585 
587  : Impl(std::make_unique<Implementation>(Ctx)) {}
588 
590 
591 bool ASTNameGenerator::writeName(const Decl *D, raw_ostream &OS) {
592  return Impl->writeName(D, OS);
593 }
594 
596  return Impl->getName(D);
597 }
598 
599 std::vector<std::string> ASTNameGenerator::getAllManglings(const Decl *D) {
600  return Impl->getAllManglings(D);
601 }
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1150
clang::MangleContext::mangleObjCMethodName
void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &OS, bool includePrefixByte=true, bool includeCategoryNamespace=true)
Definition: Mangle.cpp:327
max
__DEVICE__ int max(int __a, int __b)
Definition: __clang_cuda_math.h:196
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:414
clang::Dtor_Base
@ Dtor_Base
Base object dtor.
Definition: ABI.h:36
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2421
clang::CC_X86FastCall
@ CC_X86FastCall
Definition: Specifiers.h:266
CCM_WasmMainArgcArgv
@ CCM_WasmMainArgcArgv
Definition: Mangle.cpp:55
clang::MSGuidDeclParts
Parts of a decomposed MSGuidDecl.
Definition: DeclCXX.h:4136
clang::ASTNameGenerator::~ASTNameGenerator
~ASTNameGenerator()
Definition: Mangle.cpp:589
clang::ASTNameGenerator::writeName
bool writeName(const Decl *D, raw_ostream &OS)
Writes name for D to OS.
Definition: Mangle.cpp:591
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::ASTNameGenerator::Implementation::getAllManglings
std::vector< std::string > getAllManglings(const ObjCContainerDecl *OCD)
Definition: Mangle.cpp:451
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1356
clang::ASTNameGenerator::Implementation::ObjCClass
@ ObjCClass
Definition: Mangle.cpp:440
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:542
clang::ASTNameGenerator::Implementation::Implementation
Implementation(ASTContext &Ctx)
Definition: Mangle.cpp:399
clang::TargetCXXABI::isMicrosoft
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Definition: TargetCXXABI.h:138
clang::TargetInfo::getUserLabelPrefix
const char * getUserLabelPrefix() const
Returns the default value of the USER_LABEL_PREFIX macro, which is the prefix given to user symbols b...
Definition: TargetInfo.h:806
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::MangleContext::mangleMSGuidDecl
virtual void mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &)
Definition: Mangle.cpp:242
TargetInfo.h
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
Attr.h
mangleFunctionBlock
static void mangleFunctionBlock(MangleContext &Context, StringRef Outer, const BlockDecl *BD, raw_ostream &Out)
Definition: Mangle.cpp:36
clang::TargetInfo::getCXXABI
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Definition: TargetInfo.h:1233
clang::TargetCXXABI::isItaniumFamily
bool isItaniumFamily() const
Does this ABI generally fall into the Itanium family of ABIs?
Definition: TargetCXXABI.h:124
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:186
DeclCXX.h
clang::ObjCMethodDecl::getClassInterface
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.cpp:1176
clang::ASTContext::createMangleContext
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
Definition: ASTContext.cpp:11656
clang::MangleContext::getASTContext
ASTContext & getASTContext() const
Definition: Mangle.h:76
clang::MSGuidDecl::getParts
Parts getParts() const
Get the decomposed parts of this declaration.
Definition: DeclCXX.h:4190
clang::Decl::getOwningModuleForLinkage
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
Definition: Decl.cpp:1552
clang::Ctor_Base
@ Ctor_Base
Base object ctor.
Definition: ABI.h:26
SourceManager.h
clang::Ctor_Complete
@ Ctor_Complete
Complete object ctor.
Definition: ABI.h:25
clang::MangleContext::isUniqueInternalLinkageDecl
virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND)
Definition: Mangle.h:114
clang::MangleContext::mangleCtorBlock
void mangleCtorBlock(const CXXConstructorDecl *CD, CXXCtorType CT, const BlockDecl *BD, raw_ostream &Out)
Definition: Mangle.cpp:273
clang::ASTNameGenerator::ASTNameGenerator
ASTNameGenerator(ASTContext &Ctx)
Definition: Mangle.cpp:586
clang::Decl::getAttr
T * getAttr() const
Definition: DeclBase.h:538
clang::ASTNameGenerator::Implementation::getClassSymbolPrefix
static StringRef getClassSymbolPrefix(ObjCKind Kind, const ASTContext &Context)
Definition: Mangle.cpp:444
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3559
CCMangling
CCMangling
Definition: Mangle.cpp:49
clang::MangleContext::getBlockId
unsigned getBlockId(const BlockDecl *BD, bool Local)
Definition: Mangle.h:82
clang::Dtor_Complete
@ Dtor_Complete
Complete object dtor.
Definition: ABI.h:35
clang::CC_X86StdCall
@ CC_X86StdCall
Definition: Specifiers.h:265
clang::MangleContext::mangleDtorBlock
void mangleDtorBlock(const CXXDestructorDecl *CD, CXXDtorType DT, const BlockDecl *BD, raw_ostream &Out)
Definition: Mangle.cpp:282
Decl.h
DeclObjC.h
ABI.h
clang::GlobalDecl
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:56
clang::MangleContext::mangleObjCMethodNameAsSourceName
void mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD, raw_ostream &)
Definition: Mangle.cpp:384
clang::VTableContextBase::getThunkInfo
virtual const ThunkInfoVectorTy * getThunkInfo(GlobalDecl GD)
Definition: VTableBuilder.h:342
clang::Ctor_DefaultClosure
@ Ctor_DefaultClosure
Default closure variant of a ctor.
Definition: ABI.h:29
U
clang::MangleContext
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Definition: Mangle.h:44
clang::CXXCtorType
CXXCtorType
C++ constructor types.
Definition: ABI.h:24
DeclTemplate.h
clang::LangOptions::ObjCRuntime
clang::ObjCRuntime ObjCRuntime
Definition: LangOptions.h:390
clang::BlockDecl
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4201
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
clang::CPlusPlus
@ CPlusPlus
Definition: LangStandard.h:53
clang::CXXDtorType
CXXDtorType
C++ destructor types.
Definition: ABI.h:33
clang::MangleContext::mangleName
void mangleName(GlobalDecl GD, raw_ostream &)
Definition: Mangle.cpp:141
clang::ObjCMethodDecl::getSelector
Selector getSelector() const
Definition: DeclObjC.h:330
clang::FunctionType::getCallConv
CallingConv getCallConv() const
Definition: Type.h:3833
clang::ASTNameGenerator::Implementation
Definition: Mangle.cpp:394
clang::MSGuidDecl
A global _GUID constant.
Definition: DeclCXX.h:4159
clang::ASTContext::getTypeSize
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2285
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2688
clang::Selector::print
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
Definition: IdentifierTable.cpp:554
llvm::SmallString
Definition: LLVM.h:37
clang::MangleContext::mangleBlock
void mangleBlock(const DeclContext *DC, const BlockDecl *BD, raw_ostream &Out)
Definition: Mangle.cpp:291
ASTContext.h
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:263
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
ExprCXX.h
clang::ASTNameGenerator::Implementation::getName
std::string getName(const Decl *D)
Definition: Mangle.cpp:430
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7310
clang::TargetInfo::getTriple
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:1160
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
CCM_Fast
@ CCM_Fast
Definition: Mangle.cpp:51
clang::Decl::hasAttrs
bool hasAttrs() const
Definition: DeclBase.h:484
VTableBuilder.h
clang::NamedDecl::hasExternalFormalLinkage
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
Definition: Decl.h:401
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
clang::ASTNameGenerator::Implementation::ObjCMetaclass
@ ObjCMetaclass
Definition: Mangle.cpp:441
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3898
clang::MangleContext::shouldMangleDeclName
bool shouldMangleDeclName(const NamedDecl *D)
Definition: Mangle.cpp:107
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1876
clang::ASTNameGenerator::Implementation::getAllManglings
std::vector< std::string > getAllManglings(const Decl *D)
Definition: Mangle.cpp:474
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
CCM_Std
@ CCM_Std
Definition: Mangle.cpp:54
clang::ObjCMethodDecl::isInstanceMethod
bool isInstanceMethod() const
Definition: DeclObjC.h:431
clang::ThunkInfo
The this pointer adjustment as well as an optional return adjustment for a thunk.
Definition: Thunk.h:156
clang::CC_X86VectorCall
@ CC_X86VectorCall
Definition: Specifiers.h:268
isExternC
static bool isExternC(const NamedDecl *ND)
Definition: Mangle.cpp:58
clang::ASTNameGenerator::getAllManglings
std::vector< std::string > getAllManglings(const Decl *D)
Definition: Mangle.cpp:599
CCM_RegCall
@ CCM_RegCall
Definition: Mangle.cpp:52
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::ObjCRuntime
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:28
clang::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:768
CCM_Other
@ CCM_Other
Definition: Mangle.cpp:50
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::MangleContext::mangleCXXName
virtual void mangleCXXName(GlobalDecl GD, raw_ostream &)=0
clang::ObjCRuntime::isGNUFamily
bool isGNUFamily() const
Is this runtime basically of the GNU family of runtimes?
Definition: ObjCRuntime.h:119
std
Definition: Format.h:4296
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:195
clang::Builtin::ID
ID
Definition: Builtins.h:51
clang
Definition: CalledOnceCheck.h:17
clang::TargetInfo::getPointerWidth
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
Definition: TargetInfo.h:419
clang::ASTNameGenerator::Implementation::ObjCKind
ObjCKind
Definition: Mangle.cpp:439
clang::Dtor_Deleting
@ Dtor_Deleting
Deleting dtor.
Definition: ABI.h:34
clang::ObjCContainerDecl
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:944
clang::GlobalDecl::getDecl
const Decl * getDecl() const
Definition: GlobalDecl.h:103
Mangle.h
clang::ObjCMethodDecl::getCategory
ObjCCategoryDecl * getCategory()
If this method is declared or implemented in a category, return that category.
Definition: DeclObjC.cpp:1188
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:685
CCM_Vector
@ CCM_Vector
Definition: Mangle.cpp:53
hasDefaultCXXMethodCC
static bool hasDefaultCXXMethodCC(ASTContext &Context, const CXXMethodDecl *MD)
Definition: MicrosoftCXXABI.cpp:1243
clang::transformer::name
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
Definition: RangeSelector.cpp:200
clang::ObjCMethodDecl::isClassMethod
bool isClassMethod() const
Definition: DeclObjC.h:439
clang::ASTNameGenerator::Implementation::writeName
bool writeName(const Decl *D, raw_ostream &OS)
Definition: Mangle.cpp:403
clang::ASTContext::getVTableContext
VTableContextBase * getVTableContext()
Definition: ASTContext.cpp:11641
clang::ASTNameGenerator::getName
std::string getName(const Decl *D)
Definition: Mangle.cpp:595
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1872
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:786
clang::MangleContext::mangleGlobalBlock
void mangleGlobalBlock(const BlockDecl *BD, const NamedDecl *ID, raw_ostream &Out)
Definition: Mangle.cpp:256
getCallingConvMangling
static CCMangling getCallingConvMangling(const ASTContext &Context, const NamedDecl *ND)
Definition: Mangle.cpp:66
clang::ento::ObjKind::OS
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
clang::MangleContext::shouldMangleCXXName
virtual bool shouldMangleCXXName(const NamedDecl *D)=0
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1968
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:434
clang::ObjCInterfaceDecl::getObjCRuntimeNameAsString
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Definition: DeclObjC.cpp:1584
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274