r354823 - [libclang] Fix a trivial error introduced in D57946.

2019-02-25 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Mon Feb 25 13:15:34 2019
New Revision: 354823

URL: http://llvm.org/viewvc/llvm-project?rev=354823&view=rev
Log:
[libclang] Fix a trivial error introduced in D57946.

The value for CXCursor_ConvergentAttr is not 420. I'm not really sure how easy
it is to test this, and I'm not familiar with the python bindings, just noticed
the error while looking at D57946 to write D58570.

Differential Revision: https://reviews.llvm.org/D58571

Modified:
cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=354823&r1=354822&r2=354823&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Feb 25 13:15:34 2019
@@ -1342,7 +1342,7 @@ CursorKind.VISIBILITY_ATTR = CursorKind(
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.CONVERGENT_ATTR = CursorKind(420)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
 
 ###
 # Preprocessing


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354824 - [libclang] Expose warn_unused and warn_unused_result attributes.

2019-02-25 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Mon Feb 25 13:24:52 2019
New Revision: 354824

URL: http://llvm.org/viewvc/llvm-project?rev=354824&view=rev
Log:
[libclang] Expose warn_unused and warn_unused_result attributes.

This is helpful to properly detect them, and fixing issues like
https://github.com/rust-lang/rust-bindgen/issues/1518.

Differential Revision: https://reviews.llvm.org/D58570

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/attributes.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Feb 25 13:24:52 2019
@@ -1343,6 +1343,8 @@ CursorKind.VISIBILITY_ATTR = CursorKind(
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
+CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
+CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
 
 ###
 # Preprocessing

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Feb 25 13:24:52 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 51
+#define CINDEX_VERSION_MINOR 52
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2587,7 +2587,9 @@ enum CXCursorKind {
   CXCursor_ObjCBoxable   = 436,
   CXCursor_FlagEnum  = 437,
   CXCursor_ConvergentAttr= 438,
-  CXCursor_LastAttr  = CXCursor_ConvergentAttr,
+  CXCursor_WarnUnusedAttr= 439,
+  CXCursor_WarnUnusedResultAttr  = 440,
+  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,

Modified: cfe/trunk/test/Index/attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes.c?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Mon Feb 25 13:24:52 2019
@@ -14,6 +14,12 @@ enum __attribute((flag_enum)) FlagEnum {
 
 void convergent_fn() __attribute__((convergent));
 
+int warn_unused_result_fn() __attribute__((warn_unused_result));
+
+struct __attribute__((warn_unused)) WarnUnused {
+  int b;
+};
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -29,3 +35,7 @@ void convergent_fn() __attribute__((conv
 // CHECK: attributes.c:12:3: EnumConstantDecl=Foo:12:3 (Definition) 
Extent=[12:3 - 12:6]
 // CHECK: attributes.c:15:6: FunctionDecl=convergent_fn:15:6 Extent=[15:1 - 
15:49]
 // CHECK: attributes.c:15:37: attribute(convergent)= Extent=[15:37 - 15:47]
+// CHECK: attributes.c:17:5: FunctionDecl=warn_unused_result_fn:17:5 
Extent=[17:1 - 17:64]
+// CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
+// CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
+// CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Feb 25 13:24:52 2019
@@ -5477,6 +5477,10 @@ CXString clang_getCursorKindSpelling(enu
   return cxstring::createRef("FriendDecl");
   case CXCursor_ConvergentAttr:
   return cxstring::createRef("attribute(convergent)");
+  case CXCursor_WarnUnusedAttr:
+  return cxstring::createRef("attribute(warn_unused)");
+  case CXCursor_WarnUnusedResultAttr:
+  return cxstring::createRef("attribute(warn_unused_result)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=354824&r1=354823&r2=354824&view=diff
=

r354885 - [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-26 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Tue Feb 26 07:04:18 2019
New Revision: 354885

URL: http://llvm.org/viewvc/llvm-project?rev=354885&view=rev
Log:
[libclang] Avoid crashing when getting layout info of an undeduced type.

When the type is not deducible, return an error instead of crashing.

This fixes https://bugs.llvm.org/show_bug.cgi?id=40813.

Differential Revision: https://reviews.llvm.org/D58569

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-type-size.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=354885&r1=354884&r2=354885&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Feb 26 07:04:18 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 52
+#define CINDEX_VERSION_MINOR 53
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3841,7 +3841,11 @@ enum CXTypeLayoutError {
   /**
* The Field name is not valid for this record.
*/
-  CXTypeLayoutError_InvalidFieldName = -5
+  CXTypeLayoutError_InvalidFieldName = -5,
+  /**
+   * The type is undeduced.
+   */
+  CXTypeLayoutError_Undeduced = -6
 };
 
 /**

Modified: cfe/trunk/test/Index/print-type-size.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=354885&r1=354884&r2=354885&view=diff
==
--- cfe/trunk/test/Index/print-type-size.cpp (original)
+++ cfe/trunk/test/Index/print-type-size.cpp Tue Feb 26 07:04:18 2019
@@ -400,4 +400,10 @@ plopplop;
 struct lastValid {
 };
 
+// CHECK64: CXXMethod=Tie:[[@LINE+3]]:8 (const) [type=auto (void *) const] 
[typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] 
[resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+// CHECK32: CXXMethod=Tie:[[@LINE+2]]:8 (const) [type=auto (void *) const] 
[typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] 
[resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+class BrowsingContext {
+  auto Tie(void*) const;
+};
+
 }

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=354885&r1=354884&r2=354885&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Feb 26 07:04:18 2019
@@ -1670,29 +1670,44 @@ static enum CXChildVisitResult PrintType
   return CXChildVisit_Recurse;
 }
 
-static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
- CXClientData d) {
-  CXType T;
-  enum CXCursorKind K = clang_getCursorKind(cursor);
-  if (clang_isInvalid(K))
-return CXChildVisit_Recurse;
-  T = clang_getCursorType(cursor);
-  PrintCursor(cursor, NULL);
-  PrintTypeAndTypeKind(T, " [type=%s] [typekind=%s]");
+static void PrintSingleTypeSize(CXType T, const char *TypeKindFormat,
+const char *SizeFormat,
+const char *AlignFormat) {
+  PrintTypeAndTypeKind(T, TypeKindFormat);
   /* Print the type sizeof if applicable. */
   {
 long long Size = clang_Type_getSizeOf(T);
 if (Size >= 0 || Size < -1 ) {
-  printf(" [sizeof=%lld]", Size);
+  printf(SizeFormat, Size);
 }
   }
   /* Print the type alignof if applicable. */
   {
 long long Align = clang_Type_getAlignOf(T);
 if (Align >= 0 || Align < -1) {
-  printf(" [alignof=%lld]", Align);
+  printf(AlignFormat, Align);
 }
   }
+
+  /* Print the return type if it exists. */
+  {
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",
+  " [resultsizeof=%lld]", " [resultalignof=%lld]");
+  }
+}
+
+static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+  CXType T;
+  enum CXCursorKind K = clang_getCursorKind(cursor);
+  if (clang_isInvalid(K))
+return CXChildVisit_Recurse;
+  T = clang_getCursorType(cursor);
+  PrintCursor(cursor, NULL);
+  PrintSingleTypeSize(T, " [type=%s] [typekind=%s]", " [sizeof=%lld]",
+  " [alignof=%lld]");
   /* Print the record field offset if applicable. */
   {
 CXString FieldSpelling = clang_getCursorSpelling(cursor);
@@ -1730,7 +1745,9 @@ static enum CXChildVisitResult PrintType
 if (IsBitfield)
   printf(" [BitFieldSize=%d]", clang_getFieldDeclBitWidth(cursor));
   }
+
  

r356062 - [libclang] Expose aligned() attribute.

2019-03-13 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Wed Mar 13 09:16:54 2019
New Revision: 356062

URL: http://llvm.org/viewvc/llvm-project?rev=356062&view=rev
Log:
[libclang] Expose aligned() attribute.

Summary:
This is useful because otherwise there's no easy way to distinguish #pragma
packed(N) from attribute(packed, aligned(N)) that isn't looking at field
offsets (since pragma packed() also creates a packed attribute).

Reviewers: Anastasia, arphaman, serge-sans-paille

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59299

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/attributes.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Wed Mar 13 09:16:54 2019
@@ -1345,6 +1345,7 @@ CursorKind.DLLIMPORT_ATTR = CursorKind(4
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
 CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
 CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
+CursorKind.ALIGNED_ATTR = CursorKind(441)
 
 ###
 # Preprocessing

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Mar 13 09:16:54 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 53
+#define CINDEX_VERSION_MINOR 54
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2589,7 +2589,8 @@ enum CXCursorKind {
   CXCursor_ConvergentAttr= 438,
   CXCursor_WarnUnusedAttr= 439,
   CXCursor_WarnUnusedResultAttr  = 440,
-  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
+  CXCursor_AlignedAttr   = 441,
+  CXCursor_LastAttr  = CXCursor_AlignedAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,

Modified: cfe/trunk/test/Index/attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes.c?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Wed Mar 13 09:16:54 2019
@@ -20,6 +20,14 @@ struct __attribute__((warn_unused)) Warn
   int b;
 };
 
+struct __attribute__((aligned(64))) Aligned1 {
+  int c;
+};
+
+struct Aligned2 {
+  int c;
+} __attribute__((aligned(64)));
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -39,3 +47,7 @@ struct __attribute__((warn_unused)) Warn
 // CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
 // CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
 // CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]
+// CHECK: attributes.c:23:37: StructDecl=Aligned1:23:37 (Definition) 
Extent=[23:1 - 25:2]
+// CHECK: attributes.c:23:23: attribute(aligned)= Extent=[23:23 - 23:34]
+// CHECK: attributes.c:27:8: StructDecl=Aligned2:27:8 (Definition) 
Extent=[27:1 - 29:2]
+// CHECK: attributes.c:29:18: attribute(aligned)= Extent=[29:18 - 29:29]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Mar 13 09:16:54 2019
@@ -5484,6 +5484,8 @@ CXString clang_getCursorKindSpelling(enu
   return cxstring::createRef("attribute(warn_unused)");
   case CXCursor_WarnUnusedResultAttr:
   return cxstring::createRef("attribute(warn_unused_result)");
+  case CXCursor_AlignedAttr:
+  return cxstring::createRef("attribute(aligned)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/tools/libclang/CXCursor.

r365490 - [libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.

2019-07-09 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Tue Jul  9 07:27:01 2019
New Revision: 365490

URL: http://llvm.org/viewvc/llvm-project?rev=365490&view=rev
Log:
[libclang] Fix hang in release / assertion in debug when evaluating 
value-dependent types.

Expression evaluator doesn't work in value-dependent types, so ensure that the
precondition it asserts holds.

This fixes https://bugs.llvm.org/show_bug.cgi?id=42532

Differential Revision: https://reviews.llvm.org/D64409

Modified:
cfe/trunk/test/Index/evaluate-cursor.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/evaluate-cursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/evaluate-cursor.cpp?rev=365490&r1=365489&r2=365490&view=diff
==
--- cfe/trunk/test/Index/evaluate-cursor.cpp (original)
+++ cfe/trunk/test/Index/evaluate-cursor.cpp Tue Jul  9 07:27:01 2019
@@ -21,6 +21,11 @@ unsigned long long HUGE = 1ull << 63;
 
 long long HUGE_NEG = -(1ll << 35);
 
+template  class e {
+  using f = d;
+  static const auto g = alignof(f);
+};
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -42,3 +47,9 @@ long long HUGE_NEG = -(1ll << 35);
 // CHECK-LONG: unsigned, Value: 1152921504606846976
 // CHECK-LONG: unsigned, Value: 9223372036854775808
 // CHECK-LONG: Value: -34359738368
+
+// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \
+// RUN:-evaluate-cursor-at=%s:20:20 \
+// RUN:-evaluate-cursor-at=%s:26:21 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
+// CHECK-DOES-NOT-CRASH: Not Evaluatable

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=365490&r1=365489&r2=365490&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul  9 07:27:01 2019
@@ -3782,6 +3782,8 @@ static const ExprEvalResult* evaluateExp
 return nullptr;
 
   expr = expr->IgnoreParens();
+  if (expr->isValueDependent())
+return nullptr;
   if (!expr->EvaluateAsRValue(ER, ctx))
 return nullptr;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r301648 - [libclang] Expose some target information via the C API.

2017-04-28 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Fri Apr 28 10:56:39 2017
New Revision: 301648

URL: http://llvm.org/viewvc/llvm-project?rev=301648&view=rev
Log:
[libclang] Expose some target information via the C API.

This allows users to query the target triple and target pointer width, which
would make me able to fix https://github.com/servo/rust-bindgen/issues/593 and
other related bugs in an elegant way (without having to manually parse the
target triple in the command line arguments).

Differential Revision: https://reviews.llvm.org/D32389


Added:
cfe/trunk/test/Index/target-info.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXTranslationUnit.h
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=301648&r1=301647&r2=301648&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Apr 28 10:56:39 2017
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 37
+#define CINDEX_VERSION_MINOR 38
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -81,6 +81,12 @@ extern "C" {
 typedef void *CXIndex;
 
 /**
+ * \brief An opaque type representing target information for a given 
translation
+ * unit.
+ */
+typedef struct CXTargetInfoImpl *CXTargetInfo;
+
+/**
  * \brief A single translation unit, which resides in an index.
  */
 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
@@ -1553,6 +1559,36 @@ CINDEX_LINKAGE CXTUResourceUsage clang_g
 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
 
 /**
+ * \brief Get target information for this translation unit.
+ *
+ * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
+ */
+CINDEX_LINKAGE CXTargetInfo
+clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
+
+/**
+ * \brief Destroy the CXTargetInfo object.
+ */
+CINDEX_LINKAGE void
+clang_TargetInfo_dispose(CXTargetInfo Info);
+
+/**
+ * \brief Get the normalized target triple as a string.
+ *
+ * Returns the empty string in case of any error.
+ */
+CINDEX_LINKAGE CXString
+clang_TargetInfo_getTriple(CXTargetInfo Info);
+
+/**
+ * \brief Get the pointer width of the target in bits.
+ *
+ * Returns -1 in case of error.
+ */
+CINDEX_LINKAGE int
+clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
+
+/**
  * @}
  */
 

Added: cfe/trunk/test/Index/target-info.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/target-info.c?rev=301648&view=auto
==
--- cfe/trunk/test/Index/target-info.c (added)
+++ cfe/trunk/test/Index/target-info.c Fri Apr 28 10:56:39 2017
@@ -0,0 +1,6 @@
+// RUN: c-index-test -test-print-target-info %s 
--target=i386-unknown-linux-gnu | FileCheck %s
+// RUN: c-index-test -test-print-target-info %s 
--target=x86_64-unknown-linux-gnu | FileCheck --check-prefix=CHECK-1 %s
+// CHECK: TargetTriple: i386-unknown-linux-gnu
+// CHECK: PointerWidth: 32
+// CHECK-1: TargetTriple: x86_64-unknown-linux-gnu
+// CHECK-1: PointerWidth: 64

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=301648&r1=301647&r2=301648&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Fri Apr 28 10:56:39 2017
@@ -1560,6 +1560,51 @@ static enum CXChildVisitResult PrintType
 }
 
 
/**/
+/* Target information testing.
*/
+/**/
+
+static int print_target_info(int argc, const char **argv) {
+  CXIndex Idx;
+  CXTranslationUnit TU;
+  CXTargetInfo TargetInfo;
+  CXString Triple;
+  const char *FileName;
+  enum CXErrorCode Err;
+  int PointerWidth;
+
+  if (argc == 0) {
+fprintf(stderr, "No filename specified\n");
+return 1;
+  }
+
+  FileName = argv[1];
+
+  Idx = clang_createIndex(0, 1);
+  Err = clang_parseTranslationUnit2(Idx, FileName, argv, argc, NULL, 0,
+getDefaultParsingOptions(), &TU);
+  if (Err != CXError_Success) {
+fprintf(stderr, "Couldn't parse translation unit!\n");
+describeLibclangFailure(Err);
+clang_disposeIndex(Idx);
+return 1;
+  }
+
+  TargetInfo = clang_getTranslationUnitTargetInfo(TU);
+
+  Triple = clang_TargetInfo_getTriple(TargetInfo);
+  printf("TargetTriple: %s\n", clang_getCString(Triple));

r301902 - [libclang] Revert rL301328 and add tests for the regressions introduced.

2017-05-02 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Tue May  2 03:32:15 2017
New Revision: 301902

URL: http://llvm.org/viewvc/llvm-project?rev=301902&view=rev
Log:
[libclang] Revert rL301328 and add tests for the regressions introduced.

Differential Revision: https://reviews.llvm.org/D32566


Modified:
cfe/trunk/test/Index/print-type.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/test/Index/print-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=301902&r1=301901&r2=301902&view=diff
==
--- cfe/trunk/test/Index/print-type.cpp (original)
+++ cfe/trunk/test/Index/print-type.cpp Tue May  2 03:32:15 2017
@@ -71,10 +71,9 @@ struct Specialization;
 Specialization& > templRefParam;
 auto autoTemplRefParam = templRefParam;
 
-template
-struct DefaultedTypeExample {};
-
-typedef DefaultedTypeExample DefaultedTypeAlias;
+template struct A {};
+template using C = T;
+using baz = C>;
 
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -120,7 +119,7 @@ typedef DefaultedTypeExample Defaul
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] 
[typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux, int>] [canonicaltypekind=Record] 
[canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] 
[typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] 
[canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] 
[resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
@@ -183,3 +182,4 @@ typedef DefaultedTypeExample Defaul
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]
+// CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] 
[templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] 
[typekind=Void]] [isPOD=0]

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=301902&r1=301901&r2=301902&view=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Tue May  2 03:32:15 2017
@@ -147,6 +147,9 @@ static inline CXTranslationUnit GetTU(CX
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
@@ -154,9 +157,6 @@ GetTemplateArguments(QualType Type) {
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   return None;
 }
 


__

r301906 - Remove leftover test expectation from rL301902.

2017-05-02 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Tue May  2 04:57:30 2017
New Revision: 301906

URL: http://llvm.org/viewvc/llvm-project?rev=301906&view=rev
Log:
Remove leftover test expectation from rL301902.

Modified:
cfe/trunk/test/Index/print-type.cpp

Modified: cfe/trunk/test/Index/print-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=301906&r1=301905&r2=301906&view=diff
==
--- cfe/trunk/test/Index/print-type.cpp (original)
+++ cfe/trunk/test/Index/print-type.cpp Tue May  2 04:57:30 2017
@@ -181,5 +181,4 @@ using baz = C>;
 // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) 
[type=Specialization &>] [typekind=Auto] [templateargs/1= 
[type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
-// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]
 // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] 
[templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] 
[typekind=Void]] [isPOD=0]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits