diff options
author | Alp Toker <alp@nuanti.com> | 2014-01-26 06:17:37 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-01-26 06:17:37 +0000 |
commit | a2474459beca778d352a16e6463cf4dd9e29dc06 (patch) | |
tree | 446314f9ee030469e4c144cec8db4f4ec51e279f /lib/CodeGen/CodeGenModule.cpp | |
parent | d6de61539c778f1d8449208c381234d13f7643cb (diff) | |
download | clang-a2474459beca778d352a16e6463cf4dd9e29dc06.tar.gz clang-a2474459beca778d352a16e6463cf4dd9e29dc06.tar.bz2 clang-a2474459beca778d352a16e6463cf4dd9e29dc06.tar.xz |
Enforce safe usage of DiagnosticsEngine::getCustomDiagID()
Replace the last incorrect uses and templatize the function to require a
compile-time constant string preventing further misuse.
The diagnostic formatter expects well-formed input and has undefined behaviour
with arbitrary input or crafted user strings in source files. Accepting user
input would also have caused unbounded generation of new diagnostic IDs which
can be problematic in long-running sessions or language bindings.
This completes the work to fix several incorrect callers that passed user
input or raw messages to the diagnostics engine where a constant format string
was expected.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200132 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 95dd52c4d5..2ee232284f 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -339,9 +339,9 @@ void CodeGenModule::DecorateInstruction(llvm::Instruction *Inst, Inst->setMetadata(llvm::LLVMContext::MD_tbaa, TBAAInfo); } -void CodeGenModule::Error(SourceLocation loc, StringRef error) { - unsigned diagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error, error); - getDiags().Report(Context.getFullLoc(loc), diagID); +void CodeGenModule::Error(SourceLocation loc, StringRef message) { + unsigned diagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error, "%0"); + getDiags().Report(Context.getFullLoc(loc), diagID) << message; } /// ErrorUnsupported - Print out an error that codegen doesn't support the |