[PATCH] D19963: [scan-build] fix warnings emitted on Clang Frontend code baseFix "Logic error" warnings of the type "Called C++ object pointer isnull" reported by Clang Static Analyzer on the following file:lib/Frontend/CompilerInstance.cpp.

Apelete Seketeli via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 03:53:25 PDT 2016


apelete created this revision.
apelete added reviewers: akyrtzi, rsmith.
apelete added a subscriber: cfe-commits.

Signed-off-by: Apelete Seketeli <apelete at seketeli.net>

http://reviews.llvm.org/D19963

Files:
  lib/Frontend/CompilerInstance.cpp

Index: lib/Frontend/CompilerInstance.cpp
===================================================================
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -742,7 +742,7 @@
 
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
-    const FileEntry *File;
+    const FileEntry *File = nullptr;
     if (Opts.FindPchSource.empty()) {
       File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
     } else {
@@ -760,13 +760,14 @@
       SmallVector<std::pair<const FileEntry *, const DirectoryEntry *>, 16>
           Includers;
       Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-      File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-                            /*FromDir=*/nullptr,
-                            /*CurDir=*/UnusedCurDir, Includers,
-                            /*SearchPath=*/nullptr,
-                            /*RelativePath=*/nullptr,
-                            /*RequestingModule=*/nullptr,
-                            /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+      if (HS)
+        File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
+                              /*FromDir=*/nullptr,
+                              /*CurDir=*/UnusedCurDir, Includers,
+                              /*SearchPath=*/nullptr,
+                              /*RelativePath=*/nullptr,
+                              /*RequestingModule=*/nullptr,
+                              /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
       // Also add the header to /showIncludes output.
       if (File)
         DepOpts.ShowIncludesPretendHeader = File->getName();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19963.56260.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160505/a720e65a/attachment.bin>


More information about the cfe-commits mailing list