r361920 - Make __has_builtin work with __builtin_LINE and friends.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Tue May 28 20:15:36 PDT 2019
Author: ericwf
Date: Tue May 28 20:15:36 2019
New Revision: 361920
URL: http://llvm.org/viewvc/llvm-project?rev=361920&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
cfe/trunk/test/Preprocessor/feature_tests.c
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=361920&r1=361919&r2=361920&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 28 20:15:36 2019
@@ -1620,6 +1620,10 @@ void Preprocessor::ExpandBuiltinMacro(To
.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);
}
});
Modified: cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp?rev=361920&r1=361919&r2=361920&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp Tue May 28 20:15:36 2019
@@ -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_FUNCT
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)
Modified: cfe/trunk/test/Preprocessor/feature_tests.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/feature_tests.c?rev=361920&r1=361919&r2=361920&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/feature_tests.c (original)
+++ cfe/trunk/test/Preprocessor/feature_tests.c Tue May 28 20:15:36 2019
@@ -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
More information about the cfe-commits
mailing list