diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ef1702baa91fdbcc7285657bdd5a77b8083a7b47..ae6ea9d0561ce4e70d8e6cb63c1bae8248f17b2e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,8 +5,8 @@ stages:
 variables:
   BUILD_ENV_DOCKER_IMAGE: docker-registry.ebrains.eu/tc/ebrains-spack-build-env/okd:okd_23.06
   GITLAB_BUILD_ENV_DOCKER_IMAGE: docker-registry.ebrains.eu/tc/ebrains-spack-build-env/gitlab_runners_nfs:gitlab_runners_nfs_23.06
-  SPACK_VERSION: v0.20.0
-  SPACK_PATH_GITLAB: /mnt/spack_v0.20.0
+  SPACK_VERSION: v0.21.1
+  SPACK_PATH_GITLAB: /mnt/spack_v0.21.1
   SYSTEMNAME: ebrainslab
 
 # start an OpenShift Job that will build the Spack environment
@@ -55,7 +55,7 @@ deploy-int-release-dev-cscs:
     OPENSHIFT_TOKEN: $CSCS_OPENSHIFT_DEV_TOKEN
     OC_PROJECT: jupyterhub-int
     LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/int
-    INSTALLATION_ROOT: /srv/test-build-2309
+    INSTALLATION_ROOT: /srv/test-build-2402
     SPACK_ENV: test
     RELEASE_NAME: EBRAINS-test
   resource_group: shared-NFS-mount-dev-cscs
@@ -72,7 +72,7 @@ deploy-prod-release-prod-cscs:
     OPENSHIFT_TOKEN: $CSCS_OPENSHIFT_PROD_TOKEN
     OC_PROJECT: jupyterhub
     LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/prod
-    INSTALLATION_ROOT: /srv/main-spack-instance-2309
+    INSTALLATION_ROOT: /srv/main-spack-instance-2402
     SPACK_ENV: ebrains-23-09
     RELEASE_NAME: EBRAINS-23.09
   resource_group: shared-NFS-mount-prod-cscs
@@ -90,7 +90,7 @@ deploy-prod-release-prod-jsc:
     OPENSHIFT_TOKEN: $JSC_OPENSHIFT_PROD_TOKEN
     OC_PROJECT: jupyterhub
     LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/prod
-    INSTALLATION_ROOT: /srv/main-spack-instance-2309
+    INSTALLATION_ROOT: /srv/main-spack-instance-2402
     SPACK_ENV: ebrains-23-09
     RELEASE_NAME: EBRAINS-23.09
   resource_group: shared-NFS-mount-prod-jsc
@@ -110,7 +110,7 @@ deploy-exp-release-dev-cscs:
     OPENSHIFT_TOKEN: $CSCS_OPENSHIFT_DEV_TOKEN
     OC_PROJECT: jupyterhub-int
     LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/int
-    INSTALLATION_ROOT: /srv/test-build-2309
+    INSTALLATION_ROOT: /srv/test-build-2402
     SPACK_ENV: experimental
     RELEASE_NAME: EBRAINS-experimental
   resource_group: shared-NFS-mount-dev-cscs
@@ -129,7 +129,7 @@ deploy-exp-release-prod-cscs:
     OPENSHIFT_TOKEN: $CSCS_OPENSHIFT_PROD_TOKEN
     OC_PROJECT: jupyterhub
     LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/prod
-    INSTALLATION_ROOT: /srv/main-spack-instance-2309
+    INSTALLATION_ROOT: /srv/main-spack-instance-2402
     SPACK_ENV: experimental
     RELEASE_NAME: EBRAINS-experimental
   resource_group: shared-NFS-mount-prod-cscs
@@ -151,7 +151,7 @@ deploy-exp-release-prod-jsc:
     OPENSHIFT_TOKEN: $JSC_OPENSHIFT_PROD_TOKEN
     OC_PROJECT: jupyterhub
     LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/prod
-    INSTALLATION_ROOT: /srv/main-spack-instance-2309
+    INSTALLATION_ROOT: /srv/main-spack-instance-2402
     SPACK_ENV: experimental
     RELEASE_NAME: EBRAINS-experimental
   resource_group: shared-NFS-mount-prod-jsc
@@ -207,6 +207,8 @@ sync-gitlab-spack-instance:
     SPACK_REPO_PATH: $SPACK_PATH_GITLAB/ebrains-spack-builds
   script:
     - SPACK_NFS_ENV=${CI_COMMIT_BRANCH//./-}
+    # create spack dir if it doesn't exist
+    - mkdir -p $SPACK_PATH_GITLAB
     # get latest state of EBRAINS repo
     - rm -rf $SPACK_REPO_PATH && cp -r $CI_PROJECT_DIR $SPACK_REPO_PATH
     # run installation script
diff --git a/README.md b/README.md
index 6d29458edfb866466f94acfd4b3584f094db91e0..bda3ff5d6c20dcf541b17b9ee63221913d46d17c 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ Clone this repository. You can use the `ebrains-yy-mm` branches to install the E
 git clone --branch {branch-name} https://gitlab.ebrains.eu/technical-coordination/project-internal/devops/platform/ebrains-spack-builds.git
 ```
 
-Clone Spack. We currently use version v0.20.0:
+Clone Spack. We currently use version v0.21.1:
 ```
 git clone --depth 1 -c advice.detachedHead=false -c feature.manyFiles=true --branch v0.20.0 https://github.com/spack/spack
 ```
diff --git a/install_spack_env.sh b/install_spack_env.sh
index b354b43b923b7342bcfb460abcbbdaa9d744fcf7..536696f8a4fa342bad3f9975bc2ff57f96d62add 100644
--- a/install_spack_env.sh
+++ b/install_spack_env.sh
@@ -77,6 +77,12 @@ rm $SPACK_ROOT/var/spack/environments/$EBRAINS_SPACK_ENV/spack.lock || echo "No
 
 # activate environment
 spack env activate $EBRAINS_SPACK_ENV
+
+# fetch all sources
+spack concretize --fresh --test root
+spack-python -c "exit(not len(spack.environment.active_environment().uninstalled_specs()))" && spack fetch --dependencies --missing
+rm $SPACK_ROOT/var/spack/environments/$EBRAINS_SPACK_ENV/spack.lock
+
 # install the environment, use 2 jobs to reduce the amount of required RAM
 spack install -y -j2 --fresh --test root
 
diff --git a/packages/bazel/package.py b/packages/bazel/package.py
index 64df14b13074675a697b11db7f52d5d302b08c58..c9119da8fc1aa067567032ef565437afe9e87de6 100644
--- a/packages/bazel/package.py
+++ b/packages/bazel/package.py
@@ -439,7 +439,9 @@ class Bazel(Package):
     patch("cc_configure-0.3.0.patch", when="@0.3:0.4")
 
     # Set CC and CXX
-    patch("compile-0.29.patch", when="@0.29:")
+    # begin EBRAINS: modified, bring upstream after checking since when this is breaking the build
+    patch("compile-0.29.patch", when="@0.29:5.3")
+    # end EBRAINS
     patch("compile-0.21.patch", when="@0.21:0.28")
     patch("compile-0.16.patch", when="@0.16:0.20")
     patch("compile-0.13.patch", when="@0.13:0.15")
@@ -482,13 +484,14 @@ class Bazel(Package):
     # https://blog.bazel.build/2021/05/21/bazel-4-1.html
     conflicts("platform=darwin target=aarch64:", when="@:4.0")
 
-    # patches for compiling bazel-4.1:4 with gcc-11
+    # patches for compiling various older bazels which had ICWYU
+    # violations revealed by (but not unique to) GCC 11 header changes.
     # these are derived from
     # https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/29084/
-    patch("gcc11_1.patch", when="@0.3.2:4%gcc@11:")
-    patch("gcc11_2.patch", when="@0.3.2:4%gcc@11:")
-    patch("gcc11_3.patch", when="@0.3:4%gcc@11:")
-    patch("gcc11_4.patch", when="@4.1:4%gcc@11:")
+    patch("gcc11_1.patch", when="@0.3.2:4")
+    patch("gcc11_2.patch", when="@0.3.2:4")
+    patch("gcc11_3.patch", when="@0.3:4")
+    patch("gcc11_4.patch", when="@4.1:4")
 
     # bazel-4.0.0 does not compile with gcc-11
     # newer versions of grpc and abseil dependencies are needed but are not in
@@ -526,15 +529,11 @@ class Bazel(Package):
             "--color=no --host_javabase=@local_jdk//:jdk"
             # Enable verbose output for failures
             " --verbose_failures"
-            # Ask bazel to explain what it's up to
-            # Needs a filename as argument
-            " --explain=explainlogfile.txt"
-            # Increase verbosity of explanation,
-            " --verbose_explanations"
-            # Show (formatted) subcommands being executed
-            " --subcommands=pretty_print"
-            # expose LD_LIBRARY_PATH (to fix protoc runtime error during build)
-            " --action_env=LD_LIBRARY_PATH"
+            # begin EBRAINS: modified, bring upstream after checking since when the compile-x.patch is breaking the build
+            # expose CC and CXX (the spack compiler wrappers)
+            " --action_env=CC"
+            " --action_env=CXX"
+            # end EBRAINS
             " --jobs={0}".format(make_jobs),
         )
 
diff --git a/packages/gcc/detection_test.yaml b/packages/gcc/detection_test.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..5e53101a699d77c314c0c07e939c9195a09f6d04
--- /dev/null
+++ b/packages/gcc/detection_test.yaml
@@ -0,0 +1,38 @@
+paths:
+  # Ubuntu 18.04, system compilers without Fortran
+  - layout:
+      - executables:
+        - "bin/gcc"
+        - "bin/g++"
+        script: "echo 7.5.0"
+    results:
+      - spec: "gcc@7.5.0 languages=c,c++"
+  # Mock a version < 7 of GCC that requires -dumpversion and
+  # errors with -dumpfullversion
+  - layout:
+      - executables:
+        - "bin/gcc-5"
+        - "bin/g++-5"
+        - "bin/gfortran-5"
+        script: |
+          if [[ "$1" == "-dumpversion" ]] ; then
+            echo "5.5.0"
+          else
+            echo "gcc-5: fatal error: no input files"
+            echo "compilation terminated."
+            exit 1
+          fi
+    results:
+      - spec: "gcc@5.5.0 languages=c,c++,fortran"
+  # Multiple compilers present at the same time
+  - layout:
+      - executables:
+        - "bin/x86_64-linux-gnu-gcc-6"
+        script: 'echo 6.5.0'
+      - executables:
+        - "bin/x86_64-linux-gnu-gcc-10"
+        - "bin/x86_64-linux-gnu-g++-10"
+        script: "echo 10.1.0"
+    results:
+      - spec: "gcc@6.5.0 languages=c"
+      - spec: "gcc@10.1.0 languages=c,c++"
\ No newline at end of file
diff --git a/packages/gcc/package.py b/packages/gcc/package.py
index f572a133bd47a412aebcc627bb3e422385c95f5f..a8d36dc14145be0c21304b5b192e920a6219d713 100644
--- a/packages/gcc/package.py
+++ b/packages/gcc/package.py
@@ -35,16 +35,19 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
 
     version("master", branch="master")
 
+    version("13.2.0", sha256="e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da")
     version("13.1.0", sha256="61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86")
 
     version("12.3.0", sha256="949a5d4f99e786421a93b532b22ffab5578de7321369975b91aec97adfda8c3b")
     version("12.2.0", sha256="e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff")
     version("12.1.0", sha256="62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b")
 
+    version("11.4.0", sha256="3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9")
     version("11.3.0", sha256="b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39")
     version("11.2.0", sha256="d08edc536b54c372a1010ff6619dd274c0f1603aa49212ba20f7aa2cda36fa8b")
     version("11.1.0", sha256="4c4a6fb8a8396059241c2e674b85b351c26a5d678274007f076957afa1cc9ddf")
 
+    version("10.5.0", sha256="25109543fdf46f397c347b5d8b7a2c7e5694a5a51cce4b9c6e1ea8a71ca307c1")
     version("10.4.0", sha256="c9297d5bcd7cb43f3dfc2fed5389e948c9312fd962ef6a4ce455cff963ebe4f1")
     version("10.3.0", sha256="64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344")
     version("10.2.0", sha256="b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c")
@@ -179,7 +182,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
         depends_on("isl@0.15:0.20", when="@9:9.9")
         depends_on("isl@0.15:", when="@10:")
 
-    depends_on("zlib", when="@6:")
+    depends_on("zlib-api", when="@6:")
     depends_on("zstd", when="@10:")
     depends_on("diffutils", type="build")
     depends_on("iconv", when="platform=darwin")
@@ -334,11 +337,11 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
     #   on XCode 12.5
     conflicts("+bootstrap", when="@:11.1 %apple-clang@12.0.5")
 
-    # aarch64/M1 is supported in GCC 11.3-12.2
-    conflicts(
-        "@:11.2,12.3:",
+    # aarch64/M1 is supported in GCC 11.3-12.2 and 13
+    requires(
+        "@11.3,12.2,13.1:",
         when="target=aarch64: platform=darwin",
-        msg="Only GCC 11.3-12.2 support macOS M1 (aarch64)",
+        msg="Only GCC 11.3-12.2, 13.1+ support macOS M1 (aarch64)",
     )
 
     # Newer binutils than RHEL's is required to run `as` on some instructions
@@ -410,7 +413,17 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
             sha256="a7843b5c6bf1401e40c20c72af69c8f6fc9754ae980bb4a5f0540220b3dcb62d",
             when="@12.2.0 target=aarch64:",
         )
-        conflicts("+bootstrap", when="@11.3.0 target=aarch64:")
+        patch(
+            "https://raw.githubusercontent.com/Homebrew/formula-patches/5c206c47/gcc/gcc-13.1.0.diff",
+            sha256="cb4e8a89387f748a744da0273025d0dc2e3c76780cc390b18ada704676afea11",
+            when="@13.1.0 target=aarch64:",
+        )
+        patch(
+            "https://raw.githubusercontent.com/Homebrew/formula-patches/3c5cbc8e9cf444a1967786af48e430588e1eb481/gcc/gcc-13.2.0.diff",
+            sha256="2df7ef067871a30b2531a2013b3db661ec9e61037341977bfc451e30bf2c1035",
+            when="@13.2.0 target=aarch64:",
+        )
+        conflicts("+bootstrap", when="@11.3.0,13.1: target=aarch64:")
 
         # Use -headerpad_max_install_names in the build,
         # otherwise updated load commands won't fit in the Mach-O header.
@@ -627,7 +640,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
             "7.1.0"
         ):
             self.gnu_mirror_path = self.gnu_mirror_path.replace("xz", "bz2")
-        return super(Gcc, self).url_for_version(version)
+        return super().url_for_version(version)
 
     def patch(self):
         spec = self.spec
@@ -649,9 +662,11 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
 
         # Use installed libz
         if self.version >= Version("6"):
-            filter_file("@zlibdir@", "-L{0}".format(spec["zlib"].prefix.lib), "gcc/Makefile.in")
             filter_file(
-                "@zlibinc@", "-I{0}".format(spec["zlib"].prefix.include), "gcc/Makefile.in"
+                "@zlibdir@", "-L{0}".format(spec["zlib-api"].prefix.lib), "gcc/Makefile.in"
+            )
+            filter_file(
+                "@zlibinc@", "-I{0}".format(spec["zlib-api"].prefix.include), "gcc/Makefile.in"
             )
 
         if spec.satisfies("+nvptx"):
@@ -768,6 +783,11 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
                     "--with-as=" + binutils.join("as"),
                 ]
             )
+        elif spec.satisfies("%apple-clang@15:"):
+            # https://github.com/iains/gcc-darwin-arm64/issues/117
+            # https://github.com/iains/gcc-12-branch/issues/22
+            # https://github.com/iains/gcc-13-branch/issues/8
+            options.append("--with-ld=/Library/Developer/CommandLineTools/usr/bin/ld-classic")
 
         # enable_bootstrap
         if spec.satisfies("+bootstrap"):
@@ -1015,11 +1035,11 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
         """
         # Detect GCC package in the directory of the GCC compiler
         # or in the $PATH if self.compiler.cc is not an absolute path:
-        from spack.detection import by_executable
+        from spack.detection import by_path
 
         compiler_dir = os.path.dirname(self.compiler.cc)
-        detected_packages = by_executable(
-            [self.__class__], path_hints=([compiler_dir] if os.path.isdir(compiler_dir) else None)
+        detected_packages = by_path(
+            [self.name], path_hints=([compiler_dir] if os.path.isdir(compiler_dir) else None)
         )
 
         # We consider only packages that satisfy the following constraint:
diff --git a/packages/genpybind/package.py b/packages/genpybind/package.py
index 3f892433f891144a05488bbae1dcba5d30d39a1c..a0a631beff14bf1a6eda836c47e88c8874eb7700 100644
--- a/packages/genpybind/package.py
+++ b/packages/genpybind/package.py
@@ -43,7 +43,7 @@ class Genpybind(WafPackage):
     version('ebrains', tag='ebrains_release-1-rc1', git='https://github.com/electronicvisions/genpybind')
 
     depends_on(
-            'llvm+clang+python+visionary@5.0.0:',
+            'llvm+clang+python+visionary@5.0.0: libcxx=none',
         type=('build', 'link', 'run'))
     depends_on('binutils', type='build')
     depends_on('python@2.7:', type=('build', 'run'))
diff --git a/packages/hxtorch/package.py b/packages/hxtorch/package.py
index 1b3b9e069b30d08d34a0b631a57670e7d10d94b5..bff7e733e9fa3226d760decfc0cd2280718ce3ec 100644
--- a/packages/hxtorch/package.py
+++ b/packages/hxtorch/package.py
@@ -3,8 +3,13 @@
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 import os
+import unittest.mock
+import sys
+import xml.etree.ElementTree as ET
 
 from spack import *
+from spack.util.environment import EnvironmentModifications
+import spack.build_environment
 
 
 class Hxtorch(WafPackage):
@@ -16,11 +21,19 @@ class Hxtorch(WafPackage):
 
     maintainers = ['emuller']
 
-    version('7.0-rc1-fixup2', branch='waf')
+    version('8.0-a3',         tag='hxtorch-8.0-a3')
+    version('8.0-a2',         tag='hxtorch-8.0-a2')
+    version('8.0-a1',         tag='hxtorch-8.0-a1')
+    version('7.0-rc1-fixup3', tag='hxtorch-7.0-rc1-fixup3')
+    version('7.0-rc1-fixup2', tag='hxtorch-7.0-rc1-fixup2')
     version('7.0-rc1-fixup1', branch='waf')
 
     # compiler for the BrainScaleS-2 embedded processor ("PPU"); needed for
     # building/linking, at runtime and for testing
+    depends_on('oppulance@8.0-a3', when='@8.0-a3', type=('build', 'link', 'run', 'test'))
+    depends_on('oppulance@8.0-a2', when='@8.0-a2', type=('build', 'link', 'run', 'test'))
+    depends_on('oppulance@8.0-a1', when='@8.0-a1', type=('build', 'link', 'run', 'test'))
+    depends_on('oppulance@7.0-rc1-fixup3', when='@7.0-rc1-fixup3', type=('build', 'link', 'run', 'test'))
     depends_on('oppulance@7.0-rc1-fixup2', when='@7.0-rc1-fixup2', type=('build', 'link', 'run', 'test'))
     depends_on('oppulance@7.0-rc1-fixup1', when='@7.0-rc1-fixup1', type=('build', 'link', 'run', 'test'))
 
@@ -32,16 +45,17 @@ class Hxtorch(WafPackage):
     depends_on('cppcheck', type=('build', 'link', 'run'))
     depends_on('genpybind@ebrains', type=('build', 'link', 'run'))
     depends_on('gflags', type=('build', 'link', 'run'))
+    depends_on('git', type=('build', 'link'))
     depends_on('googletest@1.11.0:+gmock', type=('build', 'link', 'run')) # variadic templates needed
     depends_on('inja', type=('build', 'link', 'run', 'test')) # template engine for PPU source jit generation
     depends_on('intel-tbb', type=('build', 'link', 'run'))  # ppu gdbserver
     depends_on('libelf', type=('build', 'link', 'run'))
     depends_on('liblockfile', type=('build', 'link', 'run'))
-    depends_on('llvm', type=('build', 'link', 'run'))
     depends_on('log4cxx@0.12.1:', type=('build', 'link', 'run'))
     depends_on('pkgconfig', type=('build', 'link', 'run'))
     depends_on('psmisc', type=('run', 'test'))
     depends_on('python@3.7.0:', type=('build', 'link', 'run')) # BrainScaleS-2 only supports Python >= 3.7
+    depends_on('py-git-review', type=('build', 'link'))
     depends_on('py-h5py', type=('build', 'link', 'run')) # PyNN tests need it
     depends_on('py-jax@0.3.25:', type=('build', 'link', 'run'))
     depends_on('py-matplotlib', type=('build', 'link', 'run'))
@@ -63,75 +77,41 @@ class Hxtorch(WafPackage):
     depends_on('yaml-cpp+shared', type=('build', 'link', 'run'))
     extends('python')
 
-    def setup_build_environment(self, env):
-        """waf needs to find headers and libraries by itself (mostly `boost`
-        tool, but also `gtest`); it also needs to run executables during
-        configuration."""
-
-        include = []
-        include_exclude_dirs = set(['/usr/include'])
-        for dep in self.spec.traverse(deptype='build', root=False):
-            query = self.spec[dep.name]
-            if dep.name in ['pthreadpool', 'fxdiv']:
-                print('skipping {} in SPACK_INCLUDE_DIRS/CPATH/C{{,_PLUS}}_INCLUDE_PATH\n'.format(dep.name))
-                for d in query.headers.directories:
-                    if os.path.exists(d):
-                        env.remove_path('SPACK_INCLUDE_DIRS', d)
-                continue
-            try:
-                include_dirs = set(query.headers.directories)
-                include_dirs -= include_exclude_dirs
-                print('headers (', dep.name, '):', include_dirs, "\n")
-                include.extend(list(include_dirs))
-            except spack.error.NoHeadersError:
-                # we don't care if no header directories are found
-                pass
-
-        library = []
-        library_exclude_dirs = set(['/lib', '/lib64', '/usr/lib', '/usr/lib64'])
-        for dep in self.spec.traverse(deptype=('link', 'run'), root=False):
-            query = self.spec[dep.name]
-            try:
-                library_dirs = set(query.libs.directories)
-                library_dirs -= library_exclude_dirs
-                print('libs (', dep.name, '):', library_dirs, "\n")
-                library.extend(list(library_dirs))
-            except spack.error.NoLibrariesError:
-                # we don't care if no library directories are found
-                pass
-
-        path = []
-        for dep in self.spec.traverse(deptype=('build', 'link', 'run'), root=False):
-            if dep.name in ['pthreadpool', 'fxdiv']:
-                print('skipping {} for bin'.format(dep.name))
-                continue
-            query = self.spec[dep.name]
-            if os.path.exists(self.prefix.bin):
-                path.append(query.prefix.bin)
-                print('bin (', dep.name, '):', query.prefix.bin, "\n")
-
-        # llvm might be built with ~shared_libs but still builds shared libs
-        if not any('llvm' in lib for lib in library):
-            print("libs: manually adding ", self.spec['llvm'].prefix.lib)
-            library.append(self.spec['llvm'].prefix.lib)
-
-        # explicitly add googletest library if it isn't found above;
-        # adding in front of the list of libraries is a hack to circumvent
-        # issues from vendoring packages like pthreadpool
-        if not any('googletest' in lib for lib in library):
-            if os.path.isdir(self.spec['googletest'].prefix.lib64):
-                print("libs: manually inserting at front ", self.spec['googletest'].prefix.lib64)
-                library.insert(0, self.spec['googletest'].prefix.lib64)
-            if os.path.isdir(self.spec['googletest'].prefix.lib):
-                print("libs: manually inserting at front ", self.spec['googletest'].prefix.lib)
-                library.insert(0, self.spec['googletest'].prefix.lib)
-
-        env.set('CPATH', ':'.join(include))
-        env.set('C_INCLUDE_PATH', ':'.join(include))
-        env.set('CPLUS_INCLUDE_PATH', ':'.join(include))
-        env.set('LIBRARY_PATH', ':'.join(library))
-        env.set('WAF_CONFIGURE_LD_LIBRARY_PATH', ':'.join(library))
-        env.prepend_path('PATH', ':'.join(path))
+    def do_fetch(self, mirror_only=False):
+        """Setup the project."""
+
+        self.stage.create()
+        self.stage.fetch(mirror_only)
+
+        # if fetcher didn't do anything, it's cached already
+        if not os.path.exists(self.stage.source_path):
+            return
+
+        with working_dir(self.stage.source_path):
+            python = which('python3')
+            if self.spec.satisfies('@:7'):
+                python('./waf', 'setup', '--repo-db-url=https://github.com/electronicvisions/projects',
+                    '--clone-depth=2',
+                    '--without-munge',
+                    '--without-hxcomm-hostarq',
+                    '--without-hxcomm-extoll',
+                    '--project=hxtorch',
+                    '--release-branch=ebrains-' + str(self.spec.version)
+                )
+            else:
+                python('./waf', 'setup', '--repo-db-url=https://github.com/electronicvisions/projects',
+                    '--clone-depth=2',
+                    '--without-munge',
+                    '--without-hxcomm-hostarq',
+                    '--project=hxtorch',
+                    '--release-branch=ebrains-' + str(self.spec.version)
+                )
+
+        # in the configure step, we need access to all archived .git folders
+        def custom_archive(self, destination):
+            super(spack.fetch_strategy.GitFetchStrategy, self).archive(destination)
+        with unittest.mock.patch('spack.fetch_strategy.GitFetchStrategy.archive', new=custom_archive):
+            self.stage.cache_local()
 
     def _setup_common_env(self, env):
         # grenade needs to find some libraries for the JIT-compilation of
@@ -142,8 +122,37 @@ class Hxtorch(WafPackage):
             dep = self.spec[ppu_dep_name]
             dep_include_dirs = set(dep.headers.directories)
             ppu_include_dirs.extend(list(dep_include_dirs))
-        env.set('C_INCLUDE_PATH', ':'.join(ppu_include_dirs))
-        env.set('CPLUS_INCLUDE_PATH', ':'.join(ppu_include_dirs))
+        for dir in reversed(ppu_include_dirs):
+            env.prepend_path("C_INCLUDE_PATH", dir)
+            env.prepend_path("CPLUS_INCLUDE_PATH", dir)
+
+    def setup_build_environment(self, env):
+        my_envmod = EnvironmentModifications(env)
+        spack.build_environment.set_wrapper_variables(self, my_envmod)
+        my_env = {}
+        my_envmod.apply_modifications(my_env)
+
+        def get_path(env, name):
+            path = env.get(name, "").strip()
+            if path:
+                return path.split(os.pathsep)
+            return []
+
+        # spack tries to find headers and libraries by itself (i.e. it's not
+        # relying on the compiler to find it); we explicitly expose the
+        # spack-provided env vars that contain include and library paths
+        if 'SPACK_INCLUDE_DIRS' in my_env:
+            for dir in reversed(get_path(my_env, "SPACK_INCLUDE_DIRS")):
+                env.prepend_path("C_INCLUDE_PATH", dir)
+                env.prepend_path("CPLUS_INCLUDE_PATH", dir)
+        if 'SPACK_LINK_DIRS' in my_env:
+            for dir in reversed(get_path(my_env, "SPACK_LINK_DIRS")):
+                env.prepend_path("LIBRARY_PATH", dir)
+                env.prepend_path("LD_LIBRARY_PATH", dir)
+        for dir in reversed(self.compiler.implicit_rpaths()):
+            env.prepend_path("LIBRARY_PATH", dir)
+            # technically this is probably not needed for the non-configure steps
+            env.prepend_path("LD_LIBRARY_PATH", dir)
 
     def setup_dependent_build_environment(self, env, dependent_spec):
         self._setup_common_env(env)
@@ -156,25 +165,10 @@ class Hxtorch(WafPackage):
 
     # override configure step as we perform a project setup first
     def configure(self, spec, prefix):
-        """Setup and configure the project."""
-
-        env = os.environ
-        if 'SPACK_COMPILER_IMPLICIT_RPATHS' in env:
-            env['LIBRARY_PATH'] = env['SPACK_COMPILER_IMPLICIT_RPATHS'] + ':' + env['LIBRARY_PATH']
-            env['WAF_CONFIGURE_LD_LIBRARY_PATH'] = env['SPACK_COMPILER_IMPLICIT_RPATHS'] + ':' + env['WAF_CONFIGURE_LD_LIBRARY_PATH']
-
-        self.waf('setup', '--repo-db-url=https://github.com/electronicvisions/projects',
-            '--without-munge',
-            '--without-hxcomm-hostarq',
-            '--without-hxcomm-extoll',
-            '--project=hxtorch',
-            '--release-branch=ebrains-' + str(spec.version)
-         )
+        """Configure the project."""
 
         args = ['--prefix={0}'.format(self.prefix)]
         args += self.configure_args()
-
-        env['LD_LIBRARY_PATH'] = env.get('WAF_CONFIGURE_LD_LIBRARY_PATH')
         self.waf('configure', '--build-profile=release', '--disable-doxygen', *args)
 
     def build_args(self):
@@ -183,7 +177,18 @@ class Hxtorch(WafPackage):
 
     def build_test(self):
         self.builder.waf('build', '--test-execall')
-        copy_tree('build/test_results', join_path(self.prefix, '.build'))
+        copy_tree('build/test_results', join_path(self.prefix, ".build"))
+        copy_tree('build/test_results', join_path(self.stage.path, ".install_time_tests"))
+        # propagate failures from junit output to spack
+        tree = ET.parse('build/test_results/summary.xml')
+        for testsuite in tree.getroot():
+            for testcase in testsuite:
+                for elem in testcase:
+                    if (elem.tag == 'failure') and not (
+                            elem.get('message').startswith("pylint:") or
+                            elem.get('message').startswith("pycodestyle:") or
+                            ("OK" in elem.get('message') and "Segmentation fault" in elem.get('message'))):
+                        raise RuntimeError("Failed test found: {}".format(testcase.get('name')))
 
     def install_args(self):
         args = ['--test-execnone']
diff --git a/packages/libxcb/package.py b/packages/libxcb/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..feb33229a3a598ebb9ce830ef8a83eebab09a278
--- /dev/null
+++ b/packages/libxcb/package.py
@@ -0,0 +1,52 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class Libxcb(AutotoolsPackage):
+    """The X protocol C-language Binding (XCB) is a replacement
+    for Xlib featuring a small footprint, latency hiding, direct
+    access to the protocol, improved threading support, and
+    extensibility."""
+
+    homepage = "https://xcb.freedesktop.org/"
+    url = "https://xorg.freedesktop.org/archive/individual/lib/libxcb-1.14.tar.xz"
+
+    version("1.14", sha256="a55ed6db98d43469801262d81dc2572ed124edc3db31059d4e9916eb9f844c34")
+    version("1.13", sha256="0bb3cfd46dbd90066bf4d7de3cad73ec1024c7325a4a0cbf5f4a0d4fa91155fb")
+
+    depends_on("libpthread-stubs")
+    depends_on("libxau@0.99.2:")
+    depends_on("libxdmcp")
+
+    # libxcb 1.X requires xcb-proto >= 1.X
+    depends_on("xcb-proto")
+    depends_on("xcb-proto@1.14:", when="@1.14")
+    depends_on("xcb-proto@1.13:", when="@1.13")
+
+    # depends_on("python", type="build")
+    depends_on("pkgconfig", type="build")
+    depends_on("util-macros", type="build")
+
+    def url_for_version(self, version):
+        if version >= Version("1.14"):
+            url = "https://xorg.freedesktop.org/archive/individual/lib/libxcb-{0}.tar.xz"
+        else:
+            url = "https://xcb.freedesktop.org/dist/libxcb-{0}.tar.gz"
+
+        return url.format(version)
+
+    def configure_args(self):
+        config_args = []
+
+        # -Werror flags are not properly interpreted by the NVIDIA compiler
+        if self.spec.satisfies("%nvhpc@:20.11"):
+            config_args.append("--disable-selective-werror")
+
+        return config_args
+
+    def patch(self):
+        filter_file("typedef struct xcb_auth_info_t {", "typedef struct {", "src/xcb.h")
\ No newline at end of file
diff --git a/packages/llvm/add-include-for-libelf-llvm-12-14.patch b/packages/llvm/add-include-for-libelf-llvm-12-14.patch
new file mode 100644
index 0000000000000000000000000000000000000000..f585d08d010ae08438c60e575710cb4adbc76c9b
--- /dev/null
+++ b/packages/llvm/add-include-for-libelf-llvm-12-14.patch
@@ -0,0 +1,26 @@
+From e5f0939fde75f769c53c6c99c9ed6886e7d58c43 Mon Sep 17 00:00:00 2001
+From: Harmen Stoppels <me@harmenstoppels.nl>
+Date: Wed, 23 Aug 2023 11:35:23 +0200
+Subject: [PATCH] Add corresponding -I for libelf.h
+
+Funnily enough, it's added to `include_directories` in multiple places,
+except where it's necessary.
+---
+ openmp/libomptarget/plugins/amdgpu/CMakeLists.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+index 92523c23f68b..52e1923f97b7 100644
+--- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
++++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+@@ -51,6 +51,7 @@ endif()
+ include_directories(
+   ${CMAKE_CURRENT_SOURCE_DIR}/impl
+   ${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
++  ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR}
+ )
+ 
+ set(LIBOMPTARGET_DLOPEN_LIBHSA OFF)
+-- 
+2.39.2
+
diff --git a/packages/llvm/add-include-for-libelf-llvm-15.patch b/packages/llvm/add-include-for-libelf-llvm-15.patch
new file mode 100644
index 0000000000000000000000000000000000000000..7a7d57d108f5a802d2e5a2e287a8aae0bb4bdf80
--- /dev/null
+++ b/packages/llvm/add-include-for-libelf-llvm-15.patch
@@ -0,0 +1,26 @@
+From 5e149c3ec8118ad8f3d20a30ce5d3fbac4072515 Mon Sep 17 00:00:00 2001
+From: Harmen Stoppels <me@harmenstoppels.nl>
+Date: Wed, 23 Aug 2023 11:35:23 +0200
+Subject: [PATCH] Add corresponding -I for libelf.h
+
+Funnily enough, it's added to `include_directories` in multiple places,
+except where it's necessary.
+---
+ openmp/libomptarget/plugins/amdgpu/CMakeLists.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+index 66bf680d15c7..6be12ab6d7f8 100644
+--- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
++++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+@@ -99,6 +99,7 @@ target_include_directories(
+   PRIVATE
+   ${LIBOMPTARGET_INCLUDE_DIR}
+   ${CMAKE_CURRENT_SOURCE_DIR}/impl
++  ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR}
+ )
+ 
+ 
+-- 
+2.39.2
+
diff --git a/packages/llvm/llvm-version-suffix-macro.patch b/packages/llvm/llvm-version-suffix-macro.patch
deleted file mode 100644
index 62e9684386b34501a2da7e5c31ea00ac393387c8..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm-version-suffix-macro.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake
-index 4493bb65d444..e2b3c61b3c33 100644
---- a/llvm/include/llvm/Config/llvm-config.h.cmake
-+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
-@@ -74,6 +74,9 @@
- /* Patch version of the LLVM API */
- #define LLVM_VERSION_PATCH ${LLVM_VERSION_PATCH}
- 
-+/* LLVM version suffix */
-+#cmakedefine LLVM_VERSION_SUFFIX "${LLVM_VERSION_SUFFIX}"
-+
- /* LLVM version string */
- #define LLVM_VERSION_STRING "${PACKAGE_VERSION}"
- 
diff --git a/packages/llvm/llvm13-thread.patch b/packages/llvm/llvm13-thread.patch
new file mode 100644
index 0000000000000000000000000000000000000000..0067a930373e361c3f7d7cf0d9da7a19ec82340a
--- /dev/null
+++ b/packages/llvm/llvm13-thread.patch
@@ -0,0 +1,19 @@
+--- spack-src/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake.org	2022-02-08 14:58:13.000000000 +0900
++++ spack-src/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake	2022-02-08 13:58:53.000000000 +0900
+@@ -276,4 +276,5 @@
+   endif()
+ endif()
+
+-set(OPENMP_PTHREAD_LIB ${LLVM_PTHREAD_LIB})
++find_package(Threads REQUIRED)
++set(OPENMP_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
+--- spack-src/openmp/libomptarget/src/CMakeLists.txt.org	2022-02-09 08:49:35.000000000 +0900
++++ spack-src/openmp/libomptarget/src/CMakeLists.txt	2022-02-09 08:50:18.000000000 +0900
+@@ -36,6 +36,7 @@
+ endif()
+ target_link_libraries(omptarget PRIVATE
+   ${CMAKE_DL_LIBS}
++  ${OPENMP_PTHREAD_LIB}
+   "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports")
+ 
+ # Install libomptarget under the lib destination folder.
diff --git a/packages/llvm/llvm5-0001-libclang-Add-support-for-checking-abstractness-of-re.patch b/packages/llvm/llvm5-0001-libclang-Add-support-for-checking-abstractness-of-re.patch
deleted file mode 100644
index 62aabd59000ea8e99255a341945fc76ddfffbf74..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0001-libclang-Add-support-for-checking-abstractness-of-re.patch
+++ /dev/null
@@ -1,146 +0,0 @@
-From 85f611be67af9f9b5677917b4fee5bd15b5dc394 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Mon, 31 Jul 2017 14:09:08 +0200
-Subject: [PATCH 01/12] [libclang] Add support for checking abstractness of
- records
-
----
- bindings/python/clang/cindex.py             | 10 ++++++++++
- bindings/python/tests/cindex/test_cursor.py | 11 +++++++++++
- include/clang-c/Index.h                     |  6 ++++++
- test/Index/load-classes.cpp                 |  2 +-
- tools/c-index-test/c-index-test.c           |  2 ++
- tools/libclang/CIndex.cpp                   | 11 +++++++++++
- tools/libclang/libclang.exports             |  1 +
- 7 files changed, 42 insertions(+), 1 deletion(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index 236803a9ab..0f01d171ad 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -1478,6 +1478,12 @@ class Cursor(Structure):
-         """
-         return conf.lib.clang_CXXMethod_isVirtual(self)
- 
-+    def is_abstract_record(self):
-+        """Returns True if the cursor refers to a C++ record declaration
-+        that has pure virtual member functions.
-+        """
-+        return conf.lib.clang_CXXRecord_isAbstract(self)
-+
-     def is_scoped_enum(self):
-         """Returns True if the cursor refers to a scoped enum declaration.
-         """
-@@ -3319,6 +3325,10 @@ functionList = [
-    [Cursor],
-    bool),
- 
-+  ("clang_CXXRecord_isAbstract",
-+   [Cursor],
-+   bool),
-+
-   ("clang_EnumDecl_isScoped",
-    [Cursor],
-    bool),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 4787ea931e..85c455fd73 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -255,6 +255,17 @@ def test_is_virtual_method():
-     assert foo.is_virtual_method()
-     assert not bar.is_virtual_method()
- 
-+def test_is_abstract_record():
-+    """Ensure Cursor.is_abstract_record works."""
-+    source = 'struct X { virtual void x() = 0; }; struct Y : X { void x(); };'
-+    tu = get_tu(source, lang='cpp')
-+
-+    cls = get_cursor(tu, 'X')
-+    assert cls.is_abstract_record()
-+
-+    cls = get_cursor(tu, 'Y')
-+    assert not cls.is_abstract_record()
-+
- def test_is_scoped_enum():
-     """Ensure Cursor.is_scoped_enum works."""
-     source = 'class X {}; enum RegularEnum {}; enum class ScopedEnum {};'
-diff --git a/tools/clang/include/clang-c/Index.h b/tools/clang/include/clang-c/Index.h
-index 3b5ea9fa53..89957e8526 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -4419,6 +4419,12 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
- CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
- 
- /**
-+ * \brief Determine if a C++ record is abstract, i.e. whether a class or struct
-+ * has a pure virtual member function.
-+ */
-+CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
-+
-+/**
-  * \brief Determine if an enum declaration refers to a scoped enum.
-  */
- CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
-diff --git a/tools/clang/test/Index/load-classes.cpp b/tools/clang/test/Index/load-classes.cpp
-index 8b1ed317e3..b6c25b4f75 100644
---- a/tools/clang/test/Index/load-classes.cpp
-+++ b/tools/clang/test/Index/load-classes.cpp
-@@ -29,7 +29,7 @@ X::X(int value) {
- }
- 
- // RUN: c-index-test -test-load-source all %s | FileCheck %s
--// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 26:2]
-+// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) (abstract) Extent=[3:1 - 26:2]
- // CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 (converting constructor) Extent=[4:3 - 4:15] [access=public]
- // FIXME: missing TypeRef in the constructor name
- // CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14]
-diff --git a/tools/clang/tools/c-index-test/c-index-test.c b/tools/clang/tools/c-index-test/c-index-test.c
-index cf3581e259..08a187ffdd 100644
---- a/tools/clang/tools/c-index-test/c-index-test.c
-+++ b/tools/clang/tools/c-index-test/c-index-test.c
-@@ -804,6 +804,8 @@ static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) {
-       printf(" (const)");
-     if (clang_CXXMethod_isPureVirtual(Cursor))
-       printf(" (pure)");
-+    if (clang_CXXRecord_isAbstract(Cursor))
-+      printf(" (abstract)");
-     if (clang_EnumDecl_isScoped(Cursor))
-       printf(" (scoped)");
-     if (clang_Cursor_isVariadic(Cursor))
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/clang/tools/libclang/CIndex.cpp
-index ca21b6c6f6..621bc42076 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -7846,6 +7846,17 @@ unsigned clang_CXXMethod_isVirtual(CXCursor C) {
-   return (Method && Method->isVirtual()) ? 1 : 0;
- }
- 
-+unsigned clang_CXXRecord_isAbstract(CXCursor C) {
-+  if (!clang_isDeclaration(C.kind))
-+    return 0;
-+
-+  const auto *D = cxcursor::getCursorDecl(C);
-+  const auto *RD = dyn_cast_or_null<CXXRecordDecl>(D);
-+  if (RD)
-+    RD = RD->getDefinition();
-+  return (RD && RD->isAbstract()) ? 1 : 0;
-+}
-+
- unsigned clang_EnumDecl_isScoped(CXCursor C) {
-   if (!clang_isDeclaration(C.kind))
-     return 0;
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/clang/tools/libclang/libclang.exports
-index e0d178a529..9ddc055125 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -12,6 +12,7 @@ clang_CXXMethod_isConst
- clang_CXXMethod_isPureVirtual
- clang_CXXMethod_isStatic
- clang_CXXMethod_isVirtual
-+clang_CXXRecord_isAbstract
- clang_EnumDecl_isScoped
- clang_Cursor_getArgument
- clang_Cursor_getNumTemplateArguments
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0002-libclang-Keep-track-of-TranslationUnit-instance-when.patch b/packages/llvm/llvm5-0002-libclang-Keep-track-of-TranslationUnit-instance-when.patch
deleted file mode 100644
index d5d076234c36c8d14daeb86b80f1e7553f258161..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0002-libclang-Keep-track-of-TranslationUnit-instance-when.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From 0c4382f31fefe6c5575842427c83e1c26fe00efa Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Fri, 28 Jul 2017 12:25:20 +0200
-Subject: [PATCH 02/12] [libclang] Keep track of TranslationUnit instance when
- annotating tokens
-
-Previously the _tu was not propagated to the returned cursor, leading to errors when calling any
-method on that cursor (e.g. cursor.referenced).
----
- bindings/python/clang/cindex.py             |  1 +
- bindings/python/tests/cindex/test_cursor.py | 22 ++++++++++++++++++++++
- 2 files changed, 23 insertions(+)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index 0f01d171ad..ecff13f7a5 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -3199,6 +3199,7 @@ class Token(Structure):
-     def cursor(self):
-         """The Cursor this Token corresponds to."""
-         cursor = Cursor()
-+        cursor._tu = self._tu
- 
-         conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor))
- 
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 85c455fd73..87fd76ed0e 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -406,6 +406,28 @@ def test_get_tokens():
-     assert tokens[0].spelling == 'int'
-     assert tokens[1].spelling == 'foo'
- 
-+def test_get_token_cursor():
-+    """Ensure we can map tokens to cursors."""
-+    tu = get_tu('class A {}; int foo(A var = A());', lang='cpp')
-+    foo = get_cursor(tu, 'foo')
-+
-+    for cursor in foo.walk_preorder():
-+        if cursor.kind.is_expression() and not cursor.kind.is_statement():
-+            break
-+    else:
-+        assert False, "Could not find default value expression"
-+
-+    tokens = list(cursor.get_tokens())
-+    assert len(tokens) == 4, [t.spelling for t in tokens]
-+    assert tokens[0].spelling == '='
-+    assert tokens[1].spelling == 'A'
-+    assert tokens[2].spelling == '('
-+    assert tokens[3].spelling == ')'
-+    t_cursor = tokens[1].cursor
-+    assert t_cursor.kind == CursorKind.TYPE_REF
-+    r_cursor = t_cursor.referenced # should not raise an exception
-+    assert r_cursor.kind == CursorKind.CLASS_DECL
-+
- def test_get_arguments():
-     tu = get_tu('void foo(int i, int j);')
-     foo = get_cursor(tu, 'foo')
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0003-Fix-warnings-in-Tooling-QualTypeNamesTest.patch b/packages/llvm/llvm5-0003-Fix-warnings-in-Tooling-QualTypeNamesTest.patch
deleted file mode 100644
index 2fa9a8c80ce5aeffb04977ce941395bdc6543fa3..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0003-Fix-warnings-in-Tooling-QualTypeNamesTest.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 1ef6a85f73cb4f06405dfe20c225bcc0da9f9776 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Wed, 26 Jul 2017 15:09:28 +0200
-Subject: [PATCH 03/12] Fix warnings in Tooling/QualTypeNamesTest
-
-The code in question uses variadic templates and alias declarations
-and thus needs `-std=c++11`.
----
- unittests/Tooling/QualTypeNamesTest.cpp | 11 +++++++----
- 1 file changed, 7 insertions(+), 4 deletions(-)
-
-diff --git a/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp b/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-index edd5060ba0..532fae6f5a 100644
---- a/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-+++ b/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-@@ -35,7 +35,7 @@ struct TypeNameVisitor : TestVisitor<TypeNameVisitor> {
-         EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for "
-                            << VD->getQualifiedNameAsString() << std::endl
-                            << "   Actual: " << ActualName << std::endl
--                           << " Exepcted: " << ExpectedName;
-+                           << " Expected: " << ExpectedName;
-       }
-     }
-     return true;
-@@ -163,7 +163,7 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-       "};\n"
-       "EnumScopeClass::AnEnum AnEnumVar;\n",
-       TypeNameVisitor::Lang_CXX11
--);
-+  );
- 
-   TypeNameVisitor Complex;
-   Complex.ExpectedQualTypeNames["CheckTX"] = "B::TX";
-@@ -180,7 +180,9 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-       "  typedef tuple<X> TX;"
-       "  TX CheckTX;"
-       "  struct A { typedef int X; };"
--      "}");
-+      "}",
-+      TypeNameVisitor::Lang_CXX11
-+  );
- 
-   TypeNameVisitor GlobalNsPrefix;
-   GlobalNsPrefix.WithGlobalNsPrefix = true;
-@@ -215,7 +217,8 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-       "      aStruct CheckK;\n"
-       "    }\n"
-       "  }\n"
--      "}\n"
-+      "}\n",
-+      TypeNameVisitor::Lang_CXX11
-   );
- }
- 
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0004-Defer-addition-of-keywords-to-identifier-table-when-.patch b/packages/llvm/llvm5-0004-Defer-addition-of-keywords-to-identifier-table-when-.patch
deleted file mode 100644
index 426b22fdbca50d1ab82a8dafd8355dcd9217e490..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0004-Defer-addition-of-keywords-to-identifier-table-when-.patch
+++ /dev/null
@@ -1,220 +0,0 @@
-From ba4c926983036f010c3e4d28be48cfdee8495f87 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Sun, 9 Jul 2017 13:03:02 +0200
-Subject: [PATCH 04/12] Defer addition of keywords to identifier table when
- loading AST
-
-In ASTUnit::LoadFromASTFile, the preprocesor object is set up using
-default-constructed LangOptions (which only later get populated).
-Then, in the constructor of IdentifierTable, these default-constructed
-LangOptions were used in the call to AddKeywords, leading to wrong
-initialization of the identifier table.
-
-This change defers adding the keywords to the identifier table until
-after the language options have been loaded from the AST file.
----
- include/clang/Basic/IdentifierTable.h |  6 ++--
- include/clang/Lex/Preprocessor.h      |  3 +-
- lib/Basic/IdentifierTable.cpp         | 17 +++++-----
- lib/Frontend/ASTUnit.cpp              | 10 ++++--
- lib/Lex/Preprocessor.cpp              |  6 ++--
- unittests/libclang/LibclangTest.cpp   | 64 +++++++++++++++++++++++++++++++++++
- 6 files changed, 91 insertions(+), 15 deletions(-)
-
-diff --git a/tools/clang/include/clang/Basic/IdentifierTable.h b/tools/clang/include/clang/Basic/IdentifierTable.h
-index 3938e09890..1172869d45 100644
---- a/tools/clang/include/clang/Basic/IdentifierTable.h
-+++ b/tools/clang/include/clang/Basic/IdentifierTable.h
-@@ -472,9 +472,11 @@ class IdentifierTable {
- 
- public:
-   /// \brief Create the identifier table, populating it with info about the
--  /// language keywords for the language specified by \p LangOpts.
-+  /// language keywords for the language specified by \p LangOpts if
-+  /// \p DeferKeywordAddition is not set.
-   IdentifierTable(const LangOptions &LangOpts,
--                  IdentifierInfoLookup* externalLookup = nullptr);
-+                  IdentifierInfoLookup *externalLookup = nullptr,
-+                  bool DeferKeywordAddition = false);
- 
-   /// \brief Set the external identifier lookup mechanism.
-   void setExternalIdentifierLookup(IdentifierInfoLookup *IILookup) {
-diff --git a/tools/clang/include/clang/Lex/Preprocessor.h b/tools/clang/include/clang/Lex/Preprocessor.h
-index 49a95986fd..6570e4c76e 100644
---- a/tools/clang/include/clang/Lex/Preprocessor.h
-+++ b/tools/clang/include/clang/Lex/Preprocessor.h
-@@ -692,7 +692,8 @@ public:
-                HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
-                IdentifierInfoLookup *IILookup = nullptr,
-                bool OwnsHeaderSearch = false,
--               TranslationUnitKind TUKind = TU_Complete);
-+               TranslationUnitKind TUKind = TU_Complete,
-+               bool DeferKeywordAddition = false);
- 
-   ~Preprocessor();
- 
-diff --git a/tools/clang/lib/Basic/IdentifierTable.cpp b/tools/clang/lib/Basic/IdentifierTable.cpp
-index fe7829ec50..cfb0b1a702 100644
---- a/tools/clang/lib/Basic/IdentifierTable.cpp
-+++ b/tools/clang/lib/Basic/IdentifierTable.cpp
-@@ -73,17 +73,15 @@ IdentifierIterator *IdentifierInfoLookup::getIdentifiers() {
- }
- 
- IdentifierTable::IdentifierTable(const LangOptions &LangOpts,
--                                 IdentifierInfoLookup* externalLookup)
--  : HashTable(8192), // Start with space for 8K identifiers.
--    ExternalLookup(externalLookup) {
-+                                 IdentifierInfoLookup *externalLookup,
-+                                 bool DeferKeywordAddition)
-+    : HashTable(8192), // Start with space for 8K identifiers.
-+      ExternalLookup(externalLookup) {
- 
-   // Populate the identifier table with info about keywords for the current
-   // language.
--  AddKeywords(LangOpts);
--      
--
--  // Add the '_experimental_modules_import' contextual keyword.
--  get("import").setModulesImport(true);
-+  if (!DeferKeywordAddition)
-+    AddKeywords(LangOpts);
- }
- 
- //===----------------------------------------------------------------------===//
-@@ -230,6 +228,9 @@ void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
- 
-   if (LangOpts.DeclSpecKeyword)
-     AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
-+
-+  // Add the '_experimental_modules_import' contextual keyword.
-+  get("import").setModulesImport(true);
- }
- 
- /// \brief Checks if the specified token kind represents a keyword in the
-diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp
-index 07f847ca94..875f21d69a 100644
---- a/tools/clang/lib/Frontend/ASTUnit.cpp
-+++ b/tools/clang/lib/Frontend/ASTUnit.cpp
-@@ -536,6 +536,10 @@ private:
-     // Initialize the preprocessor.
-     PP.Initialize(*Target);
- 
-+    // Populate the identifier table with info about keywords for the current
-+    // language.
-+    PP.getIdentifierTable().AddKeywords(LangOpt);
-+
-     if (!Context)
-       return;
- 
-@@ -718,11 +722,13 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
-   HeaderSearch &HeaderInfo = *AST->HeaderInfo;
-   unsigned Counter;
- 
-+  // As the language options have not been loaded yet, adding keywords to the
-+  // identifier table is deferred and will be initiated by ASTInfoCollector.
-   AST->PP = std::make_shared<Preprocessor>(
-       AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
-       AST->getSourceManager(), *AST->PCMCache, HeaderInfo, AST->ModuleLoader,
--      /*IILookup=*/nullptr,
--      /*OwnsHeaderSearch=*/false);
-+      /*IILookup=*/nullptr, /*OwnsHeaderSearch=*/false, TU_Complete,
-+      /*DeferKeywordAddition=*/true);
-   Preprocessor &PP = *AST->PP;
- 
-   if (ToLoad >= LoadASTOnly)
-diff --git a/tools/clang/lib/Lex/Preprocessor.cpp b/tools/clang/lib/Lex/Preprocessor.cpp
-index 158d0eca27..64365385a3 100644
---- a/tools/clang/lib/Lex/Preprocessor.cpp
-+++ b/tools/clang/lib/Lex/Preprocessor.cpp
-@@ -73,12 +73,14 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
-                            SourceManager &SM, MemoryBufferCache &PCMCache,
-                            HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
-                            IdentifierInfoLookup *IILookup, bool OwnsHeaders,
--                           TranslationUnitKind TUKind)
-+                           TranslationUnitKind TUKind,
-+                           bool DeferKeywordAddition)
-     : PPOpts(std::move(PPOpts)), Diags(&diags), LangOpts(opts), Target(nullptr),
-       AuxTarget(nullptr), FileMgr(Headers.getFileMgr()), SourceMgr(SM),
-       PCMCache(PCMCache), ScratchBuf(new ScratchBuffer(SourceMgr)),
-       HeaderInfo(Headers), TheModuleLoader(TheModuleLoader),
--      ExternalSource(nullptr), Identifiers(opts, IILookup),
-+      ExternalSource(nullptr),
-+      Identifiers(opts, IILookup, DeferKeywordAddition),
-       PragmaHandlers(new PragmaNamespace(StringRef())),
-       IncrementalProcessing(false), TUKind(TUKind), CodeComplete(nullptr),
-       CodeCompletionFile(nullptr), CodeCompletionOffset(0),
-diff --git a/tools/clang/unittests/libclang/LibclangTest.cpp b/tools/clang/unittests/libclang/LibclangTest.cpp
-index f2a96d6be6..27c8ac7b3d 100644
---- a/tools/clang/unittests/libclang/LibclangTest.cpp
-+++ b/tools/clang/unittests/libclang/LibclangTest.cpp
-@@ -572,3 +572,67 @@ TEST_F(LibclangReparseTest, clang_parseTranslationUnit2FullArgv) {
-   EXPECT_EQ(0U, clang_getNumDiagnostics(ClangTU));
-   DisplayDiagnostics();
- }
-+
-+class LibclangSerializationTest : public LibclangParseTest {
-+public:
-+  bool SaveAndLoadTU(const std::string &Filename) {
-+    unsigned options = clang_defaultSaveOptions(ClangTU);
-+    if (clang_saveTranslationUnit(ClangTU, Filename.c_str(), options) !=
-+        CXSaveError_None) {
-+      DEBUG(llvm::dbgs() << "Saving failed\n");
-+      return false;
-+    }
-+
-+    clang_disposeTranslationUnit(ClangTU);
-+
-+    ClangTU = clang_createTranslationUnit(Index, Filename.c_str());
-+
-+    if (!ClangTU) {
-+      DEBUG(llvm::dbgs() << "Loading failed\n");
-+      return false;
-+    }
-+
-+    return true;
-+  }
-+};
-+
-+TEST_F(LibclangSerializationTest, TokenKindsAreCorrectAfterLoading) {
-+  // Ensure that "class" is recognized as a keyword token after serializing
-+  // and reloading the AST, as it is not a keyword for the default LangOptions.
-+  std::string HeaderName = "test.h";
-+  WriteFile(HeaderName, "enum class Something {};");
-+
-+  const char *Argv[] = {"-xc++-header", "-std=c++11"};
-+
-+  ClangTU = clang_parseTranslationUnit(Index, HeaderName.c_str(), Argv,
-+                                       sizeof(Argv) / sizeof(Argv[0]), nullptr,
-+                                       0, TUFlags);
-+
-+  auto CheckTokenKinds = [=]() {
-+    CXSourceRange Range =
-+        clang_getCursorExtent(clang_getTranslationUnitCursor(ClangTU));
-+
-+    CXToken *Tokens;
-+    unsigned int NumTokens;
-+    clang_tokenize(ClangTU, Range, &Tokens, &NumTokens);
-+
-+    ASSERT_EQ(6u, NumTokens);
-+    EXPECT_EQ(CXToken_Keyword, clang_getTokenKind(Tokens[0]));
-+    EXPECT_EQ(CXToken_Keyword, clang_getTokenKind(Tokens[1]));
-+    EXPECT_EQ(CXToken_Identifier, clang_getTokenKind(Tokens[2]));
-+    EXPECT_EQ(CXToken_Punctuation, clang_getTokenKind(Tokens[3]));
-+    EXPECT_EQ(CXToken_Punctuation, clang_getTokenKind(Tokens[4]));
-+    EXPECT_EQ(CXToken_Punctuation, clang_getTokenKind(Tokens[5]));
-+
-+    clang_disposeTokens(ClangTU, Tokens, NumTokens);
-+  };
-+
-+  CheckTokenKinds();
-+
-+  std::string ASTName = "test.ast";
-+  WriteFile(ASTName, "");
-+
-+  ASSERT_TRUE(SaveAndLoadTU(ASTName));
-+
-+  CheckTokenKinds();
-+}
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0005-Tooling-Fully-qualify-template-parameters-of-nested-.patch b/packages/llvm/llvm5-0005-Tooling-Fully-qualify-template-parameters-of-nested-.patch
deleted file mode 100644
index e23cb61895f88a3009cbc06cc5dd0d9006a0ef27..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0005-Tooling-Fully-qualify-template-parameters-of-nested-.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 4427624b30117c6db67b9ea7c3f16e396edc3748 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Wed, 26 Jul 2017 15:06:10 +0200
-Subject: [PATCH 05/12] [Tooling] Fully qualify template parameters of nested
- name specifier in getFullyQualifiedName
-
----
- lib/Tooling/Core/QualTypeNames.cpp      | 18 ++++++++++++++----
- unittests/Tooling/QualTypeNamesTest.cpp |  8 +++++++-
- 2 files changed, 21 insertions(+), 5 deletions(-)
-
-diff --git a/tools/clang/lib/Tooling/Core/QualTypeNames.cpp b/tools/clang/lib/Tooling/Core/QualTypeNames.cpp
-index 721c2c92fc..934624dd14 100644
---- a/tools/clang/lib/Tooling/Core/QualTypeNames.cpp
-+++ b/tools/clang/lib/Tooling/Core/QualTypeNames.cpp
-@@ -370,11 +370,21 @@ NestedNameSpecifier *createNestedNameSpecifier(const ASTContext &Ctx,
-                                                const TypeDecl *TD,
-                                                bool FullyQualify,
-                                                bool WithGlobalNsPrefix) {
-+  const Type *TypePtr = TD->getTypeForDecl();
-+  // In case of template specializations iterate over the arguments and
-+  // fully qualify them as well.
-+  if (isa<const TemplateSpecializationType>(TypePtr) ||
-+      isa<const RecordType>(TypePtr)) {
-+    // We are asked to fully qualify and we have a Record Type (which
-+    // may point to a template specialization) or Template
-+    // Specialization Type. We need to fully qualify their arguments.
-+
-+    TypePtr = getFullyQualifiedTemplateType(Ctx, TypePtr, WithGlobalNsPrefix);
-+  }
-+
-   return NestedNameSpecifier::Create(
--      Ctx,
--      createOuterNNS(Ctx, TD, FullyQualify, WithGlobalNsPrefix),
--      false /*No TemplateKeyword*/,
--      TD->getTypeForDecl());
-+      Ctx, createOuterNNS(Ctx, TD, FullyQualify, WithGlobalNsPrefix),
-+      false /*No TemplateKeyword*/, TypePtr);
- }
- 
- /// \brief Return the fully qualified type, including fully-qualified
-diff --git a/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp b/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-index 532fae6f5a..e27089b986 100644
---- a/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-+++ b/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-@@ -63,6 +63,10 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-   // Template parameter expansion.
-   Visitor.ExpectedQualTypeNames["CheckC"] =
-       "A::B::Template0<A::B::C::MyInt, A::B::AnotherClass>";
-+  // Template parameters of nested name specifier should also be fully expanded.
-+  Visitor.ExpectedQualTypeNames["CheckNested"] =
-+      // "typename A::B::Template0<A::B::C::MyInt, A::B::AnotherClass>::nested";
-+      "typename A::B::Template0<int, A::B::Class0>::nested";
-   // Recursive template parameter expansion.
-   Visitor.ExpectedQualTypeNames["CheckD"] =
-       "A::B::Template0<A::B::Template1<A::B::C::MyInt, A::B::AnotherClass>, "
-@@ -105,7 +109,7 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-       "     using InnerAlias = OuterTemplateClass<T>;\n"
-       "     InnerAlias<int> AliasTypeVal;\n"
-       "   }\n"
--      "   template<class X, class Y> class Template0;"
-+      "   template<class X, class Y> struct Template0 { typedef int nested; };"
-       "   template<class X, class Y> class Template1;"
-       "   typedef B::Class0 AnotherClass;\n"
-       "   void Function1(Template0<C::MyInt,\n"
-@@ -113,6 +117,8 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-       "   void Function2(Template0<Template1<C::MyInt, AnotherClass>,\n"
-       "                            Template0<int, long> > CheckD);\n"
-       "   void Function3(const B::Class0* CheckM);\n"
-+      "   void Function4(typename Template0<C::MyInt,\n"
-+      "                  AnotherClass>::nested CheckNested);\n"
-       "  }\n"
-       "template<typename... Values> class Variadic {};\n"
-       "Variadic<int, B::Template0<int, char>, "
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0006-libclang-Add-support-for-obtaining-fully-qualified-n.patch b/packages/llvm/llvm5-0006-libclang-Add-support-for-obtaining-fully-qualified-n.patch
deleted file mode 100644
index 441dc96ecf8216395359a5a207feea5e54063f06..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0006-libclang-Add-support-for-obtaining-fully-qualified-n.patch
+++ /dev/null
@@ -1,136 +0,0 @@
-From a24d66fca11152dbd9b8abb246dfa340e2d6843b Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Mon, 10 Jul 2017 13:53:25 +0200
-Subject: [PATCH 06/12] [libclang] Add support for obtaining fully qualified
- names of types
-
-This patch allows retrieving the fully qualified names of types
-through libclang and clang.cindex (Python).
----
- bindings/python/clang/cindex.py             | 13 +++++++++++++
- bindings/python/tests/cindex/test_cursor.py |  8 ++++++++
- include/clang-c/Index.h                     |  8 ++++++++
- tools/libclang/CXType.cpp                   | 18 ++++++++++++++++++
- tools/libclang/libclang.exports             |  1 +
- 5 files changed, 48 insertions(+)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index ecff13f7a5..496e1089ad 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -2314,6 +2314,14 @@ class Type(Structure):
-         """Retrieve the spelling of this Type."""
-         return conf.lib.clang_getTypeSpelling(self)
- 
-+    @property
-+    def fully_qualified_name(self):
-+        """Retrieve the fully qualified name of this Type."""
-+        if not hasattr(self, '_fully_qualified_name'):
-+            self._fully_qualified_name = conf.lib.clang_getFullyQualifiedTypeName(self)
-+
-+        return self._fully_qualified_name
-+
-     def __eq__(self, other):
-         if type(other) != type(self):
-             return False
-@@ -3750,6 +3758,11 @@ functionList = [
-    _CXString,
-    _CXString.from_result),
- 
-+  ("clang_getFullyQualifiedTypeName",
-+   [Type],
-+   _CXString,
-+   _CXString.from_result),
-+
-   ("clang_hashCursor",
-    [Cursor],
-    c_uint),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 87fd76ed0e..3cd499ea11 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -291,6 +291,14 @@ def test_underlying_type():
-     underlying = typedef.underlying_typedef_type
-     assert underlying.kind == TypeKind.INT
- 
-+def test_fully_qualified_type_name():
-+    source = 'namespace uiae { struct X { typedef int sometype; }; }'
-+    tu = get_tu(source, lang='cpp')
-+
-+    cls = get_cursor(tu, 'sometype')
-+    assert cls.type.fully_qualified_name.endswith(
-+        "uiae::X::sometype")
-+
- kParentTest = """\
-         class C {
-             void f();
-diff --git a/tools/clang/include/clang-c/Index.h b/tools/clang/include/clang-c/Index.h
-index 89957e8526..402ca9a436 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -3241,6 +3241,14 @@ CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
- CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
- 
- /**
-+ * \brief Retrieve the fully qualified name of the underlying type.
-+ * This includes full qualification of all template parameters etc.
-+ *
-+ * If the type is invalid, an empty string is returned.
-+ */
-+CINDEX_LINKAGE CXString clang_getFullyQualifiedTypeName(CXType CT);
-+
-+/**
-  * \brief Retrieve the underlying type of a typedef declaration.
-  *
-  * If the cursor does not reference a typedef declaration, an invalid type is
-diff --git a/tools/clang/tools/libclang/CXType.cpp b/tools/clang/tools/libclang/CXType.cpp
-index d2cb509059..e99f513d13 100644
---- a/tools/clang/tools/libclang/CXType.cpp
-+++ b/tools/clang/tools/libclang/CXType.cpp
-@@ -23,6 +23,7 @@
- #include "clang/AST/Type.h"
- #include "clang/Basic/AddressSpaces.h"
- #include "clang/Frontend/ASTUnit.h"
-+#include "clang/Tooling/Core/QualTypeNames.h"
- 
- using namespace clang;
- 
-@@ -282,6 +283,23 @@ CXString clang_getTypeSpelling(CXType CT) {
-   return cxstring::createDup(OS.str());
- }
- 
-+CXString clang_getFullyQualifiedTypeName(CXType CT) {
-+  QualType T = GetQualType(CT);
-+  if (T.isNull())
-+    return cxstring::createEmpty();
-+
-+  // For builtin types (but not typedefs pointing to builtin types) return their
-+  // spelling.  Otherwise "bool" will be turned into "_Bool".
-+  const Type *TP = T.getTypePtrOrNull();
-+  if (TP && TP->isBuiltinType() && T->getAs<TypedefType>() == nullptr)
-+    return clang_getTypeSpelling(CT);
-+
-+  CXTranslationUnit TU = GetTU(CT);
-+  ASTContext &Ctx = cxtu::getASTUnit(TU)->getASTContext();
-+  std::string name = TypeName::getFullyQualifiedName(T, Ctx, /*WithGlobalNsPrefix=*/true);
-+  return cxstring::createDup(name.c_str());
-+}
-+
- CXType clang_getTypedefDeclUnderlyingType(CXCursor C) {
-   using namespace cxcursor;
-   CXTranslationUnit TU = cxcursor::getCursorTU(C);
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/clang/tools/libclang/libclang.exports
-index 9ddc055125..9c56e88052 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -221,6 +221,7 @@ clang_getFileLocation
- clang_getFileName
- clang_getFileTime
- clang_getFileUniqueID
-+clang_getFullyQualifiedTypeName
- clang_getFunctionTypeCallingConv
- clang_getIBOutletCollectionType
- clang_getIncludedFile
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0007-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch b/packages/llvm/llvm5-0007-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch
deleted file mode 100644
index d8625c32efa08e8ec47c430d4ec114dfda36b6da..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0007-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch
+++ /dev/null
@@ -1,242 +0,0 @@
-From 25c705cda6508b56ac4ab4ccd8c08a1a8f911941 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Mon, 10 Jul 2017 14:44:22 +0200
-Subject: [PATCH 07/12] [libclang] Add option to keep whitespace when
- tokenizing
-
----
- bindings/python/clang/cindex.py             | 31 ++++++++++++++++++++++-------
- bindings/python/tests/cindex/test_cursor.py |  9 +++++++++
- include/clang-c/Index.h                     | 30 ++++++++++++++++++++++++++--
- tools/libclang/CIndex.cpp                   | 13 ++++++++++--
- tools/libclang/libclang.exports             |  1 +
- 5 files changed, 73 insertions(+), 11 deletions(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index 496e1089ad..a5bb58b44f 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -514,6 +514,13 @@ class TokenGroup(object):
- 
-     You should not instantiate this class outside of this module.
-     """
-+
-+    # Default tokenization mode.
-+    TOKENIZE_NONE = 0
-+
-+    # Used to indicate that tokens for whitespace should be returned.
-+    TOKENIZE_KEEP_WHITESPACE = 1
-+
-     def __init__(self, tu, memory, count):
-         self._tu = tu
-         self._memory = memory
-@@ -523,7 +530,7 @@ class TokenGroup(object):
-         conf.lib.clang_disposeTokens(self._tu, self._memory, self._count)
- 
-     @staticmethod
--    def get_tokens(tu, extent):
-+    def get_tokens(tu, extent, options=0):
-         """Helper method to return all tokens in an extent.
- 
-         This functionality is needed multiple places in this module. We define
-@@ -532,8 +539,8 @@ class TokenGroup(object):
-         tokens_memory = POINTER(Token)()
-         tokens_count = c_uint()
- 
--        conf.lib.clang_tokenize(tu, extent, byref(tokens_memory),
--                byref(tokens_count))
-+        conf.lib.clang_tokenizeRange(
-+            tu, extent, byref(tokens_memory), byref(tokens_count), options)
- 
-         count = int(tokens_count.value)
- 
-@@ -1801,13 +1808,16 @@ class Cursor(Structure):
-             for descendant in child.walk_preorder():
-                 yield descendant
- 
--    def get_tokens(self):
-+    def get_tokens(self, options=0):
-         """Obtain Token instances formulating that compose this Cursor.
- 
-         This is a generator for Token instances. It returns all tokens which
-         occupy the extent this cursor occupies.
-+
-+        options is a bitwise or of TokenGroup.TOKENIZE_XXX flags which will
-+        control tokenization behavior.
-         """
--        return TokenGroup.get_tokens(self._tu, self.extent)
-+        return TokenGroup.get_tokens(self._tu, self.extent, options)
- 
-     def get_field_offsetof(self):
-         """Returns the offsetof the FIELD_DECL pointed by this Cursor."""
-@@ -2971,18 +2981,21 @@ class TranslationUnit(ClangObject):
-             return CodeCompletionResults(ptr)
-         return None
- 
--    def get_tokens(self, locations=None, extent=None):
-+    def get_tokens(self, locations=None, extent=None, options=0):
-         """Obtain tokens in this translation unit.
- 
-         This is a generator for Token instances. The caller specifies a range
-         of source code to obtain tokens for. The range can be specified as a
-         2-tuple of SourceLocation or as a SourceRange. If both are defined,
-         behavior is undefined.
-+
-+        options is a bitwise or of TokenGroup.TOKENIZE_XXX flags which will
-+        control tokenization behavior.
-         """
-         if locations is not None:
-             extent = SourceRange(start=locations[0], end=locations[1])
- 
--        return TokenGroup.get_tokens(self, extent)
-+        return TokenGroup.get_tokens(self, extent, options)
- 
- class File(ClangObject):
-     """
-@@ -3850,6 +3863,10 @@ functionList = [
-   ("clang_tokenize",
-    [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint)]),
- 
-+  ("clang_tokenizeRange",
-+   [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint),
-+    c_uint]),
-+
-   ("clang_visitChildren",
-    [Cursor, callbacks['cursor_visit'], py_object],
-    c_uint),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 3cd499ea11..2d50ec5901 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -3,6 +3,7 @@ import gc
- 
- from clang.cindex import CursorKind
- from clang.cindex import TemplateArgumentKind
-+from clang.cindex import TokenGroup
- from clang.cindex import TranslationUnit
- from clang.cindex import TypeKind
- from .util import get_cursor
-@@ -436,6 +437,14 @@ def test_get_token_cursor():
-     r_cursor = t_cursor.referenced # should not raise an exception
-     assert r_cursor.kind == CursorKind.CLASS_DECL
- 
-+def test_get_tokens_with_whitespace():
-+    source = 'class C { void f(); }\nvoid C::f() { }'
-+    tu = get_tu(source)
-+
-+    tokens = list(tu.cursor.get_tokens(TokenGroup.TOKENIZE_KEEP_WHITESPACE))
-+    assert ''.join(t.spelling for t in tokens) == source
-+    assert len(tokens) == 27
-+
- def test_get_arguments():
-     tu = get_tu('void foo(int i, int j);')
-     foo = get_cursor(tu, 'foo')
-diff --git a/tools/clang/include/clang-c/Index.h b/tools/clang/include/clang-c/Index.h
-index 402ca9a436..7fd17366ee 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -4616,6 +4616,28 @@ CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
-  */
- CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
- 
-+typedef enum {
-+  /**
-+   * \brief Used to indicate that no special tokenization options are needed.
-+   */
-+  CXTokenize_None = 0x0,
-+
-+  /**
-+   * \brief Used to indicate that tokens for whitespace should be returned.
-+   */
-+  CXTokenize_KeepWhitespace = 0x1
-+} CXTokenize_Flags;
-+
-+/**
-+ * \brief Tokenize the source code described by the given range into raw
-+ * lexical tokens.
-+ *
-+ * \see clang_tokenizeRange
-+ *
-+ */
-+CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-+                                   CXToken **Tokens, unsigned *NumTokens);
-+
- /**
-  * \brief Tokenize the source code described by the given range into raw
-  * lexical tokens.
-@@ -4632,9 +4654,13 @@ CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
-  * \param NumTokens will be set to the number of tokens in the \c *Tokens
-  * array.
-  *
-+ * \param options A bitmask of options that affects tokenization. This should be
-+ * a bitwise OR of the CXTokenize_XXX flags.
-+ *
-  */
--CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
--                                   CXToken **Tokens, unsigned *NumTokens);
-+CINDEX_LINKAGE void clang_tokenizeRange(CXTranslationUnit TU,
-+                                        CXSourceRange Range, CXToken **Tokens,
-+                                        unsigned *NumTokens, unsigned options);
- 
- /**
-  * \brief Annotate the given set of tokens by providing cursors for each token
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/clang/tools/libclang/CIndex.cpp
-index 621bc42076..04fd775fb0 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -6292,7 +6292,7 @@ CXSourceRange clang_getTokenExtent(CXTranslationUnit TU, CXToken CXTok) {
- }
- 
- static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
--                      SmallVectorImpl<CXToken> &CXTokens) {
-+                      SmallVectorImpl<CXToken> &CXTokens, unsigned options) {
-   SourceManager &SourceMgr = CXXUnit->getSourceManager();
-   std::pair<FileID, unsigned> BeginLocInfo
-     = SourceMgr.getDecomposedSpellingLoc(Range.getBegin());
-@@ -6314,6 +6314,9 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
-             CXXUnit->getASTContext().getLangOpts(),
-             Buffer.begin(), Buffer.data() + BeginLocInfo.second, Buffer.end());
-   Lex.SetCommentRetentionState(true);
-+  if (options & CXTokenize_KeepWhitespace) {
-+    Lex.SetKeepWhitespaceMode(true);
-+  }
- 
-   // Lex tokens until we hit the end of the range.
-   const char *EffectiveBufferEnd = Buffer.data() + EndLocInfo.second;
-@@ -6365,6 +6368,12 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
- 
- void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-                     CXToken **Tokens, unsigned *NumTokens) {
-+  return clang_tokenizeRange(TU, Range, Tokens, NumTokens, CXTokenize_None);
-+}
-+
-+void clang_tokenizeRange(CXTranslationUnit TU, CXSourceRange Range,
-+                         CXToken **Tokens, unsigned *NumTokens,
-+                         unsigned options) {
-   LOG_FUNC_SECTION {
-     *Log << TU << ' ' << Range;
-   }
-@@ -6390,7 +6399,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-     return;
- 
-   SmallVector<CXToken, 32> CXTokens;
--  getTokens(CXXUnit, R, CXTokens);
-+  getTokens(CXXUnit, R, CXTokens, options);
- 
-   if (CXTokens.empty())
-     return;
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/clang/tools/libclang/libclang.exports
-index 9c56e88052..b8e3df23ef 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -316,6 +316,7 @@ clang_suspendTranslationUnit
- clang_sortCodeCompletionResults
- clang_toggleCrashRecovery
- clang_tokenize
-+clang_tokenizeRange
- clang_CompilationDatabase_fromDirectory
- clang_CompilationDatabase_dispose
- clang_CompilationDatabase_getCompileCommands
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0008-Fix-printing-policy-for-AST-context-loaded-from-file.patch b/packages/llvm/llvm5-0008-Fix-printing-policy-for-AST-context-loaded-from-file.patch
deleted file mode 100644
index 95ae8c9fc8bf36b8c094afd30ae6cc8abcd8c8ee..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0008-Fix-printing-policy-for-AST-context-loaded-from-file.patch
+++ /dev/null
@@ -1,137 +0,0 @@
-From f612539aaee3a46abbbc8fa30d0263d9b49dca86 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Mon, 10 Jul 2017 12:34:10 +0200
-Subject: [PATCH 08/12] Fix printing policy for AST context loaded from file
-
-In ASTUnit::LoadFromASTFile, the context object is set up using default-constructed
-LangOptions (which only later get populated).  As the language options are used in the constructor
-of PrintingPolicy, this needs to be updated explicitly after the language options are available.
----
- lib/Frontend/ASTUnit.cpp           |  3 ++
- unittests/Frontend/ASTUnitTest.cpp | 87 ++++++++++++++++++++++++++++++++++++++
- unittests/Frontend/CMakeLists.txt  |  1 +
- 3 files changed, 91 insertions(+)
- create mode 100644 unittests/Frontend/ASTUnitTest.cpp
-
-diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp
-index 875f21d69a..bb1ea6c4f8 100644
---- a/tools/clang/lib/Frontend/ASTUnit.cpp
-+++ b/tools/clang/lib/Frontend/ASTUnit.cpp
-@@ -546,6 +546,9 @@ private:
-     // Initialize the ASTContext
-     Context->InitBuiltinTypes(*Target);
- 
-+    // Adjust printing policy based on language options.
-+    Context->setPrintingPolicy(PrintingPolicy(LangOpt));
-+
-     // We didn't have access to the comment options when the ASTContext was
-     // constructed, so register them now.
-     Context->getCommentCommandTraits().registerCommentOptions(
-diff --git a/tools/clang/unittests/Frontend/ASTUnitTest.cpp b/tools/clang/unittests/Frontend/ASTUnitTest.cpp
-new file mode 100644
-index 0000000000..a7d08a992f
---- /dev/null
-+++ b/tools/clang/unittests/Frontend/ASTUnitTest.cpp
-@@ -0,0 +1,87 @@
-+//===- unittests/Frontend/ASTUnitTest.cpp - ASTUnit tests -----------------===//
-+//
-+//                     The LLVM Compiler Infrastructure
-+//
-+// This file is distributed under the University of Illinois Open Source
-+// License. See LICENSE.TXT for details.
-+//
-+//===----------------------------------------------------------------------===//
-+
-+#include <fstream>
-+
-+#include "clang/Frontend/ASTUnit.h"
-+#include "clang/Frontend/CompilerInstance.h"
-+#include "clang/Frontend/CompilerInvocation.h"
-+#include "clang/Frontend/PCHContainerOperations.h"
-+#include "llvm/Support/FileSystem.h"
-+#include "llvm/Support/Path.h"
-+#include "llvm/Support/ToolOutputFile.h"
-+#include "gtest/gtest.h"
-+
-+using namespace llvm;
-+using namespace clang;
-+
-+namespace {
-+
-+TEST(ASTUnit, SaveLoadPreservesLangOptionsInPrintingPolicy) {
-+  // Check that the printing policy is restored with the correct language
-+  // options when loading an ASTUnit from a file.  To this end, an ASTUnit
-+  // for a C++ translation unit is set up and written to a temporary file.
-+
-+  // By default `UseVoidForZeroParams` is true for non-C++ language options,
-+  // thus we can check this field after loading the ASTUnit to deduce whether
-+  // the correct (C++) language options were used when setting up the printing
-+  // policy.
-+
-+  {
-+    PrintingPolicy PolicyWithDefaultLangOpt(LangOptions{});
-+    EXPECT_TRUE(PolicyWithDefaultLangOpt.UseVoidForZeroParams);
-+  }
-+
-+  int FD;
-+  llvm::SmallString<256> InputFileName;
-+  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("ast-unit", "cpp", FD, InputFileName));
-+  tool_output_file input_file(InputFileName, FD);
-+  input_file.os() << "";
-+
-+  const char* Args[] = {"clang", "-xc++", InputFileName.c_str()};
-+
-+  IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
-+      CompilerInstance::createDiagnostics(new DiagnosticOptions());
-+
-+  std::shared_ptr<CompilerInvocation> CInvok =
-+      createInvocationFromCommandLine(Args, Diags);
-+
-+  if (!CInvok)
-+    FAIL() << "could not create compiler invocation";
-+
-+  FileManager *FileMgr =
-+      new FileManager(FileSystemOptions(), vfs::getRealFileSystem());
-+  auto PCHContainerOps = std::make_shared<PCHContainerOperations>();
-+
-+  std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCompilerInvocation(
-+      CInvok, PCHContainerOps, Diags, FileMgr);
-+
-+  if (!AST)
-+    FAIL() << "failed to create ASTUnit";
-+
-+  EXPECT_FALSE(AST->getASTContext().getPrintingPolicy().UseVoidForZeroParams);
-+
-+  llvm::SmallString<256> ASTFileName;
-+  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("ast-unit", "ast", FD, ASTFileName));
-+  tool_output_file ast_file(ASTFileName, FD);
-+  AST->Save(ASTFileName.str());
-+
-+  EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
-+
-+  std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
-+      ASTFileName.str(), PCHContainerOps->getRawReader(), ASTUnit::LoadEverything, Diags,
-+      FileSystemOptions(), /*UseDebugInfo=*/false);
-+
-+  if (!AU)
-+    FAIL() << "failed to load ASTUnit";
-+
-+  EXPECT_FALSE(AU->getASTContext().getPrintingPolicy().UseVoidForZeroParams);
-+}
-+
-+} // anonymous namespace
-diff --git a/tools/clang/unittests/Frontend/CMakeLists.txt b/tools/clang/unittests/Frontend/CMakeLists.txt
-index 674f77bd01..4312151c04 100644
---- a/tools/clang/unittests/Frontend/CMakeLists.txt
-+++ b/tools/clang/unittests/Frontend/CMakeLists.txt
-@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
-   )
- 
- add_clang_unittest(FrontendTests
-+  ASTUnitTest.cpp
-   FrontendActionTest.cpp
-   CodeGenActionTest.cpp
-   )
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0009-libclang-Visit-attributes-for-function-and-class-tem.patch b/packages/llvm/llvm5-0009-libclang-Visit-attributes-for-function-and-class-tem.patch
deleted file mode 100644
index d38d190db89771be6ee98ec92a0e3426a943f19e..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0009-libclang-Visit-attributes-for-function-and-class-tem.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From 2d3c0e5f3e3e6da701f3a5010a9700253deec16d Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Fri, 21 Jul 2017 10:16:45 +0200
-Subject: [PATCH 09/12] [libclang] Visit attributes for function and class
- templates
-
----
- bindings/python/tests/cindex/test_cursor.py | 20 ++++++++++++++++++++
- test/Index/annotate-attribute.cpp           | 12 ++++++++++++
- tools/libclang/CIndex.cpp                   |  6 ++++--
- 3 files changed, 36 insertions(+), 2 deletions(-)
-
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 2d50ec5901..863919e4c5 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -397,6 +397,26 @@ def test_annotation_attribute():
-     else:
-         assert False, "Couldn't find annotation"
- 
-+def test_annotation_template():
-+    annotation = '__attribute__ ((annotate("annotation")))'
-+    for source, kind in [
-+            ('int foo (T value) %s;', CursorKind.FUNCTION_TEMPLATE),
-+            ('class %s foo {};', CursorKind.CLASS_TEMPLATE),
-+    ]:
-+        source = 'template<typename T> ' + (source % annotation)
-+        tu = get_tu(source, lang="cpp")
-+
-+        foo = get_cursor(tu, 'foo')
-+        assert foo is not None
-+        assert foo.kind == kind
-+
-+        for c in foo.get_children():
-+            if c.kind == CursorKind.ANNOTATE_ATTR:
-+                assert c.displayname == "annotation"
-+                break
-+        else:
-+            assert False, "Couldn't find annotation for {}".format(kind)
-+
- def test_result_type():
-     tu = get_tu('int foo();')
-     foo = get_cursor(tu, 'foo')
-diff --git a/tools/clang/test/Index/annotate-attribute.cpp b/tools/clang/test/Index/annotate-attribute.cpp
-index d822210e49..bf415fc8fe 100644
---- a/tools/clang/test/Index/annotate-attribute.cpp
-+++ b/tools/clang/test/Index/annotate-attribute.cpp
-@@ -16,6 +16,12 @@ protected:
-   void methodWithoutAttribute();
- };
- 
-+template <typename T>
-+class __attribute__((annotate("works"))) TemplateTest {};
-+
-+template <typename T>
-+int templateFunction(T value) __attribute__((annotate("works")));
-+
- // CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2]
- // CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8]
- // CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60]
-@@ -31,3 +37,9 @@ protected:
- // CHECK-NEXT: CompoundStmt= Extent=[12:23 - 12:25]
- // CHECK-NEXT: CXXAccessSpecifier=:14:1 (Definition) Extent=[14:1 - 14:11]
- // CHECK-NEXT: CXXMethod=methodWithoutAttribute:16:8 Extent=[16:3 - 16:32]
-+// CHECK: ClassTemplate=TemplateTest:20:42 (Definition) Extent=[19:1 - 20:57]
-+// CHECK-NEXT: TemplateTypeParameter=T:19:20 (Definition) Extent=[19:11 - 19:21] [access=public]
-+// CHECK-NEXT: attribute(annotate)=works Extent=[20:22 - 20:39]
-+// CHECK: FunctionTemplate=templateFunction:23:5 Extent=[22:1 - 23:65]
-+// CHECK-NEXT: TemplateTypeParameter=T:22:20 (Definition) Extent=[22:11 - 22:21] [access=public]
-+// CHECK-NEXT: attribute(annotate)=works Extent=[23:46 - 23:63]
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/clang/tools/libclang/CIndex.cpp
-index 04fd775fb0..27f74b2aa2 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -907,7 +907,8 @@ bool CursorVisitor::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
-   if (VisitTemplateParameters(D->getTemplateParameters()))
-     return true;
-   
--  return VisitFunctionDecl(D->getTemplatedDecl());
-+  auto* FD = D->getTemplatedDecl();
-+  return VisitAttributes(FD) || VisitFunctionDecl(FD);
- }
- 
- bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-@@ -916,7 +917,8 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-   if (VisitTemplateParameters(D->getTemplateParameters()))
-     return true;
-   
--  return VisitCXXRecordDecl(D->getTemplatedDecl());
-+  auto* CD = D->getTemplatedDecl();
-+  return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
- }
- 
- bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0010-libclang-Add-support-for-querying-cursor-availabilit.patch b/packages/llvm/llvm5-0010-libclang-Add-support-for-querying-cursor-availabilit.patch
deleted file mode 100644
index 1119bc3b7090fd4d24356697ba86c1fdfc7fbf82..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0010-libclang-Add-support-for-querying-cursor-availabilit.patch
+++ /dev/null
@@ -1,123 +0,0 @@
-From 3206e3ef840b1ca16346f2c925edc47c5a9697ad Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <dev@jklaehn.de>
-Date: Tue, 25 Jul 2017 15:49:14 +0200
-Subject: [PATCH 10/12] [libclang] Add support for querying cursor availability
-
-This patch allows checking the availability of cursors through libclang and clang.cindex (Python).
-This e.g. allows to check whether a C++ member function has been marked as deleted.
----
- bindings/python/clang/cindex.py             | 33 +++++++++++++++++++++++++++++
- bindings/python/tests/cindex/test_cursor.py | 25 ++++++++++++++++++++++
- 2 files changed, 58 insertions(+)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index a5bb58b44f..b21f2b75f2 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -1586,6 +1586,16 @@ class Cursor(Structure):
-         return StorageClass.from_id(self._storage_class)
- 
-     @property
-+    def availability(self):
-+        """
-+        Retrieves the availability of the entity pointed at by the cursor.
-+        """
-+        if not hasattr(self, '_availability'):
-+            self._availability = conf.lib.clang_getCursorAvailability(self)
-+
-+        return AvailabilityKind.from_id(self._availability)
-+
-+    @property
-     def access_specifier(self):
-         """
-         Retrieves the access specifier (if any) of the entity pointed at by the
-@@ -1925,6 +1935,24 @@ StorageClass.OPENCLWORKGROUPLOCAL = StorageClass(5)
- StorageClass.AUTO = StorageClass(6)
- StorageClass.REGISTER = StorageClass(7)
- 
-+### Availability Kinds ###
-+
-+class AvailabilityKind(BaseEnumeration):
-+    """
-+    Describes the availability of an entity.
-+    """
-+
-+    # The unique kind objects, indexed by id.
-+    _kinds = []
-+    _name_map = None
-+
-+    def __repr__(self):
-+        return 'AvailabilityKind.%s' % (self.name,)
-+
-+AvailabilityKind.AVAILABLE = AvailabilityKind(0)
-+AvailabilityKind.DEPRECATED = AvailabilityKind(1)
-+AvailabilityKind.NOT_AVAILABLE = AvailabilityKind(2)
-+AvailabilityKind.NOT_ACCESSIBLE = AvailabilityKind(3)
- 
- ### C++ access specifiers ###
- 
-@@ -3472,6 +3500,10 @@ functionList = [
-    [TranslationUnit, SourceLocation],
-    Cursor),
- 
-+  ("clang_getCursorAvailability",
-+   [Cursor],
-+   c_int),
-+
-   ("clang_getCursorDefinition",
-    [Cursor],
-    Cursor,
-@@ -4096,6 +4128,7 @@ conf = Config()
- register_enumerations()
- 
- __all__ = [
-+    'AvailabilityKind',
-     'Config',
-     'CodeCompletionResults',
-     'CompilationDatabase',
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 863919e4c5..6c20577302 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -1,6 +1,7 @@
- import ctypes
- import gc
- 
-+from clang.cindex import AvailabilityKind
- from clang.cindex import CursorKind
- from clang.cindex import TemplateArgumentKind
- from clang.cindex import TokenGroup
-@@ -425,6 +426,30 @@ def test_result_type():
-     t = foo.result_type
-     assert t.kind == TypeKind.INT
- 
-+def test_availability():
-+    tu = get_tu('class A { A(A const&) = delete; };', lang='cpp')
-+
-+    # AvailabilityKind.AVAILABLE
-+    cursor = get_cursor(tu, 'A')
-+    assert cursor.kind == CursorKind.CLASS_DECL
-+    assert cursor.availability == AvailabilityKind.AVAILABLE
-+
-+    # AvailabilityKind.NOT_AVAILABLE
-+    cursors = get_cursors(tu, 'A')
-+    for c in cursors:
-+        if c.kind == CursorKind.CONSTRUCTOR:
-+            assert c.availability == AvailabilityKind.NOT_AVAILABLE
-+            break
-+    else:
-+        assert False, "Could not find cursor for deleted constructor"
-+
-+    # AvailabilityKind.DEPRECATED
-+    tu = get_tu('void test() __attribute__((deprecated));', lang='cpp')
-+    cursor = get_cursor(tu, 'test')
-+    assert cursor.availability == AvailabilityKind.DEPRECATED
-+
-+    # AvailabilityKind.NOT_ACCESSIBLE is only used in the code completion results
-+
- def test_get_tokens():
-     """Ensure we can map cursors back to tokens."""
-     tu = get_tu('int foo(int i);')
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0011-libclang-Allow-visiting-of-implicit-declarations-and.patch b/packages/llvm/llvm5-0011-libclang-Allow-visiting-of-implicit-declarations-and.patch
deleted file mode 100644
index b9835bbd5060fde987f0b2ef0216e8f56e0de36f..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0011-libclang-Allow-visiting-of-implicit-declarations-and.patch
+++ /dev/null
@@ -1,433 +0,0 @@
-From c7701fe91022a116e0a37f410e70fe8906f56441 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Mon, 17 Jul 2017 12:25:49 +0200
-Subject: [PATCH 11/12] [libclang] Allow visiting of implicit declarations and
- template instantiations (WIP!)
-
----
- bindings/python/clang/cindex.py             |  45 +++++++++--
- bindings/python/tests/cindex/test_cursor.py |  33 ++++++++
- include/clang-c/Index.h                     |  31 ++++++++
- tools/libclang/CIndex.cpp                   | 112 ++++++++++++++++++++++++++--
- tools/libclang/CursorVisitor.h              |  12 ++-
- tools/libclang/libclang.exports             |   2 +
- 6 files changed, 219 insertions(+), 16 deletions(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index b21f2b75f2..2416fd1803 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -1407,6 +1407,15 @@ class Cursor(Structure):
-     """
-     _fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]
- 
-+    # Default behavior.
-+    GET_CHILDREN_NONE = 0
-+
-+    # Used to indicate that implicit cursors should be visited.
-+    GET_CHILDREN_WITH_IMPLICIT = 1
-+
-+    # Used to indicate that template instantiations should be visited.
-+    GET_CHILDREN_WITH_TEMPLATE_INSTANTIATIONS = 2
-+
-     @staticmethod
-     def from_location(tu, location):
-         # We store a reference to the TU in the instance so the TU won't get
-@@ -1496,6 +1505,10 @@ class Cursor(Structure):
-         """
-         return conf.lib.clang_EnumDecl_isScoped(self)
- 
-+    def is_implicit(self):
-+        """Test whether the cursor refers to an implicit declaration."""
-+        return conf.lib.clang_isImplicit(self)
-+
-     def get_definition(self):
-         """
-         If the cursor is a reference to a declaration or a declaration of
-@@ -1790,8 +1803,12 @@ class Cursor(Structure):
-         """Returns the value of the indicated arg as an unsigned 64b integer."""
-         return conf.lib.clang_Cursor_getTemplateArgumentUnsignedValue(self, num)
- 
--    def get_children(self):
--        """Return an iterator for accessing the children of this cursor."""
-+    def get_children(self, with_implicit=False, with_template_instantiations=False):
-+        """Return an iterator for accessing the children of this cursor.
-+
-+        By default, cursors representing implicit declarations or template instantiations
-+        will be skipped.
-+        """
- 
-         # FIXME: Expose iteration from CIndex, PR6125.
-         def visitor(child, parent, children):
-@@ -1804,18 +1821,24 @@ class Cursor(Structure):
-             children.append(child)
-             return 1 # continue
-         children = []
--        conf.lib.clang_visitChildren(self, callbacks['cursor_visit'](visitor),
--            children)
-+        dispatch = conf.lib.clang_visitChildren
-+        options = Cursor.GET_CHILDREN_NONE
-+        if with_implicit:
-+            options |= Cursor.GET_CHILDREN_WITH_IMPLICIT
-+        if with_template_instantiations:
-+            options |= Cursor.GET_CHILDREN_WITH_TEMPLATE_INSTANTIATIONS
-+        conf.lib.clang_visitChildrenWithOptions(
-+            self, callbacks['cursor_visit'](visitor), children, options)
-         return iter(children)
- 
--    def walk_preorder(self):
-+    def walk_preorder(self, **kwargs):
-         """Depth-first preorder walk over the cursor and its descendants.
- 
-         Yields cursors.
-         """
-         yield self
--        for child in self.get_children():
--            for descendant in child.walk_preorder():
-+        for child in self.get_children(**kwargs):
-+            for descendant in child.walk_preorder(**kwargs):
-                 yield descendant
- 
-     def get_tokens(self, options=0):
-@@ -3840,6 +3863,10 @@ functionList = [
-    [Type],
-    bool),
- 
-+  ("clang_isImplicit",
-+   [Cursor],
-+   bool),
-+
-   ("clang_isInvalid",
-    [CursorKind],
-    bool),
-@@ -3903,6 +3930,10 @@ functionList = [
-    [Cursor, callbacks['cursor_visit'], py_object],
-    c_uint),
- 
-+  ("clang_visitChildrenWithOptions",
-+   [Cursor, callbacks['cursor_visit'], py_object, c_uint],
-+   c_uint),
-+
-   ("clang_Cursor_getNumArguments",
-    [Cursor],
-    c_int),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 6c20577302..43606b605c 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -70,6 +70,39 @@ def test_get_children():
-     assert tu_nodes[2].displayname == 'f0(int, int)'
-     assert tu_nodes[2].is_definition() == True
- 
-+def test_get_children_with_implicit():
-+    tu = get_tu('struct X {}; X x;', lang='cpp')
-+    cursor = get_cursor(tu, 'X')
-+
-+    children = list(cursor.get_children())
-+    assert len(children) == 0
-+
-+    children = list(cursor.get_children(with_implicit=True))
-+    assert len(children) > 0
-+    for child in children:
-+        assert child.is_implicit()
-+        assert child.spelling == "X"
-+        assert child.kind in [CursorKind.CONSTRUCTOR, CursorKind.STRUCT_DECL]
-+
-+def test_get_children_with_template_instantiations():
-+    tu = get_tu(
-+        'template <typename T> T frobnicate(T val);'
-+        'extern template int frobnicate<int>(int);',
-+        lang='cpp')
-+    cursor = get_cursor(tu, 'frobnicate')
-+    assert cursor.kind == CursorKind.FUNCTION_TEMPLATE
-+
-+    for child in cursor.get_children():
-+        # should not return an instantiation:
-+        assert child.kind != CursorKind.FUNCTION_DECL
-+
-+    for child in cursor.get_children(with_template_instantiations=True):
-+        if child.kind == CursorKind.FUNCTION_DECL:
-+            assert child.spelling == 'frobnicate'
-+            break
-+    else:
-+        assert False, "Couldn't find template instantiation"
-+
- def test_references():
-     """Ensure that references to TranslationUnit are kept."""
-     tu = get_tu('int x;')
-diff --git a/tools/clang/include/clang-c/Index.h b/tools/clang/include/clang-c/Index.h
-index 7fd17366ee..abe70e9566 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -2670,6 +2670,11 @@ CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
-  */
- CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
- 
-+/***
-+ * \brief Determine whether the given cursor represents an implicit declaration.
-+ */
-+CINDEX_LINKAGE unsigned clang_isImplicit(CXCursor);
-+
- /**
-  * \brief Describe the linkage of the entity referred to by a cursor.
-  */
-@@ -3961,6 +3966,32 @@ CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
- #  endif
- #endif
- 
-+typedef enum {
-+  /**
-+   * \brief Default behavior.
-+   */
-+  CXVisitChildren_None = 0x0,
-+
-+  /**
-+   * \brief Used to indicate that implicit cursors should be visited.
-+   */
-+  CXVisitChildren_WithImplicit = 0x1,
-+
-+  /**
-+   * \brief Used to indicate that template instantiations should be visited.
-+   */
-+  CXVisitChildren_WithTemplateInstantiations = 0x2
-+} CXVisitChildren_Flags;
-+
-+/**
-+ * \brief Visits the children of a cursor, allowing to pass extra options.
-+ * Behaves identically to clang_visitChildren() in all other respects.
-+ */
-+CINDEX_LINKAGE unsigned clang_visitChildrenWithOptions(CXCursor parent,
-+                                                       CXCursorVisitor visitor,
-+                                                       CXClientData client_data,
-+                                                       unsigned options);
-+
- /**
-  * @}
-  */
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/clang/tools/libclang/CIndex.cpp
-index 27f74b2aa2..f32611b8d7 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -192,10 +192,11 @@ bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
-       assert(0 && "Invalid declaration cursor");
-       return true; // abort.
-     }
--    
--    // Ignore implicit declarations, unless it's an objc method because
--    // currently we should report implicit methods for properties when indexing.
--    if (D->isImplicit() && !isa<ObjCMethodDecl>(D))
-+
-+    // Unless instructed otherwise we ignore implicit declarations.
-+    // ObjC methods are currently visited in any case, because implicit methods
-+    // for properties should be reported when indexing.
-+    if (!VisitImplicitDeclarations && D->isImplicit() && !isa<ObjCMethodDecl>(D))
-       return false;
-   }
- 
-@@ -700,10 +701,13 @@ bool CursorVisitor::VisitTagDecl(TagDecl *D) {
- 
- bool CursorVisitor::VisitClassTemplateSpecializationDecl(
-                                           ClassTemplateSpecializationDecl *D) {
--  bool ShouldVisitBody = false;
-+  bool ShouldVisitBody = VisitTemplateInstantiations;
-   switch (D->getSpecializationKind()) {
--  case TSK_Undeclared:
-   case TSK_ImplicitInstantiation:
-+    if (VisitTemplateInstantiations && VisitImplicitDeclarations) {
-+      break;
-+    }
-+  case TSK_Undeclared:
-     // Nothing to visit
-     return false;
-       
-@@ -712,6 +716,7 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl(
-     break;
-       
-   case TSK_ExplicitSpecialization:
-+    // Always visit body of explicit specializations
-     ShouldVisitBody = true;
-     break;
-   }
-@@ -908,7 +913,31 @@ bool CursorVisitor::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
-     return true;
-   
-   auto* FD = D->getTemplatedDecl();
--  return VisitAttributes(FD) || VisitFunctionDecl(FD);
-+  if (VisitAttributes(FD) || VisitFunctionDecl(FD))
-+    return true;
-+
-+  if (VisitTemplateInstantiations && D == D->getCanonicalDecl()) {
-+    for (auto *FD : D->specializations()) {
-+      for (auto *RD : FD->redecls()) {
-+        switch (RD->getTemplateSpecializationKind()) {
-+        case TSK_Undeclared:
-+        case TSK_ImplicitInstantiation:
-+        case TSK_ExplicitInstantiationDeclaration:
-+        case TSK_ExplicitInstantiationDefinition: {
-+          const Optional<bool> V = handleDeclForVisitation(RD);
-+          if (!V.hasValue())
-+            continue;
-+          return V.getValue();
-+        }
-+
-+        case TSK_ExplicitSpecialization:
-+          break;
-+        }
-+      }
-+    }
-+  }
-+
-+  return false;
- }
- 
- bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-@@ -918,7 +947,40 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-     return true;
-   
-   auto* CD = D->getTemplatedDecl();
--  return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
-+  if (VisitAttributes(CD) || VisitCXXRecordDecl(CD))
-+    return true;
-+
-+  if (VisitTemplateInstantiations && D == D->getCanonicalDecl()) {
-+    for (auto *SD : D->specializations()) {
-+      for (auto *RD : SD->redecls()) {
-+        // We don't want to visit injected-class-names in this traversal.
-+        if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
-+          continue;
-+
-+        switch (
-+            cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
-+          // Visit the implicit instantiations with the requested pattern.
-+        case TSK_Undeclared:
-+        case TSK_ImplicitInstantiation: {
-+          const Optional<bool> V = handleDeclForVisitation(RD);
-+          if (!V.hasValue())
-+            continue;
-+          return V.getValue();
-+        }
-+
-+          // We don't need to do anything on an explicit instantiation
-+          // or explicit specialization because there will be an explicit
-+          // node for it elsewhere.
-+        case TSK_ExplicitInstantiationDeclaration:
-+        case TSK_ExplicitInstantiationDefinition:
-+        case TSK_ExplicitSpecialization:
-+          break;
-+        }
-+      }
-+    }
-+  }
-+
-+  return false;
- }
- 
- bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
-@@ -4314,6 +4376,24 @@ unsigned clang_visitChildrenWithBlock(CXCursor parent,
-   return clang_visitChildren(parent, visitWithBlock, block);
- }
- 
-+unsigned clang_visitChildrenWithOptions(CXCursor parent,
-+                                        CXCursorVisitor visitor,
-+                                        CXClientData client_data,
-+                                        unsigned options) {
-+  CursorVisitor CursorVis(
-+      getCursorTU(parent), visitor, client_data,
-+      /*VisitPreprocessorLast=*/false,
-+      /*VisitIncludedPreprocessingEntries=*/false,
-+      /*RegionOfInterest=*/SourceRange(),
-+      /*VisitDeclsOnly=*/false,
-+      /*PostChildrenVisitor=*/nullptr,
-+      /*VisitImplicitDeclarations=*/(options & CXVisitChildren_WithImplicit),
-+      /*VisitTemplateInstantiations=*/
-+      (options & CXVisitChildren_WithTemplateInstantiations));
-+
-+  return CursorVis.VisitChildren(parent);
-+}
-+
- static CXString getDeclSpelling(const Decl *D) {
-   if (!D)
-     return cxstring::createEmpty();
-@@ -5402,6 +5482,22 @@ unsigned clang_isUnexposed(enum CXCursorKind K) {
-   }
- }
- 
-+unsigned clang_isImplicit(CXCursor Cursor) {
-+  if (clang_isInvalid(Cursor.kind))
-+    return false;
-+
-+  if (!clang_isDeclaration(Cursor.kind))
-+    return false;
-+
-+  const Decl *D = getCursorDecl(Cursor);
-+  if (!D) {
-+    assert(0 && "Invalid declaration cursor");
-+    return true; // abort.
-+  }
-+
-+  return D->isImplicit();
-+}
-+
- CXCursorKind clang_getCursorKind(CXCursor C) {
-   return C.kind;
- }
-diff --git a/tools/clang/tools/libclang/CursorVisitor.h b/tools/clang/tools/libclang/CursorVisitor.h
-index 82f251a348..c659e866ef 100644
---- a/tools/clang/tools/libclang/CursorVisitor.h
-+++ b/tools/clang/tools/libclang/CursorVisitor.h
-@@ -96,6 +96,12 @@ private:
-   /// record entries.
-   bool VisitDeclsOnly;
- 
-+  /// \brief Whether we should visit implicit declarations.
-+  bool VisitImplicitDeclarations;
-+
-+  /// \brief Whether we should recurse into template instantiations.
-+  bool VisitTemplateInstantiations;
-+
-   // FIXME: Eventually remove.  This part of a hack to support proper
-   // iteration over all Decls contained lexically within an ObjC container.
-   DeclContext::decl_iterator *DI_current;
-@@ -147,7 +153,9 @@ public:
-                 bool VisitIncludedPreprocessingEntries = false,
-                 SourceRange RegionOfInterest = SourceRange(),
-                 bool VisitDeclsOnly = false,
--                PostChildrenVisitorTy PostChildrenVisitor = nullptr)
-+                PostChildrenVisitorTy PostChildrenVisitor = nullptr,
-+                bool VisitImplicitDeclarations = false,
-+                bool VisitTemplateInstantiations = false)
-     : TU(TU), AU(cxtu::getASTUnit(TU)),
-       Visitor(Visitor), PostChildrenVisitor(PostChildrenVisitor),
-       ClientData(ClientData),
-@@ -155,6 +163,8 @@ public:
-       VisitIncludedEntities(VisitIncludedPreprocessingEntries),
-       RegionOfInterest(RegionOfInterest),
-       VisitDeclsOnly(VisitDeclsOnly),
-+      VisitImplicitDeclarations(VisitImplicitDeclarations),
-+      VisitTemplateInstantiations(VisitTemplateInstantiations),
-       DI_current(nullptr), FileDI_current(nullptr)
-   {
-     Parent.kind = CXCursor_NoDeclFound;
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/clang/tools/libclang/libclang.exports
-index b8e3df23ef..59c46ae09e 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -291,6 +291,7 @@ clang_isDeclaration
- clang_isExpression
- clang_isFileMultipleIncludeGuarded
- clang_isFunctionTypeVariadic
-+clang_isImplicit
- clang_isInvalid
- clang_isPODType
- clang_isPreprocessing
-@@ -332,6 +333,7 @@ clang_CompileCommand_getNumArgs
- clang_CompileCommand_getArg
- clang_visitChildren
- clang_visitChildrenWithBlock
-+clang_visitChildrenWithOptions
- clang_ModuleMapDescriptor_create
- clang_ModuleMapDescriptor_dispose
- clang_ModuleMapDescriptor_setFrameworkModuleName
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm5-0012-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch b/packages/llvm/llvm5-0012-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch
deleted file mode 100644
index 0be6629fff035d51a29441f2d5c45caecffe377c..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm5-0012-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 8566bbfaf8a34bf088cacf632b647922257d7d5f Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Mon, 31 Jul 2017 14:09:52 +0200
-Subject: [PATCH 12/12] [libclang] WIP: Fix get_tokens in macro expansion
-
----
- bindings/python/tests/cindex/test_cursor.py | 15 +++++++++++++++
- tools/libclang/CIndex.cpp                   |  4 ++--
- 2 files changed, 17 insertions(+), 2 deletions(-)
-
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index 43606b605c..5c6f9fb320 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -523,6 +523,21 @@ def test_get_tokens_with_whitespace():
-     assert ''.join(t.spelling for t in tokens) == source
-     assert len(tokens) == 27
- 
-+def test_get_tokens_in_macro():
-+    """regression test"""
-+    source = "#define IMPL(name) struct name { name(int v = 0); }; \n IMPL(X)"
-+    tu = get_tu(source, lang="cpp")
-+    ctor = get_cursors(tu, "X")[1]
-+    assert ctor.kind == CursorKind.CONSTRUCTOR
-+    p = next(ctor.get_children())
-+    assert p.kind == CursorKind.PARM_DECL
-+    children = list(p.get_children())
-+    assert len(children) == 1
-+    expr = children[0]
-+    tokens = list(expr.get_tokens())
-+    assert len(tokens) == 1
-+    assert tokens[0].spelling == "0"
-+
- def test_get_arguments():
-     tu = get_tu('void foo(int i, int j);')
-     foo = get_cursor(tu, 'foo')
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/clang/tools/libclang/CIndex.cpp
-index f32611b8d7..5849c7dfde 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -144,8 +144,8 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
-   // We want the last character in this location, so we will adjust the
-   // location accordingly.
-   SourceLocation EndLoc = R.getEnd();
--  if (EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc))
--    EndLoc = SM.getExpansionRange(EndLoc).second;
-+  // if (EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc))
-+  //   EndLoc = SM.getExpansionRange(EndLoc).second;
-   if (R.isTokenRange() && EndLoc.isValid()) {
-     unsigned Length = Lexer::MeasureTokenLength(SM.getSpellingLoc(EndLoc),
-                                                 SM, LangOpts);
--- 
-2.13.0
-
diff --git a/packages/llvm/llvm7-0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch b/packages/llvm/llvm7-0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch
deleted file mode 100644
index eba3b7a7164106b0b6a6dc84b2dd3b5c08f5023f..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm7-0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 5916da23627103563e38702de2d3bcff65d60406 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Wed, 26 Jul 2017 15:06:10 +0200
-Subject: [PATCH 1/5] [Tooling] Fully qualify template parameters of nested
- name specifier in getFullyQualifiedName
-
----
- tools/clang/lib/AST/QualTypeNames.cpp               | 18 ++++++++++++++----
- tools/clang/unittests/Tooling/QualTypeNamesTest.cpp |  8 +++++++-
- 2 files changed, 21 insertions(+), 5 deletions(-)
-
-diff --git a/tools/clang/lib/AST/QualTypeNames.cpp b/tools/clang/lib/AST/QualTypeNames.cpp
-index 8b605ef295..8fcedccf48 100644
---- a/tools/clang/lib/AST/QualTypeNames.cpp
-+++ b/tools/clang/lib/AST/QualTypeNames.cpp
-@@ -359,11 +359,21 @@ NestedNameSpecifier *createNestedNameSpecifier(const ASTContext &Ctx,
-                                                const TypeDecl *TD,
-                                                bool FullyQualify,
-                                                bool WithGlobalNsPrefix) {
-+  const Type *TypePtr = TD->getTypeForDecl();
-+  // In case of template specializations iterate over the arguments and
-+  // fully qualify them as well.
-+  if (isa<const TemplateSpecializationType>(TypePtr) ||
-+      isa<const RecordType>(TypePtr)) {
-+    // We are asked to fully qualify and we have a Record Type (which
-+    // may point to a template specialization) or Template
-+    // Specialization Type. We need to fully qualify their arguments.
-+
-+    TypePtr = getFullyQualifiedTemplateType(Ctx, TypePtr, WithGlobalNsPrefix);
-+  }
-+
-   return NestedNameSpecifier::Create(
--      Ctx,
--      createOuterNNS(Ctx, TD, FullyQualify, WithGlobalNsPrefix),
--      false /*No TemplateKeyword*/,
--      TD->getTypeForDecl());
-+      Ctx, createOuterNNS(Ctx, TD, FullyQualify, WithGlobalNsPrefix),
-+      false /*No TemplateKeyword*/, TypePtr);
- }
- 
- /// Return the fully qualified type, including fully-qualified
-diff --git a/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp b/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-index b4c56f7bd5..e9ab495098 100644
---- a/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-+++ b/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp
-@@ -67,6 +67,10 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-   // Template parameter expansion.
-   Visitor.ExpectedQualTypeNames["CheckC"] =
-       "A::B::Template0<A::B::C::MyInt, A::B::AnotherClass>";
-+  // Template parameters of nested name specifier should also be fully expanded.
-+  Visitor.ExpectedQualTypeNames["CheckNested"] =
-+      // "typename A::B::Template0<A::B::C::MyInt, A::B::AnotherClass>::nested";
-+      "typename A::B::Template0<int, A::B::Class0>::nested";
-   // Recursive template parameter expansion.
-   Visitor.ExpectedQualTypeNames["CheckD"] =
-       "A::B::Template0<A::B::Template1<A::B::C::MyInt, A::B::AnotherClass>, "
-@@ -109,7 +113,7 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-       "     using InnerAlias = OuterTemplateClass<T>;\n"
-       "     InnerAlias<int> AliasTypeVal;\n"
-       "   }\n"
--      "   template<class X, class Y> class Template0;"
-+      "   template<class X, class Y> struct Template0 { typedef int nested; };"
-       "   template<class X, class Y> class Template1;"
-       "   typedef B::Class0 AnotherClass;\n"
-       "   void Function1(Template0<C::MyInt,\n"
-@@ -117,6 +121,8 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
-       "   void Function2(Template0<Template1<C::MyInt, AnotherClass>,\n"
-       "                            Template0<int, long> > CheckD);\n"
-       "   void Function3(const B::Class0* CheckM);\n"
-+      "   void Function4(typename Template0<C::MyInt,\n"
-+      "                  AnotherClass>::nested CheckNested);\n"
-       "  }\n"
-       "template<typename... Values> class Variadic {};\n"
-       "Variadic<int, B::Template0<int, char>, "
--- 
-2.18.0
-
diff --git a/packages/llvm/llvm7-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch b/packages/llvm/llvm7-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch
deleted file mode 100644
index ec669b0dfdba49729c2b7f8ad6d4477211409169..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm7-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch
+++ /dev/null
@@ -1,153 +0,0 @@
-From 18b47d781d631667a40a543383cf2510968440e3 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann@jklaehn.de>
-Date: Fri, 3 Nov 2017 11:17:59 +0100
-Subject: [PATCH 2/5] [libclang] Add support for obtaining fully qualified
- names of types
-
-This patch allows retrieving the fully qualified names of types
-through libclang and clang.cindex (Python).
----
- tools/clang/bindings/python/clang/cindex.py             | 13 ++++++++++++
- tools/clang/bindings/python/tests/cindex/test_cursor.py |  8 ++++++++
- tools/clang/include/clang-c/Index.h                     |  8 ++++++++
- tools/clang/tools/libclang/CMakeLists.txt               |  1 +
- tools/clang/tools/libclang/CXType.cpp                   | 22 +++++++++++++++++++++
- tools/clang/tools/libclang/libclang.exports             |  1 +
- 6 files changed, 53 insertions(+)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index 56fcc78763..becf745040 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -2401,6 +2401,14 @@ class Type(Structure):
-         """Retrieve the spelling of this Type."""
-         return conf.lib.clang_getTypeSpelling(self)
- 
-+    @property
-+    def fully_qualified_name(self):
-+        """Retrieve the fully qualified name of this Type."""
-+        if not hasattr(self, '_fully_qualified_name'):
-+            self._fully_qualified_name = conf.lib.clang_getFullyQualifiedTypeName(self)
-+
-+        return self._fully_qualified_name
-+
-     def __eq__(self, other):
-         if type(other) != type(self):
-             return False
-@@ -3847,6 +3855,11 @@ functionList = [
-    _CXString,
-    _CXString.from_result),
- 
-+  ("clang_getFullyQualifiedTypeName",
-+   [Type],
-+   _CXString,
-+   _CXString.from_result),
-+
-   ("clang_hashCursor",
-    [Cursor],
-    c_uint),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index f5733fd158..26d5f01b23 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -311,6 +311,14 @@ class TestCursor(unittest.TestCase):
-         underlying = typedef.underlying_typedef_type
-         self.assertEqual(underlying.kind, TypeKind.INT)
- 
-+    def test_fully_qualified_type_name():
-+        source = 'namespace uiae { struct X { typedef int sometype; }; }'
-+        tu = get_tu(source, lang='cpp')
-+
-+        cls = get_cursor(tu, 'sometype')
-+        fqn = cls.type.fully_qualified_name
-+        self.assertTrue(fqn.endswith("uiae::X::sometype"), fqn)
-+
-     def test_semantic_parent(self):
-         tu = get_tu(kParentTest, 'cpp')
-         curs = get_cursors(tu, 'f')
-diff --git a/tools/clang/include/clang-c/Index.h b/tools/clang/include/clang-c/Index.h
-index 65dada38b0..a9bd6f4ebf 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -3318,6 +3318,14 @@ CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
-  */
- CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
- 
-+/**
-+ * Retrieve the fully qualified name of the underlying type.
-+ * This includes full qualification of all template parameters etc.
-+ *
-+ * If the type is invalid, an empty string is returned.
-+ */
-+CINDEX_LINKAGE CXString clang_getFullyQualifiedTypeName(CXType CT);
-+
- /**
-  * Retrieve the underlying type of a typedef declaration.
-  *
-diff --git a/tools/clang/tools/libclang/CMakeLists.txt b/tools/clang/tools/libclang/CMakeLists.txt
-index e539c8308e..336a5c2e98 100644
---- a/tools/clang/tools/libclang/CMakeLists.txt
-+++ b/tools/clang/tools/libclang/CMakeLists.txt
-@@ -41,6 +41,7 @@ set(LIBS
-   clangLex
-   clangSema
-   clangTooling
-+  clangToolingCore
- )
- 
- if (CLANG_ENABLE_ARCMT)
-diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
-index 7c0f307944..9651c3a84a 100644
---- a/tools/clang/tools/libclang/CXType.cpp
-+++ b/tools/clang/tools/libclang/CXType.cpp
-@@ -20,6 +20,7 @@
- #include "clang/AST/DeclObjC.h"
- #include "clang/AST/DeclTemplate.h"
- #include "clang/AST/Expr.h"
-+#include "clang/AST/QualTypeNames.h"
- #include "clang/AST/Type.h"
- #include "clang/Basic/AddressSpaces.h"
- #include "clang/Frontend/ASTUnit.h"
-@@ -293,6 +294,27 @@ CXString clang_getTypeSpelling(CXType CT) {
-   return cxstring::createDup(OS.str());
- }
- 
-+CXString clang_getFullyQualifiedTypeName(CXType CT) {
-+  QualType T = GetQualType(CT);
-+  if (T.isNull())
-+    return cxstring::createEmpty();
-+
-+  // For builtin types (but not typedefs pointing to builtin types) return their
-+  // spelling.  Otherwise "bool" will be turned into "_Bool".
-+  const Type *TP = T.getTypePtrOrNull();
-+  if (TP && TP->isBuiltinType() && T->getAs<TypedefType>() == nullptr)
-+    return clang_getTypeSpelling(CT);
-+
-+  CXTranslationUnit TU = GetTU(CT);
-+  ASTContext &Ctx = cxtu::getASTUnit(TU)->getASTContext();
-+  PrintingPolicy Policy(Ctx.getPrintingPolicy());
-+  Policy.SuppressScope = false;
-+  Policy.AnonymousTagLocations = false;
-+  Policy.PolishForDeclaration = true;
-+  std::string name = TypeName::getFullyQualifiedName(T, Ctx, Policy, /*WithGlobalNsPrefix=*/true);
-+  return cxstring::createDup(name.c_str());
-+}
-+
- CXType clang_getTypedefDeclUnderlyingType(CXCursor C) {
-   using namespace cxcursor;
-   CXTranslationUnit TU = cxcursor::getCursorTU(C);
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/clang/tools/libclang/libclang.exports
-index 95a42712c4..87773b9036 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -230,6 +230,7 @@ clang_getFileLocation
- clang_getFileName
- clang_getFileTime
- clang_getFileUniqueID
-+clang_getFullyQualifiedTypeName
- clang_getFunctionTypeCallingConv
- clang_getIBOutletCollectionType
- clang_getIncludedFile
--- 
-2.18.0
-
diff --git a/packages/llvm/llvm7-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch b/packages/llvm/llvm7-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch
deleted file mode 100644
index e00f2c7d412443241994de6fcfeedfddbd881433..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm7-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch
+++ /dev/null
@@ -1,261 +0,0 @@
-From b0c94bdd15d06359177609cd204da718844bb4d8 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann@jklaehn.de>
-Date: Fri, 3 Nov 2017 21:19:51 +0100
-Subject: [PATCH 3/5] [libclang] Add option to keep whitespace when tokenizing
-
-Introduces new `clang_tokenizeRange` function which accepts options to control
-tokenization behavior.  `clang_tokenize` is kept for backwards compatibility.
----
- bindings/python/clang/cindex.py             | 31 +++++++++++++++-----
- bindings/python/tests/cindex/test_cursor.py |  9 ++++++
- include/clang-c/Index.h                     | 32 +++++++++++++++++++--
- tools/libclang/CIndex.cpp                   | 15 ++++++++--
- tools/libclang/libclang.exports             |  1 +
- 5 files changed, 75 insertions(+), 13 deletions(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
-index becf745040..a43fcff150 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -515,6 +515,13 @@ class TokenGroup(object):
- 
-     You should not instantiate this class outside of this module.
-     """
-+
-+    # Default tokenization mode.
-+    TOKENIZE_NONE = 0
-+
-+    # Used to indicate that tokens for whitespace should be returned.
-+    TOKENIZE_KEEP_WHITESPACE = 1
-+
-     def __init__(self, tu, memory, count):
-         self._tu = tu
-         self._memory = memory
-@@ -524,7 +531,7 @@ class TokenGroup(object):
-         conf.lib.clang_disposeTokens(self._tu, self._memory, self._count)
- 
-     @staticmethod
--    def get_tokens(tu, extent):
-+    def get_tokens(tu, extent, options=0):
-         """Helper method to return all tokens in an extent.
- 
-         This functionality is needed multiple places in this module. We define
-@@ -533,8 +540,8 @@ class TokenGroup(object):
-         tokens_memory = POINTER(Token)()
-         tokens_count = c_uint()
- 
--        conf.lib.clang_tokenize(tu, extent, byref(tokens_memory),
--                byref(tokens_count))
-+        conf.lib.clang_tokenizeRange(
-+            tu, extent, byref(tokens_memory), byref(tokens_count), options)
- 
-         count = int(tokens_count.value)
- 
-@@ -1834,13 +1841,16 @@ class Cursor(Structure):
-             for descendant in child.walk_preorder():
-                 yield descendant
- 
--    def get_tokens(self):
-+    def get_tokens(self, options=0):
-         """Obtain Token instances formulating that compose this Cursor.
- 
-         This is a generator for Token instances. It returns all tokens which
-         occupy the extent this cursor occupies.
-+
-+        options is a bitwise or of TokenGroup.TOKENIZE_XXX flags which will
-+        control tokenization behavior.
-         """
--        return TokenGroup.get_tokens(self._tu, self.extent)
-+        return TokenGroup.get_tokens(self._tu, self.extent, options)
- 
-     def get_field_offsetof(self):
-         """Returns the offsetof the FIELD_DECL pointed by this Cursor."""
-@@ -3058,18 +3068,21 @@ class TranslationUnit(ClangObject):
-             return CodeCompletionResults(ptr)
-         return None
- 
--    def get_tokens(self, locations=None, extent=None):
-+    def get_tokens(self, locations=None, extent=None, options=0):
-         """Obtain tokens in this translation unit.
- 
-         This is a generator for Token instances. The caller specifies a range
-         of source code to obtain tokens for. The range can be specified as a
-         2-tuple of SourceLocation or as a SourceRange. If both are defined,
-         behavior is undefined.
-+
-+        options is a bitwise or of TokenGroup.TOKENIZE_XXX flags which will
-+        control tokenization behavior.
-         """
-         if locations is not None:
-             extent = SourceRange(start=locations[0], end=locations[1])
- 
--        return TokenGroup.get_tokens(self, extent)
-+        return TokenGroup.get_tokens(self, extent, options)
- 
- class File(ClangObject):
-     """
-@@ -3947,6 +3960,10 @@ functionList = [
-   ("clang_tokenize",
-    [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint)]),
- 
-+  ("clang_tokenizeRange",
-+   [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint),
-+    c_uint]),
-+
-   ("clang_visitChildren",
-    [Cursor, callbacks['cursor_visit'], py_object],
-    c_uint),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
-index 26d5f01b23..d7ddf83130 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -5,6 +5,7 @@ import unittest
- from clang.cindex import AvailabilityKind
- from clang.cindex import CursorKind
- from clang.cindex import TemplateArgumentKind
-+from clang.cindex import TokenGroup
- from clang.cindex import TranslationUnit
- from clang.cindex import TypeKind
- from .util import get_cursor
-@@ -483,6 +484,14 @@ class TestCursor(unittest.TestCase):
-         self.assertEqual(tokens[0].spelling, 'int')
-         self.assertEqual(tokens[1].spelling, 'foo')
- 
-+    def test_get_tokens_with_whitespace():
-+        source = 'class C { void f(); }\nvoid C::f() { }'
-+        tu = get_tu(source)
-+
-+        tokens = list(tu.cursor.get_tokens(TokenGroup.TOKENIZE_KEEP_WHITESPACE))
-+        self.assertEqual(''.join(t.spelling for t in tokens), source)
-+        self.assertEqual(len(tokens), 27, [t.spelling for t in tokens])
-+
-     def test_get_token_cursor(self):
-         """Ensure we can map tokens to cursors."""
-         tu = get_tu('class A {}; int foo(A var = A());', lang='cpp')
-diff --git a/tools/clang/include/clang-c/Index.h b/include/clang-c/Index.h
-index a9bd6f4ebf..b77483f5a9 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -32,7 +32,7 @@
-  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
-  */
- #define CINDEX_VERSION_MAJOR 0
--#define CINDEX_VERSION_MINOR 49
-+#define CINDEX_VERSION_MINOR 50
- 
- #define CINDEX_VERSION_ENCODE(major, minor) ( \
-       ((major) * 10000)                       \
-@@ -4799,6 +4799,28 @@ CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
-  */
- CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
- 
-+typedef enum {
-+  /**
-+   * \brief Used to indicate that no special tokenization options are needed.
-+   */
-+  CXTokenize_None = 0x0,
-+
-+  /**
-+   * \brief Used to indicate that tokens for whitespace should be returned.
-+   */
-+  CXTokenize_KeepWhitespace = 0x1
-+} CXTokenize_Flags;
-+
-+/**
-+ * \brief Tokenize the source code described by the given range into raw
-+ * lexical tokens.
-+ *
-+ * \see clang_tokenizeRange
-+ *
-+ */
-+CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-+                                   CXToken **Tokens, unsigned *NumTokens);
-+
- /**
-  * Tokenize the source code described by the given range into raw
-  * lexical tokens.
-@@ -4815,9 +4837,13 @@ CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
-  * \param NumTokens will be set to the number of tokens in the \c *Tokens
-  * array.
-  *
-+ * \param options A bitmask of options that affects tokenization. This should be
-+ * a bitwise OR of the CXTokenize_XXX flags.
-+ *
-  */
--CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
--                                   CXToken **Tokens, unsigned *NumTokens);
-+CINDEX_LINKAGE void clang_tokenizeRange(CXTranslationUnit TU,
-+                                        CXSourceRange Range, CXToken **Tokens,
-+                                        unsigned *NumTokens, unsigned options);
- 
- /**
-  * Annotate the given set of tokens by providing cursors for each token
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
-index 499d9abf9a..bbc29af346 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -6585,7 +6585,7 @@ CXSourceRange clang_getTokenExtent(CXTranslationUnit TU, CXToken CXTok) {
- }
- 
- static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
--                      SmallVectorImpl<CXToken> &CXTokens) {
-+                      SmallVectorImpl<CXToken> &CXTokens, unsigned options) {
-   SourceManager &SourceMgr = CXXUnit->getSourceManager();
-   std::pair<FileID, unsigned> BeginLocInfo
-     = SourceMgr.getDecomposedSpellingLoc(Range.getBegin());
-@@ -6607,6 +6607,9 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
-             CXXUnit->getASTContext().getLangOpts(),
-             Buffer.begin(), Buffer.data() + BeginLocInfo.second, Buffer.end());
-   Lex.SetCommentRetentionState(true);
-+  if (options & CXTokenize_KeepWhitespace) {
-+    Lex.SetKeepWhitespaceMode(true);
-+  }
- 
-   // Lex tokens until we hit the end of the range.
-   const char *EffectiveBufferEnd = Buffer.data() + EndLocInfo.second;
-@@ -6680,7 +6683,7 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
-   SourceLocation End = SM.getComposedLoc(DecomposedEnd.first, DecomposedEnd.second);
- 
-   SmallVector<CXToken, 32> CXTokens;
--  getTokens(CXXUnit, SourceRange(Begin, End), CXTokens);
-+  getTokens(CXXUnit, SourceRange(Begin, End), CXTokens, CXTokenize_None);
- 
-   if (CXTokens.empty())
-     return NULL;
-@@ -6694,6 +6697,12 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
- 
- void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-                     CXToken **Tokens, unsigned *NumTokens) {
-+  return clang_tokenizeRange(TU, Range, Tokens, NumTokens, CXTokenize_None);
-+}
-+
-+void clang_tokenizeRange(CXTranslationUnit TU, CXSourceRange Range,
-+                         CXToken **Tokens, unsigned *NumTokens,
-+                         unsigned options) {
-   LOG_FUNC_SECTION {
-     *Log << TU << ' ' << Range;
-   }
-@@ -6719,7 +6728,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-     return;
- 
-   SmallVector<CXToken, 32> CXTokens;
--  getTokens(CXXUnit, R, CXTokens);
-+  getTokens(CXXUnit, R, CXTokens, options);
- 
-   if (CXTokens.empty())
-     return;
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
-index 87773b9036..d185e26a2e 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -327,6 +327,7 @@ clang_suspendTranslationUnit
- clang_sortCodeCompletionResults
- clang_toggleCrashRecovery
- clang_tokenize
-+clang_tokenizeRange
- clang_CompilationDatabase_fromDirectory
- clang_CompilationDatabase_dispose
- clang_CompilationDatabase_getCompileCommands
--- 
-2.18.0
-
diff --git a/packages/llvm/llvm7-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch b/packages/llvm/llvm7-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch
deleted file mode 100644
index 50cac737fd66ca1f2c1aefd6be4ad21fe3df2085..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm7-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch
+++ /dev/null
@@ -1,433 +0,0 @@
-From e11c5d12937f1483ab4b0b509ec4a11ba5789de0 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Mon, 17 Jul 2017 12:25:49 +0200
-Subject: [PATCH 4/5] [libclang] WIP: Allow visiting of implicit declarations
- and template instantiations
-
----
- bindings/python/clang/cindex.py             |  45 ++++++--
- bindings/python/tests/cindex/test_cursor.py |  33 ++++++
- include/clang-c/Index.h                     |  31 ++++++
- tools/libclang/CIndex.cpp                   | 112 ++++++++++++++++++--
- tools/libclang/CursorVisitor.h              |  12 ++-
- tools/libclang/libclang.exports             |   2 +
- 6 files changed, 219 insertions(+), 16 deletions(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
-index a43fcff150..027f2d7f71 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -1408,6 +1408,15 @@ class Cursor(Structure):
-     """
-     _fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]
- 
-+    # Default behavior.
-+    GET_CHILDREN_NONE = 0
-+
-+    # Used to indicate that implicit cursors should be visited.
-+    GET_CHILDREN_WITH_IMPLICIT = 1
-+
-+    # Used to indicate that template instantiations should be visited.
-+    GET_CHILDREN_WITH_TEMPLATE_INSTANTIATIONS = 2
-+
-     @staticmethod
-     def from_location(tu, location):
-         # We store a reference to the TU in the instance so the TU won't get
-@@ -1497,6 +1506,10 @@ class Cursor(Structure):
-         """
-         return conf.lib.clang_EnumDecl_isScoped(self)
- 
-+    def is_implicit(self):
-+        """Test whether the cursor refers to an implicit declaration."""
-+        return conf.lib.clang_isImplicit(self)
-+
-     def get_definition(self):
-         """
-         If the cursor is a reference to a declaration or a declaration of
-@@ -1813,8 +1826,12 @@ class Cursor(Structure):
-         """Returns the value of the indicated arg as an unsigned 64b integer."""
-         return conf.lib.clang_Cursor_getTemplateArgumentUnsignedValue(self, num)
- 
--    def get_children(self):
--        """Return an iterator for accessing the children of this cursor."""
-+    def get_children(self, with_implicit=False, with_template_instantiations=False):
-+        """Return an iterator for accessing the children of this cursor.
-+
-+        By default, cursors representing implicit declarations or template instantiations
-+        will be skipped.
-+        """
- 
-         # FIXME: Expose iteration from CIndex, PR6125.
-         def visitor(child, parent, children):
-@@ -1827,18 +1844,24 @@ class Cursor(Structure):
-             children.append(child)
-             return 1 # continue
-         children = []
--        conf.lib.clang_visitChildren(self, callbacks['cursor_visit'](visitor),
--            children)
-+        dispatch = conf.lib.clang_visitChildren
-+        options = Cursor.GET_CHILDREN_NONE
-+        if with_implicit:
-+            options |= Cursor.GET_CHILDREN_WITH_IMPLICIT
-+        if with_template_instantiations:
-+            options |= Cursor.GET_CHILDREN_WITH_TEMPLATE_INSTANTIATIONS
-+        conf.lib.clang_visitChildrenWithOptions(
-+            self, callbacks['cursor_visit'](visitor), children, options)
-         return iter(children)
- 
--    def walk_preorder(self):
-+    def walk_preorder(self, **kwargs):
-         """Depth-first preorder walk over the cursor and its descendants.
- 
-         Yields cursors.
-         """
-         yield self
--        for child in self.get_children():
--            for descendant in child.walk_preorder():
-+        for child in self.get_children(**kwargs):
-+            for descendant in child.walk_preorder(**kwargs):
-                 yield descendant
- 
-     def get_tokens(self, options=0):
-@@ -3905,6 +3928,10 @@ functionList = [
-    [Type],
-    bool),
- 
-+  ("clang_isImplicit",
-+   [Cursor],
-+   bool),
-+
-   ("clang_isInvalid",
-    [CursorKind],
-    bool),
-@@ -3968,6 +3995,10 @@ functionList = [
-    [Cursor, callbacks['cursor_visit'], py_object],
-    c_uint),
- 
-+  ("clang_visitChildrenWithOptions",
-+   [Cursor, callbacks['cursor_visit'], py_object, c_uint],
-+   c_uint),
-+
-   ("clang_Cursor_getNumArguments",
-    [Cursor],
-    c_int),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
-index d7ddf83130..5a4eee4377 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -89,6 +89,39 @@ class TestCursor(unittest.TestCase):
-         self.assertEqual(tu_nodes[2].displayname, 'f0(int, int)')
-         self.assertEqual(tu_nodes[2].is_definition(), True)
- 
-+    def test_get_children_with_implicit():
-+        tu = get_tu('struct X {}; X x;', lang='cpp')
-+        cursor = get_cursor(tu, 'X')
-+
-+        children = list(cursor.get_children())
-+        self.assertEqual(len(children), 0, [(c.kind, c.spelling) for c in children])
-+
-+        children = list(cursor.get_children(with_implicit=True))
-+        self.assertNotEqual(len(children), 0)
-+        for child in children:
-+            self.assertTrue(child.is_implicit())
-+            self.assertEqual(child.spelling, "X")
-+            self.assertIn(child.kind, [CursorKind.CONSTRUCTOR, CursorKind.STRUCT_DECL])
-+
-+    def test_get_children_with_template_instantiations():
-+        tu = get_tu(
-+            'template <typename T> T frobnicate(T val);'
-+            'extern template int frobnicate<int>(int);',
-+            lang='cpp')
-+        cursor = get_cursor(tu, 'frobnicate')
-+        self.assertEqual(cursor.kind, CursorKind.FUNCTION_TEMPLATE)
-+
-+        for child in cursor.get_children():
-+            # should not return an instantiation:
-+            self.assertNotEqual(child.kind, CursorKind.FUNCTION_DECL)
-+
-+        for child in cursor.get_children(with_template_instantiations=True):
-+            if child.kind == CursorKind.FUNCTION_DECL:
-+                self.assertEqual(child.spelling, 'frobnicate')
-+                break
-+        else:
-+            self.fail("Couldn't find template instantiation")
-+
-     def test_references(self):
-         """Ensure that references to TranslationUnit are kept."""
-         tu = get_tu('int x;')
-diff --git a/tools/clang/include/clang-c/Index.h b/include/clang-c/Index.h
-index b77483f5a9..e5a47c0fca 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -2725,6 +2725,11 @@ CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
-  */
- CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
- 
-+/***
-+ * \brief Determine whether the given cursor represents an implicit declaration.
-+ */
-+CINDEX_LINKAGE unsigned clang_isImplicit(CXCursor);
-+
- /**
-  * Describe the linkage of the entity referred to by a cursor.
-  */
-@@ -4041,6 +4046,32 @@ CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
- #  endif
- #endif
- 
-+typedef enum {
-+  /**
-+   * \brief Default behavior.
-+   */
-+  CXVisitChildren_None = 0x0,
-+
-+  /**
-+   * \brief Used to indicate that implicit cursors should be visited.
-+   */
-+  CXVisitChildren_WithImplicit = 0x1,
-+
-+  /**
-+   * \brief Used to indicate that template instantiations should be visited.
-+   */
-+  CXVisitChildren_WithTemplateInstantiations = 0x2
-+} CXVisitChildren_Flags;
-+
-+/**
-+ * \brief Visits the children of a cursor, allowing to pass extra options.
-+ * Behaves identically to clang_visitChildren() in all other respects.
-+ */
-+CINDEX_LINKAGE unsigned clang_visitChildrenWithOptions(CXCursor parent,
-+                                                       CXCursorVisitor visitor,
-+                                                       CXClientData client_data,
-+                                                       unsigned options);
-+
- /**
-  * @}
-  */
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
-index bbc29af346..6e0a208d55 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -199,10 +199,11 @@ bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
-       assert(0 && "Invalid declaration cursor");
-       return true; // abort.
-     }
--    
--    // Ignore implicit declarations, unless it's an objc method because
--    // currently we should report implicit methods for properties when indexing.
--    if (D->isImplicit() && !isa<ObjCMethodDecl>(D))
-+
-+    // Unless instructed otherwise we ignore implicit declarations.
-+    // ObjC methods are currently visited in any case, because implicit methods
-+    // for properties should be reported when indexing.
-+    if (!VisitImplicitDeclarations && D->isImplicit() && !isa<ObjCMethodDecl>(D))
-       return false;
-   }
- 
-@@ -707,10 +708,13 @@ bool CursorVisitor::VisitTagDecl(TagDecl *D) {
- 
- bool CursorVisitor::VisitClassTemplateSpecializationDecl(
-                                           ClassTemplateSpecializationDecl *D) {
--  bool ShouldVisitBody = false;
-+  bool ShouldVisitBody = VisitTemplateInstantiations;
-   switch (D->getSpecializationKind()) {
--  case TSK_Undeclared:
-   case TSK_ImplicitInstantiation:
-+    if (VisitTemplateInstantiations && VisitImplicitDeclarations) {
-+      break;
-+    }
-+  case TSK_Undeclared:
-     // Nothing to visit
-     return false;
-       
-@@ -719,6 +723,7 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl(
-     break;
-       
-   case TSK_ExplicitSpecialization:
-+    // Always visit body of explicit specializations
-     ShouldVisitBody = true;
-     break;
-   }
-@@ -934,7 +939,31 @@ bool CursorVisitor::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
-     return true;
-   
-   auto* FD = D->getTemplatedDecl();
--  return VisitAttributes(FD) || VisitFunctionDecl(FD);
-+  if (VisitAttributes(FD) || VisitFunctionDecl(FD))
-+    return true;
-+
-+  if (VisitTemplateInstantiations && D == D->getCanonicalDecl()) {
-+    for (auto *FD : D->specializations()) {
-+      for (auto *RD : FD->redecls()) {
-+        switch (RD->getTemplateSpecializationKind()) {
-+        case TSK_Undeclared:
-+        case TSK_ImplicitInstantiation:
-+        case TSK_ExplicitInstantiationDeclaration:
-+        case TSK_ExplicitInstantiationDefinition: {
-+          const Optional<bool> V = handleDeclForVisitation(RD);
-+          if (!V.hasValue())
-+            continue;
-+          return V.getValue();
-+        }
-+
-+        case TSK_ExplicitSpecialization:
-+          break;
-+        }
-+      }
-+    }
-+  }
-+
-+  return false;
- }
- 
- bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-@@ -944,7 +973,40 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-     return true;
-   
-   auto* CD = D->getTemplatedDecl();
--  return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
-+  if (VisitAttributes(CD) || VisitCXXRecordDecl(CD))
-+    return true;
-+
-+  if (VisitTemplateInstantiations && D == D->getCanonicalDecl()) {
-+    for (auto *SD : D->specializations()) {
-+      for (auto *RD : SD->redecls()) {
-+        // We don't want to visit injected-class-names in this traversal.
-+        if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
-+          continue;
-+
-+        switch (
-+            cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
-+          // Visit the implicit instantiations with the requested pattern.
-+        case TSK_Undeclared:
-+        case TSK_ImplicitInstantiation: {
-+          const Optional<bool> V = handleDeclForVisitation(RD);
-+          if (!V.hasValue())
-+            continue;
-+          return V.getValue();
-+        }
-+
-+          // We don't need to do anything on an explicit instantiation
-+          // or explicit specialization because there will be an explicit
-+          // node for it elsewhere.
-+        case TSK_ExplicitInstantiationDeclaration:
-+        case TSK_ExplicitInstantiationDefinition:
-+        case TSK_ExplicitSpecialization:
-+          break;
-+        }
-+      }
-+    }
-+  }
-+
-+  return false;
- }
- 
- bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
-@@ -4391,6 +4453,24 @@ unsigned clang_visitChildrenWithBlock(CXCursor parent,
-   return clang_visitChildren(parent, visitWithBlock, block);
- }
- 
-+unsigned clang_visitChildrenWithOptions(CXCursor parent,
-+                                        CXCursorVisitor visitor,
-+                                        CXClientData client_data,
-+                                        unsigned options) {
-+  CursorVisitor CursorVis(
-+      getCursorTU(parent), visitor, client_data,
-+      /*VisitPreprocessorLast=*/false,
-+      /*VisitIncludedPreprocessingEntries=*/false,
-+      /*RegionOfInterest=*/SourceRange(),
-+      /*VisitDeclsOnly=*/false,
-+      /*PostChildrenVisitor=*/nullptr,
-+      /*VisitImplicitDeclarations=*/(options & CXVisitChildren_WithImplicit),
-+      /*VisitTemplateInstantiations=*/
-+      (options & CXVisitChildren_WithTemplateInstantiations));
-+
-+  return CursorVis.VisitChildren(parent);
-+}
-+
- static CXString getDeclSpelling(const Decl *D) {
-   if (!D)
-     return cxstring::createEmpty();
-@@ -5693,6 +5773,22 @@ unsigned clang_isUnexposed(enum CXCursorKind K) {
-   }
- }
- 
-+unsigned clang_isImplicit(CXCursor Cursor) {
-+  if (clang_isInvalid(Cursor.kind))
-+    return false;
-+
-+  if (!clang_isDeclaration(Cursor.kind))
-+    return false;
-+
-+  const Decl *D = getCursorDecl(Cursor);
-+  if (!D) {
-+    assert(0 && "Invalid declaration cursor");
-+    return true; // abort.
-+  }
-+
-+  return D->isImplicit();
-+}
-+
- CXCursorKind clang_getCursorKind(CXCursor C) {
-   return C.kind;
- }
-diff --git a/tools/clang/tools/libclang/CursorVisitor.h b/tools/libclang/CursorVisitor.h
-index f2fb68fab9..02085b1783 100644
---- a/tools/clang/tools/libclang/CursorVisitor.h
-+++ b/tools/clang/tools/libclang/CursorVisitor.h
-@@ -96,6 +96,12 @@ private:
-   /// record entries.
-   bool VisitDeclsOnly;
- 
-+  /// \brief Whether we should visit implicit declarations.
-+  bool VisitImplicitDeclarations;
-+
-+  /// \brief Whether we should recurse into template instantiations.
-+  bool VisitTemplateInstantiations;
-+
-   // FIXME: Eventually remove.  This part of a hack to support proper
-   // iteration over all Decls contained lexically within an ObjC container.
-   DeclContext::decl_iterator *DI_current;
-@@ -147,7 +153,9 @@ public:
-                 bool VisitIncludedPreprocessingEntries = false,
-                 SourceRange RegionOfInterest = SourceRange(),
-                 bool VisitDeclsOnly = false,
--                PostChildrenVisitorTy PostChildrenVisitor = nullptr)
-+                PostChildrenVisitorTy PostChildrenVisitor = nullptr,
-+                bool VisitImplicitDeclarations = false,
-+                bool VisitTemplateInstantiations = false)
-     : TU(TU), AU(cxtu::getASTUnit(TU)),
-       Visitor(Visitor), PostChildrenVisitor(PostChildrenVisitor),
-       ClientData(ClientData),
-@@ -155,6 +163,8 @@ public:
-       VisitIncludedEntities(VisitIncludedPreprocessingEntries),
-       RegionOfInterest(RegionOfInterest),
-       VisitDeclsOnly(VisitDeclsOnly),
-+      VisitImplicitDeclarations(VisitImplicitDeclarations),
-+      VisitTemplateInstantiations(VisitTemplateInstantiations),
-       DI_current(nullptr), FileDI_current(nullptr)
-   {
-     Parent.kind = CXCursor_NoDeclFound;
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
-index d185e26a2e..1376f29509 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -302,6 +302,7 @@ clang_isInvalidDeclaration
- clang_isExpression
- clang_isFileMultipleIncludeGuarded
- clang_isFunctionTypeVariadic
-+clang_isImplicit
- clang_isInvalid
- clang_isPODType
- clang_isPreprocessing
-@@ -343,6 +344,7 @@ clang_CompileCommand_getNumArgs
- clang_CompileCommand_getArg
- clang_visitChildren
- clang_visitChildrenWithBlock
-+clang_visitChildrenWithOptions
- clang_ModuleMapDescriptor_create
- clang_ModuleMapDescriptor_dispose
- clang_ModuleMapDescriptor_setFrameworkModuleName
--- 
-2.18.0
-
diff --git a/packages/llvm/llvm7-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch b/packages/llvm/llvm7-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch
deleted file mode 100644
index e71fd2ccac0d55465b2f870e31d245f49843264d..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm7-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 40ddcbc8dd69324bb4c97fd808924c5ee967f3d5 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Mon, 31 Jul 2017 14:09:52 +0200
-Subject: [PATCH 5/5] [libclang] WIP: Fix get_tokens in macro expansion
-
----
- bindings/python/tests/cindex/test_cursor.py | 15 +++++++++++++++
- tools/libclang/CIndex.cpp                   |  2 +-
- 2 files changed, 16 insertions(+), 1 deletion(-)
-
-diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
-index 5a4eee4377..a275d6b8cf 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -547,6 +547,21 @@ class TestCursor(unittest.TestCase):
-         r_cursor = t_cursor.referenced # should not raise an exception
-         self.assertEqual(r_cursor.kind, CursorKind.CLASS_DECL)
- 
-+    def test_get_tokens_in_macro_expansion(self):
-+        """regression test"""
-+        source = "#define IMPL(name) struct name { name(int v = 123); }; \n IMPL(X)"
-+        tu = get_tu(source, lang="cpp")
-+        ctor = get_cursors(tu, "X")[1]
-+        self.assertEqual(ctor.kind, CursorKind.CONSTRUCTOR)
-+        p = next(ctor.get_children())
-+        self.assertEqual(p.kind, CursorKind.PARM_DECL, (p.kind, p.spelling))
-+        children = list(p.get_children())
-+        self.assertEqual(len(children), 1, [(c.kind, c.spelling) for c in children])
-+        expr = children[0]
-+        tokens = list(expr.get_tokens())
-+        self.assertEqual(len(tokens), 1, [t.spelling for t in tokens])
-+        self.assertEqual(tokens[0].spelling, "123")
-+
-     def test_get_arguments(self):
-         tu = get_tu('void foo(int i, int j);')
-         foo = get_cursor(tu, 'foo')
-diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
-index 6e0a208d55..2ba96653ff 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -148,7 +148,7 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
-   // location accordingly.
-   SourceLocation EndLoc = R.getEnd();
-   bool IsTokenRange = R.isTokenRange();
--  if (EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc)) {
-+  if (false /*FIXME*/ && EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc)) {
-     CharSourceRange Expansion = SM.getExpansionRange(EndLoc);
-     EndLoc = Expansion.getEnd();
-     IsTokenRange = Expansion.isTokenRange();
--- 
-2.18.0
-
diff --git a/packages/llvm/llvm9-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch b/packages/llvm/llvm9-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch
deleted file mode 100644
index b1da65b18e22bc2f7052a4ed269cab6a9db2a8d7..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm9-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch
+++ /dev/null
@@ -1,162 +0,0 @@
-From e673a5527dd2df322884eb2498736483df05957d Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann@jklaehn.de>
-Date: Fri, 3 Nov 2017 11:17:59 +0100
-Subject: [PATCH 2/5] [libclang] Add support for obtaining fully qualified
- names of types
-
-This patch allows retrieving the fully qualified names of types
-through libclang and clang.cindex (Python).
----
- clang/bindings/python/clang/cindex.py         | 13 +++++++++++
- .../python/tests/cindex/test_cursor.py        |  8 +++++++
- clang/include/clang-c/Index.h                 | 10 ++++++++-
- clang/tools/libclang/CMakeLists.txt           |  1 +
- clang/tools/libclang/CXType.cpp               | 22 +++++++++++++++++++
- clang/tools/libclang/libclang.exports         |  1 +
- 6 files changed, 54 insertions(+), 1 deletion(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/tools/clang/bindings/python/clang/cindex.py
-index 8e5a9fe0068..c309f7017b2 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -2427,6 +2427,14 @@ class Type(Structure):
-         """Retrieve the spelling of this Type."""
-         return conf.lib.clang_getTypeSpelling(self)
- 
-+    @property
-+    def fully_qualified_name(self):
-+        """Retrieve the fully qualified name of this Type."""
-+        if not hasattr(self, '_fully_qualified_name'):
-+            self._fully_qualified_name = conf.lib.clang_getFullyQualifiedTypeName(self)
-+
-+        return self._fully_qualified_name
-+
-     def __eq__(self, other):
-         if type(other) != type(self):
-             return False
-@@ -3869,6 +3877,11 @@ functionList = [
-    _CXString,
-    _CXString.from_result),
- 
-+  ("clang_getFullyQualifiedTypeName",
-+   [Type],
-+   _CXString,
-+   _CXString.from_result),
-+
-   ("clang_hashCursor",
-    [Cursor],
-    c_uint),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-index ef875e97247..6a53c7205df 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -316,6 +316,14 @@ class TestCursor(unittest.TestCase):
-         underlying = typedef.underlying_typedef_type
-         self.assertEqual(underlying.kind, TypeKind.INT)
- 
-+    def test_fully_qualified_type_name():
-+        source = 'namespace uiae { struct X { typedef int sometype; }; }'
-+        tu = get_tu(source, lang='cpp')
-+
-+        cls = get_cursor(tu, 'sometype')
-+        fqn = cls.type.fully_qualified_name
-+        self.assertTrue(fqn.endswith("uiae::X::sometype"), fqn)
-+
-     def test_semantic_parent(self):
-         tu = get_tu(kParentTest, 'cpp')
-         curs = get_cursors(tu, 'f')
-diff --git a/tools/clang/include/clang-c/Index.h b/tools/clang/include/clang-c/Index.h
-index 74badac740b..b0c62fe948e 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -32,7 +32,7 @@
-  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
-  */
- #define CINDEX_VERSION_MAJOR 0
--#define CINDEX_VERSION_MINOR 59
-+#define CINDEX_VERSION_MINOR 60
- 
- #define CINDEX_VERSION_ENCODE(major, minor) ( \
-       ((major) * 10000)                       \
-@@ -3389,6 +3389,14 @@ CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
-  */
- CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
- 
-+/**
-+ * Retrieve the fully qualified name of the underlying type.
-+ * This includes full qualification of all template parameters etc.
-+ *
-+ * If the type is invalid, an empty string is returned.
-+ */
-+CINDEX_LINKAGE CXString clang_getFullyQualifiedTypeName(CXType CT);
-+
- /**
-  * Retrieve the underlying type of a typedef declaration.
-  *
-diff --git a/tools/clang/tools/libclang/CMakeLists.txt b/tools/clang/tools/libclang/CMakeLists.txt
-index 613ead1a36b..a583fa206d1 100644
---- a/tools/clang/tools/libclang/CMakeLists.txt
-+++ b/tools/clang/tools/libclang/CMakeLists.txt
-@@ -43,6 +43,7 @@ set(LIBS
-   clangSema
-   clangSerialization
-   clangTooling
-+  clangToolingCore
- )
- 
- if (CLANG_ENABLE_ARCMT)
-diff --git a/tools/clang/tools/libclang/CXType.cpp b/tools/clang/tools/libclang/CXType.cpp
-index acecf87d0cd..afdeb467769 100644
---- a/tools/clang/tools/libclang/CXType.cpp
-+++ b/tools/clang/tools/libclang/CXType.cpp
-@@ -19,6 +19,7 @@
- #include "clang/AST/DeclObjC.h"
- #include "clang/AST/DeclTemplate.h"
- #include "clang/AST/Expr.h"
-+#include "clang/AST/QualTypeNames.h"
- #include "clang/AST/Type.h"
- #include "clang/Basic/AddressSpaces.h"
- #include "clang/Frontend/ASTUnit.h"
-@@ -302,6 +303,27 @@ CXString clang_getTypeSpelling(CXType CT) {
-   return cxstring::createDup(OS.str());
- }
- 
-+CXString clang_getFullyQualifiedTypeName(CXType CT) {
-+  QualType T = GetQualType(CT);
-+  if (T.isNull())
-+    return cxstring::createEmpty();
-+
-+  // For builtin types (but not typedefs pointing to builtin types) return their
-+  // spelling.  Otherwise "bool" will be turned into "_Bool".
-+  const Type *TP = T.getTypePtrOrNull();
-+  if (TP && TP->isBuiltinType() && T->getAs<TypedefType>() == nullptr)
-+    return clang_getTypeSpelling(CT);
-+
-+  CXTranslationUnit TU = GetTU(CT);
-+  ASTContext &Ctx = cxtu::getASTUnit(TU)->getASTContext();
-+  PrintingPolicy Policy(Ctx.getPrintingPolicy());
-+  Policy.SuppressScope = false;
-+  Policy.AnonymousTagLocations = false;
-+  Policy.PolishForDeclaration = true;
-+  std::string name = TypeName::getFullyQualifiedName(T, Ctx, Policy, /*WithGlobalNsPrefix=*/true);
-+  return cxstring::createDup(name.c_str());
-+}
-+
- CXType clang_getTypedefDeclUnderlyingType(CXCursor C) {
-   using namespace cxcursor;
-   CXTranslationUnit TU = cxcursor::getCursorTU(C);
-diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/clang/tools/libclang/libclang.exports
-index 3c76090d64f..6e860e7263e 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -241,6 +241,7 @@ clang_getFileLocation
- clang_getFileName
- clang_getFileTime
- clang_getFileUniqueID
-+clang_getFullyQualifiedTypeName
- clang_getFunctionTypeCallingConv
- clang_getIBOutletCollectionType
- clang_getIncludedFile
--- 
-2.23.0
-
diff --git a/packages/llvm/llvm9-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch b/packages/llvm/llvm9-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch
deleted file mode 100644
index e3a0012bd24da636ed172ae308242c2cadb547ae..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm9-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch
+++ /dev/null
@@ -1,261 +0,0 @@
-From 075a7a3e667fe3d923de6d7a6929e61922c8b139 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann@jklaehn.de>
-Date: Fri, 3 Nov 2017 21:19:51 +0100
-Subject: [PATCH 3/5] [libclang] Add option to keep whitespace when tokenizing
-
-Introduces new `clang_tokenizeRange` function which accepts options to control
-tokenization behavior.  `clang_tokenize` is kept for backwards compatibility.
----
- clang/bindings/python/clang/cindex.py         | 31 ++++++++++++++----
- .../python/tests/cindex/test_cursor.py        |  9 ++++++
- clang/include/clang-c/Index.h                 | 32 +++++++++++++++++--
- clang/tools/libclang/CIndex.cpp               | 15 +++++++--
- clang/tools/libclang/libclang.exports         |  1 +
- 5 files changed, 75 insertions(+), 13 deletions(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
-index c309f7017b2..1589acc9e7e 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -529,6 +529,13 @@ class TokenGroup(object):
- 
-     You should not instantiate this class outside of this module.
-     """
-+
-+    # Default tokenization mode.
-+    TOKENIZE_NONE = 0
-+
-+    # Used to indicate that tokens for whitespace should be returned.
-+    TOKENIZE_KEEP_WHITESPACE = 1
-+
-     def __init__(self, tu, memory, count):
-         self._tu = tu
-         self._memory = memory
-@@ -538,7 +545,7 @@ class TokenGroup(object):
-         conf.lib.clang_disposeTokens(self._tu, self._memory, self._count)
- 
-     @staticmethod
--    def get_tokens(tu, extent):
-+    def get_tokens(tu, extent, options=0):
-         """Helper method to return all tokens in an extent.
- 
-         This functionality is needed multiple places in this module. We define
-@@ -547,8 +554,8 @@ class TokenGroup(object):
-         tokens_memory = POINTER(Token)()
-         tokens_count = c_uint()
- 
--        conf.lib.clang_tokenize(tu, extent, byref(tokens_memory),
--                byref(tokens_count))
-+        conf.lib.clang_tokenizeRange(
-+            tu, extent, byref(tokens_memory), byref(tokens_count), options)
- 
-         count = int(tokens_count.value)
- 
-@@ -1852,13 +1859,16 @@ class Cursor(Structure):
-             for descendant in child.walk_preorder():
-                 yield descendant
- 
--    def get_tokens(self):
-+    def get_tokens(self, options=0):
-         """Obtain Token instances formulating that compose this Cursor.
- 
-         This is a generator for Token instances. It returns all tokens which
-         occupy the extent this cursor occupies.
-+
-+        options is a bitwise or of TokenGroup.TOKENIZE_XXX flags which will
-+        control tokenization behavior.
-         """
--        return TokenGroup.get_tokens(self._tu, self.extent)
-+        return TokenGroup.get_tokens(self._tu, self.extent, options)
- 
-     def get_field_offsetof(self):
-         """Returns the offsetof the FIELD_DECL pointed by this Cursor."""
-@@ -3080,18 +3090,21 @@ class TranslationUnit(ClangObject):
-             return CodeCompletionResults(ptr)
-         return None
- 
--    def get_tokens(self, locations=None, extent=None):
-+    def get_tokens(self, locations=None, extent=None, options=0):
-         """Obtain tokens in this translation unit.
- 
-         This is a generator for Token instances. The caller specifies a range
-         of source code to obtain tokens for. The range can be specified as a
-         2-tuple of SourceLocation or as a SourceRange. If both are defined,
-         behavior is undefined.
-+
-+        options is a bitwise or of TokenGroup.TOKENIZE_XXX flags which will
-+        control tokenization behavior.
-         """
-         if locations is not None:
-             extent = SourceRange(start=locations[0], end=locations[1])
- 
--        return TokenGroup.get_tokens(self, extent)
-+        return TokenGroup.get_tokens(self, extent, options)
- 
- class File(ClangObject):
-     """
-@@ -3969,6 +3982,10 @@ functionList = [
-   ("clang_tokenize",
-    [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint)]),
- 
-+  ("clang_tokenizeRange",
-+   [TranslationUnit, SourceRange, POINTER(POINTER(Token)), POINTER(c_uint),
-+    c_uint]),
-+
-   ("clang_visitChildren",
-    [Cursor, callbacks['cursor_visit'], py_object],
-    c_uint),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py
-index 6a53c7205df..0965c1f4ae1 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -10,6 +10,7 @@ import unittest
- from clang.cindex import AvailabilityKind
- from clang.cindex import CursorKind
- from clang.cindex import TemplateArgumentKind
-+from clang.cindex import TokenGroup
- from clang.cindex import TranslationUnit
- from clang.cindex import TypeKind
- from .util import get_cursor
-@@ -488,6 +489,14 @@ class TestCursor(unittest.TestCase):
-         self.assertEqual(tokens[0].spelling, 'int')
-         self.assertEqual(tokens[1].spelling, 'foo')
- 
-+    def test_get_tokens_with_whitespace():
-+        source = 'class C { void f(); }\nvoid C::f() { }'
-+        tu = get_tu(source)
-+
-+        tokens = list(tu.cursor.get_tokens(TokenGroup.TOKENIZE_KEEP_WHITESPACE))
-+        self.assertEqual(''.join(t.spelling for t in tokens), source)
-+        self.assertEqual(len(tokens), 27, [t.spelling for t in tokens])
-+
-     def test_get_token_cursor(self):
-         """Ensure we can map tokens to cursors."""
-         tu = get_tu('class A {}; int foo(A var = A());', lang='cpp')
-diff --git a/tools/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
-index b0c62fe948e..84ed03b8920 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -32,7 +32,7 @@
-  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
-  */
- #define CINDEX_VERSION_MAJOR 0
--#define CINDEX_VERSION_MINOR 60
-+#define CINDEX_VERSION_MINOR 61
- 
- #define CINDEX_VERSION_ENCODE(major, minor) ( \
-       ((major) * 10000)                       \
-@@ -4969,6 +4969,28 @@ CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
-  */
- CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
- 
-+typedef enum {
-+  /**
-+   * \brief Used to indicate that no special tokenization options are needed.
-+   */
-+  CXTokenize_None = 0x0,
-+
-+  /**
-+   * \brief Used to indicate that tokens for whitespace should be returned.
-+   */
-+  CXTokenize_KeepWhitespace = 0x1
-+} CXTokenize_Flags;
-+
-+/**
-+ * \brief Tokenize the source code described by the given range into raw
-+ * lexical tokens.
-+ *
-+ * \see clang_tokenizeRange
-+ *
-+ */
-+CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-+                                   CXToken **Tokens, unsigned *NumTokens);
-+
- /**
-  * Tokenize the source code described by the given range into raw
-  * lexical tokens.
-@@ -4985,9 +5007,13 @@ CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
-  * \param NumTokens will be set to the number of tokens in the \c *Tokens
-  * array.
-  *
-+ * \param options A bitmask of options that affects tokenization. This should be
-+ * a bitwise OR of the CXTokenize_XXX flags.
-+ *
-  */
--CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
--                                   CXToken **Tokens, unsigned *NumTokens);
-+CINDEX_LINKAGE void clang_tokenizeRange(CXTranslationUnit TU,
-+                                        CXSourceRange Range, CXToken **Tokens,
-+                                        unsigned *NumTokens, unsigned options);
- 
- /**
-  * Annotate the given set of tokens by providing cursors for each token
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
-index 1dc961f58a2..3a283e76ed8 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -6670,7 +6670,7 @@ CXSourceRange clang_getTokenExtent(CXTranslationUnit TU, CXToken CXTok) {
- }
- 
- static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
--                      SmallVectorImpl<CXToken> &CXTokens) {
-+                      SmallVectorImpl<CXToken> &CXTokens, unsigned options) {
-   SourceManager &SourceMgr = CXXUnit->getSourceManager();
-   std::pair<FileID, unsigned> BeginLocInfo
-     = SourceMgr.getDecomposedSpellingLoc(Range.getBegin());
-@@ -6692,6 +6692,9 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
-             CXXUnit->getASTContext().getLangOpts(),
-             Buffer.begin(), Buffer.data() + BeginLocInfo.second, Buffer.end());
-   Lex.SetCommentRetentionState(true);
-+  if (options & CXTokenize_KeepWhitespace) {
-+    Lex.SetKeepWhitespaceMode(true);
-+  }
- 
-   // Lex tokens until we hit the end of the range.
-   const char *EffectiveBufferEnd = Buffer.data() + EndLocInfo.second;
-@@ -6765,7 +6768,7 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
-   SourceLocation End = SM.getComposedLoc(DecomposedEnd.first, DecomposedEnd.second);
- 
-   SmallVector<CXToken, 32> CXTokens;
--  getTokens(CXXUnit, SourceRange(Begin, End), CXTokens);
-+  getTokens(CXXUnit, SourceRange(Begin, End), CXTokens, CXTokenize_None);
- 
-   if (CXTokens.empty())
-     return NULL;
-@@ -6779,6 +6782,12 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
- 
- void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-                     CXToken **Tokens, unsigned *NumTokens) {
-+  return clang_tokenizeRange(TU, Range, Tokens, NumTokens, CXTokenize_None);
-+}
-+
-+void clang_tokenizeRange(CXTranslationUnit TU, CXSourceRange Range,
-+                         CXToken **Tokens, unsigned *NumTokens,
-+                         unsigned options) {
-   LOG_FUNC_SECTION {
-     *Log << TU << ' ' << Range;
-   }
-@@ -6804,7 +6813,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
-     return;
- 
-   SmallVector<CXToken, 32> CXTokens;
--  getTokens(CXXUnit, R, CXTokens);
-+  getTokens(CXXUnit, R, CXTokens, options);
- 
-   if (CXTokens.empty())
-     return;
-diff --git a/tools/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports
-index 6e860e7263e..6af6c0ca3e8 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -338,6 +338,7 @@ clang_suspendTranslationUnit
- clang_sortCodeCompletionResults
- clang_toggleCrashRecovery
- clang_tokenize
-+clang_tokenizeRange
- clang_CompilationDatabase_fromDirectory
- clang_CompilationDatabase_dispose
- clang_CompilationDatabase_getCompileCommands
--- 
-2.23.0
-
diff --git a/packages/llvm/llvm9-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch b/packages/llvm/llvm9-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch
deleted file mode 100644
index ef4a125e82d6b42b73574ce10ced78aa2d597590..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm9-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch
+++ /dev/null
@@ -1,442 +0,0 @@
-From d10d66b8e762c1dd1329d5920f9ef952cf4f6940 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Mon, 17 Jul 2017 12:25:49 +0200
-Subject: [PATCH 4/5] [libclang] WIP: Allow visiting of implicit declarations
- and template instantiations
-
----
- clang/bindings/python/clang/cindex.py         |  45 +++++--
- .../python/tests/cindex/test_cursor.py        |  33 ++++++
- clang/include/clang-c/Index.h                 |  33 +++++-
- clang/tools/libclang/CIndex.cpp               | 112 ++++++++++++++++--
- clang/tools/libclang/CursorVisitor.h          |  12 +-
- clang/tools/libclang/libclang.exports         |   2 +
- 6 files changed, 220 insertions(+), 17 deletions(-)
-
-diff --git a/tools/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
-index 1589acc9e7e..b023be6cdc8 100644
---- a/tools/clang/bindings/python/clang/cindex.py
-+++ b/tools/clang/bindings/python/clang/cindex.py
-@@ -1426,6 +1426,15 @@ class Cursor(Structure):
-     """
-     _fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]
- 
-+    # Default behavior.
-+    GET_CHILDREN_NONE = 0
-+
-+    # Used to indicate that implicit cursors should be visited.
-+    GET_CHILDREN_WITH_IMPLICIT = 1
-+
-+    # Used to indicate that template instantiations should be visited.
-+    GET_CHILDREN_WITH_TEMPLATE_INSTANTIATIONS = 2
-+
-     @staticmethod
-     def from_location(tu, location):
-         # We store a reference to the TU in the instance so the TU won't get
-@@ -1515,6 +1524,10 @@ class Cursor(Structure):
-         """
-         return conf.lib.clang_EnumDecl_isScoped(self)
- 
-+    def is_implicit(self):
-+        """Test whether the cursor refers to an implicit declaration."""
-+        return conf.lib.clang_isImplicit(self)
-+
-     def get_definition(self):
-         """
-         If the cursor is a reference to a declaration or a declaration of
-@@ -1831,8 +1844,12 @@ class Cursor(Structure):
-         """Returns the value of the indicated arg as an unsigned 64b integer."""
-         return conf.lib.clang_Cursor_getTemplateArgumentUnsignedValue(self, num)
- 
--    def get_children(self):
--        """Return an iterator for accessing the children of this cursor."""
-+    def get_children(self, with_implicit=False, with_template_instantiations=False):
-+        """Return an iterator for accessing the children of this cursor.
-+
-+        By default, cursors representing implicit declarations or template instantiations
-+        will be skipped.
-+        """
- 
-         # FIXME: Expose iteration from CIndex, PR6125.
-         def visitor(child, parent, children):
-@@ -1845,18 +1862,24 @@ class Cursor(Structure):
-             children.append(child)
-             return 1 # continue
-         children = []
--        conf.lib.clang_visitChildren(self, callbacks['cursor_visit'](visitor),
--            children)
-+        dispatch = conf.lib.clang_visitChildren
-+        options = Cursor.GET_CHILDREN_NONE
-+        if with_implicit:
-+            options |= Cursor.GET_CHILDREN_WITH_IMPLICIT
-+        if with_template_instantiations:
-+            options |= Cursor.GET_CHILDREN_WITH_TEMPLATE_INSTANTIATIONS
-+        conf.lib.clang_visitChildrenWithOptions(
-+            self, callbacks['cursor_visit'](visitor), children, options)
-         return iter(children)
- 
--    def walk_preorder(self):
-+    def walk_preorder(self, **kwargs):
-         """Depth-first preorder walk over the cursor and its descendants.
- 
-         Yields cursors.
-         """
-         yield self
--        for child in self.get_children():
--            for descendant in child.walk_preorder():
-+        for child in self.get_children(**kwargs):
-+            for descendant in child.walk_preorder(**kwargs):
-                 yield descendant
- 
-     def get_tokens(self, options=0):
-@@ -3927,6 +3950,10 @@ functionList = [
-    [Type],
-    bool),
- 
-+  ("clang_isImplicit",
-+   [Cursor],
-+   bool),
-+
-   ("clang_isInvalid",
-    [CursorKind],
-    bool),
-@@ -3990,6 +4017,10 @@ functionList = [
-    [Cursor, callbacks['cursor_visit'], py_object],
-    c_uint),
- 
-+  ("clang_visitChildrenWithOptions",
-+   [Cursor, callbacks['cursor_visit'], py_object, c_uint],
-+   c_uint),
-+
-   ("clang_Cursor_getNumArguments",
-    [Cursor],
-    c_int),
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py
-index 0965c1f4ae1..d061f37c25c 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -94,6 +94,39 @@ class TestCursor(unittest.TestCase):
-         self.assertEqual(tu_nodes[2].displayname, 'f0(int, int)')
-         self.assertEqual(tu_nodes[2].is_definition(), True)
- 
-+    def test_get_children_with_implicit():
-+        tu = get_tu('struct X {}; X x;', lang='cpp')
-+        cursor = get_cursor(tu, 'X')
-+
-+        children = list(cursor.get_children())
-+        self.assertEqual(len(children), 0, [(c.kind, c.spelling) for c in children])
-+
-+        children = list(cursor.get_children(with_implicit=True))
-+        self.assertNotEqual(len(children), 0)
-+        for child in children:
-+            self.assertTrue(child.is_implicit())
-+            self.assertEqual(child.spelling, "X")
-+            self.assertIn(child.kind, [CursorKind.CONSTRUCTOR, CursorKind.STRUCT_DECL])
-+
-+    def test_get_children_with_template_instantiations():
-+        tu = get_tu(
-+            'template <typename T> T frobnicate(T val);'
-+            'extern template int frobnicate<int>(int);',
-+            lang='cpp')
-+        cursor = get_cursor(tu, 'frobnicate')
-+        self.assertEqual(cursor.kind, CursorKind.FUNCTION_TEMPLATE)
-+
-+        for child in cursor.get_children():
-+            # should not return an instantiation:
-+            self.assertNotEqual(child.kind, CursorKind.FUNCTION_DECL)
-+
-+        for child in cursor.get_children(with_template_instantiations=True):
-+            if child.kind == CursorKind.FUNCTION_DECL:
-+                self.assertEqual(child.spelling, 'frobnicate')
-+                break
-+        else:
-+            self.fail("Couldn't find template instantiation")
-+
-     def test_references(self):
-         """Ensure that references to TranslationUnit are kept."""
-         tu = get_tu('int x;')
-diff --git a/tools/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
-index 84ed03b8920..57acbcba143 100644
---- a/tools/clang/include/clang-c/Index.h
-+++ b/tools/clang/include/clang-c/Index.h
-@@ -32,7 +32,7 @@
-  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
-  */
- #define CINDEX_VERSION_MAJOR 0
--#define CINDEX_VERSION_MINOR 61
-+#define CINDEX_VERSION_MINOR 62
- 
- #define CINDEX_VERSION_ENCODE(major, minor) ( \
-       ((major) * 10000)                       \
-@@ -2775,6 +2775,11 @@ CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
-  */
- CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
- 
-+/***
-+ * \brief Determine whether the given cursor represents an implicit declaration.
-+ */
-+CINDEX_LINKAGE unsigned clang_isImplicit(CXCursor);
-+
- /**
-  * Describe the linkage of the entity referred to by a cursor.
-  */
-@@ -4199,6 +4204,32 @@ CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
- #  endif
- #endif
- 
-+typedef enum {
-+  /**
-+   * \brief Default behavior.
-+   */
-+  CXVisitChildren_None = 0x0,
-+
-+  /**
-+   * \brief Used to indicate that implicit cursors should be visited.
-+   */
-+  CXVisitChildren_WithImplicit = 0x1,
-+
-+  /**
-+   * \brief Used to indicate that template instantiations should be visited.
-+   */
-+  CXVisitChildren_WithTemplateInstantiations = 0x2
-+} CXVisitChildren_Flags;
-+
-+/**
-+ * \brief Visits the children of a cursor, allowing to pass extra options.
-+ * Behaves identically to clang_visitChildren() in all other respects.
-+ */
-+CINDEX_LINKAGE unsigned clang_visitChildrenWithOptions(CXCursor parent,
-+                                                       CXCursorVisitor visitor,
-+                                                       CXClientData client_data,
-+                                                       unsigned options);
-+
- /**
-  * @}
-  */
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
-index 3a283e76ed8..7ee6b704647 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -195,10 +195,11 @@ bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
-       assert(0 && "Invalid declaration cursor");
-       return true; // abort.
-     }
--    
--    // Ignore implicit declarations, unless it's an objc method because
--    // currently we should report implicit methods for properties when indexing.
--    if (D->isImplicit() && !isa<ObjCMethodDecl>(D))
-+
-+    // Unless instructed otherwise we ignore implicit declarations.
-+    // ObjC methods are currently visited in any case, because implicit methods
-+    // for properties should be reported when indexing.
-+    if (!VisitImplicitDeclarations && D->isImplicit() && !isa<ObjCMethodDecl>(D))
-       return false;
-   }
- 
-@@ -703,10 +704,13 @@ bool CursorVisitor::VisitTagDecl(TagDecl *D) {
- 
- bool CursorVisitor::VisitClassTemplateSpecializationDecl(
-                                           ClassTemplateSpecializationDecl *D) {
--  bool ShouldVisitBody = false;
-+  bool ShouldVisitBody = VisitTemplateInstantiations;
-   switch (D->getSpecializationKind()) {
--  case TSK_Undeclared:
-   case TSK_ImplicitInstantiation:
-+    if (VisitTemplateInstantiations && VisitImplicitDeclarations) {
-+      break;
-+    }
-+  case TSK_Undeclared:
-     // Nothing to visit
-     return false;
-       
-@@ -715,6 +719,7 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl(
-     break;
-       
-   case TSK_ExplicitSpecialization:
-+    // Always visit body of explicit specializations
-     ShouldVisitBody = true;
-     break;
-   }
-@@ -930,7 +935,31 @@ bool CursorVisitor::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
-     return true;
-   
-   auto* FD = D->getTemplatedDecl();
--  return VisitAttributes(FD) || VisitFunctionDecl(FD);
-+  if (VisitAttributes(FD) || VisitFunctionDecl(FD))
-+    return true;
-+
-+  if (VisitTemplateInstantiations && D == D->getCanonicalDecl()) {
-+    for (auto *FD : D->specializations()) {
-+      for (auto *RD : FD->redecls()) {
-+        switch (RD->getTemplateSpecializationKind()) {
-+        case TSK_Undeclared:
-+        case TSK_ImplicitInstantiation:
-+        case TSK_ExplicitInstantiationDeclaration:
-+        case TSK_ExplicitInstantiationDefinition: {
-+          const Optional<bool> V = handleDeclForVisitation(RD);
-+          if (!V.hasValue())
-+            continue;
-+          return V.getValue();
-+        }
-+
-+        case TSK_ExplicitSpecialization:
-+          break;
-+        }
-+      }
-+    }
-+  }
-+
-+  return false;
- }
- 
- bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-@@ -940,7 +969,40 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
-     return true;
-   
-   auto* CD = D->getTemplatedDecl();
--  return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
-+  if (VisitAttributes(CD) || VisitCXXRecordDecl(CD))
-+    return true;
-+
-+  if (VisitTemplateInstantiations && D == D->getCanonicalDecl()) {
-+    for (auto *SD : D->specializations()) {
-+      for (auto *RD : SD->redecls()) {
-+        // We don't want to visit injected-class-names in this traversal.
-+        if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
-+          continue;
-+
-+        switch (
-+            cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
-+          // Visit the implicit instantiations with the requested pattern.
-+        case TSK_Undeclared:
-+        case TSK_ImplicitInstantiation: {
-+          const Optional<bool> V = handleDeclForVisitation(RD);
-+          if (!V.hasValue())
-+            continue;
-+          return V.getValue();
-+        }
-+
-+          // We don't need to do anything on an explicit instantiation
-+          // or explicit specialization because there will be an explicit
-+          // node for it elsewhere.
-+        case TSK_ExplicitInstantiationDeclaration:
-+        case TSK_ExplicitInstantiationDefinition:
-+        case TSK_ExplicitSpecialization:
-+          break;
-+        }
-+      }
-+    }
-+  }
-+
-+  return false;
- }
- 
- bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
-@@ -4426,6 +4488,24 @@ unsigned clang_visitChildrenWithBlock(CXCursor parent,
-   return clang_visitChildren(parent, visitWithBlock, block);
- }
- 
-+unsigned clang_visitChildrenWithOptions(CXCursor parent,
-+                                        CXCursorVisitor visitor,
-+                                        CXClientData client_data,
-+                                        unsigned options) {
-+  CursorVisitor CursorVis(
-+      getCursorTU(parent), visitor, client_data,
-+      /*VisitPreprocessorLast=*/false,
-+      /*VisitIncludedPreprocessingEntries=*/false,
-+      /*RegionOfInterest=*/SourceRange(),
-+      /*VisitDeclsOnly=*/false,
-+      /*PostChildrenVisitor=*/nullptr,
-+      /*VisitImplicitDeclarations=*/(options & CXVisitChildren_WithImplicit),
-+      /*VisitTemplateInstantiations=*/
-+      (options & CXVisitChildren_WithTemplateInstantiations));
-+
-+  return CursorVis.VisitChildren(parent);
-+}
-+
- static CXString getDeclSpelling(const Decl *D) {
-   if (!D)
-     return cxstring::createEmpty();
-@@ -5774,6 +5854,22 @@ unsigned clang_isUnexposed(enum CXCursorKind K) {
-   }
- }
- 
-+unsigned clang_isImplicit(CXCursor Cursor) {
-+  if (clang_isInvalid(Cursor.kind))
-+    return false;
-+
-+  if (!clang_isDeclaration(Cursor.kind))
-+    return false;
-+
-+  const Decl *D = getCursorDecl(Cursor);
-+  if (!D) {
-+    assert(0 && "Invalid declaration cursor");
-+    return true; // abort.
-+  }
-+
-+  return D->isImplicit();
-+}
-+
- CXCursorKind clang_getCursorKind(CXCursor C) {
-   return C.kind;
- }
-diff --git a/tools/clang/tools/libclang/CursorVisitor.h b/clang/tools/libclang/CursorVisitor.h
-index b0afa5a0b59..94f4596d5fa 100644
---- a/tools/clang/tools/libclang/CursorVisitor.h
-+++ b/tools/clang/tools/libclang/CursorVisitor.h
-@@ -95,6 +95,12 @@ private:
-   /// record entries.
-   bool VisitDeclsOnly;
- 
-+  /// \brief Whether we should visit implicit declarations.
-+  bool VisitImplicitDeclarations;
-+
-+  /// \brief Whether we should recurse into template instantiations.
-+  bool VisitTemplateInstantiations;
-+
-   // FIXME: Eventually remove.  This part of a hack to support proper
-   // iteration over all Decls contained lexically within an ObjC container.
-   DeclContext::decl_iterator *DI_current;
-@@ -146,7 +152,9 @@ public:
-                 bool VisitIncludedPreprocessingEntries = false,
-                 SourceRange RegionOfInterest = SourceRange(),
-                 bool VisitDeclsOnly = false,
--                PostChildrenVisitorTy PostChildrenVisitor = nullptr)
-+                PostChildrenVisitorTy PostChildrenVisitor = nullptr,
-+                bool VisitImplicitDeclarations = false,
-+                bool VisitTemplateInstantiations = false)
-     : TU(TU), AU(cxtu::getASTUnit(TU)),
-       Visitor(Visitor), PostChildrenVisitor(PostChildrenVisitor),
-       ClientData(ClientData),
-@@ -154,6 +162,8 @@ public:
-       VisitIncludedEntities(VisitIncludedPreprocessingEntries),
-       RegionOfInterest(RegionOfInterest),
-       VisitDeclsOnly(VisitDeclsOnly),
-+      VisitImplicitDeclarations(VisitImplicitDeclarations),
-+      VisitTemplateInstantiations(VisitTemplateInstantiations),
-       DI_current(nullptr), FileDI_current(nullptr)
-   {
-     Parent.kind = CXCursor_NoDeclFound;
-diff --git a/tools/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports
-index 6af6c0ca3e8..d17eb83187d 100644
---- a/tools/clang/tools/libclang/libclang.exports
-+++ b/tools/clang/tools/libclang/libclang.exports
-@@ -313,6 +313,7 @@ clang_isInvalidDeclaration
- clang_isExpression
- clang_isFileMultipleIncludeGuarded
- clang_isFunctionTypeVariadic
-+clang_isImplicit
- clang_isInvalid
- clang_isPODType
- clang_isPreprocessing
-@@ -354,6 +355,7 @@ clang_CompileCommand_getNumArgs
- clang_CompileCommand_getArg
- clang_visitChildren
- clang_visitChildrenWithBlock
-+clang_visitChildrenWithOptions
- clang_ModuleMapDescriptor_create
- clang_ModuleMapDescriptor_dispose
- clang_ModuleMapDescriptor_setFrameworkModuleName
--- 
-2.23.0
-
diff --git a/packages/llvm/llvm9-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch b/packages/llvm/llvm9-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch
deleted file mode 100644
index 68c83bce65c3253dd3653c102f417df67bd51300..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm9-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 0fa84bbd8c6f8eb8eb6a3bc30e4efe3f2cf4c283 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= <johann.klaehn@kip.uni-heidelberg.de>
-Date: Mon, 31 Jul 2017 14:09:52 +0200
-Subject: [PATCH 5/5] [libclang] WIP: Fix get_tokens in macro expansion
-
----
- clang/bindings/python/tests/cindex/test_cursor.py | 15 +++++++++++++++
- clang/tools/libclang/CIndex.cpp                   |  2 +-
- 2 files changed, 16 insertions(+), 1 deletion(-)
-
-diff --git a/tools/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py
-index d061f37c25c..38702df74f2 100644
---- a/tools/clang/bindings/python/tests/cindex/test_cursor.py
-+++ b/tools/clang/bindings/python/tests/cindex/test_cursor.py
-@@ -552,6 +552,21 @@ class TestCursor(unittest.TestCase):
-         r_cursor = t_cursor.referenced # should not raise an exception
-         self.assertEqual(r_cursor.kind, CursorKind.CLASS_DECL)
- 
-+    def test_get_tokens_in_macro_expansion(self):
-+        """regression test"""
-+        source = "#define IMPL(name) struct name { name(int v = 123); }; \n IMPL(X)"
-+        tu = get_tu(source, lang="cpp")
-+        ctor = get_cursors(tu, "X")[1]
-+        self.assertEqual(ctor.kind, CursorKind.CONSTRUCTOR)
-+        p = next(ctor.get_children())
-+        self.assertEqual(p.kind, CursorKind.PARM_DECL, (p.kind, p.spelling))
-+        children = list(p.get_children())
-+        self.assertEqual(len(children), 1, [(c.kind, c.spelling) for c in children])
-+        expr = children[0]
-+        tokens = list(expr.get_tokens())
-+        self.assertEqual(len(tokens), 1, [t.spelling for t in tokens])
-+        self.assertEqual(tokens[0].spelling, "123")
-+
-     def test_get_arguments(self):
-         tu = get_tu('void foo(int i, int j);')
-         foo = get_cursor(tu, 'foo')
-diff --git a/tools/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
-index 7ee6b704647..e4b95436704 100644
---- a/tools/clang/tools/libclang/CIndex.cpp
-+++ b/tools/clang/tools/libclang/CIndex.cpp
-@@ -145,7 +145,7 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
-   // location accordingly.
-   SourceLocation EndLoc = R.getEnd();
-   bool IsTokenRange = R.isTokenRange();
--  if (EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc)) {
-+  if (false /*FIXME*/ && EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc)) {
-     CharSourceRange Expansion = SM.getExpansionRange(EndLoc);
-     EndLoc = Expansion.getEnd();
-     IsTokenRange = Expansion.isTokenRange();
--- 
-2.23.0
-
diff --git a/packages/llvm/llvm9-disable-check-for-ipc_perm-mode.patch b/packages/llvm/llvm9-disable-check-for-ipc_perm-mode.patch
new file mode 100644
index 0000000000000000000000000000000000000000..9bac5527e83e7bb972a8c87d77cf558a5cfb73e7
--- /dev/null
+++ b/packages/llvm/llvm9-disable-check-for-ipc_perm-mode.patch
@@ -0,0 +1,11 @@
+--- spack-stage-llvm-9.0.1-yrm3zxxosstlzlp4fdvtouz6nelcrlta/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc	2019-12-11 20:15:30.000000000 +0100
++++ spack-stage-llvm-9.0.1-new/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc	2021-09-15 11:21:18.321423896 +0200
+@@ -1128,7 +1128,7 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
+ CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
+ #if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
+ /* On aarch64 glibc 2.20 and earlier provided incorrect mode field.  */
+-CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
++//CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
+ #endif
+ 
+ CHECK_TYPE_SIZE(shmid_ds);
diff --git a/packages/llvm/llvm_gcc7.patch b/packages/llvm/llvm_gcc7.patch
deleted file mode 100644
index c6d9d33a08aedffa2d3077f0384d1bec6547623e..0000000000000000000000000000000000000000
--- a/packages/llvm/llvm_gcc7.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/lldb/include/lldb/Utility/TaskPool.h	2016-09-06 16:57:50.000000000 -0400
-+++ b/lldb/include/lldb/Utility/TaskPool.h	2017-08-29 16:29:41.448584015 -0400
-@@ -28,6 +28,7 @@
- 
- #include <cassert>
- #include <cstdint>
-+#include <functional>
- #include <future>
- #include <list>
- #include <queue>
diff --git a/packages/llvm/no_cyclades9.patch b/packages/llvm/no_cyclades9.patch
index 7532865e6de87f444ac7ed8aa4ddeea16e7974b9..55cb70d1e43dda892a4831d1bf27ffb92745d4f7 100644
--- a/packages/llvm/no_cyclades9.patch
+++ b/packages/llvm/no_cyclades9.patch
@@ -1,3 +1,8 @@
+# This is a backport of https://reviews.llvm.org/D102059.
+#
+# We need the patch to be applicable when="@:9" and, therefore, cannot fetch
+# it from the upstream repo.
+
 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
 @@ -370,9 +370,0 @@
diff --git a/packages/llvm/package.py b/packages/llvm/package.py
index 9a692f8dbd6aa6e1363c2c0ec9ba1da5ef1e1af2..1417d0ce29f7e1bea54d79ce254d526d5416da26 100644
--- a/packages/llvm/package.py
+++ b/packages/llvm/package.py
@@ -26,7 +26,7 @@ class Llvm(CMakePackage, CudaPackage):
     url = "https://github.com/llvm/llvm-project/archive/llvmorg-7.1.0.tar.gz"
     list_url = "https://releases.llvm.org/download.html"
     git = "https://github.com/llvm/llvm-project"
-    maintainers("trws", "haampie")
+    maintainers("trws", "haampie", "skosukhin")
 
     tags = ["e4s"]
 
@@ -35,6 +35,14 @@ class Llvm(CMakePackage, CudaPackage):
     family = "compiler"  # Used by lmod
 
     version("main", branch="main")
+    version("17.0.4", sha256="46200b79f52a02fe26d0a43fd856ab6ceff49ab2a0b7c240ac4b700a6ada700c")
+    version("17.0.3", sha256="1e3d9d04fb5fbd8d0080042ad72c7e2a5c68788b014b186647a604dbbdd625d2")
+    version("17.0.2", sha256="dcba3eb486973dce45b6edfe618f3f29b703ae7e6ef9df65182fb50fb6fe4235")
+    version("17.0.1", sha256="d51b10be66c10a6a81f4c594b554ffbf1063ffbadcb810af37d1f88d6e0b49dd")
+    version("16.0.6", sha256="56b2f75fdaa95ad5e477a246d3f0d164964ab066b4619a01836ef08e475ec9d5")
+    version("16.0.5", sha256="e0fbca476693fcafa125bc71c8535587b6d9950293122b66b262bb4333a03942")
+    version("16.0.4", sha256="10c3fe1757d2e4f1cd7745dc548ecf687680a71824ec81701c38524c2a0753e2")
+    version("16.0.3", sha256="0bd71bc687a4e5a250c40afb0decefc50c85178fcce726137b682039de63919b")
     version("16.0.2", sha256="97c3c6aafb53c4bb0ed2781a18d6f05e75445e24bb1dc57a32b74f8d710ac19f")
     version("16.0.1", sha256="b5a9ff1793b1e2d388a3819bf35797002b1d2e40bb35a10c65605e0ea1435271")
     version("16.0.0", sha256="cba969a0782a3a398658d439f047b5e548ea04724f4fbfdbe17cfc946f4cd3ed")
@@ -74,44 +82,78 @@ class Llvm(CMakePackage, CudaPackage):
     version("5.0.1", sha256="84ca454abf262579814a2a2b846569f6e0cb3e16dc33ca3642b4f1dff6fbafd3")
     version("5.0.0", sha256="1f1843315657a4371d8ca37f01265fa9aae17dbcf46d2d0a95c1fdb3c6a4bab6")
 
-    # NOTE: The debug version of LLVM is an order of magnitude larger than
-    # the release version, and may take up 20-30 GB of space. If you want
-    # to save space, build with `build_type=Release`.
-
     variant(
         "clang", default=True, description="Build the LLVM C/C++/Objective-C compiler frontend"
     )
+
     variant(
         "flang",
         default=False,
-        when="@11: +clang",
         description="Build the LLVM Fortran compiler frontend "
         "(experimental - parser only, needs GCC)",
     )
-    variant(
-        "omp_debug",
-        default=False,
-        description="Include debugging code in OpenMP runtime libraries",
-    )
-    variant("lldb", default=True, when="+clang", description="Build the LLVM debugger")
+    conflicts("+flang", when="@:10")
+    conflicts("+flang", when="~clang")
+
+    variant("lldb", default=True, description="Build the LLVM debugger")
+    conflicts("+lldb", when="~clang")
+
     variant("lld", default=True, description="Build the LLVM linker")
     variant("mlir", default=False, when="@10:", description="Build with MLIR support")
     variant(
-        "internal_unwind", default=True, when="+clang", description="Build the libcxxabi libunwind"
+        "libunwind",
+        values=(
+            "none",
+            conditional("project", when="@:15"),
+            conditional("runtime", when="+clang @6:"),
+        ),
+        default="runtime",
+        description="Build the LLVM unwinder library"
+        "either as a runtime (with just-build Clang) "
+        "or as a project (with the compiler in use)",
     )
     variant(
         "polly",
         default=True,
-        description="Build the LLVM polyhedral optimization plugin, " "only builds for 3.7.0+",
+        description="Build the LLVM polyhedral optimization plugin, only builds for 3.7.0+",
     )
     variant(
-        "libcxx", default=True, when="+clang", description="Build the LLVM C++ standard library"
+        "libcxx",
+        values=(
+            "none",
+            conditional("project", when="@:15"),
+            conditional("runtime", when="+clang @6:"),
+        ),
+        default="runtime",
+        description="Build the LLVM C++ standard library "
+        "either as a runtime (with just-build Clang) "
+        "or as a project (with the compiler in use)",
+    )
+
+    variant("libomptarget", default=True, description="Build the OpenMP offloading library")
+    conflicts("+libomptarget", when="~clang")
+    for _p in ["darwin", "windows"]:
+        conflicts("+libomptarget", when="platform={0}".format(_p))
+    del _p
+
+    variant(
+        "libomptarget_debug",
+        default=False,
+        description="Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1",
     )
+    conflicts("+libomptarget_debug", when="~libomptarget")
+
     variant(
         "compiler-rt",
-        when="+clang",
-        default=True,
-        description="Build LLVM compiler runtime, including sanitizers",
+        values=(
+            "none",
+            conditional("project", when="+clang"),
+            conditional("runtime", when="+clang @6:"),
+        ),
+        default="runtime",
+        description="Build the LLVM compiler runtime, including sanitizers, "
+        "either as a runtime (with just-build Clang) "
+        "or as a project (with the compiler in use)",
     )
     variant(
         "gold",
@@ -132,7 +174,7 @@ class Llvm(CMakePackage, CudaPackage):
     )
     variant(
         "targets",
-        default="none",
+        default="all",
         description=(
             "What targets to build. Spack's target family is always added "
             "(e.g. X86 is automatically enabled when targeting znver2)."
@@ -162,16 +204,19 @@ class Llvm(CMakePackage, CudaPackage):
         multi=True,
     )
     variant(
-        "omp_tsan",
+        "libomp_tsan",
         default=False,
-        when="@6:",
+        # Added in https://reviews.llvm.org/D13072
+        # Removed in https://reviews.llvm.org/D103767
+        when="@4:12",
         description="Build with OpenMP capable thread sanitizer",
     )
     variant(
-        "omp_as_runtime",
-        default=True,
-        when="+clang @12:",
-        description="Build OpenMP runtime via ENABLE_RUNTIME by just-built Clang",
+        "openmp",
+        values=("project", conditional("runtime", when="+clang @12:")),
+        default="runtime",
+        description="Build OpenMP either as a runtime (with just-build Clang) "
+        "or as a project (with the compiler in use)",
     )
     variant(
         "code_signing",
@@ -180,6 +225,7 @@ class Llvm(CMakePackage, CudaPackage):
         description="Enable code-signing on macOS",
     )
     variant("python", default=False, description="Install python bindings")
+    variant("lua", default=True, description="Enable lua scripting inside lldb")
     variant("version_suffix", default="none", description="Add a symbol suffix")
     variant(
         "shlib_symbol_version",
@@ -187,9 +233,12 @@ class Llvm(CMakePackage, CudaPackage):
         description="Add shared library symbol version",
         when="@13:",
     )
-    variant(
-        "z3", default=False, when="+clang @8:", description="Use Z3 for the clang static analyzer"
-    )
+    variant("z3", default=False, description="Use Z3 for the clang static analyzer")
+    conflicts("+z3", when="@:7")
+    conflicts("+z3", when="~clang")
+    conflicts("+lua", when="@:10")
+    conflicts("+lua", when="~lldb")
+
     variant(
         "zstd",
         default=False,
@@ -197,6 +246,8 @@ class Llvm(CMakePackage, CudaPackage):
         description="Enable zstd support for static analyzer / lld",
     )
 
+    provides("libllvm@16", when="@16.0.0:16")
+    provides("libllvm@15", when="@15.0.0:15")
     provides("libllvm@14", when="@14.0.0:14")
     provides("libllvm@13", when="@13.0.0:13")
     provides("libllvm@12", when="@12.0.0:12")
@@ -212,54 +263,16 @@ class Llvm(CMakePackage, CudaPackage):
 
     extends("python", when="+python")
 
-    variant('visionary', default=False,
-            description="Include patches necessary for visionary python "
-            "bindings generator")
-    variant('force_full_view', default=False,
-            description='Force linking of all files into view, including '
-                        'known conflicts (e.g. libgomp).')
-
-    patch('llvm5-0001-libclang-Add-support-for-checking-abstractness-of-re.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0002-libclang-Keep-track-of-TranslationUnit-instance-when.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0003-Fix-warnings-in-Tooling-QualTypeNamesTest.patch',            when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0004-Defer-addition-of-keywords-to-identifier-table-when-.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0005-Tooling-Fully-qualify-template-parameters-of-nested-.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0006-libclang-Add-support-for-obtaining-fully-qualified-n.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0007-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0008-Fix-printing-policy-for-AST-context-loaded-from-file.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0009-libclang-Visit-attributes-for-function-and-class-tem.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0010-libclang-Add-support-for-querying-cursor-availabilit.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0011-libclang-Allow-visiting-of-implicit-declarations-and.patch', when='@5.0:6.999 +visionary', level=2)
-    patch('llvm5-0012-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch',       when='@5.0:6.999 +visionary', level=2)
-
-    patch('llvm7-0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch', when='@7.0:7.999 +visionary', level=2)
-    patch('llvm7-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch', when='@7.0:7.999 +visionary', level=2)
-    patch('llvm7-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch', when='@7.0:7.999 +visionary', level=2)
-    patch('llvm7-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch', when='@7.0:7.999 +visionary', level=2)
-    patch('llvm7-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch',       when='@7.0:7.999 +visionary', level=2)
-
-    patch('llvm9-0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch', when='@9.0.0:12.0.999 +visionary', level=2)
-    patch('llvm9-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch', when='@9.0:10.999 +visionary', level=2)
-    patch('llvm9-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch', when='@9.0:10.999 +visionary', level=2)
-    patch('llvm9-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch', when='@9.0:10.999 +visionary', level=2)
-    patch('llvm9-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch',       when='@9.0:10.999 +visionary', level=2)
-
-    # 0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch from above
-    patch('llvm11-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch', when='@11.0.0:11.0.999 +visionary', level=2)
-    patch('llvm11-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch', when='@11.0.0:11.0.999 +visionary', level=2)
-    patch('llvm11-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch', when='@11.0.0:11.0.999 +visionary', level=2)
-    patch('llvm11-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch',       when='@11.0.0:12.0.999 +visionary', level=2)
-
-    # 0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch from above
-    patch('llvm11_1-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch', when='@11.1.0:12.0.999 +visionary', level=2)
-    patch('llvm11_1-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch', when='@11.1.0:12.0.999 +visionary', level=2)
-    patch('llvm11_1-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch', when='@11.1.0:12.0.999 +visionary', level=2)
-    # 0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch from above
-
     # Build dependency
     depends_on("cmake@3.4.3:", type="build")
     depends_on("cmake@3.13.4:", type="build", when="@12:")
     depends_on("cmake@3.20:", type="build", when="@16:")
+    with when("@:10"):
+        # Versions 10 and older cannot build runtimes with cmake@3.17:
+        # See https://reviews.llvm.org/D77284
+        for runtime in ["libunwind", "libcxx", "compiler-rt"]:
+            depends_on("cmake@:3.16", type="build", when="{0}=runtime".format(runtime))
+        del runtime
     depends_on("python", when="~python", type="build")
     depends_on("pkgconfig", type="build")
 
@@ -272,25 +285,41 @@ class Llvm(CMakePackage, CudaPackage):
     # openmp dependencies
     depends_on("perl-data-dumper", type=("build"))
     depends_on("hwloc")
-    depends_on("hwloc@2.0.1:", when="@9:")
-    depends_on("elf", when="+cuda")  # libomptarget
-    depends_on("libffi", when="+cuda")  # libomptarget
+    depends_on("hwloc@2.0.1:", when="@13")
+    with when("@:15"):
+        depends_on("elf", when="+cuda")
+        depends_on("elf", when="+libomptarget")
+    depends_on("libffi", when="+libomptarget")
 
     # llvm-config --system-libs libraries.
-    depends_on("zlib")
+    depends_on("zlib-api")
 
     # needs zstd cmake config file, which is not added when built with makefile.
     depends_on("zstd build_system=cmake", when="+zstd")
 
     # lldb dependencies
-    with when("+lldb +python"):
-        # build fails with swig@4.1: https://github.com/llvm/llvm-project/issues/58018
-        depends_on("swig@:4.0")
+    with when("+lldb"):
+        depends_on("libedit")
+        depends_on("libxml2")
+        depends_on("lua@5.3", when="+lua")  # purposefully not a range
+        depends_on("ncurses")
+        depends_on("py-six", when="+python")
+        depends_on("swig", when="+lua")
+        depends_on("swig", when="+python")
+        depends_on("xz")
+        # begin VISIONS: modified, bring upstream FIXME: maybe no longer needed
+        depends_on("swig@2:4.0", when="@10:")
+        depends_on("swig@3:4.0", when="@12:")
+        # end VISIONS
+
+    # Use ^swig cause it's triggered by both python & lua scripting in lldb
+    with when("^swig"):
         depends_on("swig@2:", when="@10:")
         depends_on("swig@3:", when="@12:")
-    depends_on("libedit", when="+lldb")
-    depends_on("ncurses", when="+lldb")
-    depends_on("py-six", when="+lldb+python")
+        depends_on("swig@4:", when="@17:")
+        # Commits f0a25fe0b746f56295d5c02116ba28d2f965c175 and
+        # 81fc5f7909a4ef5a8d4b5da2a10f77f7cb01ba63 fixed swig 4.1 support
+        depends_on("swig@:4.0", when="@:15")
 
     # gold support, required for some features
     depends_on("binutils+gold+ld+plugins+headers", when="+gold")
@@ -305,17 +334,51 @@ class Llvm(CMakePackage, CudaPackage):
     # Internal compiler error on gcc 8.4 on aarch64 https://bugzilla.redhat.com/show_bug.cgi?id=1958295
     conflicts("%gcc@8.4:8.4.9", when="@12: target=aarch64:")
 
-    # When these versions are concretized, but not explicitly with +libcxx, these
-    # conflicts will enable clingo to set ~libcxx, making the build successful:
-
-    # libc++ of LLVM13, see https://libcxx.llvm.org/#platform-and-compiler-support
-    # @13 does not support %gcc@:10 https://bugs.llvm.org/show_bug.cgi?id=51359#c1
-    # GCC    11     - latest stable release per GCC release page
-    # Clang: 11, 12 - latest two stable releases per LLVM release page
-    # AppleClang 12 - latest stable release per Xcode release page
-    conflicts("%gcc@:10", when="@13:+libcxx")
-    conflicts("%clang@:10", when="@13:+libcxx")
-    conflicts("%apple-clang@:11", when="@13:+libcxx")
+    # libcxx=project imposes compiler conflicts
+    # see https://libcxx.llvm.org/#platform-and-compiler-support for the latest release
+    # and https://github.com/llvm/www-releases for older releases
+    with when("libcxx=project"):
+        for v, compiler_conflicts in {
+            "@7:": {"clang": "@:3.4", "gcc": "@:4.6"},
+            "@9:": {"clang": "@:3.4", "gcc": "@:4"},
+            "@11:": {"clang": "@:3", "gcc": "@:4"},
+            "@13:": {"clang": "@:10", "gcc": "@:10", "apple-clang": "@:11"},
+            "@14:": {
+                "clang": "@:11",
+                "gcc": "@:10",
+                "apple-clang": "@:11",
+                "xlc": "@:17.0",
+                "xlc_r": "@:17.0",
+            },
+            "@15:": {
+                "clang": "@:12",
+                "gcc": "@:11",
+                "apple-clang": "@:12",
+                "xlc": "@:17.0",
+                "xlc_r": "@:17.0",
+            },
+            "@16:": {
+                "clang": "@:13",
+                "gcc": "@:11",
+                "apple-clang": "@:13",
+                "xlc": "@:17.0",
+                "xlc_r": "@:17.0",
+            },
+        }.items():
+            with when(v):
+                for comp in spack.compilers.supported_compilers():
+                    conflicts("%{0}{1}".format(comp, compiler_conflicts.get(comp, "")))
+        del v, compiler_conflicts, comp
+
+    # libomptarget
+    conflicts("+cuda", when="@15:")  # +cuda variant is obselete since LLVM 15
+    conflicts(
+        "targets=none",
+        when="+libomptarget",
+        msg="Non-host backends needed for offloading, set targets=all",
+    )
+    # See https://github.com/spack/spack/pull/32476#issuecomment-1573770361
+    conflicts("~lld", when="+libomptarget")
 
     # cuda_arch value must be specified
     conflicts("cuda_arch=none", when="+cuda", msg="A value for cuda_arch must be specified.")
@@ -325,84 +388,223 @@ class Llvm(CMakePackage, CudaPackage):
     # Fixed in upstream versions of both
     conflicts("^cmake@3.19.0", when="@6:11.0.0")
 
-    # sys/ustat.h has been removed in favour of statfs from glibc-2.28. Use fixed sizes:
-    patch("llvm5-sanitizer-ustat.patch", when="@4:6.0.0+compiler-rt")
+    # begin VISIONS (added) FIXME: check patches
+    variant('visionary', default=False,
+            description="Include patches necessary for visionary python "
+            "bindings generator")
 
-    # Fix lld templates: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230463
-    patch("llvm5-lld-ELF-Symbols.patch", when="@5+lld%clang@7:")
+    conflicts("@:8", when="+visionary")
+    conflicts("@13:", when="+visionary")
+
+    patch('llvm9-0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch', when='@9.0.0:12.0.999 +visionary', level=2)
 
-    # Fix missing std:size_t in 'llvm@4:5' when built with '%clang@7:'
-    patch("xray_buffer_queue-cstddef.patch", when="@4:5+compiler-rt%clang@7:")
+    # 0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch from above
+    patch('llvm11-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch', when='@11.0.0:11.0.999 +visionary', level=2)
+    patch('llvm11-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch', when='@11.0.0:11.0.999 +visionary', level=2)
+    patch('llvm11-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch', when='@11.0.0:11.0.999 +visionary', level=2)
+    patch('llvm11-0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch',       when='@11.0.0:12.0.999 +visionary', level=2)
+
+    # 0001-Tooling-Fully-qualify-template-parameters-of-nested-.patch from above
+    patch('llvm11_1-0002-libclang-Add-support-for-obtaining-fully-qualified-n.patch', when='@11.1.0:12.0.999 +visionary', level=2)
+    patch('llvm11_1-0003-libclang-Add-option-to-keep-whitespace-when-tokenizi.patch', when='@11.1.0:12.0.999 +visionary', level=2)
+    patch('llvm11_1-0004-libclang-WIP-Allow-visiting-of-implicit-declarations.patch', when='@11.1.0:12.0.999 +visionary', level=2)
+    # 0005-libclang-WIP-Fix-get_tokens-in-macro-expansion.patch from above
+
+    # disable check for member `mode` size in `struct ipc_perm`; newer glibc changed width
+    patch('llvm9-disable-check-for-ipc_perm-mode.patch', when='@9.0.0:9.0.999', level=2)
+    # end VISIONS
 
-    # https://github.com/llvm/llvm-project/commit/947f9692440836dcb8d88b74b69dd379d85974ce
-    patch("sanitizer-ipc_perm_mode.patch", when="@5:7+compiler-rt%clang@11:")
-    patch("sanitizer-ipc_perm_mode.patch", when="@5:9+compiler-rt%gcc@9:")
+    # Fix lld templates: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230463
+    patch(
+        "https://raw.githubusercontent.com/freebsd/freebsd-ports/f8f9333d8e1e5a7a6b28c5ef0ca73785db06136e/devel/llvm50/files/lld/patch-tools_lld_ELF_Symbols.cpp",
+        sha256="c81a50c1b6b78d359c0ce3b88914477f4f2a85b8dbfa7ac745b9e7eb4e53931b",
+        when="@5+lld%clang@7:",
+    )
+
+    # Add missing include directives for the standard headers (the real need for the following
+    # patches depends on the implementation of the standard C++ library, the headers, however, must
+    # be included according to the standard, therefore, we apply the patches regardless of the
+    # compiler and compiler version).
+    #
+    # fix missing ::size_t in 'llvm@4:5'
+    # see comments in the patch file
+    patch(
+        "xray_buffer_queue-cstddef.patch",
+        # we do not cover compiler-rt=runtime because it is not supported when @:5
+        when="@4:5 compiler-rt=project",
+    )
+    #
+    # see https://reviews.llvm.org/D64937
+    # see https://github.com/spack/spack/issues/24270
+    patch(
+        "https://github.com/llvm/llvm-project/commit/b288d90b39f4b905c02092a9bfcfd6d78f99b191.patch?full_index=1",
+        sha256="2028d52e1a39326bb48fb7463132bbfe7fb4fa18f1adfeea9c3ed0320ed49564",
+        when="@8:9.0.0",
+    )
+    #
+    # committed upstream without a review
+    # see https://github.com/llvm/llvm-project/commit/b498303066a63a203d24f739b2d2e0e56dca70d1
+    # see https://github.com/spack/spack/pull/28547
+    patch(
+        "https://github.com/llvm/llvm-project/commit/b498303066a63a203d24f739b2d2e0e56dca70d1.patch?full_index=1",
+        sha256="514926d661635de47972c7d403c9c4669235aa51e22e56d44676d2a2709179b6",
+        when="@8:11",
+    )
+    #
+    # fix compilation against libstdc++13
+    patch(
+        "https://github.com/llvm/llvm-project/commit/1b4fdf18bc2aaa2d46bf072475dd9cbcd44a9fee.patch?full_index=1",
+        sha256="82481418766b4b949ea808d956ff3800b9a241a576370114862428bb0e25ee1f",
+        when="@14:15",
+    )
 
-    # github.com/spack/spack/issues/24270: MicrosoftDemangle for %gcc@10: and %clang@13:
-    patch("missing-includes.patch", when="@8")
+    # fix building of older versions of llvm with newer versions of glibc
+    for compiler_rt_as in ["project", "runtime"]:
+        with when("compiler-rt={0}".format(compiler_rt_as)):
+            # sys/ustat.h has been removed in favour of statfs from glibc-2.28
+            # see https://reviews.llvm.org/D47281
+            patch(
+                "https://github.com/llvm/llvm-project/commit/383fe5c8668f63ef21c646b43f48da9fa41aa100.patch?full_index=1",
+                sha256="66f01ac1769a6815aba09d6f4347ac1744f77f82ec9578a1158b24daca7a89e6",
+                when="@4:6.0.0",
+            )
+            # fix sanitizer-common build with glibc 2.31
+            # see https://reviews.llvm.org/D70662
+            patch("sanitizer-ipc_perm_mode.patch", when="@5:9")
+    del compiler_rt_as
 
     # Backport from llvm upstream gcc ppc const expr long double issue
     # see https://bugs.llvm.org/show_bug.cgi?id=39696
-    # This fix was initially commited (3bf63cf3b366) for the 9.0 release
+    # This fix was initially committed (3bf63cf3b366) for the 9.0 release
     # but was then broken (0583d9ea8d5e) prior to the 9.0 release and
     # eventually unbroken (d9a42ec98adc) for the 11.0 release.  The first
     # patch backports the original correct fix to previous releases.  The
     # second patch backports the un-breaking of the original fix.
-    patch("constexpr_longdouble.patch", when="@6:8+libcxx")
-    patch("constexpr_longdouble_9.0.patch", when="@9:10+libcxx")
+    for libcxx_as in ["project", "runtime"]:
+        with when("libcxx={0}".format(libcxx_as)):
+            patch(
+                "https://github.com/llvm/llvm-project/commit/3bf63cf3b366d3a57cf5cbad4112a6abf6c0c3b1.patch?full_index=1",
+                sha256="e56489a4bcf3c3636e206adca366bfcda2722ad81a5fa9a0360faed63933191a",
+                when="@6:8",
+            )
+            patch(
+                "https://github.com/llvm/llvm-project/commit/d9a42ec98adcb1ebc0c3837715df4e5a50c7ccc0.patch?full_index=1",
+                sha256="50bfc4e82c02bb5b7739990f363d99b1e43d5d11a5104f6aabbc303ebce6fbe3",
+                when="@9:10",
+            )
+    del libcxx_as
 
-    # Backport from llvm master; see
-    # https://bugs.llvm.org/show_bug.cgi?id=38233
-    # for a bug report about this problem in llvm master.
-    patch("llvm_py37.patch", when="@4:6 ^python@3.7:")
+    # Backport from llvm to fix issues related to Python 3.7
+    # see https://bugs.llvm.org/show_bug.cgi?id=38233
+    patch(
+        "https://github.com/llvm/llvm-project/commit/5457b426f5e15a29c0acc8af1a476132f8be2a36.patch?full_index=1",
+        sha256="7a1e4aa80760167807255c3e3121b1281bfcf532396b2d8fb3dce021f3f18758",
+        when="@4:6+python+lldb ^python@3.7:",
+    )
 
-    # https://github.com/spack/spack/issues/19625,
-    # merged in llvm-11.0.0_rc2, first available in 12.0.0
-    patch("lldb_external_ncurses-10.patch", when="@10.0.0:11+lldb")
+    # fix building on SUSE (with panel.h being in /usr/include/ncurses/)
+    # see https://reviews.llvm.org/D85219
+    # see https://github.com/spack/spack/issues/19625
+    patch(
+        "https://github.com/llvm/llvm-project/commit/c952ec15d38843b69e22dfd7b0665304a0459f9f.patch?full_index=1",
+        sha256="66932ba31b5bf8808ea112e42cfd79b2480a4936e711771c06ce851eac429b2c",
+        when="@10:11+lldb",
+    )
 
-    # https://github.com/spack/spack/issues/19908
-    # merged in llvm main prior to 12.0.0
-    patch("llvm_python_path.patch", when="@:11")
+    # honor Python2_EXECUTABLE and Python3_EXECUTABLE when they are passed to cmake
+    # see https://reviews.llvm.org/D91536
+    patch(
+        "https://github.com/llvm/llvm-project/commit/16de50895e96adbe261a5ce2498366bda7b3fccd.patch?full_index=1",
+        sha256="0e121ed460aa6e117f9f5f339d597a96c0fe4f97dc2209aba47b43ffc831ea24",
+        # The patch is applicable only starting version 7.0.0 (the older version might require a
+        # different patch addressing https://github.com/spack/spack/issues/19908). It looks like
+        # the patched function is used only if both compiler-rt and libcxx are enabled but we keep
+        # it simple:
+        when="@7:11",
+    )
 
     # Workaround for issue https://github.com/spack/spack/issues/18197
     patch("llvm7_intel.patch", when="@7 %intel@18.0.2,19.0.0:19.1.99")
 
     # Remove cyclades support to build against newer kernel headers
     # https://reviews.llvm.org/D102059
-    patch("no_cyclades.patch", when="@10:12.0.0")
-    patch("no_cyclades9.patch", when="@6:9")
-
-    patch("llvm-gcc11.patch", when="@9:11%gcc@11:")
-
-    # add -lpthread to build OpenMP libraries with Fujitsu compiler
-    patch("llvm12-thread.patch", when="@12 %fj")
-
-    # add -lpthread to build OpenMP libraries
-    patch("llvm13-14-thread.patch", when="@13:14")
-    patch("llvm15-thread.patch", when="@15")
+    patch(
+        "https://github.com/llvm/llvm-project/commit/68d5235cb58f988c71b403334cd9482d663841ab.patch?full_index=1",
+        sha256="742501723642675075e617f3c38339961b2c7b6fd8290dbffc52239ab0783317",
+        when="@10:12.0.0",
+    )
+    # The patch above is not applicable when "@:9" due to the file renaming and reformatting. The
+    # following patch is applicable starting at least version 5.0.0, the oldest we try to support.
+    patch("no_cyclades9.patch", when="@5:9")
+
+    with when("+libomptarget"):
+        # libomptarget makes use of multithreading via the standard C++ library (e.g.
+        # std::call_once), which, depending on the platform and the implementation of the standard
+        # library, might or might not require linking to libpthread (note that the failure might
+        # happen at the linking time as well as at the runtime). In some cases, the required linker
+        # flag comes as a transitive dependency (e.g. from the static LLVMSupport component). The
+        # following patches enforce linking to the thread library that is relevant for the system,
+        # which might lead to overlinking in some cases though.
+        # TODO: figure out why we do not use LLVM_PTHREAD_LIB but run find_package(Threads), at
+        #  least for newer versions (the solution must work with both openmp=runtime and
+        #  openmp=project)
+        patch("llvm12-thread.patch", when="@12")
+        patch("llvm13-14-thread.patch", when="@13:14")
+        patch("llvm15-thread.patch", when="@15")
 
     # avoid build failed with Fujitsu compiler
     patch("llvm13-fujitsu.patch", when="@13 %fj")
 
     # patch for missing hwloc.h include for libompd
-    patch("llvm14-hwloc-ompd.patch", when="@14")
-
-    # make libflags a list in openmp subproject when ~omp_as_runtime
-    patch("libomp-libflags-as-list.patch", when="@3.7:14")
+    # see https://reviews.llvm.org/D123888
+    patch(
+        "https://github.com/llvm/llvm-project/commit/91ccd8248c85385a5654c63c302a37d97f811bab.patch?full_index=1",
+        sha256="b216cff38659c176c5381e9dda3252edbb204e6f6f1f33e843a9ebcc42732e5d",
+        when="@14 openmp=runtime",
+    )
 
-    # Add missing include leading to build fail with clang
+    # make libflags a list in openmp subproject when openmp=project
+    # see https://reviews.llvm.org/D125370
     patch(
-        "https://github.com/llvm/llvm-project/commit/b498303066a63a203d24f739b2d2e0e56dca70d1.patch?full_index=1",
-        sha256="514926d661635de47972c7d403c9c4669235aa51e22e56d44676d2a2709179b6",
-        when="@8:11",
+        "https://github.com/llvm/llvm-project/commit/e27ce281399dca8b08b6ca593172a1bd5dbdd5c1.patch?full_index=1",
+        sha256="6f0cfa55e3ed17ee33346b0a5bca8092adcc1dc75ca712ab83901755fba9767e",
+        when="@3.7:14 openmp=project",
     )
 
     # fix detection of LLDB_PYTHON_EXE_RELATIVE_PATH
     # see https://reviews.llvm.org/D133513
-    # TODO: adjust version constraint and switch to fetching from the upstream GitHub repo
-    #  when/if the bugfix is merged
+    # TODO: the patch is not applicable after https://reviews.llvm.org/D141042 but it is not clear
+    #  yet whether we need a version of it for when="@16:"
     patch("D133513.diff", level=0, when="@14:15+lldb+python")
 
+    # Fix hwloc@:2.3 (Conditionally disable hwloc@2.0 and hwloc@2.4 code)
+    patch(
+        "https://github.com/llvm/llvm-project/commit/3a362a9f38b95978160377ee408dbc7d14af9aad.patch?full_index=1",
+        sha256="25bc503f7855229620e56e76161cf4654945aef0be493a2d8d9e94a088157b7c",
+        when="@14:15",
+    )
+
+    # Fix false positive detection of a target when building compiler-rt as a runtime
+    # https://reviews.llvm.org/D127975
+    patch(
+        "https://github.com/llvm/llvm-project/commit/9f1d90bf91570efa124c4a86cd033de374d1049a.patch?full_index=1",
+        sha256="1f4287465b3e499911e039e6cc2f395b8cb00eb8a0a223fa0db3704ba77f9969",
+        when="@13:14 compiler-rt=runtime",
+    )
+
+    patch("add-include-for-libelf-llvm-12-14.patch", when="@12:14")
+    patch("add-include-for-libelf-llvm-15.patch", when="@15")
+
+    @when("@14:17")
+    def patch(self):
+        # https://github.com/llvm/llvm-project/pull/69458
+        filter_file(
+            r"${TERMINFO_LIB}",
+            r"${Terminfo_LIBRARIES}",
+            "lldb/source/Core/CMakeLists.txt",
+            string=True,
+        )
+
     # The functions and attributes below implement external package
     # detection for LLVM. See:
     #
@@ -441,6 +643,8 @@ class Llvm(CMakePackage, CudaPackage):
             output = compiler("--version", output=str, error=str)
             if "Apple" in output:
                 return None
+            if "AMD" in output:
+                return None
             match = version_regex.search(output)
             if match:
                 return match.group(match.lastindex)
@@ -581,14 +785,6 @@ class Llvm(CMakePackage, CudaPackage):
                     os.symlink(bin, sym)
             env.prepend_path("PATH", self.stage.path)
 
-    def setup_run_environment(self, env):
-        if "+clang" in self.spec:
-            env.set("CC", join_path(self.spec.prefix.bin, "clang"))
-            env.set("CXX", join_path(self.spec.prefix.bin, "clang++"))
-        if "+flang" in self.spec:
-            env.set("FC", join_path(self.spec.prefix.bin, "flang"))
-            env.set("F77", join_path(self.spec.prefix.bin, "flang"))
-
     root_cmakelists_dir = "llvm"
 
     def cmake_args(self):
@@ -600,7 +796,6 @@ class Llvm(CMakePackage, CudaPackage):
         cmake_args = [
             define("LLVM_REQUIRES_RTTI", True),
             define("LLVM_ENABLE_RTTI", True),
-            define("LLVM_ENABLE_EH", True),
             define("LLVM_ENABLE_LIBXML2", False),
             define("CLANG_DEFAULT_OPENMP_RUNTIME", "libomp"),
             define("PYTHON_EXECUTABLE", python.command.path),
@@ -609,6 +804,16 @@ class Llvm(CMakePackage, CudaPackage):
             from_variant("LLVM_ENABLE_ZSTD", "zstd"),
         ]
 
+        # Flang does not support exceptions from core llvm.
+        # LLVM_ENABLE_EH=True when building flang will soon
+        # fail (with changes at the llvm-project level).
+        # Only enable exceptions in LLVM if we are *not*
+        # building flang.  FYI: LLVM <= 16.x will build flang
+        # successfully but the executable will suffer from
+        # link errors looking for C++ EH support.
+        if "+flang" not in spec:
+            cmake_args.append(define("LLVM_ENABLE_EH", True))
+
         version_suffix = spec.variants["version_suffix"].value
         if version_suffix != "none":
             cmake_args.append(define("LLVM_VERSION_SUFFIX", version_suffix))
@@ -639,14 +844,8 @@ class Llvm(CMakePackage, CudaPackage):
                     ),
                 ]
             )
-            if "+omp_as_runtime" in spec:
-                cmake_args.extend(
-                    [
-                        define("LIBOMPTARGET_NVPTX_ENABLE_BCLIB", True),
-                        # work around bad libelf detection in libomptarget
-                        define("LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR", spec["elf"].prefix.include),
-                    ]
-                )
+            if "openmp=runtime" in spec:
+                cmake_args.append(define("LIBOMPTARGET_NVPTX_ENABLE_BCLIB", True))
         else:
             # still build libomptarget but disable cuda
             cmake_args.extend(
@@ -658,17 +857,23 @@ class Llvm(CMakePackage, CudaPackage):
                 ]
             )
 
-        cmake_args.append(from_variant("LIBOMPTARGET_ENABLE_DEBUG", "omp_debug"))
+        cmake_args.append(from_variant("LIBOMPTARGET_ENABLE_DEBUG", "libomptarget_debug"))
 
         if "+lldb" in spec:
             projects.append("lldb")
-            cmake_args.append(define("LLDB_ENABLE_LIBEDIT", True))
-            cmake_args.append(define("LLDB_ENABLE_CURSES", True))
+            cmake_args.extend(
+                [
+                    define("LLDB_ENABLE_LIBEDIT", True),
+                    define("LLDB_ENABLE_CURSES", True),
+                    define("LLDB_ENABLE_LIBXML2", True),
+                    from_variant("LLDB_ENABLE_LUA", "lua"),
+                    define("LLDB_ENABLE_LZMA", True),
+                ]
+            )
             if spec["ncurses"].satisfies("+termlib"):
                 cmake_args.append(define("LLVM_ENABLE_TERMINFO", True))
             else:
                 cmake_args.append(define("LLVM_ENABLE_TERMINFO", False))
-            cmake_args.append(define("LLDB_ENABLE_LIBXML2", False))
             if spec.version >= Version("10"):
                 cmake_args.append(from_variant("LLDB_ENABLE_PYTHON", "python"))
             else:
@@ -684,11 +889,16 @@ class Llvm(CMakePackage, CudaPackage):
         if "+clang" in spec:
             projects.append("clang")
             projects.append("clang-tools-extra")
-            if "+omp_as_runtime" in spec:
+            if "openmp=runtime" in spec:
                 runtimes.append("openmp")
-            else:
+            elif "openmp=project" in spec:
                 projects.append("openmp")
 
+            if "+libomptarget" in spec:
+                cmake_args.append(define("OPENMP_ENABLE_LIBOMPTARGET", True))
+            else:
+                cmake_args.append(define("OPENMP_ENABLE_LIBOMPTARGET", False))
+
             if "@8" in spec:
                 cmake_args.append(from_variant("CLANG_ANALYZER_ENABLE_Z3_SOLVER", "z3"))
             elif "@9:" in spec:
@@ -698,23 +908,20 @@ class Llvm(CMakePackage, CudaPackage):
             projects.append("flang")
         if "+lld" in spec:
             projects.append("lld")
-        if "+compiler-rt" in spec:
-            if self.spec.satisfies("@15.0.0:"):
-                runtimes.append("compiler-rt")
-            else:
-                projects.append("compiler-rt")
-        if "+libcxx" in spec:
-            if self.spec.satisfies("@15.0.0:"):
-                runtimes.extend(["libcxx", "libcxxabi"])
-            else:
-                projects.extend(["libcxx", "libcxxabi"])
+        if "compiler-rt=runtime" in spec:
+            runtimes.append("compiler-rt")
+        elif "compiler-rt=project" in spec:
+            projects.append("compiler-rt")
+        if "libcxx=runtime" in spec:
+            runtimes.extend(["libcxx", "libcxxabi"])
+        elif "libcxx=project" in spec:
+            projects.extend(["libcxx", "libcxxabi"])
         if "+mlir" in spec:
             projects.append("mlir")
-        if "+internal_unwind" in spec:
-            if self.spec.satisfies("@15.0.0:"):
-                runtimes.append("libunwind")
-            else:
-                projects.append("libunwind")
+        if "libunwind=runtime" in spec:
+            runtimes.append("libunwind")
+        elif "libunwind=project" in spec:
+            projects.append("libunwind")
         if "+polly" in spec:
             projects.append("polly")
             cmake_args.append(define("LINK_POLLY_INTO_TOOLS", True))
@@ -734,7 +941,7 @@ class Llvm(CMakePackage, CudaPackage):
 
         cmake_args.append(define("LLVM_TARGETS_TO_BUILD", get_llvm_targets_to_build(spec)))
 
-        cmake_args.append(from_variant("LIBOMP_TSAN_SUPPORT", "omp_tsan"))
+        cmake_args.append(from_variant("LIBOMP_TSAN_SUPPORT", "libomp_tsan"))
 
         if self.compiler.name == "gcc":
             cmake_args.append(define("GCC_INSTALL_PREFIX", self.compiler.prefix))
@@ -742,6 +949,10 @@ class Llvm(CMakePackage, CudaPackage):
         if self.spec.satisfies("~code_signing platform=darwin"):
             cmake_args.append(define("LLDB_USE_SYSTEM_DEBUGSERVER", True))
 
+        # LLDB test suite requires libc++
+        if "libcxx=none" in spec:
+            cmake_args.append(define("LLDB_INCLUDE_TESTS", False))
+
         # Enable building with CLT [and not require full Xcode]
         # https://github.com/llvm/llvm-project/issues/57037
         if self.spec.satisfies("@15.0.0: platform=darwin"):
@@ -752,7 +963,14 @@ class Llvm(CMakePackage, CudaPackage):
 
         # Semicolon seperated list of runtimes to enable
         if runtimes:
-            cmake_args.append(define("LLVM_ENABLE_RUNTIMES", runtimes))
+            cmake_args.extend(
+                [
+                    define("LLVM_ENABLE_RUNTIMES", runtimes),
+                    define(
+                        "RUNTIMES_CMAKE_ARGS", [define("CMAKE_INSTALL_RPATH_USE_LINK_PATH", True)]
+                    ),
+                ]
+            )
 
         return cmake_args
 
@@ -762,7 +980,7 @@ class Llvm(CMakePackage, CudaPackage):
         define = self.define
 
         # unnecessary if we build openmp via LLVM_ENABLE_RUNTIMES
-        if "+cuda ~omp_as_runtime" in self.spec:
+        if "+cuda openmp=project" in self.spec:
             ompdir = "build-bootstrapped-omp"
             prefix_paths = spack.build_environment.get_cmake_prefix_path(self)
             prefix_paths.append(str(spec.prefix))
@@ -781,7 +999,6 @@ class Llvm(CMakePackage, CudaPackage):
                 cmake_args.extend(
                     [
                         define("LIBOMPTARGET_NVPTX_ENABLE_BCLIB", True),
-                        define("LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR", spec["elf"].prefix.include),
                         self.stage.source_path + "/openmp",
                     ]
                 )
@@ -808,20 +1025,6 @@ class Llvm(CMakePackage, CudaPackage):
         else:
             return ret
 
-    # ECM: might be not needed anymore?
-    def add_files_to_view(self, view, merge_map, skip_if_exists=True):
-        # we remove libgomp-related files from views as they conflict with
-        # gcc-ones
-        ignore_file_paths = [
-            join_path(self.prefix, "lib", "libgomp.so"),
-        ]
-
-        if self.spec.satisfies('~force_full_view'):
-            for path in ignore_file_paths:
-                if path in merge_map:
-                    del merge_map[path]
-
-        super(Llvm, self).add_files_to_view(view, merge_map, skip_if_exists=True)
 
 def get_llvm_targets_to_build(spec):
     targets = spec.variants["targets"].value
@@ -869,3 +1072,4 @@ def get_llvm_targets_to_build(spec):
         llvm_targets.add("PowerPC")
 
     return list(llvm_targets)
+
diff --git a/packages/llvm/sanitizer-ipc_perm_mode.patch b/packages/llvm/sanitizer-ipc_perm_mode.patch
index 8f91703a323e87a1c42b294d2c574db53d54ef2a..e270f230e76fdfaae340adb108bcdfa843817f72 100644
--- a/packages/llvm/sanitizer-ipc_perm_mode.patch
+++ b/packages/llvm/sanitizer-ipc_perm_mode.patch
@@ -1,9 +1,53 @@
-# ipc_perm.mode is not used and has changed from short to int over architecures
+# ipc_perm.mode is not used and has changed from short to int over architectures
 # and versions. The last change was in glibc-2.31.
 # LLVM upstream decided to not check ipc_perm.mode below glibc-2.31,
 # because it is not actually used in the sanitizer:
-# github.com/llvm/llvm-project/commit/947f9692440836dcb8d88b74b69dd379d85974ce
+# https://reviews.llvm.org/D70662
+#
+# We need the patch to be applicable when="@5:9" and, therefore, cannot
+# fetch it from the upstream repo.
+
 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
-@@ -1143,1 +1143,0 @@
--CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
+@@ -1126,8 +1126,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
+ CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
+ CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
+ CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
+-#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
+-/* On aarch64 glibc 2.20 and earlier provided incorrect mode field.  */
++#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31)
++/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit
++   on many architectures.  */
+ CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
+ #endif
+ 
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
++++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+@@ -203,26 +203,13 @@ namespace __sanitizer {
+     u64 __unused1;
+     u64 __unused2;
+ #elif defined(__sparc__)
+-#if defined(__arch64__)
+     unsigned mode;
+-    unsigned short __pad1;
+-#else
+-    unsigned short __pad1;
+-    unsigned short mode;
+     unsigned short __pad2;
+-#endif
+     unsigned short __seq;
+     unsigned long long __unused1;
+     unsigned long long __unused2;
+-#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__)
+-    unsigned int mode;
+-    unsigned short __seq;
+-    unsigned short __pad1;
+-    unsigned long __unused1;
+-    unsigned long __unused2;
+ #else
+-    unsigned short mode;
+-    unsigned short __pad1;
++    unsigned int mode;
+     unsigned short __seq;
+     unsigned short __pad2;
+ #if defined(__x86_64__) && !defined(_LP64)
diff --git a/packages/llvm/xray_buffer_queue-cstddef.patch b/packages/llvm/xray_buffer_queue-cstddef.patch
index b5ca841e3e10f954ce5785e40c7ad447721c1190..35e63504458d51fad7fe0d5cb1e5c3e0d4d23767 100644
--- a/packages/llvm/xray_buffer_queue-cstddef.patch
+++ b/packages/llvm/xray_buffer_queue-cstddef.patch
@@ -1,4 +1,12 @@
-# Fix missing std:size_t in 'llvm@4:5' for build with '%clang@7:'
+# The patched file uses size_t, a.k.a. ::size_t (not std::size_t), but does not
+# include <stddef.h> explicitly. Whether or not the header is included
+# implicitly via other headers, depends on the implementation of the standard
+# library. Therefore, we should not apply this patch depending on the compiler
+# version. Strictly speaking, <cstddef> is not guaranteed to provide ::size_t
+# (in contrast to std::size_t). However, it does that in most cases and that is
+# what the upstream developers seem to rely on starting LLVM 6.0.0
+# (see https://reviews.llvm.org/D39175).
+
 --- a/compiler-rt/lib/xray/xray_buffer_queue.h
 +++ b/compiler-rt/lib/xray/xray_buffer_queue.h
 @@ -18,0 +18,1 @@
diff --git a/packages/openbabel/package.py b/packages/openbabel/package.py
index ea99f8d4fc7f1d0b85f171a8a51a7a4515c4f131..2bf09af891251d33bcc0c3e5ff2408ea04a82c35 100644
--- a/packages/openbabel/package.py
+++ b/packages/openbabel/package.py
@@ -19,11 +19,11 @@ class Openbabel(CMakePackage):
     maintainers("RMeli")
 
     version("master", branch="master")
-    version("3.1.1", tag="openbabel-3-1-1")
-    version("3.1.0", tag="openbabel-3-1-0")
-    version("3.0.0", tag="openbabel-3-0-0")
-    version("2.4.1", tag="openbabel-2-4-1")
-    version("2.4.0", tag="openbabel-2-4-0")
+    version("3.1.1", tag="openbabel-3-1-1", commit="cbd4db43f8908b874864280fdc03bf92569eebc1")
+    version("3.1.0", tag="openbabel-3-1-0", commit="1e593abc1edf47352d5e8a0887654edf69a2f5f3")
+    version("3.0.0", tag="openbabel-3-0-0", commit="49f9cfb32bd0bc6ea440639d338123eb27accbe2")
+    version("2.4.1", tag="openbabel-2-4-1", commit="701f6049c483b1349118c2ff736a7f609a84dedd")
+    version("2.4.0", tag="openbabel-2-4-0", commit="087f33320e6796f39e6a1da04f4de7ec46bec4af")
 
     variant("python", default=True, description="Build Python bindings")
     variant("gui", default=True, description="Build with GUI")
@@ -44,7 +44,7 @@ class Openbabel(CMakePackage):
     depends_on("pango", when="+cairo")  # custom cairo requires custom pango
     depends_on("eigen@3.0:")  # required if using the language bindings
     depends_on("libxml2")  # required to read/write CML files, XML formats
-    depends_on("zlib")  # required to support reading gzipped files
+    depends_on("zlib-api")  # required to support reading gzipped files
     depends_on("rapidjson")  # required to support JSON
     depends_on("libsm")
     depends_on("uuid")
diff --git a/packages/oppulance/package.py b/packages/oppulance/package.py
index a12fac91a194d62cc3b3636f54b86fe739fb95ce..6db434fdf3d0509d8584df847ee8e3785046a98e 100644
--- a/packages/oppulance/package.py
+++ b/packages/oppulance/package.py
@@ -21,6 +21,22 @@ class Oppulance(Package):
     depends_on('gmp')
 
     releases = [
+        {
+            'version': '8.0-a3',
+            'tag': 'ebrains-8.0-a3'
+        },
+        {
+            'version': '8.0-a2',
+            'tag': 'ebrains-8.0-a2'
+        },
+        {
+            'version': '8.0-a1',
+            'tag': 'ebrains-8.0-a1'
+        },
+        {
+            'version': '7.0-rc1-fixup3',
+            'tag': 'ebrains-7.0-rc1-fixup3'
+        },
         {
             'version': '7.0-rc1-fixup2',
             'tag': 'ebrains-7.0-rc1-fixup2'
diff --git a/packages/py-astropy/package.py b/packages/py-astropy/package.py
index 47bd618496931d77ed46838265318fe113be113b..d0707cc8eeac91f1e577eea646dca47125fb1ffc 100644
--- a/packages/py-astropy/package.py
+++ b/packages/py-astropy/package.py
@@ -15,6 +15,7 @@ class PyAstropy(PythonPackage):
 
     homepage = "https://astropy.org/"
     pypi = "astropy/astropy-4.0.1.post1.tar.gz"
+    git = "https://github.com/astropy/astropy.git"
 
     version("5.2.2", sha256="e6a9e34716bda5945788353c63f0644721ee7e5447d16b1cdcb58c48a96b0d9c")
     version("5.1", sha256="1db1b2c7eddfc773ca66fa33bd07b25d5b9c3b5eee2b934e0ca277fa5b1b7b7e")
@@ -26,17 +27,15 @@ class PyAstropy(PythonPackage):
     version("1.1.2", sha256="6f0d84cd7dfb304bb437dda666406a1d42208c16204043bc920308ff8ffdfad1")
     version("1.1.post1", sha256="64427ec132620aeb038e4d8df94d6c30df4cc8b1c42a6d8c5b09907a31566a21")
 
-    variant("extras", default=False, description="Enable extra functionality")
+    variant("all", default=False, when="@3.2:", description="Enable all functionality")
 
     # Required dependencies
     depends_on("python@3.8:", when="@5.1:", type=("build", "run"))
-    depends_on("python@3.6:", when="@4.0:", type=("build", "run"))
-    depends_on("python@3.5:", when="@3.0:", type=("build", "run"))
-    depends_on("python@2.7:2.8,3.4:", when="@2.0:", type=("build", "run"))
-    depends_on("python@2.7:2.8,3.3:", when="@1.2:", type=("build", "run"))
-    depends_on("python@2.6:", type=("build", "run"))
     depends_on("py-setuptools", type="build")
     depends_on("py-cython@0.29.13:", type="build")
+    # in newer pip versions --install-option does not exist
+    depends_on("py-pip@:23.0", type="build")
+
     depends_on("py-numpy@1.18:", when="@5.1:", type=("build", "run"))
     depends_on("py-numpy@1.16:", when="@4.0:", type=("build", "run"))
     depends_on("py-numpy@1.13:", when="@3.1:", type=("build", "run"))
@@ -52,24 +51,47 @@ class PyAstropy(PythonPackage):
     depends_on("py-extension-helpers", when="@5.1:", type="build")
     depends_on("pkgconfig", type="build")
 
+    depends_on("py-pytest@7:", type="test")
+    depends_on("py-pytest-doctestplus@0.12:", type="test")
+    depends_on("py-pytest-astropy-header@0.2.1:", type="test")
+    depends_on("py-pytest-astropy@0.10:", type="test")
+    depends_on("py-pytest-xdist", type="test")
+
     # Optional dependencies
-    depends_on("py-scipy@0.18:", when="+extras", type=("build", "run"))
-    depends_on("py-h5py", when="+extras", type=("build", "run"))
-    depends_on("py-beautifulsoup4", when="+extras", type=("build", "run"))
-    depends_on("py-html5lib", when="+extras", type=("build", "run"))
-    depends_on("py-bleach", when="+extras", type=("build", "run"))
-    depends_on("py-pyyaml", when="+extras", type=("build", "run"))
-    depends_on("py-pandas", when="+extras", type=("build", "run"))
-    depends_on("py-bintrees", when="+extras", type=("build", "run"))
-    depends_on("py-sortedcontainers", when="+extras", type=("build", "run"))
-    depends_on("py-pytz", when="+extras", type=("build", "run"))
-    depends_on("py-jplephem", when="+extras", type=("build", "run"))
-    depends_on("py-matplotlib@2.0:", when="+extras", type=("build", "run"))
-    depends_on("py-scikit-image", when="+extras", type=("build", "run"))
-    depends_on("py-mpmath", when="+extras", type=("build", "run"))
-    depends_on("py-asdf@2.3:", when="+extras", type=("build", "run"))
-    depends_on("py-bottleneck", when="+extras", type=("build", "run"))
-    depends_on("py-pytest", when="+extras", type=("build", "run"))
+    with when("+all"):
+        depends_on("py-scipy@1.3:", when="@5:", type=("build", "run"))
+        depends_on("py-scipy@0.18:", type=("build", "run"))
+        depends_on("py-matplotlib@3.1:", when="@5:", type=("build", "run"))
+        depends_on("py-matplotlib@2.1:", when="@4:", type=("build", "run"))
+        depends_on("py-matplotlib@2.0:", type=("build", "run"))
+        depends_on("py-certifi", when="@4.3:", type=("build", "run"))
+        depends_on("py-dask+array", when="@4.1:", type=("build", "run"))
+        depends_on("py-h5py", type=("build", "run"))
+        depends_on("py-pyarrow@5:", when="@5:", type=("build", "run"))
+        depends_on("py-beautifulsoup4", type=("build", "run"))
+        depends_on("py-html5lib", type=("build", "run"))
+        depends_on("py-bleach", type=("build", "run"))
+        depends_on("py-pandas", type=("build", "run"))
+        depends_on("py-sortedcontainers", type=("build", "run"))
+        depends_on("py-pytz", type=("build", "run"))
+        depends_on("py-jplephem", type=("build", "run"))
+        depends_on("py-mpmath", type=("build", "run"))
+        depends_on("py-asdf@2.10:", when="@5.1:", type=("build", "run"))
+        depends_on("py-asdf@2.5:", when="@4.0.1post1:", type=("build", "run"))
+        depends_on("py-asdf@2.3:", type=("build", "run"))
+        depends_on("py-bottleneck", type=("build", "run"))
+        depends_on("py-ipython@4.2:", when="@4.3:", type=("build", "run"))
+        depends_on("py-ipython", type=("build", "run"))
+        depends_on("py-pytest@7:", when="@5.0.2:", type=("build", "run"))
+        depends_on("py-pytest", type=("build", "run"))
+        depends_on("py-typing-extensions@3.10.0.1:", when="@5.0.2:", type=("build", "run"))
+
+        # Historical optional dependencies
+        depends_on("py-pyyaml", when="@:5", type=("build", "run"))
+        depends_on("py-scikit-image", when="@:4.0", type=("build", "run"))
+        depends_on("py-bintrees", when="@:3.2.1", type=("build", "run"))
+
+        conflicts("^py-matplotlib@3.4.0,3.5.2")
 
     # System dependencies
     depends_on("erfa")
@@ -101,3 +123,12 @@ class PyAstropy(PythonPackage):
     def install_test(self):
         with working_dir("spack-test", create=True):
             python("-c", "import astropy; astropy.test()")
+
+    @property
+    def skip_modules(self):
+        modules = []
+
+        if self.spec.satisfies("~extras"):
+            modules.append("astropy.visualization.wcsaxes")
+
+        return modules
diff --git a/packages/py-autopep8/package.py b/packages/py-autopep8/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..cda16f9676512806a1514d1469d5a7123853890e
--- /dev/null
+++ b/packages/py-autopep8/package.py
@@ -0,0 +1,38 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class PyAutopep8(PythonPackage):
+    """autopep8 automatically formats Python code to conform to the
+    PEP 8 style guide."""
+
+    homepage = "https://github.com/hhatto/autopep8"
+    pypi = "autopep8/autopep8-1.2.4.tar.gz"
+
+    # begin EBRAINS (added): added new version
+    version("2.0.4", sha256="2913064abd97b3419d1cc83ea71f042cb821f87e45b9c88cad5ad3c4ea87fe0c")
+    # end EBRAINS
+    version("1.7.0", sha256="ca9b1a83e53a7fad65d731dc7a2a2d50aa48f43850407c59f6a1a306c4201142")
+    version("1.6.0", sha256="44f0932855039d2c15c4510d6df665e4730f2b8582704fa48f9c55bd3e17d979")
+    version("1.5.7", sha256="276ced7e9e3cb22e5d7c14748384a5cf5d9002257c0ed50c0e075b68011bb6d0")
+    version("1.4.4", sha256="4d8eec30cc81bc5617dbf1218201d770dc35629363547f17577c61683ccfb3ee")
+    version("1.3.3", sha256="ff787bffb812818c3071784b5ce9a35f8c481a0de7ea0ce4f8b68b8788a12f30")
+
+    depends_on("py-pycodestyle@2.3.0:", when="@1.3:", type=("build", "run"))
+    depends_on("py-pycodestyle@2.4.0:", when="@1.4:", type=("build", "run"))
+    depends_on("py-pycodestyle@2.7.0:", when="@1.5.6:", type=("build", "run"))
+    depends_on("py-pycodestyle@2.8.0:", when="@1.6.0:", type=("build", "run"))
+    depends_on("py-pycodestyle@2.9.1:", when="@1.7.0:", type=("build", "run"))
+    # begin EBRAINS (added): py-pycodestyle@1.11 breaks py-autopep8@:2.0.3, solved in 2.0.4
+    # https://github.com/hhatto/autopep8/issues/689
+    depends_on("py-pycodestyle@:2.10", when="@:2.0.3", type=("build", "run"))
+    depends_on("py-pycodestyle@2.10.0:", when="@2.0.4:", type=("build", "run"))
+    # end EBRAINS
+
+    depends_on("py-toml", when="@1.5.3:", type=("build", "run"))
+
+    depends_on("py-setuptools", type="build")
diff --git a/packages/py-elephant/package.py b/packages/py-elephant/package.py
index fce120077bf513eff4fe5c23dcc6af7770b5eb56..7a6bb1ca86e31cd20322bec7c7e86a9ee28f8964 100644
--- a/packages/py-elephant/package.py
+++ b/packages/py-elephant/package.py
@@ -6,7 +6,7 @@
 from spack.package import *
 
 
-class PyElephant(PythonPackage):
+class PyElephant(PythonPackage, CudaPackage):
     """Elephant is a package for analysis of electrophysiology data in Python"""
 
     homepage = "http://neuralensemble.org/elephant/"
@@ -71,6 +71,7 @@ class PyElephant(PythonPackage):
     depends_on("py-scipy@1.5.4:", type=("build", "run"), when="@0.6.4:")
     depends_on("py-six@1.10.0:", type=("build", "run"), when="@0.6.4:")
     depends_on("py-tqdm", type=("build", "run"), when="@0.6.4:")
+    depends_on("py-pycuda", type=("build", "run"), when="@0.10.0:+cuda")
     depends_on("py-pytest", type=("test"), when="@0.6.4:")
     depends_on("py-statsmodels@0.12.1:", type=("test"),when="@0.6.4:")
 
diff --git a/packages/py-ipycanvas/package.py b/packages/py-ipycanvas/package.py
index 4456c1fdfac3679290a84f517169a9c88f331500..0b70aa45e00cf3f140ffddef478acc44d364fa6d 100644
--- a/packages/py-ipycanvas/package.py
+++ b/packages/py-ipycanvas/package.py
@@ -22,9 +22,7 @@ class PyIpycanvas(PythonPackage):
     depends_on("python@3.6:", when="@10:", type=("build", "run"))
     depends_on("python@3.7:", when="@11:", type=("build", "run"))
     depends_on("py-setuptools@40.8:", type="build")
-    # TODO: replace this after concretizer learns how to concretize separate build deps
-    depends_on("py-jupyter-packaging7", type="build")
-    # depends_on('py-jupyter-packaging@0.7.0:0.7', type='build')
+    depends_on("py-jupyter-packaging@0.7", type="build")
     depends_on("py-jupyterlab@3.0:3", type="build")
     depends_on("py-ipywidgets@7.6:", type=("build", "run"))
     depends_on("pil@6:", type=("build", "run"))
diff --git a/packages/py-matplotlib-scalebar/package.py b/packages/py-matplotlib-scalebar/package.py
deleted file mode 100644
index 31907e85922ecf0ccd2f057f4329f31d380afd29..0000000000000000000000000000000000000000
--- a/packages/py-matplotlib-scalebar/package.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
-# Spack Project Developers. See the top-level COPYRIGHT file for details.
-#
-# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-from spack.package import *
-
-
-class PyMatplotlibScalebar(PythonPackage):
-    """Matplotlib-Scalebar provides a new artist for matplotlib to display a scale bar, aka micron bar."""
-
-    homepage = "https://kolibril13.github.io/plywood-gallery-matplotlib-scalebar/"
-    pypi = "matplotlib-scalebar/matplotlib-scalebar-0.8.1.tar.gz"
-    git = "https://github.com/ppinard/matplotlib-scalebar.git"
-
-    # list of GitHub accounts to notify when the package is updated.
-    maintainers = ["ppinard"]
-
-    version("0.8.1", sha256="14887af1093579c5e6afae51a0a1ecc3f715cdbc5c4d7ef59cdeec76ee6bb15d")
-
-    depends_on("py-matplotlib", type=("build", "run"))
diff --git a/packages/py-numba/package.py b/packages/py-numba/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..9d15817a99117c6b88e0a836c75256e1d40c70c0
--- /dev/null
+++ b/packages/py-numba/package.py
@@ -0,0 +1,60 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class PyNumba(PythonPackage):
+    """NumPy aware dynamic Python compiler using LLVM"""
+
+    homepage = "https://numba.pydata.org/"
+    pypi = "numba/numba-0.35.0.tar.gz"
+    git = "https://github.com/numba/numba.git"
+
+    version("0.57.0", sha256="2af6d81067a5bdc13960c6d2519dbabbf4d5d597cf75d640c5aeaefd48c6420a")
+    version("0.56.4", sha256="32d9fef412c81483d7efe0ceb6cf4d3310fde8b624a9cecca00f790573ac96ee")
+    version("0.56.0", sha256="87a647dd4b8fce389869ff71f117732de9a519fe07663d9a02d75724eb8e244d")
+    version("0.55.2", sha256="e428d9e11d9ba592849ccc9f7a009003eb7d30612007e365afe743ce7118c6f4")
+    version("0.55.1", sha256="03e9069a2666d1c84f93b00dbd716fb8fedde8bb2c6efafa2f04842a46442ea3")
+    version("0.54.0", sha256="bad6bd98ab2e41c34aa9c80b8d9737e07d92a53df4f74d3ada1458b0b516ccff")
+    version("0.51.1", sha256="1e765b1a41535684bf3b0465c1d0a24dcbbff6af325270c8f4dad924c0940160")
+    version("0.50.1", sha256="89e81b51b880f9b18c82b7095beaccc6856fcf84ba29c4f0ced42e4e5748a3a7")
+    version("0.48.0", sha256="9d21bc77e67006b5723052840c88cc59248e079a907cc68f1a1a264e1eaba017")
+    version("0.40.1", sha256="52d046c13bcf0de79dbfb936874b7228f141b9b8e3447cc35855e9ad3e12aa33")
+
+    depends_on("python@3.8:3.11", when="@0.57", type=("build", "run"))
+    depends_on("python@3.7:3.10", when="@0.55:0.56", type=("build", "run"))
+    depends_on("python@3.7:3.9", when="@0.54", type=("build", "run"))
+    depends_on("python@3.6:3.9", when="@0.53", type=("build", "run"))
+    depends_on("python@3.6:3.8", when="@0.52", type=("build", "run"))
+    depends_on("python@3.6:3.8", when="@0.48:0.51", type=("build", "run"))
+    depends_on("python@3.3:3.7", when="@0.40.1:0.47", type=("build", "run"))
+    depends_on("py-numpy@1.21:1.24", when="@0.57:", type=("build", "run"))
+    depends_on("py-numpy@1.18:1.23", when="@0.56.1:0.56.4", type=("build", "run"))
+    depends_on("py-numpy@1.18:1.22", when="@0.55.2:0.56.0", type=("build", "run"))
+    depends_on("py-numpy@1.18:1.21", when="@0.55.0:0.55.1", type=("build", "run"))
+    depends_on("py-numpy@1.17:1.20", when="@0.54", type=("build", "run"))
+    depends_on("py-numpy@1.15:1.20", when="@0.48:0.53", type=("build", "run"))
+    depends_on("py-numpy@1.10:1.20", when="@:0.47", type=("build", "run"))
+    depends_on("py-setuptools", type=("build", "run"))
+    depends_on("py-llvmlite@0.40", when="@0.57", type=("build", "run"))
+    depends_on("py-llvmlite@0.39", when="@0.56", type=("build", "run"))
+    depends_on("py-llvmlite@0.38", when="@0.55", type=("build", "run"))
+    depends_on("py-llvmlite@0.37", when="@0.54.0", type=("build", "run"))
+    depends_on("py-llvmlite@0.34", when="@0.51.1", type=("build", "run"))
+    depends_on("py-llvmlite@0.33", when="@0.50.1", type=("build", "run"))
+    depends_on("py-llvmlite@0.31", when="@0.47,0.48", type=("build", "run"))
+    depends_on("py-llvmlite@0.25", when="@0.40", type=("build", "run"))
+    depends_on("py-llvmlite@0.20:0.25", when="@0.35.1", type=("build", "run"))
+    depends_on("py-importlib-metadata", when="@0.56:^python@:3.8", type=("build", "run"))
+
+    # Version 6.0.0 of llvm had a hidden symbol which breaks numba at runtime.
+    # See https://reviews.llvm.org/D44140
+    conflicts("^llvm@6.0.0")
+
+    # begin EBRAINS (added): numba>=0.57 requires at least version 14.0.0 of LLVM
+    conflicts("llvm@:13", when="@0.57.0:")
+    # end EBRAINS
+
diff --git a/packages/py-pycuda/package.py b/packages/py-pycuda/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..7b524993e154fc6eba668838bab850e9ef6014f4
--- /dev/null
+++ b/packages/py-pycuda/package.py
@@ -0,0 +1,53 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+from spack.pkg.builtin.boost import Boost
+
+
+class PyPycuda(PythonPackage):
+    """PyCUDA gives you easy, Pythonic access to Nvidia's CUDA parallel
+    computation API
+    """
+
+    homepage = "https://mathema.tician.de/software/pycuda/"
+    pypi = "pycuda/pycuda-2019.1.2.tar.gz"
+
+    # begin EBRAINS (added): added new version
+    version("2023.1", sha256="175ff675f0cf10e38e9adc03ed5df3ed8d8abf7da5134c8dccec752e8a0a3e91")
+    # end EBRAINS
+    version("2021.1", sha256="ab87312d0fc349d9c17294a087bb9615cffcf966ad7b115f5b051008a48dd6ed")
+    version("2020.1", sha256="effa3b99b55af67f3afba9b0d1b64b4a0add4dd6a33bdd6786df1aa4cc8761a5")
+    version("2019.1.2", sha256="ada56ce98a41f9f95fe18809f38afbae473a5c62d346cfa126a2d5477f24cc8a")
+    version("2016.1.2", sha256="a7dbdac7e2f0c0d2ad98f5f281d5a9d29d6673b3c20210e261b96e9a2d0b6e37")
+
+    @run_before("install")
+    def configure(self):
+        pyver = self.spec["python"].version.up_to(2).joined
+        boostlib = "boost_python{0}".format(pyver)
+        configure_args = [
+            "--no-use-shipped-boost",
+            "--boost-inc-dir={0}".format(self.spec["boost"].prefix.include),
+            "--boost-lib-dir={0}".format(self.spec["boost"].libs.directories[0]),
+            "--boost-python-libname={0}".format(boostlib),
+        ]
+        python("configure.py", *configure_args)
+
+    depends_on("py-setuptools", type="build")
+    depends_on("cuda")
+    depends_on("boost+python")
+    # TODO: replace this with an explicit list of components of Boost,
+    # for instance depends_on('boost +filesystem')
+    # See https://github.com/spack/spack/pull/22303 for reference
+    depends_on(Boost.with_default_variants)
+    depends_on("python@3.6:3", type=("build", "run"), when="@2020.1:")
+    depends_on("py-numpy@1.6:", type=("build", "run"))
+    depends_on("py-pytools@2011.2:", type=("build", "run"))
+    depends_on("py-six", type="run", when="@:2020.1")
+    depends_on("py-decorator@3.2.0:", type=("build", "run"), when="@:2020.1")
+    depends_on("py-appdirs@1.4.0:", type=("build", "run"))
+    depends_on("py-mako", type=("build", "run"))
+
+    depends_on("cuda@:8.0.61", when="@2016.1.2")
diff --git a/packages/py-pynn/package.py b/packages/py-pynn/package.py
index eea8e7cafeca3969e063cbd580151d606948c562..21ca836e8dfc340d8219370660f32d84c18c8bdf 100644
--- a/packages/py-pynn/package.py
+++ b/packages/py-pynn/package.py
@@ -32,6 +32,7 @@ class PyPynn(PythonPackage):
     depends_on('python@3.8:',         when="@0.11.0:")
 
     depends_on('py-setuptools',         type=('build'))
+    depends_on('py-setuptools@61:',     type=('build'), when="@0.11:")
 
     depends_on('py-jinja2@2.7:',        type=('run', 'test'))
     depends_on('py-docutils@0.10:',     type=('run', 'test'))
diff --git a/packages/py-pynrrd/package.py b/packages/py-pynrrd/package.py
deleted file mode 100644
index 99093c34d46e6e8a116842e9db56449cfe0238fe..0000000000000000000000000000000000000000
--- a/packages/py-pynrrd/package.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
-# Spack Project Developers. See the top-level COPYRIGHT file for details.
-#
-# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-from spack.package import *
-
-
-class PyPynrrd(PythonPackage):
-    """Python library for reading and writing NRRD files into and from numpy arrays"""
-
-    homepage = "https://github.com/mhe/pynrrd"
-    pypi = "pynrrd/pynrrd-0.4.0.tar.gz"
-
-    version("1.0.0", sha256="4eb4caba03fbca1b832114515e748336cb67bce70c7f3ae36bfa2e135fc990d2")
-
-    depends_on("py-setuptools", type="build")
-    depends_on("py-numpy@1.11.1:", type=("build", "run"))
-    depends_on("py-nptyping", type=("build", "run"))
-    depends_on("py-typing-extensions", type=("build", "run"))
-
diff --git a/packages/py-pyspike/package.py b/packages/py-pyspike/package.py
index e3fb08286e611069a31e58f906992a6a92134c12..a2264ab4b9bef7bc1ae255431b1442a8a5a77fa8 100644
--- a/packages/py-pyspike/package.py
+++ b/packages/py-pyspike/package.py
@@ -16,6 +16,7 @@ class PyPyspike(PythonPackage):
 
     maintainers = ['dionperd', 'paulapopa', "ldomide"]
 
+    version('0.8.0', '76137b861ed531608aaf55af1a5ebf8a586e98653dab2467b4c1da7b2d9aa4e5')
     version('0.7.0', 'a5d1c1472d3e7c3ac85c8a4ce069d750cca02acf18f185677b29c0a757e78efe')
 
     # python_requires
@@ -30,7 +31,7 @@ class PyPyspike(PythonPackage):
     depends_on('py-scipy', type=('build', 'run'))
     depends_on('py-matplotlib', type=('build', 'run'))
     depends_on('py-pytest', type=('build', 'run'))
-    depends_on('py-cython', type=('build', 'run'))
+    depends_on('py-cython@:2', type=('build', 'run'))
 
     # Test dependency
     depends_on('py-pytest@:7.1', type='test')
diff --git a/packages/py-ray/package.py b/packages/py-ray/package.py
index da6ae703cb6d4e6fd0a3b663efd0b9c2c92cc845..21e6bd228910065ae51bb563acc215491e7a431c 100644
--- a/packages/py-ray/package.py
+++ b/packages/py-ray/package.py
@@ -13,14 +13,37 @@ class PyRay(PythonPackage):
     homepage = "https://github.com/ray-project/ray"
     url = "https://github.com/ray-project/ray/archive/ray-0.8.7.tar.gz"
 
+    # begin EBRAINS (added): ECM new node-js -> new react whatever -> new py-ray
+    version("2.4.0", sha256="b0110a84630b2f6d10cd13e8ac955875c3658373eb6cabcc77cf316de3c28066")
+    # end EBRAINS
     version("2.0.1", sha256="b8b2f0a99d2ac4c001ff11c78b4521b217e2a02df95fb6270fd621412143f28b")
     version("0.8.7", sha256="2df328f1bcd3eeb4fa33119142ea0d669396f4ab2a3e78db90178757aa61534b")
 
     variant("default", default=False, description="Install default extras", when="@2.0.1")
 
+    # begin EBRAINS (added): ECM new node-js -> new react whatever -> new py-ray
+    conflicts("node-js@17:", when="@:2.0.1")
+    # end EBRAINS
+
+    # begin EBRAINS (added): ElM add missing dependencies/constraints for added version 2.4.0
+    depends_on("python@3.6:3.11", when="@2.4.0", type=("build", "run"))
+    depends_on("bazel@5", when="@2.4.0", type="build")
+    depends_on("py-cython@0.29.32:", when="@2.4.0", type="build")
+    depends_on("py-attrs", when="@2.4.0", type=("build", "run"))
+    depends_on("py-click@7.0:", when="@2.4.0", type=("build", "run"))
+    depends_on("py-grpcio@1.32:1.51.3", when="@2.4.0 ^python@:3.9", type=("build", "run"))
+    depends_on("py-grpcio@1.42:1.51.3", when="@2.4.0 ^python@3.10:", type=("build", "run"))
+    depends_on("py-protobuf@3.15.3:", when="@2.4.0", type=("build", "run"))
+    depends_on("py-frozenlist", when="@2.4.0", type=("build", "run"))
+    depends_on("py-typing-extensions", when="@2.4.0 ^python@:3.7", type=("build", "run"))
+    depends_on("py-virtualenv@20.0.24:", when="@2.4.0", type=("build", "run"))
+    # end EBRAINS
+
     depends_on("python@3.6:3.10", when="@2.0.1", type=("build", "run"))
     depends_on("python@3.6:3.8", when="@0.8.7", type=("build", "run"))
+    # begin EBRAINS (modified): ECM relax constraint to allow newer bazel
     depends_on("bazel@4.2.2:5", when="@2.0.1", type="build")
+    # end EBRAINS (modified)
     depends_on("bazel@3.2.0", when="@0.8.7", type="build")
     depends_on("npm", type="build")
     depends_on("py-setuptools", type="build")
@@ -45,11 +68,12 @@ class PyRay(PythonPackage):
     depends_on("py-typing-extensions", when="@2.0.1 ^python@:3.7", type=("build", "run"))
     depends_on("py-virtualenv", when="@2.0.1", type=("build", "run"))
 
-    # needed to fix import errors
+    # begin EBRAINS (added): ElM needed to fix import errors
     depends_on("py-setproctitle", type=("build", "run"))
     depends_on("py-colorama", type=("build", "run"))
     depends_on("py-psutil", type=("build", "run"))
-    
+    # end EBRAINS
+
     with when("+default"):
         depends_on("py-aiohttp@3.7:", type=("build", "run"))
         depends_on("py-aiohttp-cors", type=("build", "run"))
@@ -100,4 +124,4 @@ class PyRay(PythonPackage):
         with working_dir(join_path("python", "ray", "dashboard", "client")):
             npm = which("npm")
             npm("ci")
-            npm("run", "build")
\ No newline at end of file
+            npm("run", "build")
diff --git a/packages/py-tvb-multiscale/package.py b/packages/py-tvb-multiscale/package.py
index f98ba9cbaea4e49c38135d8a2cef0ee4174b02b4..660d45e0f498d1f69b3d5ff013a204381c20bf48 100644
--- a/packages/py-tvb-multiscale/package.py
+++ b/packages/py-tvb-multiscale/package.py
@@ -18,6 +18,8 @@ class PyTvbMultiscale(PythonPackage):
 
     version('2.1.0.ebrains', sha256='eab51e235f565cffbf300daa4b7c65a7afacde149e2eda0f49437db3c2429253')
 
+    patch('tvb-multiscale-2.1.0-version-pep440.patch', when='@2.1.0.ebrains')
+
     # python_requires
     depends_on('python@3.8:3.10', type=('build', 'run'))
 
diff --git a/packages/py-tvb-multiscale/tvb-multiscale-2.1.0-version-pep440.patch b/packages/py-tvb-multiscale/tvb-multiscale-2.1.0-version-pep440.patch
new file mode 100644
index 0000000000000000000000000000000000000000..46f68f7c5cc7b0268bb2c72815286aba7edee0fd
--- /dev/null
+++ b/packages/py-tvb-multiscale/tvb-multiscale-2.1.0-version-pep440.patch
@@ -0,0 +1,12 @@
+diff --git a/setup.py b/setup.py
+index 4359f2c0..2e00e648 100644
+--- a/setup.py
++++ b/setup.py
+@@ -15,7 +15,7 @@ import shutil
+ import setuptools
+ 
+ 
+-VERSION = "2.1.0."
++VERSION = "2.1.0"
+ 
+ INSTALL_REQUIREMENTS = ["pandas", "xarray", "elephant", "pyspike", "dill", "ANNarchy", "neuron", "netpyne", "ray"]
diff --git a/packages/pynn-brainscales/package.py b/packages/pynn-brainscales/package.py
index 6ad4f12e3c68ebede065a024608d9c62b3ffba2f..e61b7b61fde63c2b60d7a1a0b6d4dec6b06294d3 100644
--- a/packages/pynn-brainscales/package.py
+++ b/packages/pynn-brainscales/package.py
@@ -3,8 +3,13 @@
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 import os
+import unittest.mock
+import sys
+import xml.etree.ElementTree as ET
 
 from spack import *
+from spack.util.environment import EnvironmentModifications
+import spack.build_environment
 
 
 class PynnBrainscales(WafPackage):
@@ -15,12 +20,20 @@ class PynnBrainscales(WafPackage):
     git      = "https://github.com/electronicvisions/pynn-brainscales.git"
 
     maintainers = ['emuller']
-    
-    version('7.0-rc1-fixup2', branch='waf')
+
+    version('8.0-a3',         tag='pynn-brainscales-8.0-a3')
+    version('8.0-a2',         tag='pynn-brainscales-8.0-a2')
+    version('8.0-a1',         tag='pynn-brainscales-8.0-a1')
+    version('7.0-rc1-fixup3', tag='pynn-brainscales-7.0-rc1-fixup3')
+    version('7.0-rc1-fixup2', tag='pynn-brainscales-7.0-rc1-fixup2')
     version('7.0-rc1-fixup1', branch='waf')
 
     # compiler for the BrainScaleS-2 embedded processor ("PPU"); needed for
     # building/linking, at runtime and for testing
+    depends_on('oppulance@8.0-a3', when='@8.0-a3', type=('build', 'link', 'run', 'test'))
+    depends_on('oppulance@8.0-a2', when='@8.0-a2', type=('build', 'link', 'run', 'test'))
+    depends_on('oppulance@8.0-a1', when='@8.0-a1', type=('build', 'link', 'run', 'test'))
+    depends_on('oppulance@7.0-rc1-fixup3', when='@7.0-rc1-fixup3', type=('build', 'link', 'run', 'test'))
     depends_on('oppulance@7.0-rc1-fixup2', when='@7.0-rc1-fixup2', type=('build', 'link', 'run', 'test'))
     depends_on('oppulance@7.0-rc1-fixup1', when='@7.0-rc1-fixup1', type=('build', 'link', 'run', 'test'))
 
@@ -32,17 +45,18 @@ class PynnBrainscales(WafPackage):
     depends_on('cppcheck', type=('build', 'link', 'run'))
     depends_on('genpybind@ebrains', type=('build', 'link', 'run'))
     depends_on('gflags', type=('build', 'link', 'run'))
+    depends_on('git', type=('build', 'link'))
     depends_on('googletest@1.11.0:+gmock', type=('build', 'link', 'run')) # variadic templates needed
     depends_on('inja', type=('build', 'link', 'run', 'test')) # template engine for PPU source jit generation
     depends_on('intel-tbb', type=('build', 'link', 'run'))  # ppu gdbserver
     depends_on('libelf', type=('build', 'link', 'run'))
     depends_on('liblockfile', type=('build', 'link', 'run'))
-    depends_on('llvm', type=('build', 'link', 'run'))
     depends_on('log4cxx@0.12.1:', type=('build', 'link', 'run'))
     depends_on('pkgconfig', type=('build', 'link', 'run'))
     depends_on('psmisc', type=('run', 'test'))
     depends_on('python@3.7.0:', type=('build', 'link', 'run')) # BrainScaleS-2 only supports Python >= 3.7
     depends_on('py-deap@1.3.1:', type=('build', 'link', 'run'))
+    depends_on('py-git-review', type=('build', 'link'))
     depends_on('py-h5py', type=('build', 'link', 'run')) # PyNN tests need it
     depends_on('py-matplotlib', type=('build', 'link', 'run'))
     depends_on('py-nose', type=('build', 'link', 'run'))
@@ -60,55 +74,42 @@ class PynnBrainscales(WafPackage):
     depends_on('yaml-cpp+shared', type=('build', 'link', 'run'))
     extends('python')
 
-    def setup_build_environment(self, env):
-        """waf needs to find headers and libraries by itself (mostly `boost`
-        tool, but also `gtest`); it also needs to run executables during
-        configuration."""
-
-        include = []
-        include_exclude_dirs = set(['/usr/include'])
-        for dep in self.spec.traverse(deptype='build', root=False):
-            query = self.spec[dep.name]
-            try:
-                include_dirs = set(query.headers.directories)
-                include_dirs -= include_exclude_dirs
-                print('headers (', dep.name, '):', include_dirs, "\n")
-                include.extend(list(include_dirs))
-            except spack.error.NoHeadersError:
-                # we don't care if no header directories are found
-                pass
-
-        library = []
-        library_exclude_dirs = set(['/lib', '/lib64', '/usr/lib', '/usr/lib64'])
-        for dep in self.spec.traverse(deptype=('link', 'run'), root=False):
-            query = self.spec[dep.name]
-            try:
-                library_dirs = set(query.libs.directories)
-                library_dirs -= library_exclude_dirs
-                print('libs (', dep.name, '):', library_dirs, "\n")
-                library.extend(list(library_dirs))
-            except spack.error.NoLibrariesError:
-                # we don't care if no library directories are found
-                pass
-
-        path = []
-        for dep in self.spec.traverse(deptype=('build', 'link', 'run'), root=False):
-            query = self.spec[dep.name]
-            if os.path.exists(self.prefix.bin):
-                path.append(query.prefix.bin)
-                print('bin (', dep.name, '):', query.prefix.bin, "\n")
-
-        # llvm might be built with ~shared_libs but still builds shared libs
-        if not any('llvm' in lib for lib in library):
-            print("libs: manually adding ", self.spec['llvm'].prefix.lib)
-            library.append(self.spec['llvm'].prefix.lib)
-
-        env.set('CPATH', ':'.join(include))
-        env.set('C_INCLUDE_PATH', ':'.join(include))
-        env.set('CPLUS_INCLUDE_PATH', ':'.join(include))
-        env.set('LIBRARY_PATH', ':'.join(library))
-        env.set('WAF_CONFIGURE_LD_LIBRARY_PATH', ':'.join(library))
-        env.prepend_path('PATH', ':'.join(path))
+    def do_fetch(self, mirror_only=False):
+        """Setup the project."""
+
+        self.stage.create()
+        self.stage.fetch(mirror_only)
+
+        # if fetcher didn't do anything, it's cached already
+        if not os.path.exists(self.stage.source_path):
+            return
+
+        with working_dir(self.stage.source_path):
+            python = which('python3')
+            if self.spec.satisfies('@:7'):
+                python('./waf', 'setup', '--repo-db-url=https://github.com/electronicvisions/projects',
+                    '--clone-depth=2',
+                    '--without-munge',
+                    '--without-hxcomm-hostarq',
+                    '--without-hxcomm-extoll',
+                    '--project=pynn-brainscales',
+                    '--release-branch=ebrains-' + str(self.spec.version)
+                )
+            else:
+                python('./waf', 'setup', '--repo-db-url=https://github.com/electronicvisions/projects',
+                    '--clone-depth=2',
+                    '--without-munge',
+                    '--without-hxcomm-hostarq',
+                    '--project=pynn-brainscales',
+                    '--release-branch=ebrains-' + str(self.spec.version)
+                )
+
+
+        # in the configure step, we need access to all archived .git folders
+        def custom_archive(self, destination):
+            super(spack.fetch_strategy.GitFetchStrategy, self).archive(destination)
+        with unittest.mock.patch('spack.fetch_strategy.GitFetchStrategy.archive', new=custom_archive):
+            self.stage.cache_local()
 
     def _setup_common_env(self, env):
         # grenade needs to find some libraries for the JIT-compilation of
@@ -119,8 +120,37 @@ class PynnBrainscales(WafPackage):
             dep = self.spec[ppu_dep_name]
             dep_include_dirs = set(dep.headers.directories)
             ppu_include_dirs.extend(list(dep_include_dirs))
-        env.set('C_INCLUDE_PATH', ':'.join(ppu_include_dirs))
-        env.set('CPLUS_INCLUDE_PATH', ':'.join(ppu_include_dirs))
+        for dir in reversed(ppu_include_dirs):
+            env.prepend_path("C_INCLUDE_PATH", dir)
+            env.prepend_path("CPLUS_INCLUDE_PATH", dir)
+
+    def setup_build_environment(self, env):
+        my_envmod = EnvironmentModifications(env)
+        spack.build_environment.set_wrapper_variables(self, my_envmod)
+        my_env = {}
+        my_envmod.apply_modifications(my_env)
+
+        def get_path(env, name):
+            path = env.get(name, "").strip()
+            if path:
+                return path.split(os.pathsep)
+            return []
+
+        # spack tries to find headers and libraries by itself (i.e. it's not
+        # relying on the compiler to find it); we explicitly expose the
+        # spack-provided env vars that contain include and library paths
+        if 'SPACK_INCLUDE_DIRS' in my_env:
+            for dir in reversed(get_path(my_env, "SPACK_INCLUDE_DIRS")):
+                env.prepend_path("C_INCLUDE_PATH", dir)
+                env.prepend_path("CPLUS_INCLUDE_PATH", dir)
+        if 'SPACK_LINK_DIRS' in my_env:
+            for dir in reversed(get_path(my_env, "SPACK_LINK_DIRS")):
+                env.prepend_path("LIBRARY_PATH", dir)
+                env.prepend_path("LD_LIBRARY_PATH", dir)
+        for dir in reversed(self.compiler.implicit_rpaths()):
+            env.prepend_path("LIBRARY_PATH", dir)
+            # technically this is probably not needed for the non-configure steps
+            env.prepend_path("LD_LIBRARY_PATH", dir)
 
     def setup_dependent_build_environment(self, env, dependent_spec):
         self._setup_common_env(env)
@@ -133,25 +163,10 @@ class PynnBrainscales(WafPackage):
 
     # override configure step as we perform a project setup first
     def configure(self, spec, prefix):
-        """Setup and configure the project."""
-
-        env = os.environ
-        if 'SPACK_COMPILER_IMPLICIT_RPATHS' in env:
-            env['LIBRARY_PATH'] = env['SPACK_COMPILER_IMPLICIT_RPATHS'] + ':' + env['LIBRARY_PATH']
-            env['WAF_CONFIGURE_LD_LIBRARY_PATH'] = env['SPACK_COMPILER_IMPLICIT_RPATHS'] + ':' + env['WAF_CONFIGURE_LD_LIBRARY_PATH']
-
-        self.waf('setup', '--repo-db-url=https://github.com/electronicvisions/projects',
-            '--without-munge',
-            '--without-hxcomm-hostarq',
-            '--without-hxcomm-extoll',
-            '--project=pynn-brainscales',
-            '--release-branch=ebrains-' + str(spec.version)
-         )
+        """Configure the project."""
 
         args = ['--prefix={0}'.format(self.prefix)]
         args += self.configure_args()
-
-        env['LD_LIBRARY_PATH'] = env.get('WAF_CONFIGURE_LD_LIBRARY_PATH')
         self.waf('configure', '--build-profile=release', '--disable-doxygen', *args)
 
     def build_args(self):
@@ -160,7 +175,18 @@ class PynnBrainscales(WafPackage):
 
     def build_test(self):
         self.builder.waf('build', '--test-execall')
-        copy_tree('build/test_results', join_path(self.prefix, '.build'))
+        copy_tree('build/test_results', join_path(self.prefix, ".build"))
+        copy_tree('build/test_results', join_path(self.stage.path, ".install_time_tests"))
+        # propagate failures from junit output to spack
+        tree = ET.parse('build/test_results/summary.xml')
+        for testsuite in tree.getroot():
+            for testcase in testsuite:
+                for elem in testcase:
+                    if (elem.tag == 'failure') and not (
+                            elem.get('message').startswith("pylint:") or
+                            elem.get('message').startswith("pycodestyle:") or
+                            ("OK" in elem.get('message') and "Segmentation fault" in elem.get('message'))):
+                        raise RuntimeError("Failed test found: {}".format(testcase.get('name')))
 
     def install_args(self):
         args = ['--test-execnone']
diff --git a/packages/sbml/package.py b/packages/sbml/package.py
index 25504b607647581f8b1efdf4a48185bb7239a62d..52abe1383d4136f6a3217290f27c6e14371b6d4f 100644
--- a/packages/sbml/package.py
+++ b/packages/sbml/package.py
@@ -60,7 +60,7 @@ class Sbml(CMakePackage):
 
     depends_on("swig@2:", type="build")
     depends_on("cmake", type="build")
-    depends_on("zlib")
+    depends_on("zlib-api")
     depends_on("bzip2")
     depends_on("libxml2")
 
diff --git a/packages/sleef/package.py b/packages/sleef/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..288f36b0491b10affb1a280e279fb72592c8656a
--- /dev/null
+++ b/packages/sleef/package.py
@@ -0,0 +1,63 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class Sleef(CMakePackage):
+    """SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT."""
+
+    homepage = "https://sleef.org"
+    url = "https://github.com/shibatch/sleef/archive/3.2.tar.gz"
+    git = "https://github.com/shibatch/sleef.git"
+
+    version("master", branch="master")
+    version("3.5.1_2020-12-22", commit="e0a003ee838b75d11763aa9c3ef17bf71a725bff")  # py-torch@1.8:
+    version(
+        "3.5.1",
+        sha256="415ee9b1bcc5816989d3d4d92afd0cd3f9ee89cbd5a33eb008e69751e40438ab",
+        preferred=True,
+    )
+    version(
+        "3.4.0_2019-07-30", commit="7f523de651585fe25cade462efccca647dcc8d02"
+    )  # py-torch@1.3:1.7
+    version(
+        "3.4.0_2019-05-13",
+        commit="9b249c53a80343cc1a394ca961d7d5696ea76409",  # py-torch@1.2
+        git="https://github.com/zdevito/sleef.git",
+    )
+    version(
+        "3.3.1_2018-12-09",
+        commit="191f655caa25526ae226cf88dd2529265176014a",  # py-torch@1.1
+        git="https://github.com/zdevito/sleef.git",
+    )
+    version(
+        "3.2_2018-05-09", commit="6ff7a135a1e31979d1e1844a2e7171dfbd34f54f"
+    )  # py-torch@0.4.1:1.0
+    version("3.2", sha256="3130c5966e204e6d6a3ace81e543d12b5b21f60897f1c185bfa587c1bd77bee2")
+
+    # https://github.com/shibatch/sleef/issues/474
+    conflicts("%apple-clang@15:")
+
+    generator("ninja")
+    depends_on("cmake@3.4.3:", type="build")
+
+    # # https://github.com/shibatch/sleef/issues/475
+    # depends_on("fftw-api")
+    # depends_on("mpfr")
+    # depends_on("openssl")
+
+    # # https://github.com/shibatch/sleef/issues/458
+    # conflicts("^mpfr@4.2:")
+
+    # begin EBRAINS (modified): removed "disable shared lib build" to fix py-torch
+    #                           this was fixed upstream in 8c061e51.
+    def cmake_args(self):
+        # https://salsa.debian.org/science-team/sleef/-/blob/master/debian/rules
+        return [
+            self.define("BUILD_DFT", False),
+            self.define("BUILD_TESTS", False),
+        ]
+    # end EBRAINS
diff --git a/packages/wf-brainscales2-demos/package.py b/packages/wf-brainscales2-demos/package.py
index f54ebef167c8e2ee55c19ad27a214e726b93b78a..914fa180f7c3828d4c238b191d40d9f100f2ffe9 100644
--- a/packages/wf-brainscales2-demos/package.py
+++ b/packages/wf-brainscales2-demos/package.py
@@ -17,6 +17,7 @@ class WfBrainscales2Demos(Package):
     maintainer = ["muffgaga"]
 
     # ECM: we probably should build the ipynb file in this package
+    version("7.0-rc1-fixup3", tag="jupyter-notebooks-7.0-rc1-fixup3")
     version("23.6", branch="jupyter-notebooks-experimental")
 
     depends_on('hxtorch', type=("run", "test"))
diff --git a/packages/xcb-proto/package.py b/packages/xcb-proto/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..2269e3042ba75d74ac6b5dfdbf4c590998607e5d
--- /dev/null
+++ b/packages/xcb-proto/package.py
@@ -0,0 +1,33 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class XcbProto(AutotoolsPackage):
+    """xcb-proto provides the XML-XCB protocol descriptions that libxcb uses to
+    generate the majority of its code and API."""
+
+    homepage = "https://xcb.freedesktop.org/"
+    url = "https://xorg.freedesktop.org/archive/individual/proto/xcb-proto-1.14.1.tar.xz"
+
+    version("1.15.2", sha256="7072beb1f680a2fe3f9e535b797c146d22528990c72f63ddb49d2f350a3653ed")
+    version("1.14.1", sha256="f04add9a972ac334ea11d9d7eb4fc7f8883835da3e4859c9afa971efdf57fcc3")
+    version("1.14", sha256="186a3ceb26f9b4a015f5a44dcc814c93033a5fc39684f36f1ecc79834416a605")
+    version("1.13", sha256="0698e8f596e4c0dbad71d3dc754d95eb0edbb42df5464e0f782621216fa33ba7")
+    version("1.12", sha256="cfa49e65dd390233d560ce4476575e4b76e505a0e0bacdfb5ba6f8d0af53fd59")
+    version("1.11", sha256="d12152193bd71aabbdbb97b029717ae6d5d0477ab239614e3d6193cc0385d906")
+
+    # extends("python")
+
+    patch("xcb-proto-1.12-schema-1.patch", when="@1.12")
+
+    def url_for_version(self, version):
+        if version >= Version("1.14"):
+            url = "https://xorg.freedesktop.org/archive/individual/proto/xcb-proto-{0}.tar.xz"
+        else:
+            url = "http://xcb.freedesktop.org/dist/xcb-proto-{0}.tar.gz"
+
+        return url.format(version)
\ No newline at end of file
diff --git a/packages/xcb-proto/xcb-proto-1.12-schema-1.patch b/packages/xcb-proto/xcb-proto-1.12-schema-1.patch
new file mode 100644
index 0000000000000000000000000000000000000000..932889368bf6ffcd7adb9ea4b124c7aef29dfbc2
--- /dev/null
+++ b/packages/xcb-proto/xcb-proto-1.12-schema-1.patch
@@ -0,0 +1,51 @@
+Submitted By: Bruce Dubbs <bdubbs at linuxfromscratch dot org>
+Date: 2016-06-01
+Initial Package Version: 1.12
+Upstream Status: Not Committed
+Origin: https://lists.freedesktop.org/archives/xcb/2016-February/010676.html
+Description: Fixes make check
+
+
+--- a/src/xcb.xsd
++++ b/src/xcb.xsd
+@@ -44,6 +44,15 @@ authorization from the authors.
+     <xsd:complexType>
+       <xsd:attribute name="bytes" type="xsd:integer" use="optional" />
+       <xsd:attribute name="align" type="xsd:integer" use="optional" />
++      <xsd:attribute name="serialize" type="xsd:boolean" use="optional" />
++    </xsd:complexType>
++  </xsd:element>
++
++  <!-- Alignment -->
++  <xsd:element name="required_start_align" >
++    <xsd:complexType>
++      <xsd:attribute name="align" type="xsd:integer" use="required" />
++      <xsd:attribute name="offset" type="xsd:integer" use="optional" />
+     </xsd:complexType>
+   </xsd:element>
+ 
+@@ -76,14 +85,13 @@ authorization from the authors.
+     <xsd:sequence>
+       <!-- switch(expression) -->
+       <xsd:group ref="expression" minOccurs="1" maxOccurs="1" />
++      <xsd:element ref="required_start_align" minOccurs="0" maxOccurs="1" />
+       <xsd:choice>
+         <!-- bitcase expression - bit test -->
+         <xsd:element name="bitcase" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
+         <!-- case expression - value test -->
+         <xsd:element name="case" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
+       </xsd:choice>
+-      <!-- default: -->
+-      <xsd:group ref="fields" minOccurs="0" maxOccurs="1" />
+     </xsd:sequence>
+     <xsd:attribute name="name" type="xsd:string" use="required" />
+   </xsd:complexType>
+@@ -201,6 +209,7 @@ authorization from the authors.
+       <xsd:element ref="field" />
+       <xsd:element ref="list" />
+       <xsd:element ref="fd" />
++      <xsd:element ref="required_start_align" />
+     </xsd:choice>
+   </xsd:group>
+ 
+
diff --git a/site-config/ebrainslab/packages.yaml b/site-config/ebrainslab/packages.yaml
index 81f106b499d4e77c03a96f9000e83d0648fd5ee0..8098616ee0c202557df247fccebb7b9ccbb9d3f7 100644
--- a/site-config/ebrainslab/packages.yaml
+++ b/site-config/ebrainslab/packages.yaml
@@ -8,7 +8,7 @@ packages:
         require: "@3.8.11"
     r:
         # EM: +X fixes build for collab
-        require: "@4.1.3+X"
+        require: "@4.3.0+X"
     py-torch:
         # ECM: keep at latest w.r.t. tracked upstream spack
         version: [1.11.0]
diff --git a/spack.yaml b/spack.yaml
index 6bb4c779f6319e4f7d8823c68e7746cf6bf87d84..726a38bc6b4b43582c064fcba2078aecbf370e34 100644
--- a/spack.yaml
+++ b/spack.yaml
@@ -12,7 +12,7 @@ spack:
     - biobb-model@4.0.0
     - biobb-structure-checking@3.12.1
     - biobb-structure-utils@4.0.0
-    - hxtorch@7.0-rc1-fixup2
+    - hxtorch@8.0-a3
     - nest@3.6 +sonata
     - neuron@8.2.3 +mpi
     - py-bluepyefe@2.2.18
@@ -53,14 +53,14 @@ spack:
     - py-tvb-multiscale@2.1.0.ebrains
     - py-tvb-storage@2.8.1
     - py-viziphant@0.4.0
-    - pynn-brainscales@7.0-rc1-fixup2
+    - pynn-brainscales@8.0-a3
     - r-rgsl@0.1.1
     - r-sbtabvfgen@0.1
     - r-uqsa@2.2
     - sda@7.3.3d
     # Workflows (meta-packages)
     - wf-biobb
-    - wf-brainscales2-demos
+    - wf-brainscales2-demos@7.0-rc1-fixup3
     - wf-protein-association-rates@0.1
     - wf-multi-area-model@1.1.1
     - wf-uq-akar4@0.1