]> granicus.if.org Git - clang/commitdiff
Make __has_builtin work with __builtin_LINE and friends.
authorEric Fiselier <eric@efcs.ca>
Wed, 29 May 2019 03:15:36 +0000 (03:15 +0000)
committerEric Fiselier <eric@efcs.ca>
Wed, 29 May 2019 03:15:36 +0000 (03:15 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361920 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp
test/CodeGenCXX/builtin_FUNCTION.cpp
test/Preprocessor/feature_tests.c

index 4576f1a47e15d825dff4d0f9d5faead20535362b..72f8f48839d059a836673a817413c013ac1f784b 100644 (file)
@@ -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);
         }
       });
index b3156ea45ae62c820f07e0ce6d5b8a8724f9f25d..02e616351a9395c6b994a56d8545cdfc4fd1f9f6 100644 (file)
@@ -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)
index c2fbd11c97cd28918378fe1e41c667bd8446c99c..2035a729f2d0e9f8aafe8c2a8f38a559a2cc3629 100644 (file)
 #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