Check that update.py's VERSION matches toolchain.gni's clang_version.

We can't just let update.py compute the contents of clang_revision because
that's used in several .gn files and we'd have to shell out to slow python
several times.  This would slow down gn while only being beneficial every
6 months when the LLVM version increases.

However, we can hand down clang_revision to the script in the one place
where we call it with --print-revision, and make the script check that
the handed-in version matches the internal VERSION.  This way, gn at
least checks that the two values are in sync so that we won't again
forget to update clang_revision.  (update.py already checks that
VERSION matches what `clang --version` prints.)

Bug: none
Change-Id: I6f130a848ad881f18915c30e84061ffa59128a53
Reviewed-on: https://chromium-review.googlesource.com/928829
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#538403}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 80edee6cf6cb6c16abbd07343d42bf5276a07e2e
diff --git a/scripts/update.py b/scripts/update.py
index 3113f75..5fedfaa 100755
--- a/scripts/update.py
+++ b/scripts/update.py
@@ -870,6 +870,8 @@
   parser.add_argument('--use-system-cmake', action='store_true',
                       help='use the cmake from PATH instead of downloading '
                       'and using prebuilt cmake binaries')
+  parser.add_argument('--verify-version',
+                      help='verify that clang has the passed-in version')
   parser.add_argument('--without-android', action='store_false',
                       help='don\'t build Android ASan runtime (linux only)',
                       dest='with_android',
@@ -888,6 +890,12 @@
       args.force_local_build):
     AddSvnToPathOnWin()
 
+  if args.verify_version and args.verify_version != VERSION:
+    print 'VERSION is %s but --verify-version argument was %s, exiting.' % (
+        VERSION, args.verify_version)
+    print 'clang_version in build/toolchain/toolchain.gni is likely outdated.'
+    return 1
+
   global CLANG_REVISION, PACKAGE_VERSION
   if args.print_revision:
     if use_head_revision or args.llvm_force_head_revision: