class StringLiteral
Declaration
class StringLiteral : public Expr, private TrailingObjects { /* full declaration omitted */ };
Description
StringLiteral - This represents a string literal expression, e.g. "foo" or L"bar" (wide strings). The actual string data can be obtained with getBytes() and is NOT null-terminated. The length of the string data is determined by calling getByteLength(). The C type for a string is always a ConstantArrayType. In C++, the char type is const qualified, in C it is not. Note that strings in C can be formed by concatenation of multiple string literal pptokens in translation phase #6. This keeps track of the locations of each of these pieces. Strings in C can also be truncated and extended by assigning into arrays, e.g. with constructs like: char X[2] = "foobar"; In this case, getByteLength() will return 6, but the string literal will have type "char[2]".
Declared at: clang/include/clang/AST/Expr.h:1767
Inherits from: Expr, TrailingObjects
Member Variables
Inherited from Stmt:
Method Overview
- public static clang::StringLiteral * Create(const clang::ASTContext & Ctx, llvm::StringRef Str, clang::StringLiteral::StringKind Kind, bool Pascal, clang::QualType Ty, const clang::SourceLocation * Loc, unsigned int NumConcatenated)
- public static clang::StringLiteral * Create(const clang::ASTContext & Ctx, llvm::StringRef Str, clang::StringLiteral::StringKind Kind, bool Pascal, clang::QualType Ty, clang::SourceLocation Loc)
- public static clang::StringLiteral * CreateEmpty(const clang::ASTContext & Ctx, unsigned int NumConcatenated, unsigned int Length, unsigned int CharByteWidth)
- private StringLiteral(const clang::ASTContext & Ctx, llvm::StringRef Str, clang::StringLiteral::StringKind Kind, bool Pascal, clang::QualType Ty, const clang::SourceLocation * Loc, unsigned int NumConcatenated)
- private StringLiteral(clang::Stmt::EmptyShell Empty, unsigned int NumConcatenated, unsigned int Length, unsigned int CharByteWidth)
- public clang::Stmt::const_child_range children() const
- public clang::Stmt::child_range children()
- public static bool classof(const clang::Stmt * T)
- public bool containsNonAscii() const
- public bool containsNonAsciiOrNull() const
- public clang::SourceLocation getBeginLoc() const
- public unsigned int getByteLength() const
- public llvm::StringRef getBytes() const
- public unsigned int getCharByteWidth() const
- public uint32_t getCodeUnit(size_t i) const
- public clang::SourceLocation getEndLoc() const
- public clang::StringLiteral::StringKind getKind() const
- public unsigned int getLength() const
- public clang::SourceLocation getLocationOfByte(unsigned int ByteNo, const clang::SourceManager & SM, const clang::LangOptions & Features, const clang::TargetInfo & Target, unsigned int * StartToken = nullptr, unsigned int * StartTokenByteOffset = nullptr) const
- public unsigned int getNumConcatenated() const
- private const char * getStrDataAsChar() const
- private char * getStrDataAsChar()
- private const uint16_t * getStrDataAsUInt16() const
- private const uint32_t * getStrDataAsUInt32() const
- public clang::SourceLocation getStrTokenLoc(unsigned int TokNum) const
- public llvm::StringRef getString() const
- public bool isOrdinary() const
- public bool isPascal() const
- public bool isUTF16() const
- public bool isUTF32() const
- public bool isUTF8() const
- public bool isWide() const
- private static unsigned int mapCharByteWidth(const clang::TargetInfo & Target, clang::StringLiteral::StringKind SK)
- private unsigned int numTrailingObjects(OverloadToken<char>) const
- private unsigned int numTrailingObjects(OverloadToken<clang::SourceLocation>) const
- private unsigned int numTrailingObjects(OverloadToken<unsigned int>) const
- public void outputString(llvm::raw_ostream & OS) const
- private void setStrTokenLoc(unsigned int TokNum, clang::SourceLocation L)
- public clang::StringLiteral::tokloc_iterator tokloc_begin() const
- public clang::StringLiteral::tokloc_iterator tokloc_end() const
Inherited from Expr:
- public Classify
- public ClassifyLValue
- public ClassifyModifiable
- public EvaluateAsBooleanCondition
- public EvaluateAsConstantExpr
- public EvaluateAsFixedPoint
- public EvaluateAsFloat
- public EvaluateAsInitializer
- public EvaluateAsInt
- public EvaluateAsLValue
- public EvaluateAsRValue
- public EvaluateForOverflow
- public EvaluateKnownConstInt
- public EvaluateKnownConstIntCheckOverflow
- public EvaluateWithSubstitution
- public HasSideEffects
- public IgnoreCasts
- public IgnoreCasts
- public IgnoreConversionOperatorSingleStep
- public IgnoreConversionOperatorSingleStep
- public IgnoreImpCasts
- public IgnoreImpCasts
- public IgnoreImplicit
- public IgnoreImplicit
- public IgnoreImplicitAsWritten
- public IgnoreImplicitAsWritten
- public IgnoreParenBaseCasts
- public IgnoreParenBaseCasts
- public IgnoreParenCasts
- public IgnoreParenCasts
- public IgnoreParenImpCasts
- public IgnoreParenImpCasts
- public IgnoreParenLValueCasts
- public IgnoreParenLValueCasts
- public IgnoreParenNoopCasts
- public IgnoreParenNoopCasts
- public IgnoreParens
- public IgnoreParens
- public IgnoreUnlessSpelledInSource
- public IgnoreUnlessSpelledInSource
- public classof
- public containsErrors
- public containsUnexpandedParameterPack
- public findBoundMemberType
- public getAsBuiltinConstantDeclRef
- public getBestDynamicClassType
- public getBestDynamicClassTypeExpr
- public getDependence
- public getExprLoc
- public getFPFeaturesInEffect
- public getIntegerConstantExpr
- public getObjCProperty
- public getObjectKind
- public getReferencedDeclOfCallee
- public getReferencedDeclOfCallee
- public getSourceBitField
- public getSourceBitField
- public getType
- public getValueKind
- public getValueKindForType
- public hasAnyTypeDependentArguments
- public hasNonTrivialCall
- public hasPlaceholderType
- public hasPlaceholderType
- public isBoundMemberFunction
- public isCXX11ConstantExpr
- public isCXX98IntegralConstantExpr
- public isConstantInitializer
- public isDefaultArgument
- public isEvaluatable
- public isGLValue
- public isImplicitCXXThis
- public isInstantiationDependent
- public isIntegerConstantExpr
- public isKnownToHaveBooleanValue
- public isLValue
- public isModifiableLvalue
- public isNullPointerConstant
- public isOBJCGCCandidate
- public isObjCSelfExpr
- public isOrdinaryOrBitFieldObject
- public isPRValue
- public isPotentialConstantExpr
- public isPotentialConstantExprUnevaluated
- public isReadIfDiscardedInCPlusPlus11
- public isSameComparisonOperand
- public isTemporaryObject
- public isTypeDependent
- public isUnusedResultAWarning
- public isValueDependent
- public isXValue
- public refersToBitField
- public refersToGlobalRegisterVar
- public refersToMatrixElement
- public refersToVectorElement
- protected setDependence
- public setObjectKind
- public setType
- public setValueKind
- public skipRValueSubobjectAdjustments
- public skipRValueSubobjectAdjustments
- public tryEvaluateObjectSize
- public tryEvaluateStrLen
Inherited from ValueStmt:
Inherited from Stmt:
- public EnableStatistics
- public IgnoreContainers
- public IgnoreContainers
- public PrintStats
- public ProcessODRHash
- public Profile
- public addStmtClass
- public child_begin
- public child_begin
- public child_end
- public child_end
- public children
- public children
- public determineLikelihoodConflict
- public dump
- public dump
- public dumpColor
- public dumpPretty
- public getBeginLoc
- public getEndLoc
- public getID
- public getLikelihood
- public getLikelihood
- public getLikelihood
- public getLikelihoodAttr
- public getSourceRange
- public getStmtClass
- public getStmtClassName
- public printJson
- public printPretty
- public printPrettyControlled
- public stripLabelLikeStatements
- public stripLabelLikeStatements
- public viewAST
Methods
¶static clang::StringLiteral* Create(
const clang::ASTContext& Ctx,
llvm::StringRef Str,
clang::StringLiteral::StringKind Kind,
bool Pascal,
clang::QualType Ty,
const clang::SourceLocation* Loc,
unsigned int NumConcatenated)
static clang::StringLiteral* Create(
const clang::ASTContext& Ctx,
llvm::StringRef Str,
clang::StringLiteral::StringKind Kind,
bool Pascal,
clang::QualType Ty,
const clang::SourceLocation* Loc,
unsigned int NumConcatenated)
Description
This is the "fully general" constructor that allows representation of strings formed from multiple concatenated tokens.
Declared at: clang/include/clang/AST/Expr.h:1833
Parameters
- const clang::ASTContext& Ctx
- llvm::StringRef Str
- clang::StringLiteral::StringKind Kind
- bool Pascal
- clang::QualType Ty
- const clang::SourceLocation* Loc
- unsigned int NumConcatenated
¶static clang::StringLiteral* Create(
const clang::ASTContext& Ctx,
llvm::StringRef Str,
clang::StringLiteral::StringKind Kind,
bool Pascal,
clang::QualType Ty,
clang::SourceLocation Loc)
static clang::StringLiteral* Create(
const clang::ASTContext& Ctx,
llvm::StringRef Str,
clang::StringLiteral::StringKind Kind,
bool Pascal,
clang::QualType Ty,
clang::SourceLocation Loc)
Description
Simple constructor for string literals made from one token.
Declared at: clang/include/clang/AST/Expr.h:1839
Parameters
- const clang::ASTContext& Ctx
- llvm::StringRef Str
- clang::StringLiteral::StringKind Kind
- bool Pascal
- clang::QualType Ty
- clang::SourceLocation Loc
¶static clang::StringLiteral* CreateEmpty(
const clang::ASTContext& Ctx,
unsigned int NumConcatenated,
unsigned int Length,
unsigned int CharByteWidth)
static clang::StringLiteral* CreateEmpty(
const clang::ASTContext& Ctx,
unsigned int NumConcatenated,
unsigned int Length,
unsigned int CharByteWidth)
Description
Construct an empty string literal.
Declared at: clang/include/clang/AST/Expr.h:1846
Parameters
- const clang::ASTContext& Ctx
- unsigned int NumConcatenated
- unsigned int Length
- unsigned int CharByteWidth
¶StringLiteral(
const clang::ASTContext& Ctx,
llvm::StringRef Str,
clang::StringLiteral::StringKind Kind,
bool Pascal,
clang::QualType Ty,
const clang::SourceLocation* Loc,
unsigned int NumConcatenated)
StringLiteral(
const clang::ASTContext& Ctx,
llvm::StringRef Str,
clang::StringLiteral::StringKind Kind,
bool Pascal,
clang::QualType Ty,
const clang::SourceLocation* Loc,
unsigned int NumConcatenated)
Description
Build a string literal.
Declared at: clang/include/clang/AST/Expr.h:1813
Parameters
- const clang::ASTContext& Ctx
- llvm::StringRef Str
- clang::StringLiteral::StringKind Kind
- bool Pascal
- clang::QualType Ty
- const clang::SourceLocation* Loc
- unsigned int NumConcatenated
¶StringLiteral(clang::Stmt::EmptyShell Empty,
unsigned int NumConcatenated,
unsigned int Length,
unsigned int CharByteWidth)
StringLiteral(clang::Stmt::EmptyShell Empty,
unsigned int NumConcatenated,
unsigned int Length,
unsigned int CharByteWidth)
Description
Build an empty string literal.
Declared at: clang/include/clang/AST/Expr.h:1818
Parameters
- clang::Stmt::EmptyShell Empty
- unsigned int NumConcatenated
- unsigned int Length
- unsigned int CharByteWidth
¶clang::Stmt::const_child_range children() const
clang::Stmt::const_child_range children() const
Declared at: clang/include/clang/AST/Expr.h:1953
¶clang::Stmt::child_range children()
clang::Stmt::child_range children()
Declared at: clang/include/clang/AST/Expr.h:1950
¶static bool classof(const clang::Stmt* T)
static bool classof(const clang::Stmt* T)
Declared at: clang/include/clang/AST/Expr.h:1945
Parameters
- const clang::Stmt* T
¶bool containsNonAscii() const
bool containsNonAscii() const
Declared at: clang/include/clang/AST/Expr.h:1893
¶bool containsNonAsciiOrNull() const
bool containsNonAsciiOrNull() const
Declared at: clang/include/clang/AST/Expr.h:1900
¶clang::SourceLocation getBeginLoc() const
clang::SourceLocation getBeginLoc() const
Declared at: clang/include/clang/AST/Expr.h:1942
¶unsigned int getByteLength() const
unsigned int getByteLength() const
Declared at: clang/include/clang/AST/Expr.h:1878
¶llvm::StringRef getBytes() const
llvm::StringRef getBytes() const
Description
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral().
Declared at: clang/include/clang/AST/Expr.h:1858
¶unsigned int getCharByteWidth() const
unsigned int getCharByteWidth() const
Declared at: clang/include/clang/AST/Expr.h:1880
¶uint32_t getCodeUnit(size_t i) const
uint32_t getCodeUnit(size_t i) const
Declared at: clang/include/clang/AST/Expr.h:1865
Parameters
- size_t i
¶clang::SourceLocation getEndLoc() const
clang::SourceLocation getEndLoc() const
Declared at: clang/include/clang/AST/Expr.h:1943
¶clang::StringLiteral::StringKind getKind() const
clang::StringLiteral::StringKind getKind() const
Declared at: clang/include/clang/AST/Expr.h:1882
¶unsigned int getLength() const
unsigned int getLength() const
Declared at: clang/include/clang/AST/Expr.h:1879
¶clang::SourceLocation getLocationOfByte(
unsigned int ByteNo,
const clang::SourceManager& SM,
const clang::LangOptions& Features,
const clang::TargetInfo& Target,
unsigned int* StartToken = nullptr,
unsigned int* StartTokenByteOffset =
nullptr) const
clang::SourceLocation getLocationOfByte(
unsigned int ByteNo,
const clang::SourceManager& SM,
const clang::LangOptions& Features,
const clang::TargetInfo& Target,
unsigned int* StartToken = nullptr,
unsigned int* StartTokenByteOffset =
nullptr) const
Description
getLocationOfByte - Return a source location that points to the specified byte of this string literal. Strings are amazingly complex. They can be formed from multiple tokens and can have escape sequences in them in addition to the usual trigraph and escaped newline business. This routine handles this complexity.
Declared at: clang/include/clang/AST/Expr.h:1927
Parameters
- unsigned int ByteNo
- const clang::SourceManager& SM
- const clang::LangOptions& Features
- const clang::TargetInfo& Target
- unsigned int* StartToken = nullptr
- unsigned int* StartTokenByteOffset = nullptr
¶unsigned int getNumConcatenated() const
unsigned int getNumConcatenated() const
Description
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation phase #6 to form this string literal.
Declared at: clang/include/clang/AST/Expr.h:1909
¶const char* getStrDataAsChar() const
const char* getStrDataAsChar() const
Declared at: clang/include/clang/AST/Expr.h:1802
¶char* getStrDataAsChar()
char* getStrDataAsChar()
Declared at: clang/include/clang/AST/Expr.h:1801
¶const uint16_t* getStrDataAsUInt16() const
const uint16_t* getStrDataAsUInt16() const
Declared at: clang/include/clang/AST/Expr.h:1804
¶const uint32_t* getStrDataAsUInt32() const
const uint32_t* getStrDataAsUInt32() const
Declared at: clang/include/clang/AST/Expr.h:1808
¶clang::SourceLocation getStrTokenLoc(
unsigned int TokNum) const
clang::SourceLocation getStrTokenLoc(
unsigned int TokNum) const
Description
Get one of the string literal token.
Declared at: clang/include/clang/AST/Expr.h:1914
Parameters
- unsigned int TokNum
¶llvm::StringRef getString() const
llvm::StringRef getString() const
Declared at: clang/include/clang/AST/Expr.h:1850
¶bool isOrdinary() const
bool isOrdinary() const
Declared at: clang/include/clang/AST/Expr.h:1886
¶bool isPascal() const
bool isPascal() const
Declared at: clang/include/clang/AST/Expr.h:1891
¶bool isUTF16() const
bool isUTF16() const
Declared at: clang/include/clang/AST/Expr.h:1889
¶bool isUTF32() const
bool isUTF32() const
Declared at: clang/include/clang/AST/Expr.h:1890
¶bool isUTF8() const
bool isUTF8() const
Declared at: clang/include/clang/AST/Expr.h:1888
¶bool isWide() const
bool isWide() const
Declared at: clang/include/clang/AST/Expr.h:1887
¶static unsigned int mapCharByteWidth(
const clang::TargetInfo& Target,
clang::StringLiteral::StringKind SK)
static unsigned int mapCharByteWidth(
const clang::TargetInfo& Target,
clang::StringLiteral::StringKind SK)
Description
Map a target and string kind to the appropriate character width.
Declared at: clang/include/clang/AST/Expr.h:1822
Parameters
- const clang::TargetInfo& Target
- clang::StringLiteral::StringKind SK
¶unsigned int numTrailingObjects(
OverloadToken<char>) const
unsigned int numTrailingObjects(
OverloadToken<char>) const
Declared at: clang/include/clang/AST/Expr.h:1797
Parameters
- OverloadToken<char>
¶unsigned int numTrailingObjects(
OverloadToken<clang::SourceLocation>) const
unsigned int numTrailingObjects(
OverloadToken<clang::SourceLocation>) const
Declared at: clang/include/clang/AST/Expr.h:1793
Parameters
- OverloadToken<clang::SourceLocation>
¶unsigned int numTrailingObjects(
OverloadToken<unsigned int>) const
unsigned int numTrailingObjects(
OverloadToken<unsigned int>) const
Declared at: clang/include/clang/AST/Expr.h:1792
Parameters
- OverloadToken<unsigned int>
¶void outputString(llvm::raw_ostream& OS) const
void outputString(llvm::raw_ostream& OS) const
Declared at: clang/include/clang/AST/Expr.h:1863
Parameters
¶void setStrTokenLoc(unsigned int TokNum,
clang::SourceLocation L)
void setStrTokenLoc(unsigned int TokNum,
clang::SourceLocation L)
Description
Set one of the string literal token.
Declared at: clang/include/clang/AST/Expr.h:1825
Parameters
- unsigned int TokNum
- clang::SourceLocation L
¶clang::StringLiteral::tokloc_iterator
tokloc_begin() const
clang::StringLiteral::tokloc_iterator
tokloc_begin() const
Declared at: clang/include/clang/AST/Expr.h:1934
¶clang::StringLiteral::tokloc_iterator tokloc_end()
const
clang::StringLiteral::tokloc_iterator tokloc_end()
const
Declared at: clang/include/clang/AST/Expr.h:1938