r371934 - [OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 15 09:05:20 PDT 2019


Author: rksimon
Date: Sun Sep 15 09:05:20 2019
New Revision: 371934

URL: http://llvm.org/viewvc/llvm-project?rev=371934&view=rev
Log:
[OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.

Fixes static analyzer uninitialized variable warning for the OMPClause - the function appears to cover all cases, but I've added an assertion to make sure.

Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=371934&r1=371933&r2=371934&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Sep 15 09:05:20 2019
@@ -12202,7 +12202,7 @@ Expected<unsigned> ASTRecordReader::read
 ////===----------------------------------------------------------------------===//
 
 OMPClause *OMPClauseReader::readClause() {
-  OMPClause *C;
+  OMPClause *C = nullptr;
   switch (Record.readInt()) {
   case OMPC_if:
     C = new (Context) OMPIfClause();
@@ -12403,6 +12403,8 @@ OMPClause *OMPClauseReader::readClause()
     C = OMPAllocateClause::CreateEmpty(Context, Record.readInt());
     break;
   }
+  assert(C && "Unknown OMPClause type");
+
   Visit(C);
   C->setLocStart(Record.readSourceLocation());
   C->setLocEnd(Record.readSourceLocation());




More information about the cfe-commits mailing list