diff --git a/interpreter/cling/lib/Utils/AST.cpp b/interpreter/cling/lib/Utils/AST.cpp index f1136a10ce000..4cd16d7ebdc24 100644 --- a/interpreter/cling/lib/Utils/AST.cpp +++ b/interpreter/cling/lib/Utils/AST.cpp @@ -560,21 +560,20 @@ namespace utils { } else { Decl* decl = nullptr; - const TypedefType* typedeftype = - dyn_cast_or_null(&(*desugared)); - const UsingType* usingtype = - dyn_cast_or_null(&(*desugared)); - if (typedeftype) { - decl = typedeftype->getDecl(); - } else if (usingtype) { - decl = usingtype->getFoundDecl(); - } else { - // There are probably other cases ... - const TagType* tagdecltype = dyn_cast_or_null(&(*desugared)); - if (tagdecltype) { - decl = tagdecltype->getDecl(); - } else { - decl = desugared->getAsCXXRecordDecl(); + if (!desugared.isNull()) { + const Type* desugaredTy = desugared.getTypePtr(); + switch (desugaredTy->getTypeClass()) { + case Type::Typedef: + decl = cast(desugaredTy)->getDecl(); + break; + case Type::Using: + decl = cast(desugaredTy)->getFoundDecl(); + break; + case Type::Record: + case Type::Enum: + decl = cast(desugaredTy)->getDecl(); + break; + default: decl = desugared->getAsCXXRecordDecl(); break; } } if (decl) { @@ -1142,22 +1141,15 @@ namespace utils { // in which case we want to add it ... but we can't really preserve // the typedef in this case ... - Decl *decl = nullptr; - const TypedefType* typedeftype = - dyn_cast_or_null(QT.getTypePtr()); - const UsingType* usingtype = - dyn_cast_or_null(QT.getTypePtr()); - if (typedeftype) { - decl = typedeftype->getDecl(); - } else if (usingtype) { - decl = usingtype->getFoundDecl(); - } else { - // There are probably other cases ... - const TagType* tagdecltype = dyn_cast_or_null(QT.getTypePtr()); - if (tagdecltype) { - decl = tagdecltype->getDecl(); - } else { - decl = QT->getAsCXXRecordDecl(); + Decl* decl = nullptr; + if (!QT.isNull()) { + const Type* QTTy = QT.getTypePtr(); + switch (QTTy->getTypeClass()) { + case Type::Typedef: decl = cast(QTTy)->getDecl(); break; + case Type::Using: decl = cast(QTTy)->getFoundDecl(); break; + case Type::Record: + case Type::Enum: decl = cast(QTTy)->getDecl(); break; + default: decl = QT->getAsCXXRecordDecl(); break; } } if (decl) { diff --git a/interpreter/cling/test/CodeGeneration/Symbols.C b/interpreter/cling/test/CodeGeneration/Symbols.C index 87f083ea32a3c..8ec44839ff39d 100644 --- a/interpreter/cling/test/CodeGeneration/Symbols.C +++ b/interpreter/cling/test/CodeGeneration/Symbols.C @@ -6,8 +6,9 @@ // LICENSE.TXT for details. //------------------------------------------------------------------------------ -// RUN: clang -shared %fPIC -DCLING_EXPORT=%dllexport -DBUILD_SHARED %s -o%T/libSymbols%shlibext -// RUN: %cling --nologo -L%T -lSymbols %s | FileCheck %s +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: clang -shared %fPIC -DCLING_EXPORT=%dllexport -DBUILD_SHARED %s -o%t.dir/libSymbols%shlibext +// RUN: %cling --nologo -L%t.dir -lSymbols %s | FileCheck %s // Check that weak symbols do not get re-emitted (ROOT-6124) extern "C" int printf(const char*,...); diff --git a/interpreter/cling/test/CodeUnloading/PCH/VTables.C b/interpreter/cling/test/CodeUnloading/PCH/VTables.C index 5386598dfd9ee..73f7f6d9f75c9 100644 --- a/interpreter/cling/test/CodeUnloading/PCH/VTables.C +++ b/interpreter/cling/test/CodeUnloading/PCH/VTables.C @@ -1,9 +1,10 @@ -// RUN: %mkdir "%T/Rel/Path" || true -// RUN: %rm "CompGen.h.pch" && %rm "%T/Rel/Path/Relative.pch" +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: %mkdir "%t.dir/Rel/Path" || true +// RUN: %rm "CompGen.h.pch" && %rm "%t.dir/Rel/Path/Relative.pch" // RUN: clang -x c++-header -fexceptions -fcxx-exceptions -std=%std_cxx -pthread %S/Inputs/CompGen.h -o CompGen.h.pch -// RUN: clang -x c++-header -fexceptions -fcxx-exceptions -std=%std_cxx -pthread %S/Inputs/CompGen.h -o %T/Rel/Path/Relative.pch +// RUN: clang -x c++-header -fexceptions -fcxx-exceptions -std=%std_cxx -pthread %S/Inputs/CompGen.h -o %t.dir/Rel/Path/Relative.pch // RUN: cat %s | %cling -I%p -Xclang -include-pch -Xclang CompGen.h.pch 2>&1 | FileCheck %s -// RUN: cat %s | %cling -I%p -I%T/Rel/Path -include-pch Relative.pch 2>&1 | FileCheck %s +// RUN: cat %s | %cling -I%p -I%t.dir/Rel/Path -include-pch Relative.pch 2>&1 | FileCheck %s //.storeState "a" .x TriggerCompGen.h diff --git a/interpreter/cling/test/Driver/CurrentDirRm.C b/interpreter/cling/test/Driver/CurrentDirRm.C index d8ab6779d8ac1..744f7c0c26647 100644 --- a/interpreter/cling/test/Driver/CurrentDirRm.C +++ b/interpreter/cling/test/Driver/CurrentDirRm.C @@ -7,9 +7,10 @@ //------------------------------------------------------------------------------ // Removing the cwd on Unix works but on Windows cannot be done. -// RUN: %mkdir "%T/Remove" -// RUN: cd "%T/Remove" -// RUN: %rmdir "%T/Remove" +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: %mkdir "%t.dir/Remove" +// RUN: cd "%t.dir/Remove" +// RUN: %rmdir "%t.dir/Remove" // RUN: %cling %s -Xclang -verify 2>&1 | FileCheck %s // UNSUPPORTED: system-windows diff --git a/interpreter/cling/test/LibraryCall/call.C b/interpreter/cling/test/LibraryCall/call.C index c01442b506667..21fd335a0d754 100644 --- a/interpreter/cling/test/LibraryCall/call.C +++ b/interpreter/cling/test/LibraryCall/call.C @@ -6,8 +6,9 @@ // LICENSE.TXT for details. //------------------------------------------------------------------------------ -// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%T/libcall_lib2%shlibext -// RUN: cat %s | %cling -L%T | FileCheck %s +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%t.dir/libcall_lib2%shlibext +// RUN: cat %s | %cling -L%t.dir | FileCheck %s .L libcall_lib2 extern "C" int cling_testlibrary_function(); diff --git a/interpreter/cling/test/LibraryCall/callable_lib.C b/interpreter/cling/test/LibraryCall/callable_lib.C index 72a6bb16504db..ce847b6f58eee 100644 --- a/interpreter/cling/test/LibraryCall/callable_lib.C +++ b/interpreter/cling/test/LibraryCall/callable_lib.C @@ -6,8 +6,9 @@ // LICENSE.TXT for details. //------------------------------------------------------------------------------ -// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%T/libcall_lib%shlibext -// RUN: cat %s | %cling -L%T | FileCheck %s +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%t.dir/libcall_lib%shlibext +// RUN: cat %s | %cling -L%t.dir | FileCheck %s .L libcall_lib extern "C" int cling_testlibrary_function(); diff --git a/interpreter/cling/test/Pragmas/add_env_path.C b/interpreter/cling/test/Pragmas/add_env_path.C index 99ac809e7f9bd..48badf5dcf8c2 100644 --- a/interpreter/cling/test/Pragmas/add_env_path.C +++ b/interpreter/cling/test/Pragmas/add_env_path.C @@ -6,10 +6,11 @@ // LICENSE.TXT for details. //------------------------------------------------------------------------------ -// RUN: %mkdir "%T/subdir" || true -// RUN: %rm "%T/subdir/libtest%shlibext" -// RUN: clang -DCLING_EXPORT=%dllexport -shared %S/call_lib.c -o %T/subdir/libtest%shlibext -// RUN: cat %s | %cling -I %S -DENVVAR_LIB="\"%/T/subdir\"" -DENVVAR_INC="\"%/p/subdir\"" -Xclang -verify 2>&1 | FileCheck %s +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: %mkdir "%t.dir/subdir" || true +// RUN: %rm "%t.dir/subdir/libtest%shlibext" +// RUN: clang -DCLING_EXPORT=%dllexport -shared %S/call_lib.c -o %t.dir/subdir/libtest%shlibext +// RUN: cat %s | %cling -I %S -DENVVAR_LIB="\"%/t.dir/subdir\"" -DENVVAR_INC="\"%/p/subdir\"" -Xclang -verify 2>&1 | FileCheck %s extern "C" int cling_testlibrary_function(); diff --git a/interpreter/cling/test/Pragmas/load.C b/interpreter/cling/test/Pragmas/load.C index 7c3f0709fa796..5313e15fd4319 100644 --- a/interpreter/cling/test/Pragmas/load.C +++ b/interpreter/cling/test/Pragmas/load.C @@ -6,8 +6,9 @@ // LICENSE.TXT for details. //------------------------------------------------------------------------------ -// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%T/libcall_lib%shlibext -// RUN: cat %s | %cling -L %T -Xclang -verify 2>&1 | FileCheck %s +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%t.dir/libcall_lib%shlibext +// RUN: cat %s | %cling -L %t.dir -Xclang -verify 2>&1 | FileCheck %s #pragma cling load("DoesNotExistPleaseRecover") // expected-error@input_line_12:1{{'DoesNotExistPleaseRecover' file not found}} diff --git a/interpreter/cling/test/Prompt/OutputRedirect.C b/interpreter/cling/test/Prompt/OutputRedirect.C index 1ddb1f1ac80e3..a292f1331557a 100644 --- a/interpreter/cling/test/Prompt/OutputRedirect.C +++ b/interpreter/cling/test/Prompt/OutputRedirect.C @@ -1,11 +1,12 @@ -// RUN: cat %s | %cling -DCLING_TMP="\"%/T\"" | FileCheck --check-prefix=CHECKOUT %s -// RUN: cat %T/outfile.txt | FileCheck --check-prefix=CHECK-REDIRECTOUT %s -// RUN: cat %T/errfile.txt | FileCheck --check-prefix=CHECK-REDIRECTERR %s -// RUN: cat %T/bothfile.txt | FileCheck --check-prefix=CHECK-REDIRECTBOTH %s -// RUN: cat %T/anotheroutfile.txt | FileCheck --check-prefix=CHECK-REDIRECTANOTHER %s -// RUN: cat %T/nospace.txt | FileCheck --check-prefix=CHECK-NOSPACE %s -// RUN: cat %s | %cling -DCLING_TMP="\"%/T\"" 2> %T/stderr.txt && cat %T/stderr.txt | FileCheck --check-prefix=CHECKERR %s -// RUN: cat %s | %cling -DCLING_TMP="\"%/T\"" 2>&1 | FileCheck --check-prefix=CHECKERR --check-prefix=CHECKOUT %s +// RUN: rm -rf %t.dir && mkdir -p %t.dir +// RUN: cat %s | %cling -DCLING_TMP="\"%/t.dir\"" | FileCheck --check-prefix=CHECKOUT %s +// RUN: cat %t.dir/outfile.txt | FileCheck --check-prefix=CHECK-REDIRECTOUT %s +// RUN: cat %t.dir/errfile.txt | FileCheck --check-prefix=CHECK-REDIRECTERR %s +// RUN: cat %t.dir/bothfile.txt | FileCheck --check-prefix=CHECK-REDIRECTBOTH %s +// RUN: cat %t.dir/anotheroutfile.txt | FileCheck --check-prefix=CHECK-REDIRECTANOTHER %s +// RUN: cat %t.dir/nospace.txt | FileCheck --check-prefix=CHECK-NOSPACE %s +// RUN: cat %s | %cling -DCLING_TMP="\"%/t.dir\"" 2> %t.dir/stderr.txt && cat %t.dir/stderr.txt | FileCheck --check-prefix=CHECKERR %s +// RUN: cat %s | %cling -DCLING_TMP="\"%/t.dir\"" 2>&1 | FileCheck --check-prefix=CHECKERR --check-prefix=CHECKOUT %s #include