forked from OSchip/llvm-project
Make __has_builtin work with __builtin_LINE and friends.
The source location builtins are implemented as keywords, but __has_builtin should still report true for them. This patch also fixes a test failure on systemz where the alignment of string literals is 2 not 1. llvm-svn: 361920
This commit is contained in:
parent
f6cb3bcb4c
commit
586831b2b0
|
@ -1620,6 +1620,10 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
|
|||
.Case("__is_target_vendor", true)
|
||||
.Case("__is_target_os", true)
|
||||
.Case("__is_target_environment", true)
|
||||
.Case("__builtin_LINE", true)
|
||||
.Case("__builtin_FILE", true)
|
||||
.Case("__builtin_FUNCTION", true)
|
||||
.Case("__builtin_COLUMN", true)
|
||||
.Default(false);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace test_func {
|
|||
constexpr const char *test_default_arg(const char *f = __builtin_FUNCTION()) {
|
||||
return f;
|
||||
}
|
||||
// CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
// CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] zeroinitializer
|
||||
|
||||
// CHECK: @_ZN9test_func6globalE = {{(dso_local )?}}global i8* getelementptr inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0)
|
||||
const char *global = test_default_arg();
|
||||
|
@ -16,9 +16,9 @@ const char *global_two = __builtin_FUNCTION();
|
|||
|
||||
const char * const global_three = test_default_arg();
|
||||
|
||||
// CHECK: @[[STR_ONE:.+]] = private unnamed_addr constant [14 x i8] c"test_func_one\00", align 1
|
||||
// CHECK: @[[STR_TWO:.+]] = private unnamed_addr constant [14 x i8] c"test_func_two\00", align 1
|
||||
// CHECK: @[[STR_THREE:.+]] = private unnamed_addr constant [20 x i8] c"do_default_arg_test\00", align 1
|
||||
// CHECK: @[[STR_ONE:.+]] = private unnamed_addr constant [14 x i8] c"test_func_one\00"
|
||||
// CHECK: @[[STR_TWO:.+]] = private unnamed_addr constant [14 x i8] c"test_func_two\00"
|
||||
// CHECK: @[[STR_THREE:.+]] = private unnamed_addr constant [20 x i8] c"do_default_arg_test\00"
|
||||
|
||||
// CHECK: define {{(dso_local )?}}i8* @_ZN9test_func13test_func_oneEv()
|
||||
// CHECK: ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR_ONE]], i32 0, i32 0)
|
||||
|
|
|
@ -20,6 +20,15 @@
|
|||
#error Clang should have these
|
||||
#endif
|
||||
|
||||
// These are technically implemented as keywords, but __has_builtin should
|
||||
// still return true.
|
||||
#if !__has_builtin(__builtin_LINE) || \
|
||||
!__has_builtin(__builtin_FILE) || \
|
||||
!__has_builtin(__builtin_FUNCTION) || \
|
||||
!__has_builtin(__builtin_COLUMN)
|
||||
#error Clang should have these
|
||||
#endif
|
||||
|
||||
#if __has_builtin(__builtin_insanity)
|
||||
#error Clang should not have this
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue