-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] Merge some delarations which currently have different attributes #79349
Open
philnik777
wants to merge
1
commit into
llvm:main
Choose a base branch
from
philnik777:builtins_merge_declarations
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvmbot
added
clang
Clang issues not falling into any other category
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
labels
Jan 24, 2024
@llvm/pr-subscribers-clang Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/79349.diff 1 Files Affected:
diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index 22e616e6cde5990..127236bb0d57dad 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -727,12 +727,6 @@ def RotateRight : BitInt8_16_32_64BuiltinsTemplate, Builtin {
// FIXME: The builtins marked FunctionWithBuiltinPrefix below should be
// merged with the library definitions. They are currently not because
// the attributes are different.
-def BuiltinCalloc : Builtin {
- let Spellings = ["__builtin_calloc"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
- let Prototype = "void*(size_t, size_t)";
-}
-
def BuiltinConstantP : Builtin {
let Spellings = ["__builtin_constant_p"];
let Attributes = [NoThrow, Const, CustomTypeChecking, UnevaluatedArguments, Constexpr];
@@ -775,48 +769,18 @@ def BuiltinAssumeAligned : Builtin {
let Prototype = "void*(void const*, size_t, ...)";
}
-def BuiltinFree : Builtin {
- let Spellings = ["__builtin_free"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
- let Prototype = "void(void*)";
-}
-
-def BuiltinMalloc : Builtin {
- let Spellings = ["__builtin_malloc"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
- let Prototype = "void*(size_t)";
-}
-
def BuiltinMemcpyInline : Builtin {
let Spellings = ["__builtin_memcpy_inline"];
let Attributes = [NoThrow];
let Prototype = "void(void*, void const*, _Constant size_t)";
}
-def BuiltinMempcpy : Builtin {
- let Spellings = ["__builtin_mempcpy"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
- let Prototype = "void*(void*, void const*, size_t)";
-}
-
def BuiltinMemsetInline : Builtin {
let Spellings = ["__builtin_memset_inline"];
let Attributes = [NoThrow];
let Prototype = "void(void*, int, _Constant size_t)";
}
-def BuiltinStrcspn : Builtin {
- let Spellings = ["__builtin_strcspn"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
- let Prototype = "size_t(char const*, char const*)";
-}
-
-def BuiltinRealloc : Builtin {
- let Spellings = ["__builtin_realloc"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
- let Prototype = "void*(void*, size_t)";
-}
-
def BuiltinReturnAddress : Builtin {
let Spellings = ["__builtin_return_address"];
let Attributes = [NoThrow];
@@ -2539,7 +2503,9 @@ def Abort : LibBuiltin<"stdlib.h"> {
def Calloc : LibBuiltin<"stdlib.h"> {
let Spellings = ["calloc"];
+ let Attributes = [NoThrow];
let Prototype = "void*(size_t, size_t)";
+ let AddBuiltinPrefixedAlias = 1;
}
def Exit : LibBuiltin<"stdlib.h"> {
@@ -2550,17 +2516,23 @@ def Exit : LibBuiltin<"stdlib.h"> {
def Malloc : LibBuiltin<"stdlib.h"> {
let Spellings = ["malloc"];
+ let Attributes = [NoThrow];
let Prototype = "void*(size_t)";
+ let AddBuiltinPrefixedAlias = 1;
}
def Realloc : LibBuiltin<"stdlib.h"> {
let Spellings = ["realloc"];
+ let Attributes = [NoThrow];
let Prototype = "void*(void*, size_t)";
+ let AddBuiltinPrefixedAlias = 1;
}
def Free : LibBuiltin<"stdlib.h"> {
let Spellings = ["free"];
+ let Attributes = [NoThrow];
let Prototype = "void(void*)";
+ let AddBuiltinPrefixedAlias = 1;
}
def StrToD : LibBuiltin<"stdlib.h"> {
@@ -2612,16 +2584,11 @@ def MemCpy : LibBuiltin<"string.h"> {
let AddBuiltinPrefixedAlias = 1;
}
-def BuiltinMemCmp : Builtin {
- let Spellings = ["__builtin_memcmp"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Constexpr];
- let Prototype = "int(void const*, void const*, size_t)";
-}
-
def MemCmp : LibBuiltin<"string.h"> {
let Spellings = ["memcmp"];
- let Attributes = [Constexpr];
+ let Attributes = [NoThrow, Constexpr];
let Prototype = "int(void const*, void const*, size_t)";
+ let AddBuiltinPrefixedAlias = 1;
}
def MemMove : LibBuiltin<"string.h"> {
@@ -2694,7 +2661,9 @@ def StrChr : LibBuiltin<"string.h"> {
def StrcSpn : LibBuiltin<"string.h"> {
let Spellings = ["strcspn"];
+ let Attributes = [NoThrow];
let Prototype = "size_t(char const*, char const*)";
+ let AddBuiltinPrefixedAlias = 1;
}
def StrpBrk : LibBuiltin<"string.h"> {
@@ -2753,14 +2722,7 @@ def StrLen : LibBuiltin<"string.h"> {
// FIXME: This list is incomplete.
def Printf : LibBuiltin<"stdio.h"> {
let Spellings = ["printf"];
- let Attributes = [PrintfFormat<0>];
- let Prototype = "int(char const*, ...)";
-}
-
-// FIXME: The builtin and library function should have the same signature.
-def BuiltinPrintf : Builtin {
- let Spellings = ["__builtin_printf"];
- let Attributes = [NoThrow, PrintfFormat<0>, FunctionWithBuiltinPrefix];
+ let Attributes = [NoThrow, PrintfFormat<0>];
let Prototype = "int(char const* restrict, ...)";
}
@@ -3060,7 +3022,9 @@ def MemcCpy : GNULibBuiltin<"stdlib.h"> {
def MempCpy : GNULibBuiltin<"stdlib.h"> {
let Spellings = ["mempcpy"];
+ let Attributes = [NoThrow]
let Prototype = "void*(void*, void const*, size_t)";
+ let AddBuiltinPrefixedAlias = 1;
}
def StpCpy : GNULibBuiltin<"stdlib.h"> {
@@ -3121,17 +3085,11 @@ def Bcopy : GNULibBuiltin<"strings.h"> {
let AddBuiltinPrefixedAlias = 1;
}
-// FIXME: This should be part of BCmp.
-def BuiltinBCmp : Builtin {
- let Spellings = ["__builtin_bcmp"];
- let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Constexpr];
- let Prototype = "int(void const*, void const*, size_t)";
-}
-
def BCmp : GNULibBuiltin<"strings.h"> {
let Spellings = ["bcmp"];
- let Attributes = [Constexpr];
+ let Attributes = [NoThrow, Constexpr];
let Prototype = "int(void const*, void const*, size_t)";
+ let AddBuiltinPrefixedAlias = 1;
}
def StrCaseCmp : GNULibBuiltin<"strings.h"> {
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.