clang 22.0.0git
clang::Qualifiers Class Reference

The collection of all-type qualifiers we support. More...

#include "clang/AST/TypeBase.h"

Inheritance diagram for clang::Qualifiers:
[legend]

Public Types

enum  TQ : uint64_t { Const = 0x1 , Restrict = 0x2 , Volatile = 0x4 , CVRMask = Const | Volatile | Restrict }
enum  GC { GCNone = 0 , Weak , Strong }
enum  ObjCLifetime {
  OCL_None , OCL_ExplicitNone , OCL_Strong , OCL_Weak ,
  OCL_Autoreleasing
}
enum  : uint64_t { MaxAddressSpace = 0x7fffffu , FastWidth = 3 , FastMask = (1 << FastWidth) - 1 }

Public Member Functions

 Qualifiers ()=default
uint64_t getAsOpaqueValue () const
bool hasConst () const
bool hasOnlyConst () const
void removeConst ()
void addConst ()
Qualifiers withConst () const
bool hasVolatile () const
bool hasOnlyVolatile () const
void removeVolatile ()
void addVolatile ()
Qualifiers withVolatile () const
bool hasRestrict () const
bool hasOnlyRestrict () const
void removeRestrict ()
void addRestrict ()
Qualifiers withRestrict () const
bool hasCVRQualifiers () const
unsigned getCVRQualifiers () const
unsigned getCVRUQualifiers () const
void setCVRQualifiers (unsigned mask)
void removeCVRQualifiers (unsigned mask)
void removeCVRQualifiers ()
void addCVRQualifiers (unsigned mask)
void addCVRUQualifiers (unsigned mask)
bool hasUnaligned () const
void setUnaligned (bool flag)
void removeUnaligned ()
void addUnaligned ()
bool hasObjCGCAttr () const
GC getObjCGCAttr () const
void setObjCGCAttr (GC type)
void removeObjCGCAttr ()
void addObjCGCAttr (GC type)
Qualifiers withoutObjCGCAttr () const
Qualifiers withoutObjCLifetime () const
Qualifiers withoutAddressSpace () const
bool hasObjCLifetime () const
ObjCLifetime getObjCLifetime () const
void setObjCLifetime (ObjCLifetime type)
void removeObjCLifetime ()
void addObjCLifetime (ObjCLifetime type)
bool hasNonTrivialObjCLifetime () const
 True if the lifetime is neither None or ExplicitNone.
bool hasStrongOrWeakObjCLifetime () const
 True if the lifetime is either strong or weak.
bool hasAddressSpace () const
LangAS getAddressSpace () const
bool hasTargetSpecificAddressSpace () const
unsigned getAddressSpaceAttributePrintValue () const
 Get the address space attribute value to be printed by diagnostics.
void setAddressSpace (LangAS space)
void removeAddressSpace ()
void addAddressSpace (LangAS space)
bool hasPointerAuth () const
PointerAuthQualifier getPointerAuth () const
void setPointerAuth (PointerAuthQualifier Q)
void removePointerAuth ()
void addPointerAuth (PointerAuthQualifier Q)
bool hasFastQualifiers () const
unsigned getFastQualifiers () const
void setFastQualifiers (unsigned mask)
void removeFastQualifiers (unsigned mask)
void removeFastQualifiers ()
void addFastQualifiers (unsigned mask)
bool hasNonFastQualifiers () const
 Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
Qualifiers getNonFastQualifiers () const
bool hasQualifiers () const
 Return true if the set contains any qualifiers.
bool empty () const
void addQualifiers (Qualifiers Q)
 Add the qualifiers from the given set to this set.
void removeQualifiers (Qualifiers Q)
 Remove the qualifiers from the given set from this set.
void addConsistentQualifiers (Qualifiers qs)
 Add the qualifiers from the given set to this set, given that they don't conflict.
bool isAddressSpaceSupersetOf (Qualifiers other, const ASTContext &Ctx) const
 Returns true if the address space in these qualifiers is equal to or a superset of the address space in the argument qualifiers.
bool compatiblyIncludes (Qualifiers other, const ASTContext &Ctx) const
 Determines if these qualifiers compatibly include another set.
bool compatiblyIncludesObjCLifetime (Qualifiers other) const
 Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspective of Objective-C ARC lifetime.
bool isStrictSupersetOf (Qualifiers Other) const
 Determine whether this set of qualifiers is a strict superset of another set of qualifiers, not considering qualifier compatibility.
bool operator== (Qualifiers Other) const
bool operator!= (Qualifiers Other) const
 operator bool () const
Qualifiersoperator+= (Qualifiers R)
Qualifiersoperator-= (Qualifiers R)
std::string getAsString () const
std::string getAsString (const PrintingPolicy &Policy) const
bool isEmptyWhenPrinted (const PrintingPolicy &Policy) const
void print (raw_ostream &OS, const PrintingPolicy &Policy, bool appendSpaceIfNonEmpty=false) const
void Profile (llvm::FoldingSetNodeID &ID) const

Static Public Member Functions

static Qualifiers removeCommonQualifiers (Qualifiers &L, Qualifiers &R)
 Returns the common set of qualifiers while removing them from the given sets.
static Qualifiers fromFastMask (unsigned Mask)
static Qualifiers fromCVRMask (unsigned CVR)
static Qualifiers fromCVRUMask (unsigned CVRU)
static Qualifiers fromOpaqueValue (uint64_t opaque)
static bool isAddressSpaceSupersetOf (LangAS A, LangAS B, const ASTContext &Ctx)
 Returns true if address space A is equal to or a superset of B.
static bool isTargetAddressSpaceSupersetOf (LangAS A, LangAS B, const ASTContext &Ctx)
static std::string getAddrSpaceAsString (LangAS AS)

Friends

Qualifiers operator+ (Qualifiers L, Qualifiers R)
Qualifiers operator- (Qualifiers L, Qualifiers R)
 Compute the difference between two qualifier sets.

Detailed Description

The collection of all-type qualifiers we support.

Clang supports five independent qualifiers:

  • C99: const, volatile, and restrict
  • MS: __unaligned
  • Embedded C (TR18037): address spaces
  • Objective C: the GC attributes (none, weak, or strong)

Definition at line 331 of file TypeBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : uint64_t
Enumerator
MaxAddressSpace 

The maximum supported address space number.

23 bits should be enough for anyone.

FastWidth 

The width of the "fast" qualifier mask.

FastMask 

The fast qualifier mask.

Definition at line 370 of file TypeBase.h.

◆ GC

Enumerator
GCNone 
Weak 
Strong 

Definition at line 342 of file TypeBase.h.

◆ ObjCLifetime

Enumerator
OCL_None 

There is no lifetime qualification on this type.

OCL_ExplicitNone 

This object can be modified without requiring retains or releases.

OCL_Strong 

Assigning into this object requires the old value to be released and the new value to be retained.

The timing of the release of the old value is inexact: it may be moved to immediately after the last known point where the value is live.

OCL_Weak 

Reading or writing from this object requires a barrier call.

OCL_Autoreleasing 

Assigning into this object requires a lifetime extension.

Definition at line 348 of file TypeBase.h.

◆ TQ

enum clang::Qualifiers::TQ : uint64_t
Enumerator
Const 
Restrict 
Volatile 
CVRMask 

Definition at line 334 of file TypeBase.h.

Constructor & Destructor Documentation

◆ Qualifiers()

Member Function Documentation

◆ addAddressSpace()

◆ addConsistentQualifiers()

void clang::Qualifiers::addConsistentQualifiers ( Qualifiers qs)
inline

◆ addConst()

◆ addCVRQualifiers()

void clang::Qualifiers::addCVRQualifiers ( unsigned mask)
inline

◆ addCVRUQualifiers()

void clang::Qualifiers::addCVRUQualifiers ( unsigned mask)
inline

Definition at line 506 of file TypeBase.h.

References CVRMask.

Referenced by fromCVRUMask(), and GetFullTypeForDeclarator().

◆ addFastQualifiers()

void clang::Qualifiers::addFastQualifiers ( unsigned mask)
inline

◆ addObjCGCAttr()

void clang::Qualifiers::addObjCGCAttr ( GC type)
inline

Definition at line 524 of file TypeBase.h.

References setObjCGCAttr(), and clang::ast_matchers::type.

Referenced by addQualifiers(), and clang::ASTContext::getObjCGCQualType().

◆ addObjCLifetime()

◆ addPointerAuth()

void clang::Qualifiers::addPointerAuth ( PointerAuthQualifier Q)
inline

Definition at line 611 of file TypeBase.h.

References clang::PointerAuthQualifier::isPresent(), and setPointerAuth().

Referenced by addQualifiers().

◆ addQualifiers()

◆ addRestrict()

void clang::Qualifiers::addRestrict ( )
inline

◆ addUnaligned()

void clang::Qualifiers::addUnaligned ( )
inline

Definition at line 516 of file TypeBase.h.

◆ addVolatile()

void clang::Qualifiers::addVolatile ( )
inline

◆ compatiblyIncludes()

bool clang::Qualifiers::compatiblyIncludes ( Qualifiers other,
const ASTContext & Ctx ) const
inline

◆ compatiblyIncludesObjCLifetime()

bool clang::Qualifiers::compatiblyIncludesObjCLifetime ( Qualifiers other) const
inline

Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspective of Objective-C ARC lifetime.

One set of Objective-C lifetime qualifiers compatibly includes the other if the lifetime qualifiers match, or if both are non-__weak and the including set also contains the 'const' qualifier, or both are non-__weak and one is None (which can only happen in non-ARC modes).

Definition at line 750 of file TypeBase.h.

References getObjCLifetime(), hasConst(), OCL_None, OCL_Weak, and Qualifiers().

Referenced by CastsAwayConstness(), checkPointerTypesForAssignment(), and isQualificationConversionStep().

◆ empty()

◆ fromCVRMask()

◆ fromCVRUMask()

Qualifiers clang::Qualifiers::fromCVRUMask ( unsigned CVRU)
inlinestatic

Definition at line 441 of file TypeBase.h.

References addCVRUQualifiers(), and Qualifiers().

Referenced by clang::Sema::FindCompositePointerType().

◆ fromFastMask()

Qualifiers clang::Qualifiers::fromFastMask ( unsigned Mask)
inlinestatic

Definition at line 429 of file TypeBase.h.

References addFastQualifiers(), and Qualifiers().

Referenced by clang::FunctionType::getFastTypeQuals(), and clang::QualType::split().

◆ fromOpaqueValue()

Qualifiers clang::Qualifiers::fromOpaqueValue ( uint64_t opaque)
inlinestatic

◆ getAddressSpace()

◆ getAddressSpaceAttributePrintValue()

unsigned clang::Qualifiers::getAddressSpaceAttributePrintValue ( ) const
inline

Get the address space attribute value to be printed by diagnostics.

Definition at line 578 of file TypeBase.h.

References clang::Addr, clang::Default, getAddressSpace(), hasTargetSpecificAddressSpace(), and clang::toTargetAddressSpace().

Referenced by clang::Sema::ActOnCXXDelete(), and clang::Sema::CheckAllocatedType().

◆ getAddrSpaceAsString()

◆ getAsOpaqueValue()

◆ getAsString() [1/2]

◆ getAsString() [2/2]

std::string Qualifiers::getAsString ( const PrintingPolicy & Policy) const

Definition at line 2650 of file TypePrinter.cpp.

References print().

◆ getCVRQualifiers()

◆ getCVRUQualifiers()

unsigned clang::Qualifiers::getCVRUQualifiers ( ) const
inline

Definition at line 489 of file TypeBase.h.

References CVRMask.

Referenced by clang::Sema::FindCompositePointerType().

◆ getFastQualifiers()

◆ getNonFastQualifiers()

Qualifiers clang::Qualifiers::getNonFastQualifiers ( ) const
inline

Definition at line 639 of file TypeBase.h.

References Qualifiers(), and setFastQualifiers().

◆ getObjCGCAttr()

◆ getObjCLifetime()

◆ getPointerAuth()

◆ hasAddressSpace()

◆ hasConst()

◆ hasCVRQualifiers()

bool clang::Qualifiers::hasCVRQualifiers ( ) const
inline

Definition at line 487 of file TypeBase.h.

References getCVRQualifiers().

Referenced by clang::Sema::ActOnCXXDelete().

◆ hasFastQualifiers()

bool clang::Qualifiers::hasFastQualifiers ( ) const
inline

Definition at line 618 of file TypeBase.h.

References getFastQualifiers().

◆ hasNonFastQualifiers()

bool clang::Qualifiers::hasNonFastQualifiers ( ) const
inline

Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.

Definition at line 638 of file TypeBase.h.

References FastMask.

Referenced by clang::QualifierCollector::apply(), clang::QualifierCollector::apply(), clang::ASTContext::getQualifiedType(), clang::ASTContext::getQualifiedType(), and clang::ASTContext::removeAddrSpaceQualType().

◆ hasNonTrivialObjCLifetime()

bool clang::Qualifiers::hasNonTrivialObjCLifetime ( ) const
inline

True if the lifetime is neither None or ExplicitNone.

Definition at line 559 of file TypeBase.h.

References getObjCLifetime(), and OCL_ExplicitNone.

Referenced by DeduceTemplateArgumentsByTypeMatch(), and clang::QualType::hasNonTrivialObjCLifetime().

◆ hasObjCGCAttr()

◆ hasObjCLifetime()

◆ hasOnlyConst()

bool clang::Qualifiers::hasOnlyConst ( ) const
inline

Definition at line 458 of file TypeBase.h.

References Const.

Referenced by AddFunctionTypeQuals(), and TryObjectArgumentInitialization().

◆ hasOnlyRestrict()

bool clang::Qualifiers::hasOnlyRestrict ( ) const
inline

Definition at line 478 of file TypeBase.h.

References Restrict.

Referenced by AddFunctionTypeQuals().

◆ hasOnlyVolatile()

bool clang::Qualifiers::hasOnlyVolatile ( ) const
inline

Definition at line 468 of file TypeBase.h.

References Volatile.

Referenced by AddFunctionTypeQuals().

◆ hasPointerAuth()

bool clang::Qualifiers::hasPointerAuth ( ) const
inline

Definition at line 602 of file TypeBase.h.

Referenced by addConsistentQualifiers(), and addQualifiers().

◆ hasQualifiers()

bool clang::Qualifiers::hasQualifiers ( ) const
inline

Return true if the set contains any qualifiers.

Definition at line 646 of file TypeBase.h.

Referenced by clang::InitializationSequence::Diagnose(), operator bool(), and clang::ASTNodeTraverser< Derived, NodeDelegateType >::Visit().

◆ hasRestrict()

◆ hasStrongOrWeakObjCLifetime()

bool clang::Qualifiers::hasStrongOrWeakObjCLifetime ( ) const
inline

True if the lifetime is either strong or weak.

Definition at line 565 of file TypeBase.h.

References getObjCLifetime(), OCL_Strong, and OCL_Weak.

Referenced by clang::QualType::hasStrongOrWeakObjCLifetime().

◆ hasTargetSpecificAddressSpace()

bool clang::Qualifiers::hasTargetSpecificAddressSpace ( ) const
inline

Definition at line 574 of file TypeBase.h.

References getAddressSpace(), and clang::isTargetAddressSpace().

Referenced by getAddressSpaceAttributePrintValue().

◆ hasUnaligned()

◆ hasVolatile()

◆ isAddressSpaceSupersetOf() [1/2]

bool clang::Qualifiers::isAddressSpaceSupersetOf ( LangAS A,
LangAS B,
const ASTContext & Ctx )
inlinestatic

Returns true if address space A is equal to or a superset of B.

OpenCL v2.0 defines conversion rules (OpenCLC v2.0 s6.5.5) and notion of overlapping address spaces. CL1.1 or CL1.2: every address space is a superset of itself. CL2.0 adds: __generic is a superset of any address space except for __constant.

Definition at line 708 of file TypeBase.h.

References isTargetAddressSpaceSupersetOf().

Referenced by clang::Sema::AddOverloadCandidate(), checkConditionalPointerCompatibility(), checkPointerTypesForAssignment(), compatiblyIncludes(), clang::InitializationSequence::Diagnose(), clang::Sema::FindCompositePointerType(), clang::QualType::isAddressSpaceOverlapping(), isAddressSpaceSupersetOf(), clang::isBetterOverloadCandidate(), isQualificationConversionStep(), clang::ASTContext::mergeTypes(), clang::Sema::PerformImplicitConversion(), TryObjectArgumentInitialization(), TryReferenceInitializationCore(), TryReferenceListInitialization(), and TryReinterpretCast().

◆ isAddressSpaceSupersetOf() [2/2]

bool clang::Qualifiers::isAddressSpaceSupersetOf ( Qualifiers other,
const ASTContext & Ctx ) const
inline

Returns true if the address space in these qualifiers is equal to or a superset of the address space in the argument qualifiers.

Definition at line 719 of file TypeBase.h.

References getAddressSpace(), isAddressSpaceSupersetOf(), and Qualifiers().

◆ isEmptyWhenPrinted()

◆ isStrictSupersetOf()

bool Qualifiers::isStrictSupersetOf ( Qualifiers Other) const

Determine whether this set of qualifiers is a strict superset of another set of qualifiers, not considering qualifier compatibility.

Definition at line 57 of file Type.cpp.

References CVRMask, getAddressSpace(), getObjCGCAttr(), getObjCLifetime(), hasAddressSpace(), hasObjCGCAttr(), hasObjCLifetime(), clang::Other, and Qualifiers().

Referenced by DeduceTemplateArgumentsByTypeMatch().

◆ isTargetAddressSpaceSupersetOf()

◆ operator bool()

clang::Qualifiers::operator bool ( ) const
inlineexplicit

Definition at line 770 of file TypeBase.h.

References hasQualifiers().

◆ operator!=()

bool clang::Qualifiers::operator!= ( Qualifiers Other) const
inline

Definition at line 768 of file TypeBase.h.

References clang::Other, and Qualifiers().

◆ operator+=()

Qualifiers & clang::Qualifiers::operator+= ( Qualifiers R)
inline

Definition at line 772 of file TypeBase.h.

References addQualifiers(), and Qualifiers().

◆ operator-=()

Qualifiers & clang::Qualifiers::operator-= ( Qualifiers R)
inline

Definition at line 784 of file TypeBase.h.

References Qualifiers(), and removeQualifiers().

◆ operator==()

bool clang::Qualifiers::operator== ( Qualifiers Other) const
inline

Definition at line 767 of file TypeBase.h.

References clang::Other, and Qualifiers().

◆ print()

◆ Profile()

void clang::Qualifiers::Profile ( llvm::FoldingSetNodeID & ID) const
inline

Definition at line 804 of file TypeBase.h.

◆ removeAddressSpace()

◆ removeCommonQualifiers()

◆ removeConst()

◆ removeCVRQualifiers() [1/2]

void clang::Qualifiers::removeCVRQualifiers ( )
inline

Definition at line 499 of file TypeBase.h.

References CVRMask, and removeCVRQualifiers().

Referenced by removeCVRQualifiers().

◆ removeCVRQualifiers() [2/2]

◆ removeFastQualifiers() [1/2]

void clang::Qualifiers::removeFastQualifiers ( )
inline

Definition at line 628 of file TypeBase.h.

References FastMask, and removeFastQualifiers().

Referenced by removeFastQualifiers().

◆ removeFastQualifiers() [2/2]

void clang::Qualifiers::removeFastQualifiers ( unsigned mask)
inline

Definition at line 624 of file TypeBase.h.

References FastMask.

◆ removeObjCGCAttr()

◆ removeObjCLifetime()

◆ removePointerAuth()

◆ removeQualifiers()

void clang::Qualifiers::removeQualifiers ( Qualifiers Q)
inline

Remove the qualifiers from the given set from this set.

Definition at line 669 of file TypeBase.h.

References CVRMask, getAddressSpace(), getObjCGCAttr(), getObjCLifetime(), getPointerAuth(), Qualifiers(), removeAddressSpace(), removeObjCGCAttr(), removeObjCLifetime(), and removePointerAuth().

Referenced by operator-=().

◆ removeRestrict()

void clang::Qualifiers::removeRestrict ( )
inline

◆ removeUnaligned()

void clang::Qualifiers::removeUnaligned ( )
inline

◆ removeVolatile()

◆ setAddressSpace()

◆ setCVRQualifiers()

void clang::Qualifiers::setCVRQualifiers ( unsigned mask)
inline

Definition at line 491 of file TypeBase.h.

References CVRMask.

Referenced by DeduceTemplateArgumentsByTypeMatch().

◆ setFastQualifiers()

void clang::Qualifiers::setFastQualifiers ( unsigned mask)
inline

Definition at line 620 of file TypeBase.h.

References FastMask.

Referenced by getNonFastQualifiers().

◆ setObjCGCAttr()

void clang::Qualifiers::setObjCGCAttr ( GC type)
inline

◆ setObjCLifetime()

◆ setPointerAuth()

◆ setUnaligned()

void clang::Qualifiers::setUnaligned ( bool flag)
inline

Definition at line 512 of file TypeBase.h.

Referenced by clang::Sema::BuildQualifiedType().

◆ withConst()

Qualifiers clang::Qualifiers::withConst ( ) const
inline

Definition at line 461 of file TypeBase.h.

References addConst(), and Qualifiers().

◆ withoutAddressSpace()

Qualifiers clang::Qualifiers::withoutAddressSpace ( ) const
inline

◆ withoutObjCGCAttr()

Qualifiers clang::Qualifiers::withoutObjCGCAttr ( ) const
inline

Definition at line 528 of file TypeBase.h.

References Qualifiers(), and removeObjCGCAttr().

Referenced by checkPointerTypesForAssignment().

◆ withoutObjCLifetime()

Qualifiers clang::Qualifiers::withoutObjCLifetime ( ) const
inline

◆ withRestrict()

Qualifiers clang::Qualifiers::withRestrict ( ) const
inline

Definition at line 481 of file TypeBase.h.

References addRestrict(), and Qualifiers().

◆ withVolatile()

Qualifiers clang::Qualifiers::withVolatile ( ) const
inline

Definition at line 471 of file TypeBase.h.

References addVolatile(), and Qualifiers().

◆ operator+

Qualifiers operator+ ( Qualifiers L,
Qualifiers R )
friend

Definition at line 779 of file TypeBase.h.

References Qualifiers().

◆ operator-

Qualifiers operator- ( Qualifiers L,
Qualifiers R )
friend

Compute the difference between two qualifier sets.

Definition at line 790 of file TypeBase.h.

References Qualifiers().


The documentation for this class was generated from the following files: