clang API Documentation
#include <Expr.h>


Public Types | |
| enum | StringKind { Ascii, Wide, UTF8, UTF16, UTF32 } |
| typedef const SourceLocation * | tokloc_iterator |
Public Member Functions | |
| StringRef | getString () const |
| StringRef | getBytes () const |
| uint32_t | getCodeUnit (size_t i) const |
| unsigned | getByteLength () const |
| unsigned | getLength () const |
| unsigned | getCharByteWidth () const |
| void | setString (ASTContext &C, StringRef Str, StringKind Kind, bool IsPascal) |
| Sets the string data to the given string data. | |
| StringKind | getKind () const |
| bool | isAscii () const |
| bool | isWide () const |
| bool | isUTF8 () const |
| bool | isUTF16 () const |
| bool | isUTF32 () const |
| bool | isPascal () const |
| bool | containsNonAsciiOrNull () const |
| unsigned | getNumConcatenated () const |
| SourceLocation | getStrTokenLoc (unsigned TokNum) const |
| void | setStrTokenLoc (unsigned TokNum, SourceLocation L) |
| SourceLocation | getLocationOfByte (unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target) const |
| tokloc_iterator | tokloc_begin () const |
| tokloc_iterator | tokloc_end () const |
| SourceRange | getSourceRange () const LLVM_READONLY |
| child_range | children () |
Static Public Member Functions | |
| static StringLiteral * | Create (ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs) |
| static StringLiteral * | Create (ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, SourceLocation Loc) |
| Simple constructor for string literals made from one token. | |
| static StringLiteral * | CreateEmpty (ASTContext &C, unsigned NumStrs) |
| Construct an empty string literal. | |
| static bool | classof (const Stmt *T) |
| static bool | classof (const StringLiteral *) |
Friends | |
| class | ASTStmtReader |
StringLiteral - This represents a string literal expression, e.g. "foo" or L"bar" (wide strings). The actual string is returned by getStrData() is NOT null-terminated, and the length of the string 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]".
| typedef const SourceLocation* clang::StringLiteral::tokloc_iterator |
| child_range clang::StringLiteral::children | ( | ) | [inline] |
Reimplemented from clang::Stmt.
| static bool clang::StringLiteral::classof | ( | const Stmt * | T | ) | [inline, static] |
Reimplemented from clang::Expr.
Definition at line 1465 of file Expr.h.
References clang::Stmt::getStmtClass().
| static bool clang::StringLiteral::classof | ( | const StringLiteral * | ) | [inline, static] |
| bool clang::StringLiteral::containsNonAsciiOrNull | ( | ) | const [inline] |
Definition at line 1426 of file Expr.h.
References getString().
Referenced by GetConstantCFStringEntry().
| StringLiteral * StringLiteral::Create | ( | ASTContext & | C, |
| StringRef | Str, | ||
| StringKind | Kind, | ||
| bool | Pascal, | ||
| QualType | Ty, | ||
| const SourceLocation * | Loc, | ||
| unsigned | NumStrs | ||
| ) | [static] |
This is the "fully general" constructor that allows representation of strings formed from multiple concatenated tokens.
Definition at line 603 of file Expr.cpp.
References clang::ASTContext::Allocate(), and setString().
Referenced by clang::Sema::ActOnNumericConstant(), clang::Sema::ActOnStringLiteral(), Create(), and clang::Sema::ParseObjCStringLiteral().
| static StringLiteral* clang::StringLiteral::Create | ( | ASTContext & | C, |
| StringRef | Str, | ||
| StringKind | Kind, | ||
| bool | Pascal, | ||
| QualType | Ty, | ||
| SourceLocation | Loc | ||
| ) | [inline, static] |
| StringLiteral * StringLiteral::CreateEmpty | ( | ASTContext & | C, |
| unsigned | NumStrs | ||
| ) | [static] |
Construct an empty string literal.
Definition at line 625 of file Expr.cpp.
References clang::ASTContext::Allocate().
| unsigned clang::StringLiteral::getByteLength | ( | ) | const [inline] |
Definition at line 1408 of file Expr.h.
Referenced by getBytes(), and getString().
| StringRef clang::StringLiteral::getBytes | ( | ) | const [inline] |
Allow clients that need the byte representation, such as ASTWriterStmt ::VisitStringLiteral(), access.
Definition at line 1386 of file Expr.h.
References getByteLength().
| unsigned clang::StringLiteral::getCharByteWidth | ( | ) | const [inline] |
Definition at line 1410 of file Expr.h.
Referenced by ExtractStringLiteralCharacter(), and clang::CodeGen::CodeGenModule::GetConstantArrayFromStringLiteral().
| uint32_t clang::StringLiteral::getCodeUnit | ( | size_t | i | ) | const [inline] |
Definition at line 1398 of file Expr.h.
Referenced by ExtractStringLiteralCharacter(), and clang::CodeGen::CodeGenModule::GetConstantArrayFromStringLiteral().
| StringKind clang::StringLiteral::getKind | ( | ) | const [inline] |
Definition at line 1416 of file Expr.h.
Referenced by IsStringInit().
| unsigned clang::StringLiteral::getLength | ( | ) | const [inline] |
Definition at line 1409 of file Expr.h.
Referenced by diagnoseStringPlusInt(), and clang::CodeGen::CodeGenModule::GetConstantArrayFromStringLiteral().
| SourceLocation StringLiteral::getLocationOfByte | ( | unsigned | ByteNo, |
| const SourceManager & | SM, | ||
| const LangOptions & | Features, | ||
| const TargetInfo & | Target | ||
| ) | const |
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.
Definition at line 680 of file Expr.cpp.
References clang::Lexer::AdvanceToTokenCharacter(), Ascii, clang::SourceManager::getBufferData(), clang::SourceManager::getDecomposedLoc(), clang::SourceManager::getLocForStartOfFile(), getNumConcatenated(), clang::StringLiteralParser::getOffsetOfStringByte(), clang::SourceManager::getSpellingLoc(), clang::StringLiteralParser::GetStringLength(), and getStrTokenLoc().
Referenced by getAsmSrcLocInfo(), and clang::Sema::getLocationOfStringLiteralByte().
| unsigned clang::StringLiteral::getNumConcatenated | ( | ) | const [inline] |
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation phase #6 to form this string literal.
Definition at line 1436 of file Expr.h.
Referenced by getLocationOfByte().
| SourceRange clang::StringLiteral::getSourceRange | ( | ) | const [inline] |
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpreted by SourceManager. We assume AST clients will have a pointer to the respective SourceManager.
Reimplemented from clang::Stmt.
Definition at line 1462 of file Expr.h.
Referenced by clang::Sema::ActOnAsmStmt(), clang::Sema::BuildObjCStringLiteral(), and clang::Sema::ParseObjCStringLiteral().
| StringRef clang::StringLiteral::getString | ( | ) | const [inline] |
Definition at line 1378 of file Expr.h.
References getByteLength().
Referenced by clang::Sema::ActOnAsmStmt(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnVariableDeclarator(), clang::AsmStmt::AnalyzeAsmString(), clang::Sema::CheckCallingConvAttr(), containsNonAsciiOrNull(), clang::CodeGen::CodeGenFunction::EmitAsmStmt(), clang::CodeGen::CodeGenModule::EmitTopLevelDecl(), clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromLiteral(), getAsmSrcLocInfo(), clang::CodeGen::CodeGenModule::GetConstantArrayFromStringLiteral(), GetConstantCFStringEntry(), GetConstantStringEntry(), clang::AsmStmt::getInputConstraint(), clang::AsmStmt::getOutputConstraint(), handleAliasAttr(), handleAnnotateAttr(), handleAttrWithMessage(), handleAvailabilityAttr(), handleCallConvAttr(), handleSectionAttr(), handleUuidAttr(), handleVisibilityAttr(), handleWeakRefAttr(), clang::Sema::ParseObjCStringLiteral(), and TryEvaluateBuiltinNaN().
| SourceLocation clang::StringLiteral::getStrTokenLoc | ( | unsigned | TokNum | ) | const [inline] |
Definition at line 1438 of file Expr.h.
Referenced by clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnVariableDeclarator(), and getLocationOfByte().
| bool clang::StringLiteral::isAscii | ( | ) | const [inline] |
Definition at line 1419 of file Expr.h.
References Ascii.
Referenced by clang::Sema::ActOnAsmStmt(), clang::Sema::CheckCallingConvAttr(), clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromLiteral(), handleAliasAttr(), handleCallConvAttr(), handleUuidAttr(), handleVisibilityAttr(), handleWeakRefAttr(), MakeObjCStringLiteralFixItHint(), clang::Sema::ParseObjCStringLiteral(), and SemaBuiltinAnnotation().
| bool clang::StringLiteral::isUTF16 | ( | ) | const [inline] |
| bool clang::StringLiteral::isUTF32 | ( | ) | const [inline] |
| bool clang::StringLiteral::isUTF8 | ( | ) | const [inline] |
Definition at line 1421 of file Expr.h.
References UTF8.
Referenced by clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromLiteral().
| bool clang::StringLiteral::isWide | ( | ) | const [inline] |
| void StringLiteral::setString | ( | ASTContext & | C, |
| StringRef | Str, | ||
| StringKind | Kind, | ||
| bool | IsPascal | ||
| ) |
Sets the string data to the given string data.
Definition at line 636 of file Expr.cpp.
References clang::ASTContext::getTargetInfo().
Referenced by Create().
| void clang::StringLiteral::setStrTokenLoc | ( | unsigned | TokNum, |
| SourceLocation | L | ||
| ) | [inline] |
| tokloc_iterator clang::StringLiteral::tokloc_begin | ( | ) | const [inline] |
Definition at line 1459 of file Expr.h.
Referenced by clang::Sema::ParseObjCStringLiteral().
| tokloc_iterator clang::StringLiteral::tokloc_end | ( | ) | const [inline] |
Definition at line 1460 of file Expr.h.
Referenced by clang::Sema::ParseObjCStringLiteral().
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.
| const char* clang::StringLiteral::asChar |
| const uint16_t* clang::StringLiteral::asUInt16 |
| const uint32_t* clang::StringLiteral::asUInt32 |