[clang] 8cc842a - [clang][Sema] Use enumerator instead of hard-coded constant

Mikhail Maltsev via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 02:24:35 PDT 2020


Author: Mikhail Maltsev
Date: 2020-09-24T10:24:22+01:00
New Revision: 8cc842a95072aaa87b5067a12aa9ef5b3ac8e592

URL: https://github.com/llvm/llvm-project/commit/8cc842a95072aaa87b5067a12aa9ef5b3ac8e592
DIFF: https://github.com/llvm/llvm-project/commit/8cc842a95072aaa87b5067a12aa9ef5b3ac8e592.diff

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

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.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D88164

Added: 
    

Modified: 
    clang/lib/Sema/SemaDeclAttr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 3babbe05ca8f..d15ef232a5fb 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5868,7 +5868,7 @@ bool Sema::DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc,
 
       if (!F->hasWrittenPrototype()) {
         Diag(Loc, diag::warn_attribute_wrong_decl_type) << AL
-            << /* non-K&R-style functions */12;
+            << ExpectedFunctionWithProtoType;
         return false;
       }
     }


        


More information about the cfe-commits mailing list