From d7bf4a4e9c100fb5fe098b0e1870d61891c09dd3 Mon Sep 17 00:00:00 2001
From: Argyrios Kyrtzidis <akyrtzi@gmail.com>
Date: Wed, 16 Jan 2013 18:13:00 +0000
Subject: [PATCH] [libclang] In clang_reparseTranslationUnit_Impl, move the
 check whether TU is null before using it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172632 91177308-0d34-0410-b5e6-96231b3b80d8
---
 tools/libclang/CIndex.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 7b271dcd502..6f790ae6852 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -2834,6 +2834,8 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
   ReparseTranslationUnitInfo *RTUI =
     static_cast<ReparseTranslationUnitInfo*>(UserData);
   CXTranslationUnit TU = RTUI->TU;
+  if (!TU)
+    return;
 
   // Reset the associated diagnostics.
   delete static_cast<CXDiagnosticSetImpl*>(TU->Diagnostics);
@@ -2845,9 +2847,6 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
   (void) options;
   RTUI->result = 1;
 
-  if (!TU)
-    return;
-
   CIndexer *CXXIdx = (CIndexer*)TU->CIdx;
   if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForEditing))
     setThreadBackgroundPriority();
-- 
GitLab