llvm-capstone/clang
Manna, Soumi cc6a6c48d4 [NFC][Clang] Fix Coverity bug with dereference null return value in clang::CodeGen::CodeGenFunction::EmitOMPArraySectionExpr()
Reported by Coverity:

Inside  "CGExpr.cpp" file, in clang::CodeGen::CodeGenFunction::EmitOMPArraySectionExpr(clang::OMPArraySectionExpr const *, bool): Return value of function which returns null is dereferenced without checking.

    } else {
  	//returned_null: getAsConstantArrayType returns nullptr (checked 83 out of 95 times).
  	// var_assigned: Assigning: CAT = nullptr return value from getAsConstantArrayType.
      auto *CAT = C.getAsConstantArrayType(ArrayTy);
  	//identity_transfer: Member function call CAT->getSize() returns an offset off CAT (this).

     // Dereference null return value (NULL_RETURNS)
     //dereference: Dereferencing a pointer that might be nullptr CAT->getSize() when calling APInt.
     ConstLength = CAT->getSize();
    }

This patch adds an assert to resolve the bug.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D151137
2023-05-23 07:25:21 -07:00
..
bindings [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra 2023-05-23 08:29:52 +02:00
cmake [BOLT][CMake] Use correct output paths and passthrough necessary options 2023-05-19 17:43:27 +00:00
docs Revert "[Sema] setInvalidDecl for error deduction declaration" 2023-05-23 11:44:51 +01:00
examples [clang][pp] Handle attributes defined by plugin in __has_attribute 2023-03-13 16:47:51 +01:00
include Reland "Reland [clang-repl] Introduce Value to capture expression results" 2023-05-23 19:32:31 +08:00
lib [NFC][Clang] Fix Coverity bug with dereference null return value in clang::CodeGen::CodeGenFunction::EmitOMPArraySectionExpr() 2023-05-23 07:25:21 -07:00
runtime [NFC] Add split-file as runtime test dependency 2023-02-02 11:22:26 -08:00
test [Driver] Try to fix linux-ld.c test with DEFAULT_LINKER set (NFC) 2023-05-23 16:05:27 +02:00
tools Reland "Reland [clang-repl] Introduce Value to capture expression results" 2023-05-23 19:32:31 +08:00
unittests Reland "Reland [clang-repl] Introduce Value to capture expression results" 2023-05-23 19:32:31 +08:00
utils [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra 2023-05-23 08:29:52 +02:00
www Revert "[clang] Add tests for CWG issues 977, 1482, 2516" 2023-05-23 15:29:14 +03:00
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt Revert "Reland "[CMake] Bumps minimum version to 3.20.0."" 2023-05-17 10:53:33 -04:00
CodeOwners.rst
INSTALL.txt
LICENSE.TXT
ModuleInfo.txt
NOTES.txt
README.txt

//===----------------------------------------------------------------------===//
// C Language Family Front-end
//===----------------------------------------------------------------------===//

Welcome to Clang.  This is a compiler front-end for the C family of languages
(C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM
compiler infrastructure project.

Unlike many other compiler frontends, Clang is useful for a number of things
beyond just compiling code: we intend for Clang to be host to a number of
different source-level tools.  One example of this is the Clang Static Analyzer.

If you're interested in more (including how to build Clang) it is best to read
the relevant web sites.  Here are some pointers:

Information on Clang:             http://clang.llvm.org/
Building and using Clang:         http://clang.llvm.org/get_started.html
Clang Static Analyzer:            http://clang-analyzer.llvm.org/
Information on the LLVM project:  http://llvm.org/

If you have questions or comments about Clang, a great place to discuss them is
on the Clang forums:
  https://discourse.llvm.org/c/clang/

If you find a bug in Clang, please file it in the LLVM bug tracker:
  http://llvm.org/bugs/