[PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 23:38:43 PDT 2015


danielmarjamaki added a comment.

The full output log I got when building clang was very big. 47MB. Roughly half of that is lines saying "In file included from". I also saw false positives for constructors. The initialisation list is not considered properly.

I reduced the output with this grep command:

grep 'tools/clang/.*\.cpp.*\[-Wnonconst' clang-nonconst.txt > 1.txt

So these are all warnings for cpp files in the clang folder. There are 91 warnings:

I have not triaged these now.. but plan to do it asap..

/home/danielm/llvm/tools/clang/lib/Basic/IdentifierTable.cpp:577:54: warning: parameter 'P' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Basic/SourceLocation.cpp:135:46: warning: parameter 'Invalid' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Lex/PPDirectives.cpp:220:40: warning: parameter 'ShadowFlag' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Parse/ParseStmtAsm.cpp:111:70: warning: parameter 'Context' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Parse/ParseTemplate.cpp:1308:47: warning: parameter 'P' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Parse/Parser.cpp:530:54: warning: parameter 'P' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/Decl.cpp:566:62: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/Decl.cpp:2101:27: warning: parameter 'UntypedValue' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/DeclTemplate.cpp:250:51: warning: parameter 'Ptr' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/DeclTemplate.cpp:327:48: warning: parameter 'Ptr' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/DeclTemplate.cpp:940:52: warning: parameter 'Ptr' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/DeclTemplate.cpp:967:46: warning: parameter 'Ptr' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/NestedNameSpecifier.cpp:367:43: warning: parameter 'Data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/NestedNameSpecifier.cpp:375:27: warning: parameter 'Data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/NestedNameSpecifier.cpp:469:26: warning: parameter 'Ptr' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/StmtPrinter.cpp:705:46: warning: parameter 'Node' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/AST/StmtProfile.cpp:337:47: warning: parameter 'Node' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Sema/SemaDecl.cpp:2557:47: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Sema/SemaDecl.cpp:2565:50: warning: parameter 'New' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Sema/SemaExpr.cpp:13905:55: warning: parameter 'E' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Sema/SemaExpr.cpp:14000:55: warning: parameter 'E' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:40:72: warning: parameter 'NewDecl' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:305:54: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:220:73: warning: parameter 'Context' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:229:41: warning: parameter 'Context' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Analysis/CFGStmtMap.cpp:23:26: warning: parameter 'm' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Analysis/FormatString.cpp:126:57: warning: parameter 'argIndex' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Analysis/LiveVariables.cpp:111:41: warning: parameter 'x' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Analysis/LiveVariables.cpp:478:36: warning: parameter 'im' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Analysis/PrintfFormatString.cpp:39:38: warning: parameter 'argIndex' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:2763:45: warning: parameter 'context' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:407:11: warning: parameter 'DeserializationListener' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp:1090:56: warning: parameter 'MainAddr' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Frontend/DependencyFile.cpp:237:56: warning: parameter 'Impl' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Format/Format.cpp:1294:38: warning: parameter 'IncompleteFormat' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Format/Format.cpp:1330:38: warning: parameter 'IncompleteFormat' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Format/Format.cpp:1581:38: warning: parameter 'IncompleteFormat' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Format/Format.cpp:1590:58: warning: parameter 'IncompleteFormat' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Rewrite/DeltaTree.cpp:383:37: warning: parameter 'Root' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Rewrite/RewriteRope.cpp:711:42: warning: parameter 'P' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp:384:31: warning: parameter 'Start' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp:412:73: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp:2285:66: warning: parameter 'Existing' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp:2889:65: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp:2915:65: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp:3042:63: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp:3063:70: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp:187:71: warning: parameter 'Common' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp:195:43: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/ASTMatchers/Dynamic/VariantValue.cpp:203:34: warning: parameter 'Specificity' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/StaticAnalyzer/Core/BlockCounter.cpp:50:37: warning: parameter 'D' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/StaticAnalyzer/Core/BlockCounter.cpp:54:51: warning: parameter 'F' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/StaticAnalyzer/Core/ProgramState.cpp:484:71: warning: parameter 'Key' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/StaticAnalyzer/Core/ProgramState.cpp:484:82: warning: parameter 'Data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/lib/StaticAnalyzer/Core/ProgramState.cpp:496:77: warning: parameter 'Key' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/ARCMigrate.cpp:123:46: warning: parameter 'map' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/ARCMigrate.cpp:128:43: warning: parameter 'map' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/ARCMigrate.cpp:138:38: warning: parameter 'map' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:2064:46: warning: parameter 'Node' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:2920:33: warning: parameter 'CIdx' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:2925:45: warning: parameter 'CIdx' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:2930:49: warning: parameter 'CIdx' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:3534:43: warning: parameter 'client_data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:5951:67: warning: parameter 'client_data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:5956:60: warning: parameter 'client_data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndex.cpp:6033:48: warning: parameter 'client_data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndexHigh.cpp:376:53: warning: parameter 'client_data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndexHigh.cpp:412:61: warning: parameter 'file' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CIndexHigh.cpp:481:64: warning: parameter 'file' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXCompilationDatabase.cpp:34:57: warning: parameter 'CDb' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXCompilationDatabase.cpp:72:49: warning: parameter 'Cmds' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXCompilationDatabase.cpp:115:50: warning: parameter 'CCmd' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXCompilationDatabase.cpp:138:59: warning: parameter 'CCmd' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXCursor.cpp:1351:52: warning: parameter 'pool' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXLoadedDiagnostic.cpp:239:37: warning: parameter 'e' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXLoadedDiagnostic.cpp:393:62: warning: parameter 'error' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/CXSourceLocation.cpp:156:52: warning: parameter 'file' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/Indexing.cpp:409:39: warning: parameter 'clientData' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/Indexing.cpp:461:37: warning: parameter 'cIdx' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/Indexing.cpp:468:45: warning: parameter 'client_data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/Indexing.cpp:690:43: warning: parameter 'client_data' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/Indexing.cpp:889:48: warning: parameter 'CIdx' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/libclang/Indexing.cpp:893:46: warning: parameter 'idxAction' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/driver/cc1_main.cpp:67:68: warning: parameter 'MainAddr' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/diagtool/DiagTool.cpp:28:39: warning: parameter 'v' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/tools/extra/unittests/clang-modernize/TransformTest.cpp:76:32: warning: parameter 'Called' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/unittests/Tooling/RefactoringTest.cpp:289:31: warning: parameter 'Visitor' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/unittests/Tooling/RefactoringTest.cpp:301:29: warning: parameter 'Visitor' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp:51:43: warning: parameter 'FoundTopLevelDecl' can be const [-Wnonconst-parameter]
/home/danielm/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp:74:32: warning: parameter 'FoundClassDeclX' can be const [-Wnonconst-parameter]


http://reviews.llvm.org/D12359





More information about the cfe-commits mailing list