brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.9 KiB · 7bb50af Raw
320 lines · c
1// RUN: rm -rf %t2// RUN: split-file %s %t3// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \4// RUN: %t/reference.output.json.in >> %t/reference.output.json5// RUN: %clang -extract-api --pretty-sgf --product-name=Macros -target arm64-apple-macosx \6// RUN: -x objective-c-header %t/input.h -o %t/output.json | FileCheck -allow-empty %s7 8// Generator version is not consistent across test runs, normalize it.9// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \10// RUN: %t/output.json >> %t/output-normalized.json11// RUN: diff %t/reference.output.json %t/output-normalized.json12 13// CHECK-NOT: error:14// CHECK-NOT: warning:15 16//--- input.h17#define HELLO 118#define FUNC_GEN(NAME, ...) void NAME(__VA_ARGS__);19FUNC_GEN(foo)20FUNC_GEN(bar, const int *, unsigned);21#undef FUNC_GEN22// Undefining a not previously defined macro should not result in a crash.23#undef FOO24 25//--- reference.output.json.in26{27  "metadata": {28    "formatVersion": {29      "major": 0,30      "minor": 5,31      "patch": 332    },33    "generator": "?"34  },35  "module": {36    "name": "Macros",37    "platform": {38      "architecture": "arm64",39      "operatingSystem": {40        "minimumVersion": {41          "major": 11,42          "minor": 0,43          "patch": 044        },45        "name": "macosx"46      },47      "vendor": "apple"48    }49  },50  "relationships": [],51  "symbols": [52    {53      "accessLevel": "public",54      "declarationFragments": [55        {56          "kind": "typeIdentifier",57          "preciseIdentifier": "c:v",58          "spelling": "void"59        },60        {61          "kind": "text",62          "spelling": " "63        },64        {65          "kind": "identifier",66          "spelling": "foo"67        },68        {69          "kind": "text",70          "spelling": "();"71        }72      ],73      "functionSignature": {74        "returns": [75          {76            "kind": "typeIdentifier",77            "preciseIdentifier": "c:v",78            "spelling": "void"79          }80        ]81      },82      "identifier": {83        "interfaceLanguage": "objective-c",84        "precise": "c:@F@foo"85      },86      "kind": {87        "displayName": "Function",88        "identifier": "objective-c.func"89      },90      "location": {91        "position": {92          "character": 0,93          "line": 294        },95        "uri": "file://INPUT_DIR/input.h"96      },97      "names": {98        "navigator": [99          {100            "kind": "identifier",101            "spelling": "foo"102          }103        ],104        "subHeading": [105          {106            "kind": "identifier",107            "spelling": "foo"108          }109        ],110        "title": "foo"111      },112      "pathComponents": [113        "foo"114      ]115    },116    {117      "accessLevel": "public",118      "declarationFragments": [119        {120          "kind": "typeIdentifier",121          "preciseIdentifier": "c:v",122          "spelling": "void"123        },124        {125          "kind": "text",126          "spelling": " "127        },128        {129          "kind": "identifier",130          "spelling": "bar"131        },132        {133          "kind": "text",134          "spelling": "("135        },136        {137          "kind": "keyword",138          "spelling": "const"139        },140        {141          "kind": "text",142          "spelling": " "143        },144        {145          "kind": "typeIdentifier",146          "preciseIdentifier": "c:I",147          "spelling": "int"148        },149        {150          "kind": "text",151          "spelling": " *"152        },153        {154          "kind": "internalParam",155          "spelling": ""156        },157        {158          "kind": "text",159          "spelling": ", "160        },161        {162          "kind": "typeIdentifier",163          "preciseIdentifier": "c:i",164          "spelling": "unsigned int"165        },166        {167          "kind": "text",168          "spelling": " "169        },170        {171          "kind": "internalParam",172          "spelling": ""173        },174        {175          "kind": "text",176          "spelling": ");"177        }178      ],179      "functionSignature": {180        "parameters": [181          {182            "declarationFragments": [183              {184                "kind": "keyword",185                "spelling": "const"186              },187              {188                "kind": "text",189                "spelling": " "190              },191              {192                "kind": "typeIdentifier",193                "preciseIdentifier": "c:I",194                "spelling": "int"195              },196              {197                "kind": "text",198                "spelling": " *"199              },200              {201                "kind": "internalParam",202                "spelling": ""203              }204            ],205            "name": ""206          },207          {208            "declarationFragments": [209              {210                "kind": "typeIdentifier",211                "preciseIdentifier": "c:i",212                "spelling": "unsigned int"213              },214              {215                "kind": "text",216                "spelling": " "217              },218              {219                "kind": "internalParam",220                "spelling": ""221              }222            ],223            "name": ""224          }225        ],226        "returns": [227          {228            "kind": "typeIdentifier",229            "preciseIdentifier": "c:v",230            "spelling": "void"231          }232        ]233      },234      "identifier": {235        "interfaceLanguage": "objective-c",236        "precise": "c:@F@bar"237      },238      "kind": {239        "displayName": "Function",240        "identifier": "objective-c.func"241      },242      "location": {243        "position": {244          "character": 0,245          "line": 3246        },247        "uri": "file://INPUT_DIR/input.h"248      },249      "names": {250        "navigator": [251          {252            "kind": "identifier",253            "spelling": "bar"254          }255        ],256        "subHeading": [257          {258            "kind": "identifier",259            "spelling": "bar"260          }261        ],262        "title": "bar"263      },264      "pathComponents": [265        "bar"266      ]267    },268    {269      "accessLevel": "public",270      "declarationFragments": [271        {272          "kind": "keyword",273          "spelling": "#define"274        },275        {276          "kind": "text",277          "spelling": " "278        },279        {280          "kind": "identifier",281          "spelling": "HELLO"282        }283      ],284      "identifier": {285        "interfaceLanguage": "objective-c",286        "precise": "c:input.h@8@macro@HELLO"287      },288      "kind": {289        "displayName": "Macro",290        "identifier": "objective-c.macro"291      },292      "location": {293        "position": {294          "character": 8,295          "line": 0296        },297        "uri": "file://INPUT_DIR/input.h"298      },299      "names": {300        "navigator": [301          {302            "kind": "identifier",303            "spelling": "HELLO"304          }305        ],306        "subHeading": [307          {308            "kind": "identifier",309            "spelling": "HELLO"310          }311        ],312        "title": "HELLO"313      },314      "pathComponents": [315        "HELLO"316      ]317    }318  ]319}320