diff options
-rw-r--r-- | clang/include/clang/AST/ASTContext.h | 9 | ||||
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 16 |
2 files changed, 9 insertions, 16 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 387120ea3d2..74a999366bb 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/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 <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. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f76d320c386..d059201b5cd 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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 <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 { |