[clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations
Reviewed By: kadircet Differential Revision: https://reviews.llvm.org/D111711
This commit is contained in:
		
							parent
							
								
									7812f510d2
								
							
						
					
					
						commit
						c521288ed3
					
				| 
						 | 
				
			
			@ -39,6 +39,13 @@ public:
 | 
			
		|||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool VisitFunctionDecl(FunctionDecl *FD) {
 | 
			
		||||
    // Function definition will require redeclarations to be included.
 | 
			
		||||
    if (FD == FD->getDefinition())
 | 
			
		||||
      add(FD);
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 | 
			
		||||
    add(CCE->getConstructor());
 | 
			
		||||
    return true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,6 +79,19 @@ TEST(IncludeCleaner, ReferencedLocations) {
 | 
			
		|||
          "struct ^X { ^X(int) {} int ^foo(); };",
 | 
			
		||||
          "auto x = X(42); auto y = x.foo();",
 | 
			
		||||
      },
 | 
			
		||||
      // Function
 | 
			
		||||
      {
 | 
			
		||||
          "void ^foo();",
 | 
			
		||||
          "void foo() {}",
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
          "void foo() {}",
 | 
			
		||||
          "void foo();",
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
          "inline void ^foo() {}",
 | 
			
		||||
          "void bar() { foo(); }",
 | 
			
		||||
      },
 | 
			
		||||
      // Static function
 | 
			
		||||
      {
 | 
			
		||||
          "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue