r290009 - Fix MSVC build of libclang after r288438
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 16 15:44:44 PST 2016
Author: rnk
Date: Fri Dec 16 17:44:44 2016
New Revision: 290009
URL: http://llvm.org/viewvc/llvm-project?rev=290009&view=rev
Log:
Fix MSVC build of libclang after r288438
Modified:
cfe/trunk/tools/libclang/CXType.cpp
Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=290009&r1=290008&r2=290009&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Fri Dec 16 17:44:44 2016
@@ -143,6 +143,45 @@ static inline CXTranslationUnit GetTU(CX
return static_cast<CXTranslationUnit>(CT.data[1]);
}
+static Optional<ArrayRef<TemplateArgument>>
+GetTemplateArguments(QualType Type) {
+ assert(!Type.isNull());
+ if (const auto *Specialization = Type->getAs<TemplateSpecializationType>())
+ return Specialization->template_arguments();
+
+ if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
+ const auto *TemplateDecl =
+ dyn_cast<ClassTemplateSpecializationDecl>(RecordDecl);
+ if (TemplateDecl)
+ return TemplateDecl->getTemplateArgs().asArray();
+ }
+
+ return None;
+}
+
+static Optional<QualType> TemplateArgumentToQualType(const TemplateArgument &A) {
+ if (A.getKind() == TemplateArgument::Type)
+ return A.getAsType();
+ return None;
+}
+
+static Optional<QualType>
+FindTemplateArgumentTypeAt(ArrayRef<TemplateArgument> TA, unsigned index) {
+ unsigned current = 0;
+ for (const auto &A : TA) {
+ if (A.getKind() == TemplateArgument::Pack) {
+ if (index < current + A.pack_size())
+ return TemplateArgumentToQualType(A.getPackAsArray()[index - current]);
+ current += A.pack_size();
+ continue;
+ }
+ if (current == index)
+ return TemplateArgumentToQualType(A);
+ current++;
+ }
+ return None;
+}
+
extern "C" {
CXType clang_getCursorType(CXCursor C) {
@@ -920,22 +959,6 @@ CXString clang_getDeclObjCTypeEncoding(C
return cxstring::createDup(encoding);
}
-static Optional<ArrayRef<TemplateArgument>>
-GetTemplateArguments(QualType Type) {
- assert(!Type.isNull());
- if (const auto *Specialization = Type->getAs<TemplateSpecializationType>())
- return Specialization->template_arguments();
-
- if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
- const auto *TemplateDecl =
- dyn_cast<ClassTemplateSpecializationDecl>(RecordDecl);
- if (TemplateDecl)
- return TemplateDecl->getTemplateArgs().asArray();
- }
-
- return None;
-}
-
static unsigned GetTemplateArgumentArraySize(ArrayRef<TemplateArgument> TA) {
unsigned size = TA.size();
for (const auto &Arg : TA)
@@ -956,29 +979,6 @@ int clang_Type_getNumTemplateArguments(C
return GetTemplateArgumentArraySize(TA.getValue());
}
-static Optional<QualType> TemplateArgumentToQualType(const TemplateArgument &A) {
- if (A.getKind() == TemplateArgument::Type)
- return A.getAsType();
- return None;
-}
-
-static Optional<QualType>
-FindTemplateArgumentTypeAt(ArrayRef<TemplateArgument> TA, unsigned index) {
- unsigned current = 0;
- for (const auto &A : TA) {
- if (A.getKind() == TemplateArgument::Pack) {
- if (index < current + A.pack_size())
- return TemplateArgumentToQualType(A.getPackAsArray()[index - current]);
- current += A.pack_size();
- continue;
- }
- if (current == index)
- return TemplateArgumentToQualType(A);
- current++;
- }
- return None;
-}
-
CXType clang_Type_getTemplateArgumentAsType(CXType CT, unsigned index) {
QualType T = GetQualType(CT);
if (T.isNull())
More information about the cfe-commits
mailing list