HomePhabricator

PR12350: Handle remaining cases permitted by CWG DR 244.

Authored by rsmith on Fri, Feb 7, 4:34 PM.

Description

PR12350: Handle remaining cases permitted by CWG DR 244.

Also add extension warnings for the cases that are disallowed by the
current rules for destructor name lookup, refactor and simplify the
lookup code, and improve the diagnostic quality when lookup fails.

The special case we previously supported for converting
p->N::S<int>::~S() from naming a class template into naming a
specialization thereof is subsumed by a more general rule here (which is
also consistent with Clang's historical behavior and that of other
compilers): if we can't find a suitable S in N, also look in N::S<int>.

The extension warnings are off by default, except for a warning when
lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S).
That seems sufficiently heinous to warn on by default, especially since
we can't support it for a dependent nested-name-specifier.

Details

Committed
rsmithFri, Feb 7, 6:40 PM
Parents
rG3e70a9196387: [lldb/Plugin] Use LLDB_PLUGIN_DECLARE to forward declare plugin initializers
Branches
Unknown
Tags
Unknown

Event Timeline

Post-commit review, although i'm not sure this is the commit that is the problem.

/clang/lib/AST/NestedNameSpecifier.cpp
485–487

Was this change intentional?
It seems, http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/17720/steps/annotate/logs/stdio is pointing at this line/change with:

FAIL: Clang :: AST/ast-dump-expr.cpp (136 of 16826)
******************** TEST 'Clang :: AST/ast-dump-expr.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1';   /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang -cc1 -internal-isystem /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/11.0.0/include -nostdsysteminc -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -ast-dump /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/AST/ast-dump-expr.cpp | /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck -strict-whitespace /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/AST/ast-dump-expr.cpp
--
Exit Code: 2

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:485:23: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:43:28: note: nonnull attribute specified here
    #0 0x5f80492 in Append(char*, char*, char*&, unsigned int&, unsigned int&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:485:5
    #1 0x5f808ca in SaveSourceLocation(clang::SourceLocation, char*&, unsigned int&, unsigned int&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:500:3
    #2 0x5f80a68 in clang::NestedNameSpecifierLocBuilder::Extend(clang::ASTContext&, clang::NamespaceDecl*, clang::SourceLocation, clang::SourceLocation) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:603:3
    #3 0x4f5f84a in clang::CXXScopeSpec::Extend(clang::ASTContext&, clang::NamespaceDecl*, clang::SourceLocation, clang::SourceLocation) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Sema/DeclSpec.cpp:73:11
    #4 0x4fc1af9 in clang::Sema::BuildCXXNestedNameSpecifier(clang::Scope*, clang::Sema::NestedNameSpecInfo&, bool, clang::CXXScopeSpec&, clang::NamedDecl*, bool, bool*, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Sema/SemaCXXScopeSpec.cpp:714:10
    #5 0x4fc32b4 in clang::Sema::ActOnCXXNestedNameSpecifier(clang::Scope*, clang::Sema::NestedNameSpecInfo&, bool, clang::CXXScopeSpec&, bool, bool*, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Sema/SemaCXXScopeSpec.cpp:841:10
    #6 0x4efb997 in clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&, clang::OpaquePtr<clang::QualType>, bool, bool*, bool, clang::IdentifierInfo**, bool, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:455:19
    #7 0x4ea7c72 in clang::Parser::TryAnnotateCXXScopeToken(bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/Parser.cpp:2045:7
    #8 0x4ebd1d5 in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:3359:13
    #9 0x4ed0326 in clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&, clang::SourceLocation&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:6732:5
    #10 0x4ece524 in clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:6444:7
    #11 0x4ecc563 in clang::Parser::ParseDirectDeclarator(clang::Declarator&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:6126:7
    #12 0x4ecaf80 in clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:5679:7
    #13 0x4ecb076 in clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:5702:5
    #14 0x4ec0b24 in ParseDeclarator /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:5547:3
    #15 0x4ec0b24 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2009:3
    #16 0x4ea1f23 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/Parser.cpp:1109:10
    #17 0x4ea1677 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/Parser.cpp:1125:12
    #18 0x4ea0a0b in clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/Parser.cpp:945:12
    #19 0x4e9f2eb in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/Parser.cpp:696:12
    #20 0x4e99c3c in clang::ParseAST(clang::Sema&, bool, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Parse/ParseAST.cpp:158:20
    #21 0x39058b1 in clang::FrontendAction::Execute() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:940:8
    #22 0x38b631c in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:969:33
    #23 0x39f75a3 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:292:25
    #24 0x9df38e in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/cc1_main.cpp:240:15
    #25 0x9da28a in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/driver.cpp:328:12
    #26 0x9d7b61 in main /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/tools/driver/driver.cpp:402:12
    #27 0x7f385c8be2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #28 0x9bbd29 in _start (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang-11+0x9bbd29)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:485:23 in