зеркало из https://github.com/microsoft/clang-1.git
change IsStringLiteralInit into a static function in SemaInit.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65395 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
dd8e006520
Коммит
6c291a88bc
|
@ -1897,7 +1897,6 @@ public:
|
||||||
bool CheckAddressConstantExpressionLValue(const Expr* e);
|
bool CheckAddressConstantExpressionLValue(const Expr* e);
|
||||||
void InitializerElementNotConstant(const Expr *e);
|
void InitializerElementNotConstant(const Expr *e);
|
||||||
|
|
||||||
StringLiteral *IsStringLiteralInit(Expr *Init, QualType DeclType);
|
|
||||||
bool CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT);
|
bool CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT);
|
||||||
bool CheckValueInitialization(QualType Type, SourceLocation Loc);
|
bool CheckValueInitialization(QualType Type, SourceLocation Loc);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ using namespace clang;
|
||||||
// Sema Initialization Checking
|
// Sema Initialization Checking
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
StringLiteral *Sema::IsStringLiteralInit(Expr *Init, QualType DeclType) {
|
static StringLiteral *IsStringInit(Expr *Init, QualType DeclType,
|
||||||
|
ASTContext &Context) {
|
||||||
if (const ArrayType *AT = Context.getAsArrayType(DeclType))
|
if (const ArrayType *AT = Context.getAsArrayType(DeclType))
|
||||||
if (AT->getElementType()->isCharType())
|
if (AT->getElementType()->isCharType())
|
||||||
return dyn_cast<StringLiteral>(Init->IgnoreParens());
|
return dyn_cast<StringLiteral>(Init->IgnoreParens());
|
||||||
|
@ -105,7 +106,7 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
|
||||||
InitListExpr *InitList = dyn_cast<InitListExpr>(Init);
|
InitListExpr *InitList = dyn_cast<InitListExpr>(Init);
|
||||||
if (!InitList) {
|
if (!InitList) {
|
||||||
// FIXME: Handle wide strings
|
// FIXME: Handle wide strings
|
||||||
if (StringLiteral *StrLiteral = IsStringLiteralInit(Init, DeclType))
|
if (StringLiteral *StrLiteral = IsStringInit(Init, DeclType, Context))
|
||||||
return CheckStringLiteralInit(StrLiteral, DeclType);
|
return CheckStringLiteralInit(StrLiteral, DeclType);
|
||||||
|
|
||||||
// C++ [dcl.init]p14:
|
// C++ [dcl.init]p14:
|
||||||
|
@ -475,7 +476,7 @@ void InitListChecker::CheckExplicitInitList(InitListExpr *IList, QualType &T,
|
||||||
if (Index < IList->getNumInits()) {
|
if (Index < IList->getNumInits()) {
|
||||||
// We have leftover initializers
|
// We have leftover initializers
|
||||||
if (IList->getNumInits() > 0 &&
|
if (IList->getNumInits() > 0 &&
|
||||||
SemaRef->IsStringLiteralInit(IList->getInit(Index), T)) {
|
IsStringInit(IList->getInit(Index), T, SemaRef->Context)) {
|
||||||
unsigned DK = diag::warn_excess_initializers_in_char_array_initializer;
|
unsigned DK = diag::warn_excess_initializers_in_char_array_initializer;
|
||||||
if (SemaRef->getLangOptions().CPlusPlus)
|
if (SemaRef->getLangOptions().CPlusPlus)
|
||||||
DK = diag::err_excess_initializers_in_char_array_initializer;
|
DK = diag::err_excess_initializers_in_char_array_initializer;
|
||||||
|
@ -579,8 +580,8 @@ void InitListChecker::CheckSubElementType(InitListExpr *IList,
|
||||||
newStructuredList, newStructuredIndex);
|
newStructuredList, newStructuredIndex);
|
||||||
++StructuredIndex;
|
++StructuredIndex;
|
||||||
++Index;
|
++Index;
|
||||||
} else if (StringLiteral *lit =
|
} else if (StringLiteral *lit = IsStringInit(expr, ElemType,
|
||||||
SemaRef->IsStringLiteralInit(expr, ElemType)) {
|
SemaRef->Context)) {
|
||||||
SemaRef->CheckStringLiteralInit(lit, ElemType);
|
SemaRef->CheckStringLiteralInit(lit, ElemType);
|
||||||
UpdateStructuredListElement(StructuredList, StructuredIndex, lit);
|
UpdateStructuredListElement(StructuredList, StructuredIndex, lit);
|
||||||
++Index;
|
++Index;
|
||||||
|
@ -765,8 +766,8 @@ void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
|
||||||
unsigned &StructuredIndex) {
|
unsigned &StructuredIndex) {
|
||||||
// Check for the special-case of initializing an array with a string.
|
// Check for the special-case of initializing an array with a string.
|
||||||
if (Index < IList->getNumInits()) {
|
if (Index < IList->getNumInits()) {
|
||||||
if (StringLiteral *lit =
|
if (StringLiteral *lit = IsStringInit(IList->getInit(Index), DeclType,
|
||||||
SemaRef->IsStringLiteralInit(IList->getInit(Index), DeclType)) {
|
SemaRef->Context)) {
|
||||||
SemaRef->CheckStringLiteralInit(lit, DeclType);
|
SemaRef->CheckStringLiteralInit(lit, DeclType);
|
||||||
// We place the string literal directly into the resulting
|
// We place the string literal directly into the resulting
|
||||||
// initializer list. This is the only place where the structure
|
// initializer list. This is the only place where the structure
|
||||||
|
|
Загрузка…
Ссылка в новой задаче