[clang] 0350672 - [clang] Do not traverse EnumDecl's type in RecursiveASTVisitor

Kirill Bobyrev via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 26 08:17:28 PDT 2021


Author: Kirill Bobyrev
Date: 2021-10-26T17:17:10+02:00
New Revision: 03506722e0c348ce52d87f7f37f024d7adec5c43

URL: https://github.com/llvm/llvm-project/commit/03506722e0c348ce52d87f7f37f024d7adec5c43
DIFF: https://github.com/llvm/llvm-project/commit/03506722e0c348ce52d87f7f37f024d7adec5c43.diff

LOG: [clang] Do not traverse EnumDecl's type in RecursiveASTVisitor

This is inconsistent with the code and comments in
RecursiveASTVisitor.h and is not a correct behavior:

https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/RecursiveASTVisitor.h#L1879-L1880

> We shouldn't traverse D->getTypeForDecl(); it's a result of
> declaring the type, not something that was written in the source.

Fixes the failures in 1c2e249f938c50e1b331a1f7adc83c0a381f3897

Added: 
    

Modified: 
    clang/include/clang/AST/RecursiveASTVisitor.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index dfc1bd35e51f..f200cd3920e6 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1863,9 +1863,6 @@ DEF_TRAVERSE_DECL(UnresolvedUsingIfExistsDecl, {})
 DEF_TRAVERSE_DECL(EnumDecl, {
   TRY_TO(TraverseDeclTemplateParameterLists(D));
 
-  if (D->getTypeForDecl())
-    TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
-
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
   if (auto *TSI = D->getIntegerTypeSourceInfo())
     TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));


        


More information about the cfe-commits mailing list