[PATCH] D148696: [clang][Sema][NFC] Sprinkle some const around in Sema

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 12:26:58 PDT 2023


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Changes generally LGTM though I spotted a few places where we might as well update to `auto` and one place where I think a `const` was missed.



================
Comment at: clang/lib/Sema/SemaExpr.cpp:2122-2123
 
-  FieldDecl *FD = dyn_cast<FieldDecl>(D);
-  if (IndirectFieldDecl *IFD = dyn_cast<IndirectFieldDecl>(D))
+  const FieldDecl *FD = dyn_cast<FieldDecl>(D);
+  if (const IndirectFieldDecl *IFD = dyn_cast<IndirectFieldDecl>(D))
     FD = IFD->getAnonField();
----------------



================
Comment at: clang/lib/Sema/SemaExpr.cpp:2222
           CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
-  CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext);
+  const CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext);
   bool isInstance = CurMethod && CurMethod->isInstance() &&
----------------



================
Comment at: clang/lib/Sema/SemaExpr.cpp:3012
                                     NamedDecl *Member) {
-  CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Member->getDeclContext());
+  const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Member->getDeclContext());
   if (!RD)
----------------



================
Comment at: clang/lib/Sema/SemaExpr.cpp:3037
     }
-  } else if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
+  } else if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
     if (Method->isStatic())
----------------



================
Comment at: clang/lib/Sema/SemaLookup.cpp:1337
       if (S->isClassScope())
-        if (CXXRecordDecl *Record =
-                dyn_cast_or_null<CXXRecordDecl>(S->getEntity()))
+        if (auto *Record = dyn_cast_if_present<CXXRecordDecl>(S->getEntity()))
           R.setNamingClass(Record);
----------------
Right?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148696/new/

https://reviews.llvm.org/D148696



More information about the cfe-commits mailing list