]> granicus.if.org Git - clang/commitdiff
[OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 15 Sep 2019 16:05:20 +0000 (16:05 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 15 Sep 2019 16:05:20 +0000 (16:05 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371934 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReader.cpp

index 10b2a5c4f9dfba2def9e7c81f8dccc1f1e3a1203..fcb437e0cb1e7f2adf15fa8ebf3957bac81ccd87 100644 (file)
@@ -12202,7 +12202,7 @@ Expected<unsigned> ASTRecordReader::readRecord(llvm::BitstreamCursor &Cursor,
 ////===----------------------------------------------------------------------===//
 
 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());