-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ast print of variables with attributes
Previously clang AST prints the following declaration: int fun_var_unused() { int x __attribute__((unused)) = 0; return x; } and int __declspec(thread) x = 0; as: int fun_var_unused() { int x = 0 __attribute__((unused)); return x; } and int x = __declspec(thread) 0; which is rejected by C/C++ parser. This patch modifies the logic to print old C attributes for variables as: int __attribute__((unused)) x = 0; and the __declspec case as: int __declspec(thread) x = 0; Fixes: #59973 Previous version: D141714. Differential Revision:https://reviews.llvm.org/D141714
- Loading branch information
1 parent
04224d1
commit 46f3ade
Showing
18 changed files
with
243 additions
and
55 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file contain tests for attribute arguments on K&R functions. | ||
|
||
// RUN: %clang_cc1 -ast-print -x c -std=c89 -fms-extensions %s -o - | FileCheck %s | ||
|
||
// CHECK: int knr(i) | ||
// CHECK-NEXT: int i __attribute__((unused)); | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: return 0; | ||
// CHECK-NEXT: } | ||
int knr(i) int i __attribute__((unused)); { return 0; } | ||
|
||
// CHECK: __attribute__((unused)) int knr2(i) | ||
// CHECK-NEXT: int i; | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: return 0; | ||
// CHECK-NEXT: } | ||
__attribute__((unused)) int knr2(i) int i; { return 0; } |
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
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
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
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
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
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
Oops, something went wrong.