summaryrefslogtreecommitdiffstats
path: root/clang/lib/ARCMigrate/FileRemapper.cpp
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-01-26 06:17:37 +0000
committerAlp Toker <alp@nuanti.com>2014-01-26 06:17:37 +0000
commit29cb66ba2f0b251a430941d00eea305b6d6c6966 (patch)
treeaf69b9830f8f0ed823d1ab7f097b4f1d7f8e6088 /clang/lib/ARCMigrate/FileRemapper.cpp
parentead3b3d7a1f4ada0d7eb8cc46185fbea4a58060f (diff)
downloadbcm5719-llvm-29cb66ba2f0b251a430941d00eea305b6d6c6966.tar.gz
bcm5719-llvm-29cb66ba2f0b251a430941d00eea305b6d6c6966.zip
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. llvm-svn: 200132
Diffstat (limited to 'clang/lib/ARCMigrate/FileRemapper.cpp')
-rw-r--r--clang/lib/ARCMigrate/FileRemapper.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/clang/lib/ARCMigrate/FileRemapper.cpp b/clang/lib/ARCMigrate/FileRemapper.cpp
index e406d47c025..88e54ff89df 100644
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -271,9 +271,7 @@ void FileRemapper::resetTarget(Target &targ) {
}
bool FileRemapper::report(const Twine &err, DiagnosticsEngine &Diag) {
- SmallString<128> buf;
- unsigned ID = Diag.getDiagnosticIDs()->getCustomDiagID(DiagnosticIDs::Error,
- err.toStringRef(buf));
- Diag.Report(ID);
+ Diag.Report(Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
+ << err.str();
return true;
}
OpenPOWER on IntegriCloud