From: Chris Lattner Date: Thu, 26 Feb 2009 23:43:47 +0000 (+0000) Subject: make ASTContext::WCharTy a bit more sensical. In C++, it is a disctint type, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a2503227c3db04a3619735127483263c1075ef7;p=clang make ASTContext::WCharTy a bit more sensical. In C++, it is a disctint type, but in C99 it is just another int type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65590 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 387120ea3d..74a999366b 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -160,7 +160,7 @@ public: QualType VoidTy; QualType BoolTy; QualType CharTy; - QualType WCharTy; // [C++ 3.9.1p5] + QualType WCharTy; // [C++ 3.9.1p5], integer type in C99. QualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy; QualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; QualType UnsignedLongLongTy; @@ -304,9 +304,10 @@ public: /// in . The sizeof operator requires this (C99 6.5.3.4p4). QualType getSizeType() const; - /// getWCharType - Return the unique type for "wchar_t" (C99 7.17), defined - /// in . Wide strings require this (C99 6.4.5p5). - QualType getWCharType() const; + /// getWCharType - In C++, this returns the unique wchar_t type. In C99, this + /// returns a type compatible with the type defined in as defined + /// by the target. + QualType getWCharType() const { return WCharTy; } /// getSignedWCharType - Return the type of "signed wchar_t". /// Used when in C++, as a GCC extension. diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index f76d320c38..d059201b5c 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -213,8 +213,10 @@ void ASTContext::InitBuiltinTypes() { InitBuiltinType(DoubleTy, BuiltinType::Double); InitBuiltinType(LongDoubleTy, BuiltinType::LongDouble); - // C++ 3.9.1p5 - InitBuiltinType(WCharTy, BuiltinType::WChar); + if (LangOpts.CPlusPlus) // C++ 3.9.1p5 + InitBuiltinType(WCharTy, BuiltinType::WChar); + else // C99 + WCharTy = getFromTargetType(Target.getWCharType()); // Placeholder type for functions. InitBuiltinType(OverloadTy, BuiltinType::Overload); @@ -1437,16 +1439,6 @@ QualType ASTContext::getSizeType() const { return getFromTargetType(Target.getSizeType()); } -/// getWCharType - Return the unique type for "wchar_t" (C99 7.17), the -/// width of characters in wide strings, The value is target dependent and -/// needs to agree with the definition in . -QualType ASTContext::getWCharType() const { - if (LangOpts.CPlusPlus) - return WCharTy; - - return getFromTargetType(Target.getWCharType()); -} - /// getSignedWCharType - Return the type of "signed wchar_t". /// Used when in C++, as a GCC extension. QualType ASTContext::getSignedWCharType() const {