[clang] 8c7c1f1 - Silence unused variable warning in NDEBUG builds

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 23 06:42:13 PDT 2023


Author: Benjamin Kramer
Date: 2023-03-23T14:41:03+01:00
New Revision: 8c7c1f11ffaacf762e612c65440fd2cbb58ee426

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

LOG: Silence unused variable warning in NDEBUG builds

I usually would fold this into the assert, but the comment there
suggests side effects. NFC.

ModuleMap.cpp:938:9: error: unused variable 'MainFile' [-Werror,-Wunused-variable]
  auto *MainFile = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());

Added: 
    

Modified: 
    clang/lib/Lex/ModuleMap.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index f2b2d0b8c69f1..44c872336ce9c 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -936,6 +936,7 @@ Module *ModuleMap::createModuleForImplementationUnit(SourceLocation Loc,
   // Mark the main source file as being within the newly-created module so that
   // declarations and macros are properly visibility-restricted to it.
   auto *MainFile = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());
+  (void)MainFile;
   assert(MainFile && "no input file for module implementation");
 
   return Result;


        


More information about the cfe-commits mailing list