Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/test/Driver/dwarf-default-version.c
- This file was added.
// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=4 -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF2 | |||||
probinson: As a rule, driver tests should pass `-###` which causes the driver to print the command lines… | |||||
MaskRayUnsubmitted Not Done ReplyInline Actions-emit-llvm -> -###. @probinson mentioned that we just need to test -cc1 options. We can use the following to check that codeview is not emitted. // NOCODEVIEW-NOT: "-gcodeview" MaskRay: `-emit-llvm` -> `-###`. @probinson mentioned that we just need to test -cc1 options.
We can… | |||||
// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF3 | |||||
// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -fdwarf-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 | |||||
// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -fdwarf-default-version=2 -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF5 | |||||
// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=5 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF5 | |||||
// RUN: %clang -target x86_64-linux-gnu -gdwarf -fdwarf-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF2 | |||||
// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF | |||||
// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT | |||||
// environment variable which indirecty overrides the version in the target | |||||
probinsonUnsubmitted Not Done ReplyInline Actionsindirectly probinson: indirectly | |||||
// triple used here. | |||||
// RUN: %clang -target x86_64-apple-macosx10.11 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF4 | |||||
// RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF2 | |||||
// RUN: %clang -target x86_64-apple-macosx10.11 -fdwarf-default-version=5 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF5 | |||||
// RUN: %clang -target x86_64-apple-darwin14 -g -fdwarf-default-version=4 -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF4 | |||||
// RUN: %clang -target powerpc-unknown-openbsd -fdwarf-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 | |||||
// RUN: %clang -target powerpc-unknown-freebsd -g -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 | |||||
// RUN: %clang -target i386-pc-solaris -fdwarf-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 | |||||
// Check which debug info formats we use on Windows. By default, in an MSVC | |||||
// environment, we should use codeview. You can enable dwarf, which implicitly | |||||
// disables codeview, of you can explicitly ask for both if you don't know how | |||||
probinsonUnsubmitted Not Done ReplyInline Actionss/of/or/ probinson: s/of/or/ | |||||
// the app will be debugged. | |||||
// RUN: %clang -target i686-pc-windows-msvc -fdwarf-default-version=2 -gdwarf -S -emit-llvm -o - %s \ | |||||
// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW | |||||
// Explicitly request both. | |||||
// RUN: %clang -target i686-pc-windows-msvc -fdwarf-default-version=4 -gdwarf -gcodeview -S -emit-llvm -o - %s \ | |||||
// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW | |||||
int main (void) { | |||||
return 0; | |||||
} | |||||
// NODEBUGINFO-NOT: !llvm.dbg.cu = !{!0} | |||||
// NOCODEVIEW-NOT: !"CodeView" | |||||
// DWARF2: !{i32 2, !"Dwarf Version", i32 2} | |||||
// DWARF3: !{i32 2, !"Dwarf Version", i32 3} | |||||
// DWARF4: !{i32 2, !"Dwarf Version", i32 4} | |||||
// DWARF5: !{i32 2, !"Dwarf Version", i32 5} | |||||
// NODWARF-NOT: !"Dwarf Version" | |||||
// CODEVIEW: !{i32 2, !"CodeView", i32 1} | |||||
// NOCODEVIEW-NOT: !"CodeView" | |||||
// NODWARF-NOT: !"Dwarf Version" |
As a rule, driver tests should pass -### which causes the driver to print the command lines instead of running the commands. Then the checks would examine the command lines constructed by the driver, to verify they say what you want.
In this case, you'd look at the emitted -dwarf-version option and make sure it's what you want, and/or look for the option that says to do codeview.
The result is a test that is a more focused specifically on driver behavior, and also runs a bit faster (not starting any subprocesses etc).