зеркало из https://github.com/microsoft/clang-1.git
When producing -Wuninitialized Fix-Its for pointers, prefer " = NULL"
over "= 0". Fixes <rdar://problem/9714386>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134302 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
14508ff0bf
Коммит
8ba44264e0
|
@ -486,7 +486,8 @@ static void SuggestInitializationFixit(Sema &S, const VarDecl *VD) {
|
|||
const char *initialization = 0;
|
||||
QualType VariableTy = VD->getType().getCanonicalType();
|
||||
|
||||
if (VariableTy->getAs<ObjCObjectPointerType>()) {
|
||||
if (VariableTy->isObjCObjectPointerType() ||
|
||||
VariableTy->isBlockPointerType()) {
|
||||
// Check if 'nil' is defined.
|
||||
if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("nil")))
|
||||
initialization = " = nil";
|
||||
|
@ -499,6 +500,13 @@ static void SuggestInitializationFixit(Sema &S, const VarDecl *VD) {
|
|||
initialization = " = false";
|
||||
else if (VariableTy->isEnumeralType())
|
||||
return;
|
||||
else if (VariableTy->isPointerType() || VariableTy->isMemberPointerType()) {
|
||||
// Check if 'NULL' is defined.
|
||||
if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("NULL")))
|
||||
initialization = " = NULL";
|
||||
else
|
||||
initialization = " = 0";
|
||||
}
|
||||
else if (VariableTy->isScalarType())
|
||||
initialization = " = 0";
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче