This revision was automatically updated to reflect the committed changes. Closed by commit rG557e32e002ed: [clang] SIGSEGV fix at clang::ASTContext::getRawCommentForDeclNoCacheImpl (authored by ivanmurashko).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131675/new/ https://reviews.llvm.org/D131675 Files: clang/lib/AST/ASTContext.cpp clang/test/AST/ast-crash-doc.cpp Index: clang/test/AST/ast-crash-doc.cpp =================================================================== --- /dev/null +++ clang/test/AST/ast-crash-doc.cpp @@ -0,0 +1,30 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -emit-module -x c++ -fmodules -I %t/Inputs -fmodule-name=aa %t/Inputs/module.modulemap -o %t/aa.pcm +// RUN: rm %t/Inputs/b.h +// RUN: not %clang_cc1 -x c++ -Wdocumentation -ast-dump-all -fmodules -I %t/Inputs -fmodule-file=%t/aa.pcm %t/test.cpp | FileCheck %s + +//--- Inputs/module.modulemap +module aa { + header "a.h" + header "b.h" +} + +//--- Inputs/a.h +// empty file + +//--- Inputs/b.h +/// test foo @return +int foo(); + + +//--- test.cpp +#include "a.h" + +/// test comment at the primary file + +int a = foo(); + + +// CHECK: TranslationUnitDecl Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -298,6 +298,9 @@ return nullptr; const FileID File = SourceMgr.getDecomposedLoc(DeclLoc).first; + if (!File.isValid()) { + return nullptr; + } const auto CommentsInThisFile = Comments.getCommentsInFile(File); if (!CommentsInThisFile || CommentsInThisFile->empty()) return nullptr;
Index: clang/test/AST/ast-crash-doc.cpp =================================================================== --- /dev/null +++ clang/test/AST/ast-crash-doc.cpp @@ -0,0 +1,30 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -emit-module -x c++ -fmodules -I %t/Inputs -fmodule-name=aa %t/Inputs/module.modulemap -o %t/aa.pcm +// RUN: rm %t/Inputs/b.h +// RUN: not %clang_cc1 -x c++ -Wdocumentation -ast-dump-all -fmodules -I %t/Inputs -fmodule-file=%t/aa.pcm %t/test.cpp | FileCheck %s + +//--- Inputs/module.modulemap +module aa { + header "a.h" + header "b.h" +} + +//--- Inputs/a.h +// empty file + +//--- Inputs/b.h +/// test foo @return +int foo(); + + +//--- test.cpp +#include "a.h" + +/// test comment at the primary file + +int a = foo(); + + +// CHECK: TranslationUnitDecl Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -298,6 +298,9 @@ return nullptr; const FileID File = SourceMgr.getDecomposedLoc(DeclLoc).first; + if (!File.isValid()) { + return nullptr; + } const auto CommentsInThisFile = Comments.getCommentsInFile(File); if (!CommentsInThisFile || CommentsInThisFile->empty()) return nullptr;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits