MarcusJohnson91 updated this revision to Diff 359590.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103426/new/
https://reviews.llvm.org/D103426
Files:
clang/include/clang/AST/Expr.h
clang/include/clang/AST/FormatString.h
clang/include/clang/AST/Type.h
clang/lib/AST/Expr.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/AST/Type.cpp
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -1962,18 +1962,6 @@
return false;
}
-bool Type::isType(const std::string TypeName) const {
- QualType Desugar = this->getLocallyUnqualifiedSingleStepDesugaredType();
-
-
- while (!Desugar->isCanonicalUnqualified()) {
- if (Desugar.getAsString() == TypeName) {
- return true;
- }
- Desugar = Desugar->getLocallyUnqualifiedSingleStepDesugaredType();
- }
-}
-
bool Type::isChar8Type() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Char8;
@@ -1985,7 +1973,15 @@
if (BT->getKind() == BuiltinType::Char16)
return true;
if (!LangOpts.CPlusPlus) {
- return isType("char16_t");
+ QualType Desugar = this->getLocallyUnqualifiedSingleStepDesugaredType();
+
+
+ while (!Desugar->isCanonicalUnqualified()) {
+ if (Desugar.getAsString() == "char16_t") {
+ return true;
+ }
+ Desugar = Desugar->getLocallyUnqualifiedSingleStepDesugaredType();
+ }
}
return false;
}
@@ -1995,7 +1991,14 @@
if (BT->getKind() == BuiltinType::Char32)
return true;
if (!LangOpts.CPlusPlus) {
- return isType("char32_t");
+ QualType Desugar = this->getLocallyUnqualifiedSingleStepDesugaredType();
+
+ while (!Desugar->isCanonicalUnqualified()) {
+ if (Desugar.getAsString() == "char32_t") {
+ return true;
+ }
+ Desugar = Desugar->getLocallyUnqualifiedSingleStepDesugaredType();
+ }
}
return false;
}
Index: clang/lib/AST/PrintfFormatString.cpp
===================================================================
--- clang/lib/AST/PrintfFormatString.cpp
+++ clang/lib/AST/PrintfFormatString.cpp
@@ -643,6 +643,9 @@
"const unichar *");
return ArgType(ArgType::WCStrTy, "wchar_t *");
}
+ if (LM.getKind() == LengthModifier::AsWide) {
+ return ArgType(ArgType::WCStrTy, "wchar_t *");
+ }
if (LM.getKind() == LengthModifier::AsUTF16)
return ArgType(ArgType::Char16Ty, "char16_t *");
if (LM.getKind() == LengthModifier::AsUTF32)
@@ -860,6 +863,9 @@
LM.setKind(LengthModifier::AsLongDouble);
break;
+ case BuiltinType::Char8:
+ LM.setKind(LengthModifier::AsUTF8);
+
case BuiltinType::Char16:
LM.setKind(LengthModifier::AsUTF16);
break;
Index: clang/lib/AST/Expr.cpp
===================================================================
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1331,6 +1331,8 @@
const LangOptions &Features,
const TargetInfo &Target, unsigned *StartToken,
unsigned *StartTokenByteOffset) const {
+ assert((getKind() == StringLiteral::Ascii || getKind() == StringLiteral::UTF8) &&
+ "Only narrow string literals are currently supported");
// Loop over all of the tokens in this string until we find the one that
// contains the byte we're looking for.
unsigned TokNo = 0;
Index: clang/include/clang/AST/Type.h
===================================================================
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1972,7 +1972,6 @@
/// Determine whether this type is a scoped enumeration type.
bool isScopedEnumeralType() const;
bool isBooleanType() const;
- bool isType(const std::string TypeName) const;
bool isCharType() const;
bool isChar8Type() const;
bool isWideCharType() const;
Index: clang/include/clang/AST/FormatString.h
===================================================================
--- clang/include/clang/AST/FormatString.h
+++ clang/include/clang/AST/FormatString.h
@@ -80,8 +80,8 @@
AsLongDouble, // 'L'
AsAllocate, // for '%as', GNU extension to C90 scanf
AsMAllocate, // for '%ms', GNU extension to scanf
- AsUTF16, // for '%l16(c|s)', soon to be standardized
- AsUTF32, // for '%l32(c|s)', soon to be standardized
+ AsUTF16, // for '%l16(c|s)', Clang extension
+ AsUTF32, // for '%l32(c|s)', Clang extension
AsWide, // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
AsWideChar = AsLong // for '%ls', only makes sense for printf
};
Index: clang/include/clang/AST/Expr.h
===================================================================
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -1850,21 +1850,18 @@
std::u16string getStringAsChar16() const {
assert(getCharByteWidth() == 2 &&
"This function is used in places that assume strings use char16_t");
- //return reinterpret_cast<const char16_t *>(getTrailingObjects<char>());
return std::u16string(reinterpret_cast<const char16_t *>(getTrailingObjects<char>()), reinterpret_cast<const char16_t *>(getTrailingObjects<char>() + getByteLength()));
}
std::u32string getStringAsChar32() const {
assert(getCharByteWidth() == 4 &&
"This function is used in places that assume strings use char32_t");
- //return reinterpret_cast<const char32_t *>(getTrailingObjects<char>());
return std::u32string(reinterpret_cast<const char32_t *>(getTrailingObjects<char>()), reinterpret_cast<const char32_t *>(getTrailingObjects<char>() + getByteLength()));
}
std::wstring getStringAsWChar() const {
assert((getCharByteWidth() == 2 || getCharByteWidth() == 4) &&
"This function is used in places that assume strings use wchar_t");
- //return reinterpret_cast<const wchar_t *>(getTrailingObjects<char>());
return std::wstring(reinterpret_cast<const wchar_t *>(getTrailingObjects<char>()), reinterpret_cast<const wchar_t *>(getTrailingObjects<char>() + getByteLength()));
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits