If two variables are declared with attribute((section(name))) and
the implicit section types (e.g. read only vs writeable) conflict, an
error is raised. Extend this mechanism so that an error is raised if the
section type implied by a function's attribute((section)) conflicts
with that of another variable.
Details
- Reviewers
aaron.ballman pratlucas
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
60 ms | x64 windows > LLVM.CodeGen/XCore::threads.ll |
Event Timeline
clang/lib/Sema/SemaDeclAttr.cpp | ||
---|---|---|
3048 | Does this need to be limited to function declarations? It seems to me that this should also be used on say ObjCMethod declarations or global variables as well, right? If so, then Sema::UnifySection() may need to be updated as well as it currently accepts a DeclaratorDecl but some of these constructs (like ObjcMethodDecl and ObjCPropertyDecl) are NamedDecls and not declarators. | |
3049 | NewAttr is already declared as being a SectionAttr, so this isn't needed, you can use NewAttr->getName() below instead. | |
clang/test/Sema/attr-section.c | ||
42 | Some other tests that may be interesting: const int whatever1 __attribute__((section("seg4, sec4"))) = 10; void test5(void) __attribute__((section("seg4, sec4"))); void test5(void) {} void test6(void); const int whatever2 __attribute__((section("seg5, sec5"))) = 10; void test6(void) __attribute__((section("seg5, sec5"))); void test6(void) {} |
Extended to Objective-C methods and properties.
Added suggested C tests, C++ template function test and Objective-C tests.
I had to removed PSF_Implicit flag so that cases where the function was declared before the global variable were caught.
clang/lib/Sema/SemaDeclAttr.cpp | ||
---|---|---|
3048 | I've extended this to include Objective-C methods and properties and template functions. Gobal variables are handled by Sema::CheckCompleteVariableDeclaration. |
LGTM aside from a minor nit. Thank you for the patch! Do you need me to commit on your behalf? If so, are you okay with Tomas Matheson <Tomas.Matheson@arm.com> for patch attribution?
clang/lib/Sema/SemaDeclAttr.cpp | ||
---|---|---|
3048–3049 |
Thanks for the review. I will ask for commit access for future but if you could commit this one in the meantime that would be appreciated. That's fine for attribution.
I've commit on your behalf in f50066292477fb26806336e5604615d0eddde399, thank you for the patch!
clang-tidy: warning: 'auto FD' can be declared as 'auto *FD' [llvm-qualified-auto]
not useful