Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:38

0001 //=== MangleNumberingContext.h - Context for mangling numbers ---*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 //  This file defines the LambdaBlockMangleContext interface, which keeps track
0010 //  of the Itanium C++ ABI mangling numbers for lambda expressions and block
0011 //  literals.
0012 //
0013 //===----------------------------------------------------------------------===//
0014 #ifndef LLVM_CLANG_AST_MANGLENUMBERINGCONTEXT_H
0015 #define LLVM_CLANG_AST_MANGLENUMBERINGCONTEXT_H
0016 
0017 #include "clang/Basic/LLVM.h"
0018 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0019 
0020 namespace clang {
0021 
0022 class BlockDecl;
0023 class CXXMethodDecl;
0024 class TagDecl;
0025 class VarDecl;
0026 
0027 /// Keeps track of the mangled names of lambda expressions and block
0028 /// literals within a particular context.
0029 class MangleNumberingContext {
0030   // The index of the next lambda we encounter in this context.
0031   unsigned LambdaIndex = 0;
0032 
0033 public:
0034   virtual ~MangleNumberingContext() {}
0035 
0036   /// Retrieve the mangling number of a new lambda expression with the
0037   /// given call operator within this context.
0038   virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator) = 0;
0039 
0040   /// Retrieve the mangling number of a new block literal within this
0041   /// context.
0042   virtual unsigned getManglingNumber(const BlockDecl *BD) = 0;
0043 
0044   /// Static locals are numbered by source order.
0045   virtual unsigned getStaticLocalNumber(const VarDecl *VD) = 0;
0046 
0047   /// Retrieve the mangling number of a static local variable within
0048   /// this context.
0049   virtual unsigned getManglingNumber(const VarDecl *VD,
0050                                      unsigned MSLocalManglingNumber) = 0;
0051 
0052   /// Retrieve the mangling number of a static local variable within
0053   /// this context.
0054   virtual unsigned getManglingNumber(const TagDecl *TD,
0055                                      unsigned MSLocalManglingNumber) = 0;
0056 
0057   /// Retrieve the mangling number of a new lambda expression with the
0058   /// given call operator within the device context. No device number is
0059   /// assigned if there's no device numbering context is associated.
0060   virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *) { return 0; }
0061 
0062   // Retrieve the index of the next lambda appearing in this context, which is
0063   // used for deduplicating lambdas across modules. Note that this is a simple
0064   // sequence number and is not ABI-dependent.
0065   unsigned getNextLambdaIndex() { return LambdaIndex++; }
0066 };
0067 
0068 } // end namespace clang
0069 #endif