LLVM 17.0.0git
Public Types | Public Member Functions | List of all members
llvm::ExpressionFormat Struct Reference

Type representing the format an expression value should be textualized into for matching. More...

#include "FileCheck/FileCheckImpl.h"

Public Types

enum class  Kind {
  NoFormat , Unsigned , Signed , HexUpper ,
  HexLower
}
 

Public Member Functions

 operator bool () const
 Evaluates a format to true if it can be used in a match.
 
bool operator== (const ExpressionFormat &Other) const
 Define format equality: formats are equal if neither is NoFormat and their kinds and precision are the same.
 
bool operator!= (const ExpressionFormat &Other) const
 
bool operator== (Kind OtherValue) const
 
bool operator!= (Kind OtherValue) const
 
StringRef toString () const
 
 ExpressionFormat ()
 
 ExpressionFormat (Kind Value)
 
 ExpressionFormat (Kind Value, unsigned Precision)
 
 ExpressionFormat (Kind Value, unsigned Precision, bool AlternateForm)
 
Expected< std::string > getWildcardRegex () const
 
Expected< std::string > getMatchingString (ExpressionValue Value) const
 
Expected< ExpressionValuevalueFromStringRepr (StringRef StrVal, const SourceMgr &SM) const
 

Detailed Description

Type representing the format an expression value should be textualized into for matching.

Used to represent both explicit format specifiers as well as implicit format from using numeric variables.

Definition at line 39 of file FileCheckImpl.h.

Member Enumeration Documentation

◆ Kind

enum class llvm::ExpressionFormat::Kind
strong
Enumerator
NoFormat 

Denote absence of format.

Used for implicit format of literals and empty expressions.

Unsigned 

Value is an unsigned integer and should be printed as a decimal number.

Signed 

Value is a signed integer and should be printed as a decimal number.

HexUpper 

Value should be printed as an uppercase hex number.

HexLower 

Value should be printed as a lowercase hex number.

Definition at line 40 of file FileCheckImpl.h.

Constructor & Destructor Documentation

◆ ExpressionFormat() [1/4]

llvm::ExpressionFormat::ExpressionFormat ( )
inline

Definition at line 82 of file FileCheckImpl.h.

◆ ExpressionFormat() [2/4]

llvm::ExpressionFormat::ExpressionFormat ( Kind  Value)
inlineexplicit

Definition at line 83 of file FileCheckImpl.h.

◆ ExpressionFormat() [3/4]

llvm::ExpressionFormat::ExpressionFormat ( Kind  Value,
unsigned  Precision 
)
inlineexplicit

Definition at line 84 of file FileCheckImpl.h.

◆ ExpressionFormat() [4/4]

llvm::ExpressionFormat::ExpressionFormat ( Kind  Value,
unsigned  Precision,
bool  AlternateForm 
)
inlineexplicit

Definition at line 86 of file FileCheckImpl.h.

Member Function Documentation

◆ getMatchingString()

Expected< std::string > ExpressionFormat::getMatchingString ( ExpressionValue  Value) const
Returns
the string representation of Value in the format represented by this instance, or an error if conversion to this format failed or the format is NoFormat.

Definition at line 80 of file FileCheck.cpp.

References llvm::cantFail(), llvm::createStringError(), llvm::ExpressionValue::getAbsolute(), llvm::ExpressionValue::getSignedValue(), llvm::ExpressionValue::getUnsignedValue(), HexLower, HexUpper, llvm::ExpressionValue::isNegative(), Signed, llvm::Expected< T >::takeError(), and Unsigned.

◆ getWildcardRegex()

Expected< std::string > ExpressionFormat::getWildcardRegex ( ) const
Returns
a wildcard regular expression string that matches any value in the format represented by this instance and no other value, or an error if the format is NoFormat.

Definition at line 47 of file FileCheck.cpp.

References llvm::createStringError(), HexLower, HexUpper, Signed, and Unsigned.

◆ operator bool()

llvm::ExpressionFormat::operator bool ( ) const
inlineexplicit

Evaluates a format to true if it can be used in a match.

Definition at line 62 of file FileCheckImpl.h.

References NoFormat.

◆ operator!=() [1/2]

bool llvm::ExpressionFormat::operator!= ( const ExpressionFormat Other) const
inline

Definition at line 71 of file FileCheckImpl.h.

References llvm::Other.

◆ operator!=() [2/2]

bool llvm::ExpressionFormat::operator!= ( Kind  OtherValue) const
inline

Definition at line 77 of file FileCheckImpl.h.

◆ operator==() [1/2]

bool llvm::ExpressionFormat::operator== ( const ExpressionFormat Other) const
inline

Define format equality: formats are equal if neither is NoFormat and their kinds and precision are the same.

Definition at line 66 of file FileCheckImpl.h.

References NoFormat, and llvm::Other.

◆ operator==() [2/2]

bool llvm::ExpressionFormat::operator== ( Kind  OtherValue) const
inline

Definition at line 75 of file FileCheckImpl.h.

◆ toString()

StringRef ExpressionFormat::toString ( ) const
Returns
the format specifier corresponding to this format as a string.

Definition at line 31 of file FileCheck.cpp.

References HexLower, HexUpper, llvm_unreachable, NoFormat, Signed, and Unsigned.

◆ valueFromStringRepr()

Expected< ExpressionValue > ExpressionFormat::valueFromStringRepr ( StringRef  StrVal,
const SourceMgr SM 
) const
Returns
the value corresponding to string representation StrVal according to the matching format represented by this instance or an error with diagnostic against SM if StrVal does not correspond to a valid and representable value.

Definition at line 128 of file FileCheck.cpp.

References assert(), llvm::ErrorDiagnostic::get(), HexLower, HexUpper, and Signed.


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