]> granicus.if.org Git - clang/commitdiff
make ASTContext::WCharTy a bit more sensical. In C++, it is a disctint type,
authorChris Lattner <sabre@nondot.org>
Thu, 26 Feb 2009 23:43:47 +0000 (23:43 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 26 Feb 2009 23:43:47 +0000 (23:43 +0000)
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

include/clang/AST/ASTContext.h
lib/AST/ASTContext.cpp

index 387120ea3d2f4aed9fb580fca8b981fd71fa3fb7..74a999366bb9f031dffec4d4c0b3a2673ced0194 100644 (file)
@@ -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 <stddef.h>. 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 <stddef.h>. 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 <stddef.h> 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.
index f76d320c3864965ce7270e1a20bf05ec77213844..d059201b5cdfd03dd55041687afc78947d596feb 100644 (file)
@@ -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 <stddef.h>.
-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 {