Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / bindings / python / tests / cindex / test_linkage.py
blob4a8838276fae570d8d3abd1bebfc10046aa0fbac
1 import os
2 from clang.cindex import Config
4 if "CLANG_LIBRARY_PATH" in os.environ:
5 Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])
7 from clang.cindex import LinkageKind
8 from clang.cindex import Cursor
9 from clang.cindex import TranslationUnit
11 from .util import get_cursor
12 from .util import get_tu
14 import unittest
17 class TestLinkage(unittest.TestCase):
18 def test_linkage(self):
19 """Ensure that linkage specifers are available on cursors"""
21 tu = get_tu(
22 """
23 void foo() { int no_linkage; }
24 static int internal;
25 namespace { struct unique_external_type {} }
26 unique_external_type unique_external;
27 extern int external;
28 """,
29 lang="cpp",
32 no_linkage = get_cursor(tu.cursor, "no_linkage")
33 self.assertEqual(no_linkage.linkage, LinkageKind.NO_LINKAGE)
35 internal = get_cursor(tu.cursor, "internal")
36 self.assertEqual(internal.linkage, LinkageKind.INTERNAL)
38 unique_external = get_cursor(tu.cursor, "unique_external")
39 self.assertEqual(unique_external.linkage, LinkageKind.UNIQUE_EXTERNAL)
41 external = get_cursor(tu.cursor, "external")
42 self.assertEqual(external.linkage, LinkageKind.EXTERNAL)