[PATCH] D88164: [clang][Sema] Use enumerator instead of hard-coded constant

Mikhail Maltsev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 23 09:51:22 PDT 2020


miyuki created this revision.
miyuki added reviewers: compnerd, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
miyuki requested review of this revision.

Sema::DiagnoseSwiftName uses the constant 12 instead of the
corresponding enumerator ExpectedFunctionWithProtoType. This is
fragile and will fail if a new value gets added in the middle of the
enum.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88164

Files:
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5864,7 +5864,7 @@
 
       if (!F->hasWrittenPrototype()) {
         Diag(Loc, diag::warn_attribute_wrong_decl_type) << AL
-            << /* non-K&R-style functions */12;
+            << ExpectedFunctionWithProtoType;
         return false;
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88164.293778.patch
Type: text/x-patch
Size: 441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200923/7bd448b3/attachment.bin>


More information about the cfe-commits mailing list