зеркало из https://github.com/microsoft/clang-1.git
Connect ASTContext to TargetInfo when determining the size_t, ptrdiff_t, and wchar_t types. Fixes recent breakage on Linux.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58609 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
8f6ce5796f
Коммит
b4e66d5259
|
@ -15,6 +15,7 @@
|
||||||
#define LLVM_CLANG_AST_ASTCONTEXT_H
|
#define LLVM_CLANG_AST_ASTCONTEXT_H
|
||||||
|
|
||||||
#include "clang/Basic/LangOptions.h"
|
#include "clang/Basic/LangOptions.h"
|
||||||
|
#include "clang/Basic/TargetInfo.h"
|
||||||
#include "clang/AST/Builtins.h"
|
#include "clang/AST/Builtins.h"
|
||||||
#include "clang/AST/DeclBase.h"
|
#include "clang/AST/DeclBase.h"
|
||||||
#include "clang/AST/Type.h"
|
#include "clang/AST/Type.h"
|
||||||
|
@ -33,7 +34,6 @@ namespace clang {
|
||||||
class ASTRecordLayout;
|
class ASTRecordLayout;
|
||||||
class Expr;
|
class Expr;
|
||||||
class IdentifierTable;
|
class IdentifierTable;
|
||||||
class TargetInfo;
|
|
||||||
class SelectorTable;
|
class SelectorTable;
|
||||||
class SourceManager;
|
class SourceManager;
|
||||||
// Decls
|
// Decls
|
||||||
|
@ -319,6 +319,8 @@ public:
|
||||||
void setBuiltinVaListType(QualType T);
|
void setBuiltinVaListType(QualType T);
|
||||||
QualType getBuiltinVaListType() const { return BuiltinVaListType; }
|
QualType getBuiltinVaListType() const { return BuiltinVaListType; }
|
||||||
|
|
||||||
|
QualType getFromTargetType(TargetInfo::IntType Type) const;
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Type Predicates.
|
// Type Predicates.
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
|
@ -1090,9 +1090,7 @@ QualType ASTContext::getTagDeclType(TagDecl *Decl) {
|
||||||
/// of the sizeof operator (C99 6.5.3.4p4). The value is target dependent and
|
/// of the sizeof operator (C99 6.5.3.4p4). The value is target dependent and
|
||||||
/// needs to agree with the definition in <stddef.h>.
|
/// needs to agree with the definition in <stddef.h>.
|
||||||
QualType ASTContext::getSizeType() const {
|
QualType ASTContext::getSizeType() const {
|
||||||
// On Darwin, size_t is defined as a "long unsigned int".
|
return getFromTargetType(Target.getSizeType());
|
||||||
// FIXME: should derive from "Target".
|
|
||||||
return UnsignedLongTy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getWCharType - Return the unique type for "wchar_t" (C99 7.17), the
|
/// getWCharType - Return the unique type for "wchar_t" (C99 7.17), the
|
||||||
|
@ -1102,9 +1100,9 @@ QualType ASTContext::getWCharType() const {
|
||||||
if (LangOpts.CPlusPlus)
|
if (LangOpts.CPlusPlus)
|
||||||
return WCharTy;
|
return WCharTy;
|
||||||
|
|
||||||
// On Darwin, wchar_t is defined as a "int".
|
// FIXME: In C, shouldn't WCharTy just be a typedef of the target's
|
||||||
// FIXME: should derive from "Target".
|
// wide-character type?
|
||||||
return IntTy;
|
return getFromTargetType(Target.getWCharType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getSignedWCharType - Return the type of "signed wchar_t".
|
/// getSignedWCharType - Return the type of "signed wchar_t".
|
||||||
|
@ -1124,9 +1122,7 @@ QualType ASTContext::getUnsignedWCharType() const {
|
||||||
/// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?)
|
/// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?)
|
||||||
/// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
|
/// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
|
||||||
QualType ASTContext::getPointerDiffType() const {
|
QualType ASTContext::getPointerDiffType() const {
|
||||||
// On Darwin, ptrdiff_t is defined as a "int". This seems like a bug...
|
return getFromTargetType(Target.getPtrDiffType(0));
|
||||||
// FIXME: should derive from "Target".
|
|
||||||
return IntTy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1796,6 +1792,23 @@ void ASTContext::setObjCConstantStringInterface(ObjCInterfaceDecl *Decl) {
|
||||||
ObjCConstantStringType = getObjCInterfaceType(Decl);
|
ObjCConstantStringType = getObjCInterfaceType(Decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getFromTargetType - Given one of the integer types provided by
|
||||||
|
/// TargetInfo, produce the corresponding type.
|
||||||
|
QualType ASTContext::getFromTargetType(TargetInfo::IntType Type) const {
|
||||||
|
switch (Type) {
|
||||||
|
case TargetInfo::NoInt: return QualType();
|
||||||
|
case TargetInfo::SignedShort: return ShortTy;
|
||||||
|
case TargetInfo::UnsignedShort: return UnsignedShortTy;
|
||||||
|
case TargetInfo::SignedInt: return IntTy;
|
||||||
|
case TargetInfo::UnsignedInt: return UnsignedIntTy;
|
||||||
|
case TargetInfo::SignedLong: return LongTy;
|
||||||
|
case TargetInfo::UnsignedLong: return UnsignedLongTy;
|
||||||
|
case TargetInfo::SignedLongLong: return LongLongTy;
|
||||||
|
case TargetInfo::UnsignedLongLong: return UnsignedLongLongTy;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false && "Unhandled TargetInfo::IntType value");
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Type Predicates.
|
// Type Predicates.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче