зеркало из https://github.com/microsoft/clang.git
Merge commit '1db40ee0042d3ff4ca47ec282fadf5870268e397' into HEAD
This commit is contained in:
Коммит
2d5ab8398c
|
@ -6187,7 +6187,8 @@ bool IntExprEvaluator::CheckReferencedDecl(const Expr* E, const Decl* D) {
|
|||
|
||||
/// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
|
||||
/// as GCC.
|
||||
static int EvaluateBuiltinClassifyType(const CallExpr *E) {
|
||||
static int EvaluateBuiltinClassifyType(const CallExpr *E,
|
||||
const LangOptions &LangOpts) {
|
||||
// The following enum mimics the values returned by GCC.
|
||||
// FIXME: Does GCC differ between lvalue and rvalue references here?
|
||||
enum gcc_type_class {
|
||||
|
@ -6207,37 +6208,132 @@ static int EvaluateBuiltinClassifyType(const CallExpr *E) {
|
|||
if (E->getNumArgs() == 0)
|
||||
return no_type_class;
|
||||
|
||||
QualType ArgTy = E->getArg(0)->getType();
|
||||
if (ArgTy->isVoidType())
|
||||
return void_type_class;
|
||||
else if (ArgTy->isEnumeralType())
|
||||
return enumeral_type_class;
|
||||
else if (ArgTy->isBooleanType())
|
||||
return boolean_type_class;
|
||||
else if (ArgTy->isCharType())
|
||||
return string_type_class; // gcc doesn't appear to use char_type_class
|
||||
else if (ArgTy->isIntegerType())
|
||||
return integer_type_class;
|
||||
else if (ArgTy->isPointerType())
|
||||
QualType CanTy = E->getArg(0)->getType().getCanonicalType();
|
||||
const BuiltinType *BT = dyn_cast<BuiltinType>(CanTy);
|
||||
|
||||
switch (CanTy->getTypeClass()) {
|
||||
#define TYPE(ID, BASE)
|
||||
#define DEPENDENT_TYPE(ID, BASE) case Type::ID:
|
||||
#define NON_CANONICAL_TYPE(ID, BASE) case Type::ID:
|
||||
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(ID, BASE) case Type::ID:
|
||||
#include "clang/AST/TypeNodes.def"
|
||||
llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
|
||||
|
||||
case Type::Builtin:
|
||||
switch (BT->getKind()) {
|
||||
#define BUILTIN_TYPE(ID, SINGLETON_ID)
|
||||
#define SIGNED_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return integer_type_class;
|
||||
#define FLOATING_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return real_type_class;
|
||||
#define PLACEHOLDER_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: break;
|
||||
#include "clang/AST/BuiltinTypes.def"
|
||||
case BuiltinType::Void:
|
||||
return void_type_class;
|
||||
|
||||
case BuiltinType::Bool:
|
||||
return boolean_type_class;
|
||||
|
||||
case BuiltinType::Char_U: // gcc doesn't appear to use char_type_class
|
||||
case BuiltinType::UChar:
|
||||
case BuiltinType::UShort:
|
||||
case BuiltinType::UInt:
|
||||
case BuiltinType::ULong:
|
||||
case BuiltinType::ULongLong:
|
||||
case BuiltinType::UInt128:
|
||||
return integer_type_class;
|
||||
|
||||
case BuiltinType::NullPtr:
|
||||
return pointer_type_class;
|
||||
|
||||
case BuiltinType::WChar_U:
|
||||
case BuiltinType::Char16:
|
||||
case BuiltinType::Char32:
|
||||
case BuiltinType::ObjCId:
|
||||
case BuiltinType::ObjCClass:
|
||||
case BuiltinType::ObjCSel:
|
||||
case BuiltinType::OCLImage1d:
|
||||
case BuiltinType::OCLImage1dArray:
|
||||
case BuiltinType::OCLImage2d:
|
||||
case BuiltinType::OCLImage2dArray:
|
||||
case BuiltinType::OCLImage1dBuffer:
|
||||
case BuiltinType::OCLImage2dDepth:
|
||||
case BuiltinType::OCLImage2dArrayDepth:
|
||||
case BuiltinType::OCLImage2dMSAA:
|
||||
case BuiltinType::OCLImage2dArrayMSAA:
|
||||
case BuiltinType::OCLImage2dMSAADepth:
|
||||
case BuiltinType::OCLImage2dArrayMSAADepth:
|
||||
case BuiltinType::OCLImage3d:
|
||||
case BuiltinType::OCLSampler:
|
||||
case BuiltinType::OCLEvent:
|
||||
case BuiltinType::OCLClkEvent:
|
||||
case BuiltinType::OCLQueue:
|
||||
case BuiltinType::OCLNDRange:
|
||||
case BuiltinType::OCLReserveID:
|
||||
case BuiltinType::Dependent:
|
||||
llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
|
||||
};
|
||||
|
||||
case Type::Enum:
|
||||
return LangOpts.CPlusPlus ? enumeral_type_class : integer_type_class;
|
||||
break;
|
||||
|
||||
case Type::Pointer:
|
||||
return pointer_type_class;
|
||||
else if (ArgTy->isReferenceType())
|
||||
return reference_type_class;
|
||||
else if (ArgTy->isRealType())
|
||||
return real_type_class;
|
||||
else if (ArgTy->isComplexType())
|
||||
break;
|
||||
|
||||
case Type::MemberPointer:
|
||||
if (CanTy->isMemberDataPointerType())
|
||||
return offset_type_class;
|
||||
else {
|
||||
// We expect member pointers to be either data or function pointers,
|
||||
// nothing else.
|
||||
assert(CanTy->isMemberFunctionPointerType());
|
||||
return method_type_class;
|
||||
}
|
||||
|
||||
case Type::Complex:
|
||||
return complex_type_class;
|
||||
else if (ArgTy->isFunctionType())
|
||||
return function_type_class;
|
||||
else if (ArgTy->isStructureOrClassType())
|
||||
return record_type_class;
|
||||
else if (ArgTy->isUnionType())
|
||||
return union_type_class;
|
||||
else if (ArgTy->isArrayType())
|
||||
return array_type_class;
|
||||
else if (ArgTy->isUnionType())
|
||||
return union_type_class;
|
||||
else // FIXME: offset_type_class, method_type_class, & lang_type_class?
|
||||
|
||||
case Type::FunctionNoProto:
|
||||
case Type::FunctionProto:
|
||||
return LangOpts.CPlusPlus ? function_type_class : pointer_type_class;
|
||||
|
||||
case Type::Record:
|
||||
if (const RecordType *RT = CanTy->getAs<RecordType>()) {
|
||||
switch (RT->getDecl()->getTagKind()) {
|
||||
case TagTypeKind::TTK_Struct:
|
||||
case TagTypeKind::TTK_Class:
|
||||
case TagTypeKind::TTK_Interface:
|
||||
return record_type_class;
|
||||
|
||||
case TagTypeKind::TTK_Enum:
|
||||
return LangOpts.CPlusPlus ? enumeral_type_class : integer_type_class;
|
||||
|
||||
case TagTypeKind::TTK_Union:
|
||||
return union_type_class;
|
||||
}
|
||||
}
|
||||
llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
|
||||
|
||||
case Type::ConstantArray:
|
||||
case Type::VariableArray:
|
||||
case Type::IncompleteArray:
|
||||
return LangOpts.CPlusPlus ? array_type_class : pointer_type_class;
|
||||
|
||||
case Type::BlockPointer:
|
||||
case Type::LValueReference:
|
||||
case Type::RValueReference:
|
||||
case Type::Vector:
|
||||
case Type::ExtVector:
|
||||
case Type::Auto:
|
||||
case Type::ObjCObject:
|
||||
case Type::ObjCInterface:
|
||||
case Type::ObjCObjectPointer:
|
||||
case Type::Pipe:
|
||||
case Type::Atomic:
|
||||
llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
|
||||
}
|
||||
|
||||
llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
|
||||
}
|
||||
|
||||
/// EvaluateBuiltinConstantPForLValue - Determine the result of
|
||||
|
@ -6609,7 +6705,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) {
|
|||
}
|
||||
|
||||
case Builtin::BI__builtin_classify_type:
|
||||
return Success(EvaluateBuiltinClassifyType(E), E);
|
||||
return Success(EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
|
||||
|
||||
// FIXME: BI__builtin_clrsb
|
||||
// FIXME: BI__builtin_clrsbl
|
||||
|
|
|
@ -1060,7 +1060,7 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
|
|||
}
|
||||
|
||||
if (!Args.getLastArg(options::OPT_stdlib_EQ) &&
|
||||
GetDefaultCXXStdlibType() == ToolChain::CST_Libcxx)
|
||||
GetCXXStdlibType(Args) == ToolChain::CST_Libcxx)
|
||||
DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_stdlib_EQ),
|
||||
"libc++");
|
||||
|
||||
|
|
|
@ -559,7 +559,10 @@ bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI,
|
|||
StringRef Filename) {
|
||||
WrappedAction->setCurrentInput(getCurrentInput());
|
||||
WrappedAction->setCompilerInstance(&CI);
|
||||
return WrappedAction->BeginSourceFileAction(CI, Filename);
|
||||
auto Ret = WrappedAction->BeginSourceFileAction(CI, Filename);
|
||||
// BeginSourceFileAction may change CurrentInput, e.g. during module builds.
|
||||
setCurrentInput(WrappedAction->getCurrentInput());
|
||||
return Ret;
|
||||
}
|
||||
void WrapperFrontendAction::ExecuteAction() {
|
||||
WrappedAction->ExecuteAction();
|
||||
|
|
|
@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok,
|
|||
|
||||
// Find the first non-whitespace character, so that we can make the
|
||||
// diagnostic more succinct.
|
||||
StringRef Msg = StringRef(Message).ltrim(" ");
|
||||
StringRef Msg = StringRef(Message).ltrim(' ');
|
||||
|
||||
if (isWarning)
|
||||
Diag(Tok, diag::pp_hash_warning) << Msg;
|
||||
|
|
|
@ -1000,7 +1000,7 @@ void EmptyLocalizationContextChecker::MethodCrawler::VisitObjCMessageExpr(
|
|||
return;
|
||||
|
||||
StringRef Comment =
|
||||
StringRef(Result.getLiteralData(), Result.getLength()).trim("\"");
|
||||
StringRef(Result.getLiteralData(), Result.getLength()).trim('"');
|
||||
|
||||
if ((Comment.trim().size() == 0 && Comment.size() > 0) || // Is Whitespace
|
||||
Comment.empty()) {
|
||||
|
|
|
@ -75,7 +75,7 @@ void MacOSXAPIChecker::CheckDispatchOnce(CheckerContext &C, const CallExpr *CE,
|
|||
// _dispatch_once is then a function which then calls the real dispatch_once.
|
||||
// Users do not care; they just want the warning at the top-level call.
|
||||
if (CE->getLocStart().isMacroID()) {
|
||||
StringRef TrimmedFName = FName.ltrim("_");
|
||||
StringRef TrimmedFName = FName.ltrim('_');
|
||||
if (TrimmedFName != FName)
|
||||
FName = TrimmedFName;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_MySecretNamespace.A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_METACLASS_$_MySecretNamespace.A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak hidden global {{.*}}
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak hidden global
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = hidden global {{.*}}, section "__DATA,__objc_const", align 8
|
||||
// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_METACLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH1" = weak hidden global {{.*}}
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH1" = weak hidden global
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH2" = external global
|
||||
// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH3" = hidden global {{.*}}, section "__DATA,__objc_const", align 8
|
||||
// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
// RUN: touch %T/ps4-ld.exe
|
||||
// RUN: touch %T/ps4-ld.gold.exe
|
||||
|
||||
// RUN: env "PATH=%T;%PATH%" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
|
||||
// RUN: env "PATH=%T;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-PS4-GOLD %s
|
||||
// RUN: env "PATH=%T;%PATH%" %clang -target x86_64-scei-ps4 %s -shared -### 2>&1 \
|
||||
// RUN: env "PATH=%T;%PATH%;" %clang -target x86_64-scei-ps4 %s -shared -### 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-PS4-GOLD %s
|
||||
|
||||
// RUN: env "PATH=%T;%PATH%" %clang -target x86_64-scei-ps4 %s -### 2>&1 \
|
||||
// RUN: env "PATH=%T;%PATH%;" %clang -target x86_64-scei-ps4 %s -### 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
|
||||
// RUN: env "PATH=%T;%PATH%" %clang -target x86_64-scei-ps4 %s -fuse-ld=ps4 -### 2>&1 \
|
||||
// RUN: env "PATH=%T;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=ps4 -### 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
|
||||
// RUN: env "PATH=%T;%PATH%" %clang -target x86_64-scei-ps4 %s -shared \
|
||||
// RUN: env "PATH=%T;%PATH%;" %clang -target x86_64-scei-ps4 %s -shared \
|
||||
// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
|
||||
|
||||
// FIXME: "Output\\" is hardcoded part of %T.
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
enum gcc_type_class {
|
||||
no_type_class = -1,
|
||||
void_type_class, integer_type_class, char_type_class,
|
||||
enumeral_type_class, boolean_type_class,
|
||||
pointer_type_class, reference_type_class, offset_type_class,
|
||||
real_type_class, complex_type_class,
|
||||
function_type_class, method_type_class,
|
||||
record_type_class, union_type_class,
|
||||
array_type_class, string_type_class,
|
||||
lang_type_class
|
||||
};
|
||||
|
||||
void foo() {
|
||||
int i;
|
||||
char c;
|
||||
enum { red, green, blue } enum_obj;
|
||||
int *p;
|
||||
double d;
|
||||
_Complex double cc;
|
||||
extern void f();
|
||||
struct { int a; float b; } s_obj;
|
||||
union { int a; float b; } u_obj;
|
||||
int arr[10];
|
||||
|
||||
int a1[__builtin_classify_type(f()) == void_type_class ? 1 : -1];
|
||||
int a2[__builtin_classify_type(i) == integer_type_class ? 1 : -1];
|
||||
int a3[__builtin_classify_type(c) == integer_type_class ? 1 : -1];
|
||||
int a4[__builtin_classify_type(enum_obj) == integer_type_class ? 1 : -1];
|
||||
int a5[__builtin_classify_type(p) == pointer_type_class ? 1 : -1];
|
||||
int a6[__builtin_classify_type(d) == real_type_class ? 1 : -1];
|
||||
int a7[__builtin_classify_type(cc) == complex_type_class ? 1 : -1];
|
||||
int a8[__builtin_classify_type(f) == pointer_type_class ? 1 : -1];
|
||||
int a0[__builtin_classify_type(s_obj) == record_type_class ? 1 : -1];
|
||||
int a10[__builtin_classify_type(u_obj) == union_type_class ? 1 : -1];
|
||||
int a11[__builtin_classify_type(arr) == pointer_type_class ? 1 : -1];
|
||||
int a12[__builtin_classify_type("abc") == pointer_type_class ? 1 : -1];
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
enum gcc_type_class {
|
||||
no_type_class = -1,
|
||||
void_type_class, integer_type_class, char_type_class,
|
||||
enumeral_type_class, boolean_type_class,
|
||||
pointer_type_class, reference_type_class, offset_type_class,
|
||||
real_type_class, complex_type_class,
|
||||
function_type_class, method_type_class,
|
||||
record_type_class, union_type_class,
|
||||
array_type_class, string_type_class,
|
||||
lang_type_class
|
||||
};
|
||||
|
||||
class cl {
|
||||
public:
|
||||
void bar() {}
|
||||
int baz;
|
||||
};
|
||||
|
||||
int builtin_result;
|
||||
|
||||
void foo() {
|
||||
int i;
|
||||
char c;
|
||||
enum { red, green, blue} enum_obj;
|
||||
bool b;
|
||||
int *p;
|
||||
int &r = i;
|
||||
double d;
|
||||
extern void f();
|
||||
cl cl_obj;
|
||||
union { int a; float b; } u_obj;
|
||||
int arr[10];
|
||||
|
||||
int a1[__builtin_classify_type(f()) == void_type_class ? 1 : -1];
|
||||
int a2[__builtin_classify_type(i) == integer_type_class ? 1 : -1];
|
||||
int a3[__builtin_classify_type(c) == integer_type_class ? 1 : -1];
|
||||
int a4[__builtin_classify_type(enum_obj) == enumeral_type_class ? 1 : -1];
|
||||
int a5[__builtin_classify_type(b) == boolean_type_class ? 1 : -1];
|
||||
int a6[__builtin_classify_type(p) == pointer_type_class ? 1 : -1];
|
||||
int a7[__builtin_classify_type(r) == integer_type_class ? 1 : -1];
|
||||
int a8[__builtin_classify_type(&cl::baz) == offset_type_class ? 1 : -1];
|
||||
int a9[__builtin_classify_type(d) == real_type_class ? 1 : -1];
|
||||
int a10[__builtin_classify_type(f) == function_type_class ? 1 : -1];
|
||||
int a11[__builtin_classify_type(&cl::bar) == method_type_class ? 1 : -1];
|
||||
int a12[__builtin_classify_type(cl_obj) == record_type_class ? 1 : -1];
|
||||
int a13[__builtin_classify_type(u_obj) == union_type_class ? 1 : -1];
|
||||
int a14[__builtin_classify_type(arr) == array_type_class ? 1 : -1];
|
||||
int a15[__builtin_classify_type("abc") == array_type_class ? 1 : -1];
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче