Add clang-tools-extra, lld and lldb to the scripts

The scripts aren't very consistent about which repos they handle (e.g.
clang-tools-extra was handled in llvm-prepare, but not in the other scripts).
This commit tries to improve on that by:
* adding support for clang-tools-extra in llvm-projs, llvm-sync and llvm-branch
* adding support for lld and lldb to llvm-branch.

Change-Id: I82b0aeb95b5116d1d75f0721e0c4d31c4744e04b
diff --git a/helpers/llvm-branch b/helpers/llvm-branch
index 3ed3cef..98a9504 100755
--- a/helpers/llvm-branch
+++ b/helpers/llvm-branch
@@ -79,6 +79,13 @@
   clang_branches=`get_branches`
 fi
 
+CLANG_EXTRA_SRC=$LLVM_SRC/tools/clang/tools/extra
+if [ -d $CLANG_EXTRA_SRC ]; then
+  cd $CLANG_EXTRA_SRC
+  clang_extra_branch=`get_branch`
+  clang_extra_branches=`get_branches`
+fi
+
 RT_SRC=$LLVM_SRC/projects/compiler-rt
 if [ -d $RT_SRC ]; then
   cd $RT_SRC
@@ -107,6 +114,20 @@
   unw_branches=`get_branches`
 fi
 
+LLD_SRC=$LLVM_SRC/tools/lld
+if [ -d $LLD_SRC ]; then
+  cd $LLD_SRC
+  lld_branch=`get_branch`
+  lld_branches=`get_branches`
+fi
+
+LLDB_SRC=$LLVM_SRC/tools/lldb
+if [ -d $LLDB_SRC ]; then
+  cd $LLDB_SRC
+  lldb_branch=`get_branch`
+  lldb_branches=`get_branches`
+fi
+
 # Delete chosen branch
 DEL=''
 if [[ $1 = '-d' || $1 = '-D' ]]; then
@@ -124,6 +145,11 @@
     print_branches $clang_branch $clang_branches
     echo
   fi
+  if [ -d $CLANG_EXTRA_SRC ]; then
+    echo -n "Clang tools extra branches: "
+    print_branches $clang_extra_branch $clang_extra_branches
+    echo
+  fi
   if [ -d $RT_SRC ]; then
     echo -n "Compiler-RT branches: "
     print_branches $rt_branch $rt_branches
@@ -144,6 +170,16 @@
     print_branches $unw_branch $unw_branches
     echo
   fi
+  if [ -d $LLD_SRC ]; then
+    echo -n "LLD branches: "
+    print_branches $lld_branch $lld_branches
+    echo
+  fi
+  if [ -d $LLDB_SRC ]; then
+    echo -n "LLDB branches: "
+    print_branches $lldb_branch $lldb_branches
+    echo
+  fi
   exit
 fi
 
@@ -158,12 +194,16 @@
 # Check which projects the branch is
 in_llvm=`has $branch $llvm_branches`
 in_clang=`has $branch $clang_branches`
+in_clang_extra=`has $branch $clang_extra_branches`
 in_rt=`has $branch $rt_branches`
 in_cxx=`has $branch $cxx_branches`
 in_cxxabi=`has $branch $cxxabi_branches`
 in_unw=`has $branch $unw_branches`
-if [[ $in_clang = 'no' && $in_llvm = 'no' && $in_rt = 'no' && \
-      $in_cxx = 'no' && $in_cxxabi = 'no' && $in_unw = 'no' ]]; then
+in_lld=`has $branch $lld_branches`
+in_lldb=`has $branch $lldb_branches`
+if [[ $in_clang = 'no' && $in_clang_extra && $in_llvm = 'no' && \
+      $in_rt = 'no' && $in_cxx = 'no' && $in_cxxabi = 'no' && \
+      $in_unw = 'no' && $in_lld = 'no' && $in_lldb = 'no' ]]; then
   echo "Branch $branch doesn't exist on any repository"
   exit 1
 fi
@@ -171,7 +211,10 @@
 # DO IT
 switch $LLVM_SRC $branch $in_llvm
 switch $CLANG_SRC $branch $in_clang
+switch $CLANG_EXTRA_SRC $branch $in_clang_extra
 switch $RT_SRC $branch $in_rt
 switch $CXX_SRC $branch $in_cxx
 switch $CXXABI_SRC $branch $in_cxxabi
 switch $UNW_SRC $branch $in_unw
+switch $LLD_SRC $branch $in_lld
+switch $LLDB_SRC $branch $in_lldb
diff --git a/helpers/llvm-projs b/helpers/llvm-projs
index e0ff2da..ac20999 100755
--- a/helpers/llvm-projs
+++ b/helpers/llvm-projs
@@ -8,7 +8,7 @@
 
 prog=`basename $0`
 syntax() {
-  echo "Syntax: $prog {+/-}[clang|rt|libs|tools|test]"
+  echo "Syntax: $prog {+/-}[clang|cextra|rt|libs|tools|test]"
   echo " noarg: list linked projects"
   echo " {+/-}: link / unlik projects (default: link)"
 }
@@ -16,6 +16,8 @@
 # Dirs and links into LLVM
 clang_dir=clang
 clang_link=tools/clang
+clang_extra_dir=clang-tools-extra
+clang_extra_link=tools/clang/tools/extra
 rt_dir=compiler-rt
 rt_link=projects/compiler-rt
 libcxx_dir=libcxx
@@ -63,6 +65,7 @@
 list_all() {
   echo "Projects linked:"
   has $clang_link && echo " + Clang"
+  has $clang_extra_link && echo " + Clang Tools Extra"
   has $rt_link && echo " + Compiler-RT"
   has $libcxx_link && echo " + LibC++"
   has $libcxxabi_link && echo " + LibC++abi"
@@ -83,6 +86,7 @@
 
 # Need/not need
 clang=`init $clang_link`
+clang_extra=`init $clang_extra_link`
 rt=`init $rt_link`
 libcxx=`init $libcxx_link`
 libcxxabi=`init $libcxxabi_link`
@@ -108,6 +112,9 @@
     clang)
       clang=$flag
       ;;
+    cextra)
+      clang_extra=$flag
+      ;;
     rt)
       rt=$flag
       ;;
@@ -147,4 +154,5 @@
 update $libcxx_dir $libcxx_link $libcxx
 update $rt_dir $rt_link $rt
 update $clang_dir $clang_link $clang
+update $clang_extra_dir $clang_extra_link $clang_extra
 list_all
diff --git a/helpers/llvm-reset b/helpers/llvm-reset
index f219cd8..3c88eef 100755
--- a/helpers/llvm-reset
+++ b/helpers/llvm-reset
@@ -17,6 +17,7 @@
 
 reset_git_svn LLVM $LLVM_SRC
 reset_git_svn Clang $LLVM_SRC/../clang
+reset_git_svn ClangToolsExtra $LLVM_SRC/../clang-tools-extra
 reset_git_svn Compiler-RT $LLVM_SRC/../compiler-rt
 reset_git_svn Libc++ $LLVM_SRC/../libcxx
 reset_git_svn Libc++abi $LLVM_SRC/../libcxxabi
diff --git a/helpers/llvm-sync b/helpers/llvm-sync
index bd46404..4ed2203 100755
--- a/helpers/llvm-sync
+++ b/helpers/llvm-sync
@@ -16,7 +16,8 @@
 }
 
 prog=`basename $0`
-syntax="Syntax: $prog [-compiler(r)T] [-(l)ibs] [-Lin(k)er] [-(d)ebugger] [-(t)ests] [-(w)eb pages] [-(a)ll]"
+syntax="Syntax: $prog [-clang-tools-e(x)tra] [-compiler(r)T] [-(l)ibs] [-Lin(k)er] [-(d)ebugger] [-(t)ests] [-(w)eb pages] [-(a)ll]"
+cextra=false
 rt=false
 libs=false
 linker=false
@@ -24,8 +25,11 @@
 tests=false
 web=false
 
-while getopts "rlkdtwa" opt; do
+while getopts "xrlkdtwa" opt; do
   case $opt in
+    x)
+      cextra=true
+      ;;
     r)
       rt=true
       ;;
@@ -45,6 +49,7 @@
       web=true
       ;;
     a)
+      cextra=true
       rt=true
       libs=true
       linker=true
@@ -63,6 +68,10 @@
 repo_sync Clang $LLVM_SRC/../clang
 
 # Optional updates
+if $cextra; then
+  repo_sync ClangToolsExtra $LLVM_SRC/../clang-tools-extra
+fi
+
 if $rt; then
   repo_sync RT $LLVM_SRC/../compiler-rt
 fi