-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"objective-c
Description
The following program:
#import <stdio.h>
typedef signed char BOOL;
typedef signed char TYPEDEF;
int main() {
printf("signed char* encoding: %s\n", @encode(signed char*));
printf("TYPEDEF* encoding: %s\n", @encode(TYPEDEF*));
printf("BOOL* encoding: %s\n", @encode(BOOL*));
return 0;
}Is supposed to output the following on x86_64 (godbolt Clang 15, Godbolt GCC 13.2):
signed char* encoding: *
TYPEDEF* encoding: *
BOOL* encoding: ^c
But since Clang 16, it outputs (godbolt Clang 18):
signed char* encoding: *
TYPEDEF* encoding: *
BOOL* encoding: *
Clang seemingly has code to support this, see
llvm-project/clang/lib/AST/ASTContext.cpp
Lines 7696 to 7704 in 2bf7ddf
| // This returns true if a type has been typedefed to BOOL: | |
| // typedef <type> BOOL; | |
| static bool isTypeTypedefedAsBOOL(QualType T) { | |
| if (const auto *TT = dyn_cast<TypedefType>(T)) | |
| if (IdentifierInfo *II = TT->getDecl()->getIdentifier()) | |
| return II->isStr("BOOL"); | |
| return false; | |
| } |
llvm-project/clang/lib/AST/ASTContext.cpp
Lines 8356 to 8362 in 2bf7ddf
| if (PointeeTy->isCharType()) { | |
| // char pointer types should be encoded as '*' unless it is a | |
| // type that has been typedef'd to 'BOOL'. | |
| if (!isTypeTypedefedAsBOOL(PointeeTy)) { | |
| S += '*'; | |
| return; | |
| } |
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"objective-c