xref: /llvm-project/clang/test/FixIt/fixit-pragma-attribute.cpp (revision 33a9eac6aaa495fce6fd9b17cd48aa57a95461e6)
19e7bf161SAlex Lorenz // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wno-pragma-clang-attribute %s 2>&1 | FileCheck %s
29e7bf161SAlex Lorenz 
39e7bf161SAlex Lorenz #pragma clang attribute push (annotate)
49e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:31-[[@LINE-1]]:31}:"__attribute__(("
59e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:39-[[@LINE-2]]:39}:"))"
69e7bf161SAlex Lorenz #pragma clang attribute push (annotate(("test")))
79e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:31-[[@LINE-1]]:31}:"__attribute__(("
89e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:49-[[@LINE-2]]:49}:"))"
99e7bf161SAlex Lorenz 
109e7bf161SAlex Lorenz #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( enum, function, function, namespace, function ))
119e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:97-[[@LINE-1]]:107}:""
129e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:118-[[@LINE-2]]:127}:""
139e7bf161SAlex Lorenz 
149e7bf161SAlex Lorenz #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable(is_global), function, variable(is_global), variable(is_global) ))
159e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:112-[[@LINE-1]]:133}:""
169e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:133-[[@LINE-2]]:153}:""
179e7bf161SAlex Lorenz 
189e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((annotate("subRuleContradictions"))), apply_to = any(variable, variable(is_parameter), function(is_member), variable(is_global)))
19c5a05834SErik Pilkington // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:153-[[@LINE-1]]:172}:""
20c5a05834SErik Pilkington // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:108-[[@LINE-2]]:132}:""
219e7bf161SAlex Lorenz 
229e7bf161SAlex Lorenz #pragma clang attribute pop
239e7bf161SAlex Lorenz 
249e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((annotate("subRuleContradictions2"))), apply_to = any(function(is_member),function))
259e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:99-[[@LINE-1]]:119}:""
269e7bf161SAlex Lorenz 
279e7bf161SAlex Lorenz #pragma clang attribute pop
289e7bf161SAlex Lorenz 
299e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((annotate("negatedSubRuleContradictions1"))), apply_to = any(variable(is_parameter), variable(unless(is_parameter))))
309e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:130-[[@LINE-1]]:160}:""
319e7bf161SAlex Lorenz #pragma clang attribute pop
329e7bf161SAlex Lorenz 
339e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((annotate("negatedSubRuleContradictions2"))), apply_to = any(variable(unless(is_parameter)), variable(is_thread_local), function, variable(is_global)))
349e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:106-[[@LINE-1]]:137}:""
359e7bf161SAlex Lorenz #pragma clang attribute pop
369e7bf161SAlex Lorenz 
379e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(enum, variable))
389e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:77-[[@LINE-1]]:82}:""
399e7bf161SAlex Lorenz #pragma clang attribute pop
409e7bf161SAlex Lorenz 
419e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))))
42*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:60-[[@LINE-1]]:60}:", apply_to = any(function, namespace, record(unless(is_union)), variable)"
439e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))) apply_to=function)
449e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:60-[[@LINE-1]]:60}:", "
459e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))) = function)
469e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:60-[[@LINE-1]]:60}:", apply_to"
479e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))) any(function))
489e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:60-[[@LINE-1]]:60}:", apply_to = "
499e7bf161SAlex Lorenz 
509e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))) 22)
51*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:60-[[@LINE-1]]:63}:", apply_to = any(function, namespace, record(unless(is_union)), variable)"
529e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))) function)
53*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:60-[[@LINE-1]]:69}:", apply_to = any(function, namespace, record(unless(is_union)), variable)"
549e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))) (function))
55*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:60-[[@LINE-1]]:71}:", apply_to = any(function, namespace, record(unless(is_union)), variable)"
569e7bf161SAlex Lorenz 
579e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), )
58*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:61-[[@LINE-1]]:62}:"apply_to = any(function, namespace, record(unless(is_union)), variable)"
599e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), = function)
609e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:61-[[@LINE-1]]:61}:"apply_to"
619e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), any(function))
629e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:61-[[@LINE-1]]:61}:"apply_to = "
639e7bf161SAlex Lorenz 
649e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), 22)
65*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:61-[[@LINE-1]]:64}:"apply_to = any(function, namespace, record(unless(is_union)), variable)"
669e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), 1, 2)
67*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:61-[[@LINE-1]]:66}:"apply_to = any(function, namespace, record(unless(is_union)), variable)"
689e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), function)
69*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:61-[[@LINE-1]]:70}:"apply_to = any(function, namespace, record(unless(is_union)), variable)"
709e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), (function))
71*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:61-[[@LINE-1]]:72}:"apply_to = any(function, namespace, record(unless(is_union)), variable)"
729e7bf161SAlex Lorenz 
739e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to)
74*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:70-[[@LINE-1]]:70}:" = any(function, namespace, record(unless(is_union)), variable)"
759e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to any(function))
769e7bf161SAlex Lorenz // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:70-[[@LINE-1]]:70}:" = "
779e7bf161SAlex Lorenz 
789e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to 41 (22))
79*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:70-[[@LINE-1]]:78}:" = any(function, namespace, record(unless(is_union)), variable)"
809e7bf161SAlex Lorenz 
819e7bf161SAlex Lorenz // Don't give fix-it to attributes without a strict subject set
829e7bf161SAlex Lorenz #pragma clang attribute push (__attribute__((annotate("a"))))
839e7bf161SAlex Lorenz // CHECK-NO: [[@LINE-1]]:61
84*33a9eac6SEgor Zhdan 
85*33a9eac6SEgor Zhdan #pragma clang attribute push (__attribute__((objc_externally_retained)), apply_to)
86*33a9eac6SEgor Zhdan // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:82-[[@LINE-1]]:82}:" = any(function, variable(unless(is_parameter)))"
87