[cfe-commits] r65590 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp

Chris Lattner sabre at nondot.org
Thu Feb 26 15:43:47 PST 2009


Author: lattner
Date: Thu Feb 26 17:43:47 2009
New Revision: 65590

URL: http://llvm.org/viewvc/llvm-project?rev=65590&view=rev
Log:
make ASTContext::WCharTy a bit more sensical.  In C++, it is a disctint type,
but in C99 it is just another int type.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=65590&r1=65589&r2=65590&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Feb 26 17:43:47 2009
@@ -160,7 +160,7 @@
   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 @@
   /// 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.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=65590&r1=65589&r2=65590&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Feb 26 17:43:47 2009
@@ -213,8 +213,10 @@
   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 @@
   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 {





More information about the cfe-commits mailing list